Merge pull request #795 from FHenry/develop

[ task #783 ] Add checkbox and radio into extrafield feature
This commit is contained in:
Laurent Destailleur
2013-04-02 07:06:34 -07:00
14 changed files with 188 additions and 14 deletions

View File

@@ -66,6 +66,47 @@ if ($action == 'add')
$mesg[]=$langs->trans("ErrorNoValueForSelectType");
$action = 'create';
}
if (GETPOST('type')=='checkbox' && !GETPOST('param'))
{
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
$action = 'create';
}
if (GETPOST('type')=='radio' && !GETPOST('param'))
{
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorNoValueForRadioType");
$action = 'create';
}
if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox') || (GETPOST('type')=='radio')) && GETPOST('param'))
{
// Construct array for parameter (value of select list)
$parameters = GETPOST('param');
$parameters_array = explode("\r\n",$parameters);
foreach($parameters_array as $param_ligne)
{
if (!empty($param_ligne)) {
if (preg_match_all('/,/',$param_ligne,$matches))
{
if (count($matches[0])>1) {
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
$action = 'create';
}
}
else
{
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
$action = 'create';
}
}
}
}
if (! $error)
{
@@ -138,6 +179,54 @@ if ($action == 'update')
$mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
$action = 'edit';
}
if (GETPOST('type')=='select' && !GETPOST('param'))
{
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorNoValueForSelectType");
$action = 'edit';
}
if (GETPOST('type')=='checkbox' && !GETPOST('param'))
{
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
$action = 'edit';
}
if (GETPOST('type')=='radio' && !GETPOST('param'))
{
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorNoValueForRadioType");
$action = 'edit';
}
if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox') || (GETPOST('type')=='radio')) && GETPOST('param'))
{
// Construct array for parameter (value of select list)
$parameters = GETPOST('param');
$parameters_array = explode("\r\n",$parameters);
foreach($parameters_array as $param_ligne)
{
if (!empty($param_ligne)) {
if (preg_match_all('/,/',$param_ligne,$matches))
{
if (count($matches[0])>1) {
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
$action = 'edit';
}
}
else
{
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
$action = 'edit';
}
}
}
}
if (! $error)
{

View File

@@ -2133,10 +2133,10 @@ abstract class CommonObject
$this->array_options[$key] = price2num($this->array_options[$key]);
break;
case 'date':
$this->array_options[$key] = dol_print_date($this->array_options[$key],'dayrfc');
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
break;
case 'datetime':
$this->array_options[$key] = dol_print_date($this->array_options[$key],'dayhourrfc');
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
break;
}
}

View File

@@ -64,7 +64,9 @@ class ExtraFields
'phone'=>'ExtrafieldPhone',
'mail'=>'ExtrafieldMail',
'select' => 'ExtrafieldSelect',
'separate' => 'ExtrafieldSeparator'
'separate' => 'ExtrafieldSeparator',
'checkbox' => 'ExtrafieldCheckBox',
'radio' => 'ExtrafieldRadio',
);
/**
@@ -166,7 +168,7 @@ class ExtraFields
}elseif($type=='mail') {
$typedb='varchar';
$lengthdb='128';
} elseif ($type=='select') {
} elseif (($type=='select') || ($type=='radio') ||($type=='checkbox')){
$typedb='text';
$lengthdb='';
} else {
@@ -376,7 +378,7 @@ class ExtraFields
}elseif($type=='mail') {
$typedb='varchar';
$lengthdb='128';
} elseif ($type=='select') {
} elseif (($type=='select') || ($type=='radio') ||($type=='checkbox')) {
$typedb='text';
$lengthdb='';
} else {
@@ -676,6 +678,37 @@ class ExtraFields
}
$out.='</select>';
}
elseif ($type == 'checkbox')
{
$out='';
$value_arr=explode(',',$value);
foreach ($param['options'] as $keyopt=>$val )
{
$out.='<input type="checkbox" name="options_'.$key.'[]"';
$out.=' value="'.$keyopt.'"';
if ((is_array($value_arr)) && in_array($keyopt,$value_arr)) {
$out.= 'checked="checked"';
}else {
$out.='';
}
$out.='/>'.$val.'<br>';
}
}
elseif ($type == 'radio')
{
$out='';
foreach ($param['options'] as $keyopt=>$val )
{
$out.='<input type="radio" name="options_'.$key.'"';
$out.=' value="'.$keyopt.'"';
$out.= ($value==$keyopt?'checked="checked"':'');
$out.='/>'.$val.'<br>';
}
}
/* Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)';
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
@@ -740,6 +773,21 @@ class ExtraFields
{
$value=$params['options'][$value];
}
elseif ($type == 'radio')
{
$value=$params['options'][$value];
}
elseif ($type == 'checkbox')
{
$value_arr=explode(',',$value);
$value='';
if (is_array($value_arr))
{
foreach ($value_arr as $keyval=>$valueval) {
$value.=$params['options'][$valueval].'<br>';
}
}
}
else
{
$showsize=round($size);
@@ -785,7 +833,12 @@ class ExtraFields
// Clean parameters
$value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
}
else
else if (in_array($key_type,array('checkbox')))
{
$value_arr=GETPOST("options_".$key);
$value_key=implode($value_arr,',');
}
else
{
$value_key=GETPOST("options_".$key);
}

View File

@@ -48,6 +48,8 @@
else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();}
else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();}
else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();}
else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();}
else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();}
else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();}
else size.val('').attr('disabled','disabled');
}
@@ -73,14 +75,20 @@
<tr><td class="fieldrequired"><?php echo $langs->trans("Label"); ?></td><td class="valeur"><input type="text" name="label" size="40" value="<?php echo GETPOST('label'); ?>"></td></tr>
<!-- Code -->
<tr><td class="fieldrequired"><?php echo $langs->trans("AttributeCode"); ?> (<?php echo $langs->trans("AlphaNumOnlyCharsAndNoSpace"); ?>)</td><td class="valeur"><input type="text" name="attrname" id="attrname" size="10" value="<?php echo GETPOST('attrname'); ?>"></td></tr>
<!-- Value (for select list / radio) -->
<!-- Value (for select list / radio/ checkbox) -->
<tr id="value_choice">
<td>
<?php echo $langs->trans("Value"); ?>
</td>
<td>
<table class="nobordernopadding">
<tr><td width="30%">
<textarea name="param" id="param"><?php echo GETPOST('param'); ?></textarea>
</td><td><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelp"),1,0)?></td></tr>
</table>
</td>
</tr>
<!-- Default Value -->
<tr><td><?php echo $langs->trans("DefaultValue"); ?></td><td class="valeur"><input id="default_value" type="text" name="default_value" size="5" value="<?php echo (GETPOST('"default_value"')?GETPOST('"default_value"'):''); ?>"></td></tr>

View File

@@ -55,7 +55,7 @@ $required=$extrafields->attribute_required[$attrname];
$pos=$extrafields->attribute_pos[$attrname];
$param=$extrafields->attribute_param[$attrname];
if($type == 'select' && is_array($param))
if((($type == 'select') || ($type == 'checkbox') ||(($type == 'radio'))) && is_array($param))
{
$param_chain = '';
foreach ($param['options'] as $key => $value)
@@ -80,7 +80,7 @@ if($type == 'select' && is_array($param))
</td></tr>
<!-- Value (for select list / radio) -->
<?php
if($type == 'select')
if(($type == 'select') || ($type == 'checkbox') ||(($type == 'radio')))
{
?>
<tr id="value_choice">

View File

@@ -208,4 +208,5 @@ ALTER TABLE llx_user ADD COLUMN zip varchar(25);
ALTER TABLE llx_user ADD COLUMN town varchar(50);
ALTER TABLE llx_user ADD COLUMN fk_state integer DEFAULT 0;
ALTER TABLE llx_user ADD COLUMN fk_country integer DEFAULT 0;
ALTER TABLE llx_product_price ADD COLUMN import_key varchar(14) AFTER price_by_qty;

View File

@@ -37,6 +37,7 @@ create table llx_product_price
localtax2_tx double(6,3) DEFAULT 0,
fk_user_author integer,
tosell tinyint DEFAULT 1,
price_by_qty integer NOT NULL DEFAULT 0
price_by_qty integer NOT NULL DEFAULT 0,
import_key varchar(14)
)ENGINE=innodb;

View File

@@ -354,7 +354,10 @@ ExtrafieldPhone=Telèfon
ExtrafieldPrice=Preu
ExtrafieldMail=Correu
ExtrafieldSelect=Llista de selecció
ExtrafieldSeparator=
ExtrafieldSeparator=Separator
ExtrafieldCheckBox=Casilla
ExtrafieldRadio=Opción
ExtrafieldParamHelp=Optiones Lista esta llave,valor<br><br> para exemplo : <br>1,texto1<br>2,texto2<br>3,texto3<br>...
LibraryToBuildPDF=Llibreria usada per a la creació d'arxius PDF
WarningUsingFPDF=Atenció: El seu arxiu <b>conf.php</b> conté la directiva <b>dolibarr_pdf_force_fpdf=1</b>. Això fa que s'usi la llibreria FPDF per generar els seus arxius PDF. Aquesta llibreria és antiga i no cobreix algunes funcionalitats (Unicode, transparència d'imatges, idiomes ciríl · lics, àrabs o asiàtics, etc.), Pel que pot tenir problemes en la generació dels PDF.<br> Per resoldre-ho, i disposar d'un suport complet de PDF, pot descarregar la <a href="http://www.tcpdf.org/" target="_blank"> llibreria TCPDF </a>, i a continuació comentar o eliminar la línia <b>$dolibarr_pdf_force_fpdf=1</b>, i afegir al seu lloc <b>$dolibarr_lib_TCPDF_PATH='ruta_a_TCPDF'</b>
LocalTaxDesc=Alguns països apliquen 2 o 3 taxes a cada línia de factura. Si és el cas, escolliu el tipus de la segona i tercera taxa i el seu valor. Els possibles tipus són: <br> 1: taxa local aplicable a productes i serveis sense IVA (IVA no s'aplica a la taxa local) <br> 2: taxa local s'aplica a productes i serveis abans de l'IVA (IVA es calcula sobre import + taxa local) <br> 3: taxa local s'aplica a productes sense IVA (IVA no s'aplica a la taxa local) <br> 4: taxa local s'aplica a productes abans de l'IVA (IVA es calcula sobre l'import + taxa local) <br> 5: taxa local s'aplica a serveis sense IVA (IVA no s'aplica a la taxa local) <br> 6: taxa local s'aplica a serveis abans de l'IVA (IVA es calcula sobre import + taxa local)

View File

@@ -357,6 +357,10 @@ ExtrafieldPhone = Phone
ExtrafieldPrice = Price
ExtrafieldMail = Email
ExtrafieldSelect = Select list
ExtrafieldSeparator=Separator
ExtrafieldCheckBox=Checkbox
ExtrafieldRadio=Radio button
ExtrafieldParamHelp=Parameters list have to be like key,value<br><br> for exemple : <br>1,value1<br>2,value2<br>3,value3<br>...
LibraryToBuildPDF=Library used to build PDF
WarningUsingFPDF=Warning: Your <b>conf.php</b> contains directive <b>dolibarr_pdf_force_fpdf=1</b>. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.<br>To solve this and have a full support of PDF generation, please download <a href="http://www.tcpdf.org/" target="_blank">TCPDF library</a>, then comment or remove the line <b>$dolibarr_pdf_force_fpdf=1</b>, and add instead <b>$dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir'</b>
LocalTaxDesc=Some countries apply 2 or 3 taxes on each invoice line. If this is the case, choose type for second and third tax and its rate. Possible type are:<br>1 : local tax apply on products and services without vat (vat is not applied on local tax)<br>2 : local tax apply on products and services before vat (vat is calculated on amount + localtax)<br>3 : local tax apply on products without vat (vat is not applied on local tax)<br>4 : local tax apply on products before vat (vat is calculated on amount + localtax)<br>5 : local tax apply on services without vat (vat is not applied on local tax)<br>6 : local tax apply on services before vat (vat is calculated on amount + localtax)

View File

@@ -59,6 +59,9 @@ ErrorFileSizeTooLarge=File size is too large.
ErrorSizeTooLongForIntType=Size too long for int type (%s digits maximum)
ErrorSizeTooLongForVarcharType=Size too long for string type (%s chars maximum)
ErrorNoValueForSelectType=Please fill value for select list
ErrorNoValueForCheckBoxType=Please fill value for checkbox list
ErrorNoValueForRadioType=Please fill value for radio list
ErrorBadFormatValueList=The list value cannot have more than one come : <u>%s</u>, but need at least one: llave,valores
ErrorFieldCanNotContainSpecialCharacters=Field <b>%s</b> must not contains special characters.
ErrorNoAccountancyModuleLoaded=No accountancy module activated
ErrorExportDuplicateProfil=This profil name already exists for this export set.

View File

@@ -349,12 +349,15 @@ Int=Numérico entero
Float=Decimal
DateAndTime=Fecha y hora
Unique=Único
Boolean=Boleano (Checkbox)
Boolean=Boleano (Casilla unico)
ExtrafieldPhone=Teléfono
ExtrafieldPrice=Precio
ExtrafieldMail=Correo
ExtrafieldSelect=Lista de selección
ExtrafieldSeparator=
ExtrafieldSeparator=Separator
ExtrafieldCheckBox=Casilla
ExtrafieldRadio=Opción
ExtrafieldParamHelp=Optiones Lista esta llave,valor<br><br> para exemplo : <br>1,texto1<br>2,texto2<br>3,texto3<br>...
LibraryToBuildPDF=Librería usada para la creación de archivos PDF
WarningUsingFPDF=Atención: Su archivo <b>conf.php</b> contiene la directiva <b>dolibarr_pdf_force_fpdf=1</b>. Esto hace que se use la librería FPDF para generar sus archivos PDF. Esta librería es antigua y no cubre algunas funcionalidades (Unicode, transparencia de imágenes, idiomas cirílicos, árabes o asiáticos, etc.), por lo que puede tener problemas en la generación de los PDF.<br>Para resolverlo, y disponer de un soporte completo de PDF, puede descargar la <a href="http://www.tcpdf.org/" target="_blank">librería TCPDF</a> , y a continuación comentar o eliminar la línea <b>$dolibarr_pdf_force_fpdf=1</b>, y añadir en su lugar <b>$dolibarr_lib_TCPDF_PATH='ruta_a_TCPDF'</b>
LocalTaxDesc=Algunos países aplican 2 o 3 tasas a cada línea de factura. Si es el caso, escoja el tipo de la segunda y tercera tasa y su valor. Los posibles tipos son:<br>1 : tasa local aplicable a productos y servicios sin IVA (IVA no se aplica en la tasa local)<br>2 : tasa local se aplica a productos y servicios antes del IVA (IVA se calcula sobre importe+tasa local)<br>3 : tasa local se aplica a productos sin IVA (IVA no se aplica en la tasa local)<br>4 : tasa local se aplica a productos antes del IVA (IVA se calcula sobre el importe+tasa local)<br>5 : tasa local se aplica a servicios sin IVA (IVA no se aplica a la tasa local)<br>6 : tasa local se aplica a servicios antes del IVA (IVA se calcula sobre importe + tasa local)

View File

@@ -60,6 +60,9 @@ ErrorFileSizeTooLarge=El tamaño del fichero es demasiado grande.
ErrorSizeTooLongForIntType=Longitud del campo demasiado largo para el tipo int (máximo %s cifras)
ErrorSizeTooLongForVarcharType=Longitud del campo demasiado largo para el tipo cadena (máximo %s cifras)
ErrorNoValueForSelectType=Los valores de la lista deben ser indicados
ErrorNoValueForCheckBoxType=Los valores de la lista deben ser indicados
ErrorNoValueForRadioType=Los valores de la lista deben ser indicados
ErrorBadFormatValueList=Los valores de la lista no peudo contener mas de una coma : <u>%s</u>, pero necessita una: llave,valores
ErrorFieldCanNotContainSpecialCharacters=El campo <b>%s</b> no debe contener carácteres especiales
ErrorNoAccountancyModuleLoaded=Módulo de contabilidad no activado
ErrorExportDuplicateProfil=El nombre del perfil ya existe para este lote de exportación

View File

@@ -355,6 +355,9 @@ ExtrafieldPrice = Prix
ExtrafieldMail = Email
ExtrafieldSelect = Liste de sélection
ExtrafieldSeparator = Séparateur de champ
ExtrafieldCheckBox=Case à cocher
ExtrafieldRadio=Case d'option
ExtrafieldParamHelp=La liste doit être de la forme clef,valeur<br><br> par exemple : <br>1,valeur1<br>2,valeur2<br>3,valeur3<br>...
LibraryToBuildPDF=Bibliothèque utilisée pour la génération des PDF
WarningUsingFPDF=Attention: Votre fichier <b>conf.php</b> contient la directive <b>dolibarr_pdf_force_fpdf=1</b>. Cela signifie que vous utilisez la librairie FPDF pour générer vos fichiers PDF. Cette librairie est ancienne et ne couvre pas de nombreuses fonctionnalitée (Unicode, transparence des images, langues cyrillic, arabes ou asiatiques...), aussi vous pouvez rencontrez des problèmes durant la génération des PDF.<br>Pour résoudre cela et avoir un support complet de PDF, vous pouvez télécharger la <a href="http://www.tcpdf.org/" target="_blank">librairie TCPDF</a> puis commenter ou supprimer la ligne <b>$dolibarr_pdf_force_fpdf=1</b>, et ajouter à la place <b>$dolibarr_lib_TCPDF_PATH='chemin_vers_TCPDF'</b>
LocalTaxDesc=Certains pays appliquent 2 voir 3 taux sur chaque ligne de facture. Si c'est le cas, choisissez le type du deuxième et troisième taux et sa valeur. Les types possibles sont:<br>1 : taxe locale sur les produits et services hors tva (la tva n'est pas appliquée sur la taxe locale)<br>2 : taxe locale sur les produits et services avant tva (la tva est appliquée sur le montant + la taxe locale)<br>3 : taxe locale uniquement sur les produits hors tva (la tva n'est pas appliquée sur la taxe locale)<br>4 : taxe locale uniquement sur les produits avant tva (la tva est appliquée sur le montant + la taxe locale)<br>5 : taxe locale uniquement sur les services hors tva (la tva n'est pas appliquée sur la taxe locale)<br>6 : taxe locale uniquement sur les service avant tva (la tva est appliquée sur le montant + la taxe locale)

View File

@@ -59,7 +59,10 @@ ErrorUploadBlockedByAddon=Upload bloqué par un plugin PHP/Apache.
ErrorFileSizeTooLarge=La taille du fichier est trop grande.
ErrorSizeTooLongForIntType=Longueur de champ trop longue pour le type int (%s chiffres maximum)
ErrorSizeTooLongForVarcharType=Longueur de champ trop longue pour le type chaine (%s caractères maximum)
ErrorNoValueForSelectType=Les valeurs de la liste doivent être renseignées
ErrorNoValueForSelectType=Les valeurs de la liste de selection doivent être renseignées
ErrorNoValueForCheckBoxType=Les valeurs de la liste de case a cochées doivent être renseignées
ErrorNoValueForRadioType=Les valeurs de la liste d'options doivent être renseignées
ErrorBadFormatValueList=Les valeurs de la liste ne peuvent pas contenir plus d'une virgule : <b>%s</b>, mais doivent en avoir au moins une: clef,valeur
ErrorFieldCanNotContainSpecialCharacters=Le champ <b>%s</b> ne peut contenir de caractères spéciaux.
ErrorNoAccountancyModuleLoaded=Aucun module de comptabilité activé
ErrorExportDuplicateProfil=Ce nom de profil existe déjà pour ce lot d'export.