[ task #1127 ] Add feature filter on extrafield type : select for table

This commit is contained in:
Florian Henry 2013-11-04 19:21:13 +01:00
parent b52b49cbb0
commit a57afb6d40
4 changed files with 54 additions and 14 deletions

View File

@ -87,7 +87,7 @@ if ($action == 'add')
$mesg[]=$langs->trans("ErrorNoValueForRadioType");
$action = 'create';
}
if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox') || (GETPOST('type')=='radio')) && GETPOST('param'))
if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox')) && GETPOST('param'))
{
// Construct array for parameter (value of select list)
$parameters = GETPOST('param');
@ -124,11 +124,22 @@ if ($action == 'add')
$default_value = GETPOST('default_value');
$parameters = GETPOST('param');
$parameters_array = explode("\r\n",$parameters);
foreach($parameters_array as $param_ligne)
//In sellist we have only one line and it can have come to do SQL expression
if (GETPOST('type')=='sellist') {
foreach($parameters_array as $param_ligne)
{
$params['options'] = array($parameters=>null);
}
}
else
{
list($key,$value) = explode(',',$param_ligne);
$params['options'][$key] = $value;
}
//Esle it's separated key/value and coma list
foreach($parameters_array as $param_ligne)
{
list($key,$value) = explode(',',$param_ligne);
$params['options'][$key] = $value;
}
}
$result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params);
if ($result > 0)
@ -215,7 +226,7 @@ if ($action == 'update')
$mesg[]=$langs->trans("ErrorNoValueForRadioType");
$action = 'edit';
}
if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox') || (GETPOST('type')=='radio')) && GETPOST('param'))
if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox')) && GETPOST('param'))
{
// Construct array for parameter (value of select list)
$parameters = GETPOST('param');
@ -251,10 +262,21 @@ if ($action == 'update')
// Construct array for parameter (value of select list)
$parameters = GETPOST('param');
$parameters_array = explode("\r\n",$parameters);
foreach($parameters_array as $param_ligne)
//In sellist we have only one line and it can have come to do SQL expression
if (GETPOST('type')=='sellist') {
foreach($parameters_array as $param_ligne)
{
$params['options'] = array($parameters=>null);
}
}
else
{
list($key,$value) = explode(',',$param_ligne);
$params['options'][$key] = $value;
//Esle it's separated key/value and coma list
foreach($parameters_array as $param_ligne)
{
list($key,$value) = explode(',',$param_ligne);
$params['options'][$key] = $value;
}
}
$result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$pos,$params);
if ($result > 0)

View File

@ -693,15 +693,23 @@ class ExtraFields
// 1 2 : label field name Nom du champ contenant le libelle
// 2 3 : key fields name (if differ of rowid)
// 3 4 : key field parent (for dependent lists)
// 4 5 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
$keyList='rowid';
if (count($InfoFieldList)>=3)
$keyList=$InfoFieldList[2].' as rowid';
if (count($InfoFieldList)>=4) {
if (count($InfoFieldList)>=3) {
list($parentName, $parentField) = explode('|', $InfoFieldList[3]);
$keyList.= ', '.$parentField;
}
if (count($InfoFieldList)>=4 && !empty($InfoFieldList[4])) {
if (strpos($InfoFieldList[4], 'extra')!==false) {
$keyList='main.'.$InfoFieldList[2].' as rowid';
}else {
$keyList=$InfoFieldList[2].' as rowid';
}
}
$fields_label = explode('|',$InfoFieldList[1]);
if(is_array($fields_label)) {
@ -717,6 +725,16 @@ class ExtraFields
$sql = 'SELECT '.$keyList;
$sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0];
if (!empty($InfoFieldList[4])) {
//We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra')!==false) {
$sql.= ' as main, '.MAIN_DB_PREFIX .$InfoFieldList[0].'_extrafields as extra';
$sql.= ' WHERE extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4];
}else {
$sql.= ' WHERE '.$InfoFieldList[4];
}
}
//$sql.= ' WHERE entity = '.$conf->entity;
//print $sql;

View File

@ -368,7 +368,7 @@ ExtrafieldRadio=Radio button
ExtrafieldParamHelpselect=Parameters list have to be like key,value<br><br> for exemple : <br>1,value1<br>2,value2<br>3,value3<br>...<br><br>In order to have the list depending on another :<br>1,value1|parent_list_code:parent_key<br>2,value2|parent_list_code:parent_key
ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value<br><br> for exemple : <br>1,value1<br>2,value2<br>3,value3<br>...
ExtrafieldParamHelpradio=Parameters list have to be like key,value<br><br> for exemple : <br>1,value1<br>2,value2<br>3,value3<br>...
ExtrafieldParamHelpsellist=Parameters list have come from table<br><br> for exemple : <br>c_typent:libelle:id<br><br>In order to have the list depending on another :<br>c_typent:libelle:id:parent_list_code|parent_column
ExtrafieldParamHelpsellist=Parameters list have come from table<br><br> for exemple : <br>c_typent:libelle:id::filter<br><br>In order to have the list depending on another :<br>c_typent:libelle:id:parent_list_code|parent_column:filter <br> filter can be a simple test (eg active=1) to display only active value <br> if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)
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

@ -368,7 +368,7 @@ ExtrafieldRadio=Bouton radio
ExtrafieldParamHelpselect=La liste doit être de la forme clef,valeur<br><br> par exemple : <br>1,valeur1<br>2,valeur2<br>3,valeur3<br>...<br><br>Pour que la liste soit dépendante d'une autre :<br>1,valeur1|code_liste_parent:clef_parent<br>2,valeur2|code_liste_parent:clef_parent
ExtrafieldParamHelpcheckbox=La liste doit être de la forme clef,valeur<br><br> par exemple : <br>1,valeur1<br>2,valeur2<br>3,valeur3<br>...
ExtrafieldParamHelpradio=La liste doit être de la forme clef,valeur<br><br> par exemple : <br>1,valeur1<br>2,valeur2<br>3,valeur3<br>...
ExtrafieldParamHelpsellist=La liste vient d'une table<br><br> par exemple : <br>c_typent:libelle:id<br><br>Pour que la liste soit dépendante d'une autre :<br>c_typent:libelle:id:code_liste_parent|colonne_parent
ExtrafieldParamHelpsellist=La liste vient d'une table<br><br> par exemple : <br>c_typent:libelle:id::filter<br><br>Pour que la liste soit dépendante d'une autre :<br>c_typent:libelle:id:code_liste_parent|colonne_parent:filter<br> filter peux être un test simple active=1 pour ne proposer que les valeur active<br> si vous voulez faire un filtre sur des attributs supplémentaires utiliser la syntax extra.champ=...(où champ est la code de l'attribut supplémentaire)
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és (Unicode, transparence des images, langues cyrilliques, arabes ou asiatiques...), aussi vous pouvez rencontrer des problèmes durant la génération des PDF.<br>Pour résoudre cela et avoir une prise en charge complète de PDF, vous pouvez télécharger la <a href="http://www.tcpdf.org/" target="_blank">bibliothèque 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 voire 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)