From 337897e0a131b21e6bbb36afbb9842f3a646036f Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 23 Dec 2016 15:01:49 +0100 Subject: [PATCH 1/2] NEW : Allow extrafields list select to be dependands on other standard list and not only other extrafields list --- htdocs/core/class/commonobject.class.php | 36 ++++++++++++------------ htdocs/langs/en_US/admin.lang | 6 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5e83f59ea36..7e59685b4b3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -597,11 +597,11 @@ abstract class CommonObject dol_syslog("CODE_NOT_VALID_FOR_THIS_ELEMENT"); return -3; } - + $datecreate = dol_now(); $this->db->begin(); - + // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; @@ -1230,19 +1230,19 @@ abstract class CommonObject function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $user='', $trigkey='') { global $user,$langs,$conf; - + if (empty($table)) $table=$this->table_element; if (empty($id)) $id=$this->id; if (empty($format)) $format='text'; if (empty($id_field)) $id_field='rowid'; $error=0; - + $this->db->begin(); // Special case if ($table == 'product' && $field == 'note_private') $field='note'; - + $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value); @@ -1517,7 +1517,7 @@ abstract class CommonObject if($mode == 1) { $line->subprice = 0; } - + switch ($this->element) { case 'propal': $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); @@ -2153,7 +2153,7 @@ abstract class CommonObject // Special cas //var_dump($this->table_element);exit; if ($this->table_element == 'product') $suffix=''; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL"); $sql.= " WHERE rowid =". $this->id; @@ -2163,7 +2163,7 @@ abstract class CommonObject { if ($suffix == '_public') $this->note_public = $note; else if ($suffix == '_private') $this->note_private = $note; - else + else { $this->note = $note; // deprecated $this->note_private = $note; @@ -2412,7 +2412,7 @@ abstract class CommonObject // Special case if ($origin == 'order') $origin='commande'; if ($origin == 'invoice') $origin='facture'; - + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -2899,7 +2899,7 @@ abstract class CommonObject function isObjectUsed($id=0) { if (empty($id)) $id=$this->id; - + // Check parameters if (! isset($this->childtables) || ! is_array($this->childtables) || count($this->childtables) == 0) { @@ -3341,9 +3341,9 @@ abstract class CommonObject if ($conf->global->MARGIN_TYPE == "1") print ''.$langs->trans('BuyingPrice').''; else - print ''.$langs->trans('CostPrice').''; + print ''.$langs->trans('CostPrice').''; } - + if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) print ''.$langs->trans('MarginRate').''; if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) @@ -3875,7 +3875,7 @@ abstract class CommonObject if ($filefound) { global $db; // Required to solve a conception default in commonstickergenerator.class.php making an include of code using $db - + require_once $file; $obj = new $classname($this->db); @@ -3934,7 +3934,7 @@ abstract class CommonObject // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if (in_array(get_class($this), array('Adherent'))) + if (in_array(get_class($this), array('Adherent'))) { $arrayofrecords = array(); // The write_file of templates of adherent class need this $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); @@ -4195,7 +4195,7 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); - + //Eliminate copied source object extra_fields that do not exist in target object $new_array_options=array(); foreach ($this->array_options as $key => $value) { @@ -4244,7 +4244,7 @@ abstract class CommonObject { if (is_numeric($value)) $res=$object->fetch($value); else $res=$object->fetch('',$value); - + if ($res > 0) $this->array_options[$key]=$object->id; else { @@ -4503,7 +4503,7 @@ abstract class CommonObject jQuery(document).ready(function() { function showOptions(child_list, parent_list) { - var val = $("select[name=\"options_"+parent_list+"\"]").val(); + var val = $("select[name="+parent_list+"]").val(); var parentVal = parent_list + ":" + val; if(val > 0) { $("select[name=\""+child_list+"\"] option[parent]").hide(); @@ -4518,7 +4518,7 @@ abstract class CommonObject var parent = $(this).find("option[parent]:first").attr("parent"); var infos = parent.split(":"); var parent_list = infos[0]; - $("select[name=\"options_"+parent_list+"\"]").change(function() { + $("select[name="+parent_list+"]").change(function() { showOptions(child_list, parent_list); }); }); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 82ff69fe88a..44f10c5cf36 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -373,11 +373,11 @@ ExtrafieldCheckBox=Checkbox ExtrafieldRadio=Radio button ExtrafieldCheckBoxFromList= Checkbox from table ExtrafieldLink=Link to an object -ExtrafieldParamHelpselect=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
...

In order to have the list depending on another :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key +ExtrafieldParamHelpselect=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
...

In order to have the list depending on another complementary attribute list :
1,value1|options_parent_list_code:parent_key
2,value2|options_parent_list_code:parent_key

In order to have the list depending on another list :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... -ExtrafieldParamHelpsellist=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter -ExtrafieldParamHelpchkbxlst=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelpsellist=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another complementary attribute list:
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelpchkbxlst=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another complementary attribute list :
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter ExtrafieldParamHelplink=Parameters must be ObjectName:Classpath
Syntax : ObjectName:Classpath
Example : Societe:societe/class/societe.class.php LibraryToBuildPDF=Library used for PDF generation WarningUsingFPDF=Warning: Your conf.php contains directive dolibarr_pdf_force_fpdf=1. 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.
To solve this and have a full support of PDF generation, please download TCPDF library, then comment or remove the line $dolibarr_pdf_force_fpdf=1, and add instead $dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir' From 055a00a33804fd0f41f4f2c7655a72031c482407 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 27 Jan 2017 15:18:12 +0100 Subject: [PATCH 2/2] fix travis --- htdocs/core/class/commonobject.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 36999f12dc7..4a84ac6a829 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2151,6 +2151,8 @@ abstract class CommonObject */ function update_note($note,$suffix='') { + global $user; + if (! $this->table_element) { dol_syslog(get_class($this)."::update_note was called on objet with property table_element not defined", LOG_ERR); @@ -2167,6 +2169,7 @@ abstract class CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL"); + $sql.= " ,".(in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))?"fk_user_mod":"fk_user_modif")." = ".$user->id; $sql.= " WHERE rowid =". $this->id; dol_syslog(get_class($this)."::update_note", LOG_DEBUG);