From 654e99df8c236c24252913fb034c7f750eff32e8 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 15 Mar 2013 18:56:10 +0100 Subject: [PATCH 1/8] Work on new type of extrafield : separator with no field stored in database --- htdocs/core/class/extrafields.class.php | 12 ++++++++---- htdocs/langs/fr_FR/admin.lang | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index de828e8a23743..b09ee145ebfaf 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -63,7 +63,8 @@ class ExtraFields 'price'=>'ExtrafieldPrice', 'phone'=>'ExtrafieldPhone', 'mail'=>'ExtrafieldMail', - 'select' => 'ExtrafieldSelect' + 'select' => 'ExtrafieldSelect', + 'separator' => 'ExtrafieldSeparator' ); /** @@ -103,10 +104,13 @@ function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $uni if (empty($label)) return -1; - // Create field into database - $result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param); + // Create field into database except for separator type + if ($elementtype != 'separator') + { + $result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param); + } $err1=$this->errno; - if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS') + if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $elementtype == 'separator') { // Add declaration of field into table $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param); diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 04a95bf5980b1..09325b9ab3e57 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -354,6 +354,7 @@ ExtrafieldPhone = Téléphone ExtrafieldPrice = Prix ExtrafieldMail = Email ExtrafieldSelect = Liste de sélection +ExtrafieldSeparator = Séparateur de champ LibraryToBuildPDF=Bibliothèque utilisée pour la génération des PDF WarningUsingFPDF=Attention: Votre fichier conf.php contient la directive dolibarr_pdf_force_fpdf=1. 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.
Pour résoudre cela et avoir un support complet de PDF, vous pouvez télécharger la librairie TCPDF puis commenter ou supprimer la ligne $dolibarr_pdf_force_fpdf=1, et ajouter à la place $dolibarr_lib_TCPDF_PATH='chemin_vers_TCPDF' 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:
1 : taxe locale sur les produits et services hors tva (la tva n'est pas appliquée sur la taxe locale)
2 : taxe locale sur les produits et services avant tva (la tva est appliquée sur le montant + la taxe locale)
3 : taxe locale uniquement sur les produits hors tva (la tva n'est pas appliquée sur la taxe locale)
4 : taxe locale uniquement sur les produits avant tva (la tva est appliquée sur le montant + la taxe locale)
5 : taxe locale uniquement sur les services hors tva (la tva n'est pas appliquée sur la taxe locale)
6 : taxe locale uniquement sur les service avant tva (la tva est appliquée sur le montant + la taxe locale) From b1d50e3f7fc0570f7841ba3e90799c05c6adb0d2 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 15 Mar 2013 18:56:44 +0100 Subject: [PATCH 2/8] Move extrafield type select list on top of form --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index d4f5cf9ae4029..864eaa13f0d1e 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -55,16 +55,16 @@ function init_typeoffields(type) + + - -'; + return $out; + } } ?> diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 864eaa13f0d1e..5be1b8baaae90 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -25,11 +25,18 @@ function init_typeoffields(type) var size = jQuery("#size"); var unique = jQuery("#unique"); var required = jQuery("#required"); + var default_value = jQuery("#default_value"); if (type == 'date') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } @@ -41,6 +48,7 @@ function init_typeoffields(type) 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 == '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'); } init_typeoffields(''); @@ -64,7 +72,7 @@ function init_typeoffields(type) - + - + From 7a16e1b6581e72502f1fa37d65e8e65b97dbe40c Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 15 Mar 2013 23:41:24 +0100 Subject: [PATCH 4/8] Show extrafield separator in propale --- htdocs/comm/propal.php | 51 +++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e17940379bf9e..eb4278cb52858 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1360,11 +1360,20 @@ foreach($extrafields->attribute_label as $key=>$label) { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''."\n"; + + // Show separator only + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''."\n"; + } } } @@ -1854,19 +1863,25 @@ foreach($extrafields->attribute_label as $key=>$label) { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''."\n"; + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''."\n"; + } } if(count($extrafields->attribute_label) > 0) { From ba0963ea7dbfd3241637c7e5e79cf27ac27ed5c3 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 00:00:57 +0100 Subject: [PATCH 5/8] Fix : implement separator extrafield - missing check on update --- htdocs/core/class/commonobject.class.php | 24 +++++++++++++++--------- htdocs/core/class/extrafields.class.php | 9 ++++++--- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 50bd564e8d9b2..26b8a0c582630 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2138,21 +2138,27 @@ function insertExtraFields() $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; foreach($this->array_options as $key => $value) { + $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut - $sql.=",".substr($key,8); // Remove 'options_' prefix + if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate + $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; foreach($this->array_options as $key => $value) { + $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field o fattribut - if ($this->array_options[$key] != '') - { - $sql.=",'".$this->array_options[$key]."'"; - } - else - { - $sql.=",null"; - } + if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) + { + if ($this->array_options[$key] != '') + { + $sql.=",'".$this->array_options[$key]."'"; + } + else + { + $sql.=",null"; + } + } } $sql.=")"; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d917d6283ce50..5b12672f6cefd 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -357,7 +357,6 @@ private function delete_label($attrname, $elementtype='member') function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos,$param='') { $table=$elementtype.'_extrafields'; - // Special case for not normalized table names if ($elementtype == 'member') $table='adherent_extrafields'; elseif ($elementtype == 'company') $table='societe_extrafields'; @@ -385,8 +384,12 @@ function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required= $lengthdb=$length; } $field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required?'NOT NULL':'NULL')); - $result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); - if ($result > 0) + + if ($type != 'separate') // No table update when separate type + { + $result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); + } + if ($result > 0 || $type == 'separate') { if ($label) { From f1a05528ad49e06ec1592089c0bcc5dfc162eba0 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 00:16:30 +0100 Subject: [PATCH 6/8] Show extrafield separator on invoice --- htdocs/compta/facture.php | 40 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 6b0cd0dfb9316..4e0652a9d1dfd 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2101,11 +2101,19 @@ foreach($extrafields->attribute_label as $key=>$label) { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''."\n"; + // Show separator only + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''."\n"; + } } } @@ -3090,19 +3098,25 @@ foreach($extrafields->attribute_label as $key=>$label) { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''."\n"; } - - print ''."\n"; } if(count($extrafields->attribute_label) > 0) { From f16c9dd3ac2e8ba1abda433ca11a94d57b7b9998 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 00:19:53 +0100 Subject: [PATCH 7/8] Fix : bad permission --- htdocs/compta/facture.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 4e0652a9d1dfd..96fca70af4c6c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3107,7 +3107,7 @@ print 'attribute_required[$key])) print ' class="fieldrequired"'; print '>'.$label.''; } From 9a5743187984a948a7bc2fba664e7cede7035e60 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 00:28:45 +0100 Subject: [PATCH 8/8] Show extrafield separator on thirdparty and contact --- htdocs/contact/fiche.php | 47 ++++++++++++++------ htdocs/societe/soc.php | 95 ++++++++++++++++++++++++---------------- 2 files changed, 91 insertions(+), 51 deletions(-) diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 2f1f061374031..885711bb526ed 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -521,11 +521,18 @@ foreach($extrafields->attribute_label as $key=>$label) { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:'')); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''."\n"; + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''."\n"; + } } } @@ -736,11 +743,18 @@ foreach($extrafields->attribute_label as $key=>$label) { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.'\n"; + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.'\n"; + } } } @@ -948,9 +962,16 @@ foreach($extrafields->attribute_label as $key=>$label) { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); - print '\n"; + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print '\n"; + } } } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b45bf5a8e59b0..80de6ec7146a9 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -985,20 +985,27 @@ { $colspan='3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:'')); - if (($e % 2) == 0) + if ($extrafields->attribute_type[$key] == 'separate') { - print ''; - $colspan='0'; - } - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print ''; - - if (($e % 2) == 1) print ''."\n"; - $e++; + print $extrafields->showSeparator($key); + } + else + { + if (($e % 2) == 0) + { + print ''; + $colspan='0'; + } + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''; + print ''; + + if (($e % 2) == 1) print ''."\n"; + $e++; + } } } @@ -1414,25 +1421,30 @@ { $colspan = '3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - - if (($e % 2) == 0) + if ($extrafields->attribute_type[$key] == 'separate') { - print ''."\n"; - $colspan = '0'; + print $extrafields->showSeparator($key); } - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''."\n"; - print '"."\n"; - - if (($e % 2) == 1 ) + else { - print "\n"; + if (($e % 2) == 0) + { + print ''."\n"; + $colspan = '0'; + } + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''."\n"; + print '"."\n"; + + if (($e % 2) == 1 ) + { + print "\n"; + } + $e++; } - $old_pos = $extrafields->attribute_pos[$key]; - $e++; } } // Logo @@ -1753,18 +1765,25 @@ { $colspan='3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); - if (($e % 2) == 0) + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else { - print ''; - $colspan='0'; + if (($e % 2) == 0) + { + print ''; + $colspan='0'; + } + print ''; + print '"; + + if (($e % 2) == 1) print ''; + $e++; } - print ''; - print '"; - - if (($e % 2) == 1) print ''; - $e++; } }
trans("Type"); ?> +selectarray('type',$type2label,GETPOST('type')); ?> +
trans("Position"); ?>
trans("Label"); ?>
trans("AttributeCode"); ?> (trans("AlphaNumOnlyCharsAndNoSpace"); ?>)
trans("Type"); ?> -selectarray('type',$type2label,GETPOST('type')); ?> -
From b36b776f10a3a3627223f1385fde1ccc5e24abf5 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 15 Mar 2013 23:39:18 +0100 Subject: [PATCH 3/8] IKM : work on new extrafield separator type --- htdocs/core/class/extrafields.class.php | 27 ++++++++++++++----- htdocs/core/tpl/admin_extrafields_add.tpl.php | 14 +++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index b09ee145ebfaf..d917d6283ce50 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -64,7 +64,7 @@ class ExtraFields 'phone'=>'ExtrafieldPhone', 'mail'=>'ExtrafieldMail', 'select' => 'ExtrafieldSelect', - 'separator' => 'ExtrafieldSeparator' + 'separate' => 'ExtrafieldSeparator' ); /** @@ -103,14 +103,13 @@ function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $uni if (empty($attrname)) return -1; if (empty($label)) return -1; - - // Create field into database except for separator type - if ($elementtype != 'separator') + // Create field into database except for separator type which is not stored in database + if ($type != 'separate') { $result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param); } $err1=$this->errno; - if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $elementtype == 'separator') + if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') { // Add declaration of field into table $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param); @@ -550,8 +549,13 @@ function fetch_name_optionals_label($elementtype='member',$forceload=false) { while ($tab = $this->db->fetch_object($resql)) { + // we can add this attribute to adherent object - $array_name_label[$tab->name]=$tab->label; + if ($tab->type != 'separate') + { + $array_name_label[$tab->name]=$tab->label; + } + $this->attribute_type[$tab->name]=$tab->type; $this->attribute_label[$tab->name]=$tab->label; $this->attribute_size[$tab->name]=$tab->size; @@ -734,5 +738,16 @@ function showOutputField($key,$value,$moreparam='') return $out; } + /** + * Return HTML string to print separator extrafield + * + * @param string $key Key of attribute + * @return string + */ + function showSeparator($key) + { + $out = '
'.$this->attribute_label[$key].'
trans("Label"); ?>
trans("AttributeCode"); ?> (trans("AlphaNumOnlyCharsAndNoSpace"); ?>)
trans("AttributeCode"); ?> (trans("AlphaNumOnlyCharsAndNoSpace"); ?>)
@@ -75,7 +83,7 @@ function init_typeoffields(type)
trans("DefaultValue"); ?>">
trans("DefaultValue"); ?>">
trans("Size"); ?>
'; - print $extrafields->showInputField($key,$value); - print '
'; + print $extrafields->showInputField($key,$value); + print '
'; - if ($action == 'edit_extras' && $user->rights->propal->creer) - { - print $extrafields->showInputField($key,$value); - } - else - { - print $extrafields->showOutputField($key,$value); - } - - print '
'; + if ($action == 'edit_extras' && $user->rights->propal->creer) + { + print $extrafields->showInputField($key,$value); + } + else + { + print $extrafields->showOutputField($key,$value); + } + print '
'; - print $extrafields->showInputField($key,$value); - print '
'; + print $extrafields->showInputField($key,$value); + print '
'; - if ($action == 'edit_extras' && $user->rights->propal->creer) + if ($extrafields->attribute_type[$key] == 'separate') { - print $extrafields->showInputField($key,$value); + print $extrafields->showSeparator($key); } else { - print $extrafields->showOutputField($key,$value); + print '
'; + if ($action == 'edit_extras' && $user->rights->propal->creer) + { + print $extrafields->showInputField($key,$value); + } + else + { + print $extrafields->showOutputField($key,$value); + } + print '
'; - if ($action == 'edit_extras' && $user->rights->propal->creer) + if ($action == 'edit_extras' && $user->rights->facture->creer) { print $extrafields->showInputField($key,$value); } @@ -3121,7 +3121,7 @@ if(count($extrafields->attribute_label) > 0) { - if ($action == 'edit_extras' && $user->rights->propal->creer) + if ($action == 'edit_extras' && $user->rights->facture->creer) { print '
'; print ''; @@ -3130,7 +3130,7 @@ } else { - if ($object->statut == 0 && $user->rights->propal->creer) + if ($object->statut == 0 && $user->rights->facture->creer) { print '
'.img_picto('','edit').' '.$langs->trans('Modify').'
'; - print $extrafields->showInputField($key,$value); - print '
'; + print $extrafields->showInputField($key,$value); + print '
'; - print $extrafields->showInputField($key,$value); - print "
'; + print $extrafields->showInputField($key,$value); + print "
'.$label.''; - print $extrafields->showOutputField($key,$value); - print "
'.$label.''; + print $extrafields->showOutputField($key,$value); + print "
'; - print $extrafields->showInputField($key,$value); - print '
'; + print $extrafields->showInputField($key,$value); + print '
'; - print $extrafields->showInputField($key,$value); - print "
'; + print $extrafields->showInputField($key,$value); + print "
'.$label.''; + print $extrafields->showOutputField($key,$value); + print "
'.$label.''; - print $extrafields->showOutputField($key,$value); - print "