From 2ec2dc59a40534f78448a9044ce6b9690e802c2f Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 13 May 2022 14:55:21 +0200 Subject: [PATCH 01/67] New : import fields in societe class --- .../modules/import/import_csv.modules.php | 36 +++++++++++++---- .../modules/import/import_xlsx.modules.php | 39 +++++++++++++++---- htdocs/core/modules/modSociete.class.php | 20 ++++++++++ 3 files changed, 79 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index e45630df298..62f0ca6d387 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -709,15 +709,35 @@ class ImportCsv extends ModeleImports } // Define $listfields and $listvalues to build SQL request - $listfields[] = $fieldname; - - // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { - $listvalues[] = ($newval == '0' ? $newval : "null"); - } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { - $listvalues[] = "''"; + if ($conf->socialnetworks->enabled && strpos($fieldname, "socialnetworks") !== false) { + if (!in_array("socialnetworks", $listfields)) { + $listfields[] = "socialnetworks"; + } + if (!empty($newval) && $arrayrecord[($key - 1)]['type'] > 0) { + $socialkey = array_search("socialnetworks", $listfields); + if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { + $socialnetwork = explode("_", $fieldname)[1]; + $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; + $listvalues[$socialkey] = $newvalue; + } else { + $socialnetwork = explode("_", $fieldname)[1]; + $jsondata = $listvalues[$socialkey]; + $jsondata = str_replace("'", "", $jsondata); + $json = json_decode($jsondata); + $json->$socialnetwork = $this->db->escape($newval); + $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; + } + } } else { - $listvalues[] = "'".$this->db->escape($newval)."'"; + $listfields[] = $fieldname; + // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert + if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { + $listvalues[] = "''"; + } else { + $listvalues[] = "'".$this->db->escape($newval)."'"; + } } } $i++; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 9fa5cbf2c44..a64063fa9af 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -363,6 +363,8 @@ class ImportXlsx extends ModeleImports $warning = 0; $this->errors = array(); $this->warnings = array(); + $this->nbinsert = 0; + $this->nbupdate = 0; //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); @@ -750,15 +752,36 @@ class ImportXlsx extends ModeleImports } // Define $listfields and $listvalues to build SQL request - $listfields[] = $fieldname; - - // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key)]['type'] < 0) { - $listvalues[] = ($newval == '0' ? $newval : "null"); - } elseif (empty($newval) && $arrayrecord[($key)]['type'] == 0) { - $listvalues[] = "''"; + if ($conf->socialnetworks->enabled && strpos($fieldname, "socialnetworks") !== false) { + if (!in_array("socialnetworks", $listfields)) { + $listfields[] = "socialnetworks"; + } + if (!empty($newval) && $arrayrecord[($key)]['type'] > 0) { + $socialkey = array_search("socialnetworks", $listfields); + if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { + $socialnetwork = explode("_", $fieldname)[1]; + $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; + $listvalues[$socialkey] = $newvalue; + } else { + $socialnetwork = explode("_", $fieldname)[1]; + $jsondata = $listvalues[$socialkey]; + $jsondata = str_replace("'", "", $jsondata); + $json = json_decode($jsondata); + $json->$socialnetwork = $this->db->escape($newval); + $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; + } + } } else { - $listvalues[] = "'" . $this->db->escape($newval) . "'"; + $listfields[] = $fieldname; + + // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert + if (empty($newval) && $arrayrecord[($key)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key)]['type'] == 0) { + $listvalues[] = "''"; + } else { + $listvalues[] = "'" . $this->db->escape($newval) . "'"; + } } } $i++; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 09089d57563..84a5e97f1bf 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -519,6 +519,16 @@ class modSociete extends DolibarrModules if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { $this->import_fields_array[$r] += array('s.accountancy_code_sell'=>'ProductAccountancySellCode', 's.accountancy_code_buy'=>'ProductAccountancyBuyCode'); } + // Add social networks fields + if (!empty($conf->socialnetworks->enabled)) { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; + $resql = $this->db->query($sql); + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 's.socialnetworks_'.$obj->code; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel; + } + } // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); @@ -695,6 +705,16 @@ class modSociete extends DolibarrModules 's.note_private' => "NotePrivate", 's.note_public' => "NotePublic" ); + // Add social networks fields + if (!empty($conf->socialnetworks->enabled)) { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; + $resql = $this->db->query($sql); + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 's.socialnetworks_'.$obj->code; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel; + } + } // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); From cfc8ce2ea86ce423540cfb5536dd9b8de709db0c Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 13 May 2022 15:02:17 +0200 Subject: [PATCH 02/67] Revert "New : import fields in societe class" This reverts commit 2ec2dc59a40534f78448a9044ce6b9690e802c2f. --- .../modules/import/import_csv.modules.php | 36 ++++------------- .../modules/import/import_xlsx.modules.php | 39 ++++--------------- htdocs/core/modules/modSociete.class.php | 20 ---------- 3 files changed, 16 insertions(+), 79 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 62f0ca6d387..e45630df298 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -709,35 +709,15 @@ class ImportCsv extends ModeleImports } // Define $listfields and $listvalues to build SQL request - if ($conf->socialnetworks->enabled && strpos($fieldname, "socialnetworks") !== false) { - if (!in_array("socialnetworks", $listfields)) { - $listfields[] = "socialnetworks"; - } - if (!empty($newval) && $arrayrecord[($key - 1)]['type'] > 0) { - $socialkey = array_search("socialnetworks", $listfields); - if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { - $socialnetwork = explode("_", $fieldname)[1]; - $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; - $listvalues[$socialkey] = $newvalue; - } else { - $socialnetwork = explode("_", $fieldname)[1]; - $jsondata = $listvalues[$socialkey]; - $jsondata = str_replace("'", "", $jsondata); - $json = json_decode($jsondata); - $json->$socialnetwork = $this->db->escape($newval); - $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; - } - } + $listfields[] = $fieldname; + + // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert + if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { + $listvalues[] = "''"; } else { - $listfields[] = $fieldname; - // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { - $listvalues[] = ($newval == '0' ? $newval : "null"); - } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { - $listvalues[] = "''"; - } else { - $listvalues[] = "'".$this->db->escape($newval)."'"; - } + $listvalues[] = "'".$this->db->escape($newval)."'"; } } $i++; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index a64063fa9af..9fa5cbf2c44 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -363,8 +363,6 @@ class ImportXlsx extends ModeleImports $warning = 0; $this->errors = array(); $this->warnings = array(); - $this->nbinsert = 0; - $this->nbupdate = 0; //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); @@ -752,36 +750,15 @@ class ImportXlsx extends ModeleImports } // Define $listfields and $listvalues to build SQL request - if ($conf->socialnetworks->enabled && strpos($fieldname, "socialnetworks") !== false) { - if (!in_array("socialnetworks", $listfields)) { - $listfields[] = "socialnetworks"; - } - if (!empty($newval) && $arrayrecord[($key)]['type'] > 0) { - $socialkey = array_search("socialnetworks", $listfields); - if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { - $socialnetwork = explode("_", $fieldname)[1]; - $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; - $listvalues[$socialkey] = $newvalue; - } else { - $socialnetwork = explode("_", $fieldname)[1]; - $jsondata = $listvalues[$socialkey]; - $jsondata = str_replace("'", "", $jsondata); - $json = json_decode($jsondata); - $json->$socialnetwork = $this->db->escape($newval); - $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; - } - } - } else { - $listfields[] = $fieldname; + $listfields[] = $fieldname; - // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key)]['type'] < 0) { - $listvalues[] = ($newval == '0' ? $newval : "null"); - } elseif (empty($newval) && $arrayrecord[($key)]['type'] == 0) { - $listvalues[] = "''"; - } else { - $listvalues[] = "'" . $this->db->escape($newval) . "'"; - } + // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert + if (empty($newval) && $arrayrecord[($key)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key)]['type'] == 0) { + $listvalues[] = "''"; + } else { + $listvalues[] = "'" . $this->db->escape($newval) . "'"; } } $i++; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 84a5e97f1bf..09089d57563 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -519,16 +519,6 @@ class modSociete extends DolibarrModules if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { $this->import_fields_array[$r] += array('s.accountancy_code_sell'=>'ProductAccountancySellCode', 's.accountancy_code_buy'=>'ProductAccountancyBuyCode'); } - // Add social networks fields - if (!empty($conf->socialnetworks->enabled)) { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; - $resql = $this->db->query($sql); - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 's.socialnetworks_'.$obj->code; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel; - } - } // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); @@ -705,16 +695,6 @@ class modSociete extends DolibarrModules 's.note_private' => "NotePrivate", 's.note_public' => "NotePublic" ); - // Add social networks fields - if (!empty($conf->socialnetworks->enabled)) { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; - $resql = $this->db->query($sql); - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 's.socialnetworks_'.$obj->code; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel; - } - } // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); From 1e406276c580939be97f4d76fc24bb9052206544 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 13 May 2022 15:04:30 +0200 Subject: [PATCH 03/67] New : import fields in societe class --- .../modules/import/import_csv.modules.php | 36 +++++++++++++---- .../modules/import/import_xlsx.modules.php | 39 +++++++++++++++---- htdocs/core/modules/modSociete.class.php | 20 ++++++++++ 3 files changed, 79 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index e45630df298..62f0ca6d387 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -709,15 +709,35 @@ class ImportCsv extends ModeleImports } // Define $listfields and $listvalues to build SQL request - $listfields[] = $fieldname; - - // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { - $listvalues[] = ($newval == '0' ? $newval : "null"); - } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { - $listvalues[] = "''"; + if ($conf->socialnetworks->enabled && strpos($fieldname, "socialnetworks") !== false) { + if (!in_array("socialnetworks", $listfields)) { + $listfields[] = "socialnetworks"; + } + if (!empty($newval) && $arrayrecord[($key - 1)]['type'] > 0) { + $socialkey = array_search("socialnetworks", $listfields); + if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { + $socialnetwork = explode("_", $fieldname)[1]; + $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; + $listvalues[$socialkey] = $newvalue; + } else { + $socialnetwork = explode("_", $fieldname)[1]; + $jsondata = $listvalues[$socialkey]; + $jsondata = str_replace("'", "", $jsondata); + $json = json_decode($jsondata); + $json->$socialnetwork = $this->db->escape($newval); + $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; + } + } } else { - $listvalues[] = "'".$this->db->escape($newval)."'"; + $listfields[] = $fieldname; + // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert + if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { + $listvalues[] = "''"; + } else { + $listvalues[] = "'".$this->db->escape($newval)."'"; + } } } $i++; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 9fa5cbf2c44..a64063fa9af 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -363,6 +363,8 @@ class ImportXlsx extends ModeleImports $warning = 0; $this->errors = array(); $this->warnings = array(); + $this->nbinsert = 0; + $this->nbupdate = 0; //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); @@ -750,15 +752,36 @@ class ImportXlsx extends ModeleImports } // Define $listfields and $listvalues to build SQL request - $listfields[] = $fieldname; - - // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key)]['type'] < 0) { - $listvalues[] = ($newval == '0' ? $newval : "null"); - } elseif (empty($newval) && $arrayrecord[($key)]['type'] == 0) { - $listvalues[] = "''"; + if ($conf->socialnetworks->enabled && strpos($fieldname, "socialnetworks") !== false) { + if (!in_array("socialnetworks", $listfields)) { + $listfields[] = "socialnetworks"; + } + if (!empty($newval) && $arrayrecord[($key)]['type'] > 0) { + $socialkey = array_search("socialnetworks", $listfields); + if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { + $socialnetwork = explode("_", $fieldname)[1]; + $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; + $listvalues[$socialkey] = $newvalue; + } else { + $socialnetwork = explode("_", $fieldname)[1]; + $jsondata = $listvalues[$socialkey]; + $jsondata = str_replace("'", "", $jsondata); + $json = json_decode($jsondata); + $json->$socialnetwork = $this->db->escape($newval); + $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; + } + } } else { - $listvalues[] = "'" . $this->db->escape($newval) . "'"; + $listfields[] = $fieldname; + + // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert + if (empty($newval) && $arrayrecord[($key)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key)]['type'] == 0) { + $listvalues[] = "''"; + } else { + $listvalues[] = "'" . $this->db->escape($newval) . "'"; + } } } $i++; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index e4cf484df58..3b0a297ae0c 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -519,6 +519,16 @@ class modSociete extends DolibarrModules if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { $this->import_fields_array[$r] += array('s.accountancy_code_sell'=>'ProductAccountancySellCode', 's.accountancy_code_buy'=>'ProductAccountancyBuyCode'); } + // Add social networks fields + if (!empty($conf->socialnetworks->enabled)) { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; + $resql = $this->db->query($sql); + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 's.socialnetworks_'.$obj->code; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel; + } + } // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); @@ -718,6 +728,16 @@ class modSociete extends DolibarrModules 's.note_private' => "NotePrivate", 's.note_public' => "NotePublic" ); + // Add social networks fields + if (!empty($conf->socialnetworks->enabled)) { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; + $resql = $this->db->query($sql); + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 's.socialnetworks_'.$obj->code; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel; + } + } // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); From ada81750c10ded375b2697a001043be6207da5d4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 17 May 2022 12:53:50 +0200 Subject: [PATCH 04/67] NEW: Add Customer Ref on Intervention --- htdocs/fichinter/card.php | 20 ++++- htdocs/fichinter/class/fichinter.class.php | 76 ++++++++++++++++++- htdocs/fichinter/list.php | 29 ++++++- .../install/mysql/migration/15.0.0-16.0.0.sql | 2 + htdocs/install/mysql/tables/llx_fichinter.sql | 1 + 5 files changed, 123 insertions(+), 5 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 0d7e5278a14..a2271dbb063 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -55,6 +55,7 @@ $langs->loadLangs(array('bills', 'companies', 'interventions', 'stocks')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); +$ref_client = GETPOST('ref_client', 'alpha'); $socid = (int) GETPOST('socid', 'int'); $contratid = (int) GETPOST('contratid', 'int'); $action = GETPOST('action', 'alpha'); @@ -222,6 +223,7 @@ if (empty($reshook)) { $object->author = $user->id; $object->description = GETPOST('description', 'restricthtml'); $object->ref = $ref; + $object->ref_client = $ref_client; $object->model_pdf = GETPOST('model', 'alpha'); $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); @@ -432,6 +434,7 @@ if (empty($reshook)) { $object->author = $user->id; $object->description = GETPOST('description', 'restricthtml'); $object->ref = $ref; + $object->ref_client = $ref_client; $result = $object->update($user); if ($result < 0) { @@ -449,6 +452,12 @@ if (empty($reshook)) { if ($result < 0) { dol_print_error($db, $object->error); } + } elseif ($action == 'setref_client' && $user->rights->ficheinter->creer) { + // Positionne ref client + $result = $object->setRefClient($user, GETPOST('ref_client','alpha')); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) { $result = $object->delete($user); if ($result < 0) { @@ -879,6 +888,11 @@ if ($action == 'create') { // Ref print ''.$langs->trans('Ref').''.$langs->trans("Draft").''; + // Ref customer + print ''.$langs->trans('RefCustomer').''; + print ''; + print ''; + // Description (must be a textarea and not html must be allowed (used in list view) print ''.$langs->trans("Description").''; print ''; @@ -1134,10 +1148,10 @@ if ($action == 'create') { $morehtmlref = '
'; // Ref customer - //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', 0, 1); - //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project if (!empty($conf->projet->enabled)) { $langs->load("projects"); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index b5e3a13f3c0..ec603defd62 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -44,6 +44,7 @@ class Fichinter extends CommonObject 'fk_contrat' =>array('type'=>'integer', 'label'=>'Fk contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>25), 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>30), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>35), + 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>36), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>40, 'index'=>1), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>45), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>50), @@ -146,6 +147,12 @@ class Fichinter extends CommonObject */ public $fk_project = 0; + /** + * Customer Ref + * @var string + */ + public $ref_client; + /** * @var array extraparams */ @@ -253,6 +260,9 @@ class Fichinter extends CommonObject if (!is_numeric($this->duration)) { $this->duration = 0; } + if (isset($this->ref_client)) { + $this->ref_client = trim($this->ref_client); + } if ($this->socid <= 0) { $this->error = 'ErrorFicheinterCompanyDoesNotExist'; @@ -271,6 +281,7 @@ class Fichinter extends CommonObject $sql .= "fk_soc"; $sql .= ", datec"; $sql .= ", ref"; + $sql .= ", ref_client"; $sql .= ", entity"; $sql .= ", fk_user_author"; $sql .= ", fk_user_modif"; @@ -286,6 +297,7 @@ class Fichinter extends CommonObject $sql .= $this->socid; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".$this->db->escape($this->ref)."'"; + $sql .= ", '".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null")."'"; $sql .= ", ".((int) $conf->entity); $sql .= ", ".((int) $user->id); $sql .= ", ".((int) $user->id); @@ -372,6 +384,9 @@ class Fichinter extends CommonObject if (!dol_strlen($this->fk_project)) { $this->fk_project = 0; } + if (isset($this->ref_client)) { + $this->ref_client = trim($this->ref_client); + } $error = 0; @@ -380,6 +395,7 @@ class Fichinter extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; $sql .= "description = '".$this->db->escape($this->description)."'"; $sql .= ", duree = ".((int) $this->duration); + $sql .= ", ref_client = ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null"); $sql .= ", fk_projet = ".((int) $this->fk_project); $sql .= ", note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= ", note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); @@ -422,7 +438,7 @@ class Fichinter extends CommonObject */ public function fetch($rowid, $ref = '') { - $sql = "SELECT f.rowid, f.ref, f.description, f.fk_soc, f.fk_statut,"; + $sql = "SELECT f.rowid, f.ref, f.ref_client, f.description, f.fk_soc, f.fk_statut,"; $sql .= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; $sql .= " f.date_valid as datev,"; $sql .= " f.tms as datem,"; @@ -443,6 +459,7 @@ class Fichinter extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref; + $this->ref_client = $obj->ref_client; $this->description = $obj->description; $this->socid = $obj->fk_soc; $this->statut = $obj->fk_statut; @@ -1289,6 +1306,7 @@ class Fichinter extends CommonObject // Initialise parametres $this->id = 0; $this->ref = 'SPECIMEN'; + $this->ref_client = 'SPECIMEN CLIENT'; $this->specimen = 1; $this->socid = 1; $this->datec = $now; @@ -1377,6 +1395,62 @@ class Fichinter extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Set customer reference number + * + * @param User $user Object user that modify + * @param string $ref_client Customer reference + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if ko, >0 if ok + */ + public function setRefClient($user, $ref_client, $notrigger = 0) + { + // phpcs:enable + if (!empty($user->rights->ficheinter->creer)) { + $error = 0; + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref_client = ".(empty($ref_client) ? 'NULL' : "'".$this->db->escape($ref_client)."'"); + $sql .= " WHERE rowid = ".((int) $this->id); + + dol_syslog(__METHOD__.' $this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = $this->db->error(); + $error++; + } + + if (!$error) { + $this->oldcopy = clone $this; + $this->ref_client = $ref_client; + } + + if (!$notrigger && empty($error)) { + // Call trigger + $result = $this->call_trigger('FICHINTER_MODIFY', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + foreach ($this->errors as $errmsg) { + dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } + } else { + return -1; + } + } } /** diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index f0e028ea92f..d83a1438f1a 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -58,6 +58,7 @@ $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'interventionlist'; $search_ref = GETPOST('search_ref') ?GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha'); +$search_ref_client = GETPOST('search_ref_client', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha'); $search_projet_ref = GETPOST('search_projet_ref', 'alpha'); @@ -122,6 +123,7 @@ if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) { // Definition of fields for list $arrayfields = array( 'f.ref'=>array('label'=>'Ref', 'checked'=>1), + 'f.ref_client'=>array('label'=>'RefCustomer', 'checked'=>1), 's.nom'=>array('label'=>'ThirdParty', 'checked'=>1), 'pr.ref'=>array('label'=>'Project', 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), 'c.ref'=>array('label'=>'Contract', 'checked'=>1, 'enabled'=>(empty($conf->contrat->enabled) ? 0 : 1)), @@ -166,6 +168,7 @@ if (empty($reshook)) { // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_ref = ""; + $search_ref_client = ""; $search_company = ""; $search_projet_ref = ""; $search_contrat_ref = ""; @@ -218,7 +221,7 @@ foreach ($arrayfields as $tmpkey => $tmpval) { } $sql = "SELECT"; -$sql .= " f.ref, f.rowid, f.fk_statut as status, f.description, f.datec as date_creation, f.tms as date_update, f.note_public, f.note_private,"; +$sql .= " f.ref, f.ref_client, f.rowid, f.fk_statut as status, f.description, f.datec as date_creation, f.tms as date_update, f.note_public, f.note_private,"; if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) { $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,"; } @@ -267,6 +270,9 @@ $sql .= " AND f.fk_soc = s.rowid"; if ($search_ref) { $sql .= natural_search('f.ref', $search_ref); } +if ($search_ref_client) { + $sql .= natural_search('f.ref_client', $search_ref_client); +} if ($search_company) { $sql .= natural_search('s.nom', $search_company); } @@ -351,6 +357,9 @@ if ($resql) { if ($search_ref) { $param .= "&search_ref=".urlencode($search_ref); } + if ($search_ref_client) { + $param .= "&search_ref_client=".urlencode($search_ref_client); + } if ($search_company) { $param .= "&search_company=".urlencode($search_company); } @@ -447,6 +456,11 @@ if ($resql) { print ''; print ''; } + if (!empty($arrayfields['f.ref_client']['checked'])) { + print ''; + print ''; + print ''; + } if (!empty($arrayfields['s.nom']['checked'])) { print ''; print ''; @@ -526,6 +540,9 @@ if ($resql) { if (!empty($arrayfields['f.ref']['checked'])) { print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['f.ref_client']['checked'])) { + print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], "f.ref_client", "", $param, '', $sortfield, $sortorder); + } if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); } @@ -582,6 +599,7 @@ if ($resql) { $objectstatic->id = $obj->rowid; $objectstatic->ref = $obj->ref; + $objectstatic->ref_client = $obj->ref_client; $objectstatic->statut = $obj->status; $objectstatic->status = $obj->status; @@ -630,6 +648,15 @@ if ($resql) { $totalarray['nbfield']++; } } + if (!empty($arrayfields['f.ref_client']['checked'])) { + // Customer ref + print ''; + print $obj->ref_client; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } if (!empty($arrayfields['s.nom']['checked'])) { print ''; print $companystatic->getNomUrl(1, '', 44); diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 501aa0fe751..8b00bee9b3c 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -361,4 +361,6 @@ ALTER TABLE llx_c_email_template ADD COLUMN email_to varchar(255); ALTER TABLE llx_c_email_template ADD COLUMN email_tocc varchar(255); ALTER TABLE llx_c_email_template ADD COLUMN email_tobcc varchar(255); +ALTER TABLE llx_fichinter ADD COLUMN ref_client varchar(255) after ref_ext; + diff --git a/htdocs/install/mysql/tables/llx_fichinter.sql b/htdocs/install/mysql/tables/llx_fichinter.sql index 7c1ef4cf184..999dd55b7f3 100644 --- a/htdocs/install/mysql/tables/llx_fichinter.sql +++ b/htdocs/install/mysql/tables/llx_fichinter.sql @@ -25,6 +25,7 @@ create table llx_fichinter fk_contrat integer DEFAULT 0, -- contrat auquel est rattache la fiche ref varchar(30) NOT NULL, -- number ref_ext varchar(255), + ref_client varchar(255), -- customer intervention number entity integer DEFAULT 1 NOT NULL, -- multi company id tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, datec datetime, -- date de creation From 8950ae160b563529126169b317f9039db045d4ea Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 17 May 2022 11:00:13 +0000 Subject: [PATCH 05/67] Fixing style errors. --- htdocs/fichinter/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index a2271dbb063..eeb5261ef19 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -454,7 +454,7 @@ if (empty($reshook)) { } } elseif ($action == 'setref_client' && $user->rights->ficheinter->creer) { // Positionne ref client - $result = $object->setRefClient($user, GETPOST('ref_client','alpha')); + $result = $object->setRefClient($user, GETPOST('ref_client', 'alpha')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } From 2f959306f78f3c3119a1c9ec9154774eb46915d6 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 17 May 2022 22:50:42 +0200 Subject: [PATCH 06/67] fix travis --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 -- htdocs/install/mysql/tables/llx_fichinter.sql | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 8b00bee9b3c..6288a6a2e3a 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -362,5 +362,3 @@ ALTER TABLE llx_c_email_template ADD COLUMN email_tocc varchar(255); ALTER TABLE llx_c_email_template ADD COLUMN email_tobcc varchar(255); ALTER TABLE llx_fichinter ADD COLUMN ref_client varchar(255) after ref_ext; - - diff --git a/htdocs/install/mysql/tables/llx_fichinter.sql b/htdocs/install/mysql/tables/llx_fichinter.sql index 999dd55b7f3..b9f9008f202 100644 --- a/htdocs/install/mysql/tables/llx_fichinter.sql +++ b/htdocs/install/mysql/tables/llx_fichinter.sql @@ -25,7 +25,7 @@ create table llx_fichinter fk_contrat integer DEFAULT 0, -- contrat auquel est rattache la fiche ref varchar(30) NOT NULL, -- number ref_ext varchar(255), - ref_client varchar(255), -- customer intervention number + ref_client varchar(255), -- customer intervention number entity integer DEFAULT 1 NOT NULL, -- multi company id tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, datec datetime, -- date de creation From 4420e73431538adc7c67f37632bb7754a1bc5447 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 18 May 2022 22:24:30 +0200 Subject: [PATCH 07/67] fix quote in insert sql --- htdocs/fichinter/class/fichinter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index ec603defd62..7b63e6a3d6d 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -297,7 +297,7 @@ class Fichinter extends CommonObject $sql .= $this->socid; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".$this->db->escape($this->ref)."'"; - $sql .= ", '".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null")."'"; + $sql .= ", ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null"); $sql .= ", ".((int) $conf->entity); $sql .= ", ".((int) $user->id); $sql .= ", ".((int) $user->id); From 8af848c5394b1c213b8764a443ab25a92fcd935c Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 20 May 2022 10:40:59 +0200 Subject: [PATCH 08/67] add Ref client in PDF and send to propal on create --- htdocs/comm/propal/card.php | 2 +- htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 22a816acc1d..00723597521 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1644,7 +1644,7 @@ if ($action == 'create') { // Ref customer print ''.$langs->trans('RefCustomer').''; - print ''; + print ''; print ''; // Third party diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index e93e5a3e688..29d0cc8cac4 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -612,6 +612,14 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->datec, "day", false, $outputlangs, true), '', 'R'); + if (!empty($object->ref_client)) { + $posy += 4; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); + } + + if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && $object->thirdparty->code_client) { $posy += 4; $pdf->SetXY($posx, $posy); From d698cbfd9a37cf7bef0c30103b6c57419ddbf861 Mon Sep 17 00:00:00 2001 From: priojk Date: Fri, 20 May 2022 14:48:37 +0200 Subject: [PATCH 09/67] Feature: add hooks for accountancy export --- htdocs/accountancy/admin/export.php | 7 ++-- htdocs/accountancy/bookkeeping/list.php | 3 +- .../class/accountancyexport.class.php | 36 +++++++++++++++---- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 03cd41a43a9..430c7b6abae 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -47,7 +47,8 @@ $main_option = array( 'ACCOUNTING_EXPORT_PREFIX_SPEC', ); -$configuration = AccountancyExport::getTypeConfig(); +$accountancyexport = new AccountancyExport($db); +$configuration = $accountancyexport->getTypeConfig(); $listparam = $configuration['param']; @@ -117,7 +118,7 @@ if ($action == 'update') { if (!$error) { // reload - $configuration = AccountancyExport::getTypeConfig(); + $configuration = $accountancyexport->getTypeConfig(); $listparam = $configuration['param']; setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -237,7 +238,7 @@ if (!$conf->use_javascript_ajax) { print ""; } else { print ''; - $listmodelcsv = AccountancyExport::getType(); + $listmodelcsv = $accountancyexport->getType(); print $form->selectarray("ACCOUNTING_EXPORT_MODELCSV", $listmodelcsv, $conf->global->ACCOUNTING_EXPORT_MODELCSV, 0, 0, 0, '', 0, 0, 0, '', '', 1); print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index ce0714d5651..2ee947bf720 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -204,7 +204,8 @@ if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { unset($arrayfields['t.lettering_code']); } -$listofformat = AccountancyExport::getType(); +$accountancyexport = new AccountancyExport($db); +$listofformat = $accountancyexport->getType(); $formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV; if (empty($listofformat[$formatexportset])) { $formatexportset = 1; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 128b14fa800..127a6070168 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -11,6 +11,7 @@ * Copyright (C) 2017-2019 Frédéric France * Copyright (C) 2017 André Schild * Copyright (C) 2020 Guillaume Alexandre + * Copyright (C) 2022 Joachim Kueter * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); /** @@ -93,11 +95,13 @@ class AccountancyExport */ public function __construct(DoliDB $db) { - global $conf; + global $conf, $hookmanager; $this->db = $db; $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n"); + + $hookmanager->initHooks(array('accountancyexport')); } /** @@ -105,7 +109,7 @@ class AccountancyExport * * @return array of type */ - public static function getType() + public function getType() { global $langs; @@ -132,6 +136,10 @@ class AccountancyExport self::$EXPORT_TYPE_ISUITEEXPERT => 'Export iSuite Expert', ); + // allow modules to define export formats + global $hookmanager; + $reshook = $hookmanager->executeHooks('getType', $parameters, $listofexporttypes); + ksort($listofexporttypes, SORT_NUMERIC); return $listofexporttypes; @@ -168,7 +176,12 @@ class AccountancyExport self::$EXPORT_TYPE_ISUITEEXPERT => 'isuiteexpert', ); - return $formatcode[$type]; + global $hookmanager; + $code = $formatcode[$type]; + $parameters = array('type' => $type); + $reshook = $hookmanager->executeHooks('getFormatCode', $parameters, $code); + + return $code; } /** @@ -176,11 +189,11 @@ class AccountancyExport * * @return array of type */ - public static function getTypeConfig() + public function getTypeConfig() { global $conf, $langs; - return array( + $exporttypes = array( 'param' => array( self::$EXPORT_TYPE_CONFIGURABLE => array( 'label' => $langs->trans('Modelcsv_configurable'), @@ -265,6 +278,11 @@ class AccountancyExport 'txt' => $langs->trans("txt") ), ); + + global $hookmanager; + $parameters = array(); + $reshook = $hookmanager->executeHooks('getTypeConfig', $parameters, $exporttypes); + return $exporttypes; } @@ -350,7 +368,13 @@ class AccountancyExport $this->exportiSuiteExpert($TData); break; default: - $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); + global $hookmanager; + $parameters = array('format' => $formatexportset); + // file contents will be created in the hooked function via print + $reshook = $hookmanager->executeHooks('export', $parameters, $TData); + if ($reshook != 1) { + $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); + } break; } } From 03d60ec05ec94ac8a555c184382446909beb2041 Mon Sep 17 00:00:00 2001 From: priojk Date: Fri, 20 May 2022 14:48:37 +0200 Subject: [PATCH 10/67] NEW #20905 add hooks for accountancy export --- htdocs/accountancy/admin/export.php | 7 ++-- htdocs/accountancy/bookkeeping/list.php | 3 +- .../class/accountancyexport.class.php | 36 +++++++++++++++---- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 03cd41a43a9..430c7b6abae 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -47,7 +47,8 @@ $main_option = array( 'ACCOUNTING_EXPORT_PREFIX_SPEC', ); -$configuration = AccountancyExport::getTypeConfig(); +$accountancyexport = new AccountancyExport($db); +$configuration = $accountancyexport->getTypeConfig(); $listparam = $configuration['param']; @@ -117,7 +118,7 @@ if ($action == 'update') { if (!$error) { // reload - $configuration = AccountancyExport::getTypeConfig(); + $configuration = $accountancyexport->getTypeConfig(); $listparam = $configuration['param']; setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -237,7 +238,7 @@ if (!$conf->use_javascript_ajax) { print ""; } else { print ''; - $listmodelcsv = AccountancyExport::getType(); + $listmodelcsv = $accountancyexport->getType(); print $form->selectarray("ACCOUNTING_EXPORT_MODELCSV", $listmodelcsv, $conf->global->ACCOUNTING_EXPORT_MODELCSV, 0, 0, 0, '', 0, 0, 0, '', '', 1); print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index ce0714d5651..2ee947bf720 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -204,7 +204,8 @@ if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { unset($arrayfields['t.lettering_code']); } -$listofformat = AccountancyExport::getType(); +$accountancyexport = new AccountancyExport($db); +$listofformat = $accountancyexport->getType(); $formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV; if (empty($listofformat[$formatexportset])) { $formatexportset = 1; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 128b14fa800..127a6070168 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -11,6 +11,7 @@ * Copyright (C) 2017-2019 Frédéric France * Copyright (C) 2017 André Schild * Copyright (C) 2020 Guillaume Alexandre + * Copyright (C) 2022 Joachim Kueter * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); /** @@ -93,11 +95,13 @@ class AccountancyExport */ public function __construct(DoliDB $db) { - global $conf; + global $conf, $hookmanager; $this->db = $db; $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n"); + + $hookmanager->initHooks(array('accountancyexport')); } /** @@ -105,7 +109,7 @@ class AccountancyExport * * @return array of type */ - public static function getType() + public function getType() { global $langs; @@ -132,6 +136,10 @@ class AccountancyExport self::$EXPORT_TYPE_ISUITEEXPERT => 'Export iSuite Expert', ); + // allow modules to define export formats + global $hookmanager; + $reshook = $hookmanager->executeHooks('getType', $parameters, $listofexporttypes); + ksort($listofexporttypes, SORT_NUMERIC); return $listofexporttypes; @@ -168,7 +176,12 @@ class AccountancyExport self::$EXPORT_TYPE_ISUITEEXPERT => 'isuiteexpert', ); - return $formatcode[$type]; + global $hookmanager; + $code = $formatcode[$type]; + $parameters = array('type' => $type); + $reshook = $hookmanager->executeHooks('getFormatCode', $parameters, $code); + + return $code; } /** @@ -176,11 +189,11 @@ class AccountancyExport * * @return array of type */ - public static function getTypeConfig() + public function getTypeConfig() { global $conf, $langs; - return array( + $exporttypes = array( 'param' => array( self::$EXPORT_TYPE_CONFIGURABLE => array( 'label' => $langs->trans('Modelcsv_configurable'), @@ -265,6 +278,11 @@ class AccountancyExport 'txt' => $langs->trans("txt") ), ); + + global $hookmanager; + $parameters = array(); + $reshook = $hookmanager->executeHooks('getTypeConfig', $parameters, $exporttypes); + return $exporttypes; } @@ -350,7 +368,13 @@ class AccountancyExport $this->exportiSuiteExpert($TData); break; default: - $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); + global $hookmanager; + $parameters = array('format' => $formatexportset); + // file contents will be created in the hooked function via print + $reshook = $hookmanager->executeHooks('export', $parameters, $TData); + if ($reshook != 1) { + $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); + } break; } } From 18e9a332b4c975cf4beb2bd8ee1c7e99c2f41008 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 20 May 2022 12:58:46 +0000 Subject: [PATCH 11/67] Fixing style errors. --- .../class/accountancyexport.class.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 127a6070168..2cb4c5fba1c 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; /** @@ -138,8 +138,8 @@ class AccountancyExport // allow modules to define export formats global $hookmanager; - $reshook = $hookmanager->executeHooks('getType', $parameters, $listofexporttypes); - + $reshook = $hookmanager->executeHooks('getType', $parameters, $listofexporttypes); + ksort($listofexporttypes, SORT_NUMERIC); return $listofexporttypes; @@ -179,8 +179,8 @@ class AccountancyExport global $hookmanager; $code = $formatcode[$type]; $parameters = array('type' => $type); - $reshook = $hookmanager->executeHooks('getFormatCode', $parameters, $code); - + $reshook = $hookmanager->executeHooks('getFormatCode', $parameters, $code); + return $code; } @@ -281,8 +281,8 @@ class AccountancyExport global $hookmanager; $parameters = array(); - $reshook = $hookmanager->executeHooks('getTypeConfig', $parameters, $exporttypes); - return $exporttypes; + $reshook = $hookmanager->executeHooks('getTypeConfig', $parameters, $exporttypes); + return $exporttypes; } @@ -369,12 +369,12 @@ class AccountancyExport break; default: global $hookmanager; - $parameters = array('format' => $formatexportset); + $parameters = array('format' => $formatexportset); // file contents will be created in the hooked function via print - $reshook = $hookmanager->executeHooks('export', $parameters, $TData); + $reshook = $hookmanager->executeHooks('export', $parameters, $TData); if ($reshook != 1) { $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); - } + } break; } } From 877b48729865010ad9d2e841e8ff839534563810 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Fri, 20 May 2022 19:25:46 +0200 Subject: [PATCH 12/67] Fix scrutinizer https://scrutinizer-ci.com/g/Dolibarr/dolibarr/issues/develop/files/htdocs/asset/card.php?selectedLabels%5B0%5D=9&orderField=path&order=asc&honorSelectedPaths=0 --- htdocs/asset/class/asset.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 19c15839231..5381b718d6b 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -154,6 +154,7 @@ class Asset extends CommonObject public $import_key; public $model_pdf; public $status; + public $supplier_invoice_id; // /** // * @var string Field with ID of parent key if this object has a parent From 5c01db353ae95a47f69939018d6e65c0473ae128 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 20 May 2022 17:26:17 +0000 Subject: [PATCH 13/67] Fixing style errors. --- htdocs/asset/class/asset.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 5381b718d6b..2180911d771 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -154,7 +154,7 @@ class Asset extends CommonObject public $import_key; public $model_pdf; public $status; - public $supplier_invoice_id; + public $supplier_invoice_id; // /** // * @var string Field with ID of parent key if this object has a parent From 2a22a530e98bcd574aa59b9da5f0a3821b7eeab3 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Fri, 20 May 2022 19:27:15 +0200 Subject: [PATCH 14/67] FIX scrutinizer https://scrutinizer-ci.com/g/Dolibarr/dolibarr/issues/develop/files/htdocs/asset/model/depreciation_options.php?orderField=path&order=asc&honorSelectedPaths=0 --- htdocs/asset/class/assetmodel.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index eae7b5d0fde..6390ad74c18 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -129,6 +129,7 @@ class AssetModel extends CommonObject public $import_key; public $model_pdf; public $status; + public $asset_depreciation_options; // /** // * @var string Field with ID of parent key if this object has a parent From c887f48deea212852876be93b02cf801e6ea1588 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Fri, 20 May 2022 21:12:55 +0200 Subject: [PATCH 15/67] fix in social import --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/modules/import/import_csv.modules.php | 8 +++++--- htdocs/core/modules/import/import_xlsx.modules.php | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e6852cdde03..bca479dd910 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2951,7 +2951,7 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor } else { if (!empty($dictsocialnetworks[$type]['url'])) { $link = str_replace('{socialid}', $value, $dictsocialnetworks[$type]['url']); - $htmllink .= ' '.dol_escape_htmltag($value).''; + $htmllink .= ' '.dol_escape_htmltag($value).''; } else { $htmllink .= dol_escape_htmltag($value); } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 0ca104c40c4..eef7305e1bc 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -717,14 +717,16 @@ class ImportCsv extends ModeleImports $socialkey = array_search("socialnetworks", $listfields); if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { $socialnetwork = explode("_", $fieldname)[1]; - $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; - $listvalues[$socialkey] = $newvalue; + $json = new stdClass(); + $json->$socialnetwork = $newval; + $newvalue = json_encode($json); + $listvalues[$socialkey] = "'".$this->db->escape($newvalue)."'"; } else { $socialnetwork = explode("_", $fieldname)[1]; $jsondata = $listvalues[$socialkey]; $jsondata = str_replace("'", "", $jsondata); $json = json_decode($jsondata); - $json->$socialnetwork = $this->db->escape($newval); + $json->$socialnetwork = $newval; $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; } } diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index f80cddf85e8..65985e6856a 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -760,7 +760,9 @@ class ImportXlsx extends ModeleImports $socialkey = array_search("socialnetworks", $listfields); if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { $socialnetwork = explode("_", $fieldname)[1]; - $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; + $json = new stdClass(); + $json->$socialnetwork = $newval; + $newvalue = json_encode($json); $listvalues[$socialkey] = $newvalue; } else { $socialnetwork = explode("_", $fieldname)[1]; From 5591ee7e6fd20425ccc402b1b0311ff044621998 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Fri, 20 May 2022 22:36:48 +0200 Subject: [PATCH 16/67] Update categorie.class.php --- htdocs/categories/class/categorie.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 434b994ccd2..a1fa2d1982b 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -113,7 +113,7 @@ class Categorie extends CommonObject * * @todo Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_CAT_FK = array( + public static $MAP_CAT_FK = array( 'customer' => 'soc', 'supplier' => 'soc', 'contact' => 'socpeople', @@ -125,7 +125,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_CAT_TABLE = array( + public static $MAP_CAT_TABLE = array( 'customer' => 'societe', 'supplier' => 'fournisseur', 'bank_account'=> 'account', @@ -136,7 +136,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_OBJ_CLASS = array( + public static $MAP_OBJ_CLASS = array( 'product' => 'Product', 'customer' => 'Societe', 'supplier' => 'Fournisseur', @@ -178,7 +178,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_OBJ_TABLE = array( + public static $MAP_OBJ_TABLE = array( 'customer' => 'societe', 'supplier' => 'societe', 'member' => 'adherent', From 72bfedaba15097d4e45f74f00cc79bc76fc0a75e Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 21 May 2022 00:33:28 +0200 Subject: [PATCH 17/67] Add form setup and backport as default setup builder --- htdocs/modulebuilder/index.php | 27 ++ htdocs/modulebuilder/template/admin/setup.php | 302 ++++-------------- 2 files changed, 95 insertions(+), 234 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index e8e32f73d0f..0bf2036ec33 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -238,6 +238,33 @@ if ($dirins && $action == 'initmodule' && $modulename) { } } + // Copy last html.formsetup.class.php' to backport folder + $tryToCopyFromSetupClass = true; + $backportDest = $destdir .'/backport/v17/core/class'; + $backportFileSrc = DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; + $backportFileDest = $backportDest.'/html.formsetup.class.php'; + $result = dol_mkdir($backportDest); + + if ($result < 0) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCreateDir", $backportDest), null, 'errors'); + $tryToCopyFromSetupClass = true; + } + + if ($tryToCopyFromSetupClass) { + $result = dol_copy($backportFileSrc, $backportFileDest); + if ($result <= 0) { + if ($result < 0) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCopyFile", $backportFileSrc, $backportFileDest), null, 'errors'); + } else { + setEventMessages($langs->trans("AllFilesDidAlreadyExist", $backportFileDest), null, 'warnings'); + } + } + } + if (!empty($conf->global->MODULEBUILDER_USE_ABOUT)) { dol_delete_file($destdir.'/admin/about.php'); } diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 84b394da808..c353ba420ed 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -78,65 +78,70 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; -$arrayofparameters = array( - 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1), - 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1), - //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), - //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), - //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), - //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), - //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), -); $error = 0; $setupnotempty = 0; // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only -$useFormSetup = 0; -// Convert arrayofparameter into a formSetup object -if ($useFormSetup && (float) DOL_VERSION >= 15) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; - $formSetup = new FormSetup($db); +$useFormSetup = 1; - // you can use the param convertor - $formSetup->addItemsFromParamsArray($arrayofparameters); - - // or use the new system see exemple as follow (or use both because you can ;-) ) - - /* - // Hôte - $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); - $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; - $item->cssClass = 'minwidth500'; - - // Setup conf MYMODULE_MYPARAM1 as a simple string input - $item = $formSetup->newItem('MYMODULE_MYPARAM1'); - - // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title - $item = $formSetup->newItem('MYMODULE_MYPARAM2'); - $item->nameText = $item->getNameText().' more html text '; - - // Setup conf MYMODULE_MYPARAM3 - $item = $formSetup->newItem('MYMODULE_MYPARAM3'); - $item->setAsThirdpartyType(); - - // Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style - $formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); - - // Setup conf MYMODULE_MYPARAM5 - $formSetup->newItem('MYMODULE_MYPARAM5')->setAsEmailTemplate('thirdparty'); - - // Setup conf MYMODULE_MYPARAM6 - $formSetup->newItem('MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled - - // Setup conf MYMODULE_MYPARAM7 - $formSetup->newItem('MYMODULE_MYPARAM7')->setAsProduct(); - */ - - $setupnotempty = count($formSetup->items); +if (!class_exists('FormSetup')) { + // For retrocompatibility Dolibarr < 15.0 + if (versioncompare(explode('.', DOL_VERSION), array(17)) < 0 && !class_exists('FormSetup')) { + require_once __DIR__.'/../backport/v17/core/class/html.formsetup.class.php'; + } else { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; + } } +$formSetup = new FormSetup($db); + + +// Hôte +$item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); +$item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; +$item->cssClass = 'minwidth500'; + +// Setup conf MYMODULE_MYPARAM1 as a simple string input +$item = $formSetup->newItem('MYMODULE_MYPARAM1'); + +// Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title +$item = $formSetup->newItem('MYMODULE_MYPARAM2'); +$item->nameText = $item->getNameText().' more html text '; + +// Setup conf MYMODULE_MYPARAM3 +$item = $formSetup->newItem('MYMODULE_MYPARAM3'); +$item->setAsThirdpartyType(); + +// Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style +$formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); + +// Setup conf MYMODULE_MYPARAM5 +$formSetup->newItem('MYMODULE_MYPARAM5')->setAsEmailTemplate('thirdparty'); + +// Setup conf MYMODULE_MYPARAM6 +$formSetup->newItem('MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled + +// Setup conf MYMODULE_MYPARAM7 +$formSetup->newItem('MYMODULE_MYPARAM7')->setAsProduct(); + + +$formSetup->newItem('Title')->setAsTitle(); + +$item = $formSetup->newItem('MYMODULE_MYPARAM8'); +$TField = array( + 'test01' => $langs->trans('test01'), + 'test02' => $langs->trans('test02'), + 'test03' => $langs->trans('test03'), + 'test04' => $langs->trans('test04'), + 'test05' => $langs->trans('test05'), + 'test06' => $langs->trans('test06'), +); +$item->setAsMultiSelect($TField); +$item->helpText = $langs->transnoentities('MYMODULE_MYPARAM8'); + +$setupnotempty =+ count($formSetup->items); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -145,6 +150,11 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); * Actions */ +// For retrocompatibility Dolibarr < 15.0 +if ( versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'update' && !empty($user->admin)) { + $formSetup->saveConfFromPost(); +} + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { @@ -271,191 +281,15 @@ echo ''.$langs->trans("MyModuleSetupPage").'< if ($action == 'edit') { - if ($useFormSetup && (float) DOL_VERSION >= 15) { - print $formSetup->generateOutput(true); - } else { - print '
'; - print ''; - print ''; - - print ''; - print ''; - - foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; - } - } - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; - print ''; - - if ($val['type'] == 'textarea') { - print '\n"; - } elseif ($val['type']== 'html') { - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); - $doleditor->Create(); - } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); - } elseif (preg_match('/emailtemplate:/', $val['type'])) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $tmp = explode(':', $val['type']); - $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang - //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); - $arrayofmessagename = array(); - if (is_array($formmail->lines_model)) { - foreach ($formmail->lines_model as $modelmail) { - //var_dump($modelmail); - $moreonlabel = ''; - if (!empty($arrayofmessagename[$modelmail->label])) { - $moreonlabel = ' (' . $langs->trans("SeveralLangugeVariatFound") . ')'; - } - // The 'label' is the key that is unique if we exclude the language - $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel; - } - } - print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); - } elseif (preg_match('/category:/', $val['type'])) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - $formother = new FormOther($db); - - $tmp = explode(':', $val['type']); - print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); - } elseif (preg_match('/thirdparty_type/', $val['type'])) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; - $formcompany = new FormCompany($db); - print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); - } elseif ($val['type'] == 'securekey') { - print ''; - if (!empty($conf->use_javascript_ajax)) { - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"'); - } - if (!empty($conf->use_javascript_ajax)) { - print "\n".''; - } - } elseif ($val['type'] == 'product') { - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); - $form->select_produits($selected, $constname, '', 0); - } - } else { - print ''; - } - print '
'; - - print '
'; - print ''; - print '
'; - - print '
'; - } - + print $formSetup->generateOutput(true); print '
'; +} elseif (!empty($formSetup->items)) { + print $formSetup->generateOutput(); + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; } else { - if ($useFormSetup && (float) DOL_VERSION >= 15) { - if (!empty($formSetup->items)) { - print $formSetup->generateOutput(); - } - } else { - if (!empty($arrayofparameters)) { - print ''; - print ''; - - foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; - } - } - - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print $form->textwithpicto($langs->trans($constname), $tooltiphelp); - print ''; - - if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); - } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; - } elseif ($val['type'] == 'yesno') { - print ajax_constantonoff($constname); - } elseif (preg_match('/emailtemplate:/', $val['type'])) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $tmp = explode(':', $val['type']); - - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); - if ($template<0) { - setEventMessages(null, $formmail->errors, 'errors'); - } - print $langs->trans($template->label); - } elseif (preg_match('/category:/', $val['type'])) { - $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); - if ($result < 0) { - setEventMessages(null, $c->errors, 'errors'); - } elseif ($result > 0 ) { - $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text - $toprint = array(); - foreach ($ways as $way) { - $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; - } - print '
      ' . implode(' ', $toprint) . '
    '; - } - } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { - print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { - print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { - print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { - print $langs->trans("NorProspectNorCustomer"); - } - } elseif ($val['type'] == 'product') { - $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); - if ($resprod > 0) { - print $product->ref; - } elseif ($resprod < 0) { - setEventMessages(null, $object->errors, "errors"); - } - } else { - print $conf->global->{$constname}; - } - print '
    '; - } - } - - if ($setupnotempty) { - print '
    '; - print ''.$langs->trans("Modify").''; - print '
    '; - } else { - print '
    '.$langs->trans("NothingToSetup"); - } + print '
    '.$langs->trans("NothingToSetup"); } From f8dcc1daaf6fa789ec3a4e2b5b00eef3bcc467d2 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 21 May 2022 00:36:13 +0200 Subject: [PATCH 18/67] Add form setup and backport as default setup builder --- htdocs/modulebuilder/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 0bf2036ec33..44a69c1f5e8 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -249,7 +249,7 @@ if ($dirins && $action == 'initmodule' && $modulename) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCreateDir", $backportDest), null, 'errors'); - $tryToCopyFromSetupClass = true; + $tryToCopyFromSetupClass = false; } if ($tryToCopyFromSetupClass) { @@ -260,7 +260,7 @@ if ($dirins && $action == 'initmodule' && $modulename) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCopyFile", $backportFileSrc, $backportFileDest), null, 'errors'); } else { - setEventMessages($langs->trans("AllFilesDidAlreadyExist", $backportFileDest), null, 'warnings'); + setEventMessages($langs->trans("FileDidAlreadyExist", $backportFileDest), null, 'warnings'); } } } From cf321dd8e5489f2d442aac8f931e8390b9b139c1 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 21 May 2022 01:26:02 +0200 Subject: [PATCH 19/67] change comment --- htdocs/modulebuilder/template/admin/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index c353ba420ed..73cd54100fc 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -86,7 +86,7 @@ $setupnotempty = 0; $useFormSetup = 1; if (!class_exists('FormSetup')) { - // For retrocompatibility Dolibarr < 15.0 + // For retrocompatibility Dolibarr < 17.0 if (versioncompare(explode('.', DOL_VERSION), array(17)) < 0 && !class_exists('FormSetup')) { require_once __DIR__.'/../backport/v17/core/class/html.formsetup.class.php'; } else { From 54e572b94fae7c0642b0a37ac88c42789f9e771a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 May 2022 10:25:20 +0200 Subject: [PATCH 20/67] Fix --- htdocs/adherents/class/adherent_type.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index f73ff9bf451..3f857ce827b 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -122,12 +122,10 @@ class AdherentType extends CommonObject public $members = array(); /** @var string string other */ - public $other; + public $other = array(); public $multilangs = array(); - public $other = array(); - /** * Constructor From f3ca26576dda8f78e78333bfcb8eb2126ff83e4a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 May 2022 14:17:49 +0200 Subject: [PATCH 21/67] Fix regression --- htdocs/categories/class/categorie.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ef5ea585314..bf9442b82af 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -113,7 +113,7 @@ class Categorie extends CommonObject * * @todo Move to const array when PHP 5.6 will be our minimum target */ - public static $MAP_CAT_FK = array( + public $MAP_CAT_FK = array( 'customer' => 'soc', 'supplier' => 'soc', 'contact' => 'socpeople', @@ -125,7 +125,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - public static $MAP_CAT_TABLE = array( + public $MAP_CAT_TABLE = array( 'customer' => 'societe', 'supplier' => 'fournisseur', 'bank_account'=> 'account', @@ -136,7 +136,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - public static $MAP_OBJ_CLASS = array( + public $MAP_OBJ_CLASS = array( 'product' => 'Product', 'customer' => 'Societe', 'supplier' => 'Fournisseur', From b14c04a8f0853109a843b7766a685d26142098c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 May 2022 14:28:35 +0200 Subject: [PATCH 22/67] Fix regression --- htdocs/asset/class/asset.class.php | 1 - htdocs/core/class/commonobject.class.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 710ae7fd3d0..410af398bc7 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -155,7 +155,6 @@ class Asset extends CommonObject public $import_key; public $model_pdf; public $status; - public $supplier_invoice_id; // /** // * @var string Field with ID of parent key if this object has a parent diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bf33cbe224e..14bca386018 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -116,7 +116,7 @@ abstract class CommonObject public $array_languages = null; // Value is array() when load already tried /** - * @var array To sotre result of ->liste_contact() + * @var array To store result of ->liste_contact() */ public $contacts_ids; From 9ba10202980f2a46c797592b4e15a7278f96c0b2 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 21 May 2022 15:03:10 +0200 Subject: [PATCH 23/67] Fix version detect --- htdocs/modulebuilder/template/admin/setup.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 73cd54100fc..8128ba7ca52 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -86,8 +86,8 @@ $setupnotempty = 0; $useFormSetup = 1; if (!class_exists('FormSetup')) { - // For retrocompatibility Dolibarr < 17.0 - if (versioncompare(explode('.', DOL_VERSION), array(17)) < 0 && !class_exists('FormSetup')) { + // For retrocompatibility Dolibarr < 16.0 + if (floatval(DOL_VERSION) < 16.0 && !class_exists('FormSetup')) { require_once __DIR__.'/../backport/v17/core/class/html.formsetup.class.php'; } else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; @@ -125,9 +125,9 @@ $formSetup->newItem('MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0; // disa // Setup conf MYMODULE_MYPARAM7 $formSetup->newItem('MYMODULE_MYPARAM7')->setAsProduct(); - $formSetup->newItem('Title')->setAsTitle(); +// Setup conf MYMODULE_MYPARAM8 $item = $formSetup->newItem('MYMODULE_MYPARAM8'); $TField = array( 'test01' => $langs->trans('test01'), @@ -140,6 +140,11 @@ $TField = array( $item->setAsMultiSelect($TField); $item->helpText = $langs->transnoentities('MYMODULE_MYPARAM8'); + +// Setup conf MYMODULE_MYPARAM9 +$formSetup->newItem('MYMODULE_MYPARAM9')->setAsSelect($TField); + + $setupnotempty =+ count($formSetup->items); From 2c2544d471b426eba03c23e92aa9c05f7c8a4533 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 May 2022 15:22:08 +0200 Subject: [PATCH 24/67] Fix scrutinizer --- htdocs/comm/propal/class/api_proposals.class.php | 12 ++++++++++-- htdocs/commande/class/api_orders.class.php | 10 ++++++++-- .../compta/facture/class/api_invoices.class.php | 16 ++++++++++++---- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9c8b3c653e6..258e264c5a7 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -135,8 +135,13 @@ class Proposals extends DolibarrApi } // Add external contacts ids. - $this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->propal->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->propal->contacts_ids = $tmparray; + } + $this->propal->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->propal); } @@ -228,7 +233,10 @@ class Proposals extends DolibarrApi $proposal_static = new Propal($this->db); if ($proposal_static->fetch($obj->rowid)) { // Add external contacts ids - $proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1); + $tmparray = $proposal_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $proposal_static->contacts_ids = $tmparray; + } $obj_ret[] = $this->_cleanObjectDatas($proposal_static); } $i++; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2795c325fba..ac9ce98777d 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -133,7 +133,10 @@ class Orders extends DolibarrApi } // Add external contacts ids - $this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->commande->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->commande->contacts_ids = $tmparray; + } $this->commande->fetchObjectLinked(); // Add online_payment_url, cf #20477 @@ -234,7 +237,10 @@ class Orders extends DolibarrApi $commande_static = new Commande($this->db); if ($commande_static->fetch($obj->rowid)) { // Add external contacts ids - $commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1); + $tmparray = $commande_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $commande_static->contacts_ids = $tmparray; + } // Add online_payment_url, cf #20477 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; $commande_static->online_payment_url = getOnlinePaymentUrl(0, 'order', $commande_static->ref); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 51fd8c1dd7a..3dababa3dc3 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -148,7 +148,10 @@ class Invoices extends DolibarrApi // Add external contacts ids if ($contact_list > -1) { - $this->invoice->contacts_ids = $this->invoice->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->invoice->liste_contact(-1, 'external', $contact_list); + if(is_array($tmparray)) { + $this->invoice->contacts_ids = $tmparray; + } } $this->invoice->fetchObjectLinked(); @@ -267,8 +270,10 @@ class Invoices extends DolibarrApi $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); // Add external contacts ids - $invoice_static->contacts_ids = $invoice_static->liste_contact(-1, 'external', 1); - + $tmparray = $invoice_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $invoice_static->contacts_ids = $tmparray; + } $obj_ret[] = $this->_cleanObjectDatas($invoice_static); } $i++; @@ -1768,7 +1773,10 @@ class Invoices extends DolibarrApi // Add external contacts ids if ($contact_list > -1) { - $this->template_invoice->contacts_ids = $this->template_invoice->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->template_invoice->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->template_invoice->contacts_ids = $tmparray; + } } $this->template_invoice->fetchObjectLinked(); From a65c4c2e057f5570b8614ad1b1223939a80050dc Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Sat, 21 May 2022 16:05:58 +0200 Subject: [PATCH 25/67] field ref_customer in llx_expedition is not varchar(255) #20629 --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 07a9856a1f9..6a57869bc0d 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -365,3 +365,5 @@ ALTER TABLE llx_c_email_template ADD COLUMN email_tocc varchar(255); ALTER TABLE llx_c_email_template ADD COLUMN email_tobcc varchar(255); ALTER TABLE llx_c_holiday_types ADD COLUMN sortorder smallint; + +ALTER TABLE llx_expedition MODIFY COLUMN ref_customer varchar(255); From 2b6154050ca5888f55e852424ac23960b1912632 Mon Sep 17 00:00:00 2001 From: Nicolas SILOBRE <45969285+ns-info90@users.noreply.github.com> Date: Sat, 21 May 2022 16:16:59 +0200 Subject: [PATCH 26/67] Fix : php warning 8 / backup --- htdocs/admin/tools/dolibarr_export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 36136aeef24..83d750e1209 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -257,7 +257,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { } if ($execmethod == 1) { // If we use the "exec" method for shell, we ask if we need to use the alternative low memory exec mode. - print ''; + print ''; print ''; From cc904614828239b20ba86d6d998ecf0bdb65a099 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Sat, 21 May 2022 16:28:32 +0200 Subject: [PATCH 27/67] Fix : Missing description field in function dol_dir_list_in_database --- htdocs/core/lib/files.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 5fc0d20777c..4e972b0be4e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -272,7 +272,8 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s "cover" => $obj->cover, "position" => (int) $obj->position, "acl" => $obj->acl, - "share" => $obj->share + "share" => $obj->share, + "description" => $obj->description ); } $i++; From 321195ef96b9f6c8d4757b09642e802e4f15d665 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 21 May 2022 16:35:10 +0200 Subject: [PATCH 28/67] add color --- htdocs/core/class/html.formsetup.class.php | 83 ++++++++++++++++--- htdocs/modulebuilder/index.php | 2 +- htdocs/modulebuilder/template/admin/setup.php | 17 +++- 3 files changed, 90 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 1ee9812f4fd..1cfddb588fd 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -422,7 +422,7 @@ class FormSetup if (!array($this->items)) { return false; } foreach ($this->items as $item) { - $item->reloadValueFromConf(); + $item->loadValueFromConf(); } return true; @@ -587,8 +587,11 @@ class FormSetupItem /** @var string $fieldValue */ public $fieldValue; + /** @var string $defaultFieldValue */ + public $defaultFieldValue = null; + /** @var array $fieldAttr fields attribute only for compatible fields like input text */ - public $fieldAttr; + public $fieldAttr = array(); /** @var bool|string set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too */ public $fieldOverride = false; @@ -648,17 +651,33 @@ class FormSetupItem $this->entity = $conf->entity; $this->confKey = $confKey; - $this->fieldValue = $conf->global->{$this->confKey}; + $this->loadValueFromConf(); } /** - * reload conf value from databases - * @return null + * load conf value from databases + * @return bool + */ + public function loadValueFromConf() + { + global $conf; + if (isset($conf->global->{$this->confKey})) { + $this->fieldValue = $conf->global->{$this->confKey}; + return true; + } else { + $this->fieldValue = null; + return false; + } + } + + /** + * reload conf value from databases is an aliase of loadValueFromConf + * @deprecated + * @return bool */ public function reloadValueFromConf() { - global $conf; - $this->fieldValue = $conf->global->{$this->confKey}; + return $this->loadValueFromConf(); } @@ -791,6 +810,12 @@ class FormSetupItem return $this->fieldInputOverride; } + // Set default value + if (is_null($this->fieldValue)) { + $this->fieldValue = $this->defaultFieldValue; + } + + $this->fieldAttr['name'] = $this->confKey; $this->fieldAttr['id'] = 'setup-'.$this->confKey; $this->fieldAttr['value'] = $this->fieldValue; @@ -807,6 +832,8 @@ class FormSetupItem $out.= $this->generateInputFieldTextarea(); } elseif ($this->type== 'html') { $out.= $this->generateInputFieldHtml(); + } elseif ($this->type== 'color') { + $out.= $this->generateInputFieldColor(); } elseif ($this->type == 'yesno') { $out.= $this->form->selectyesno($this->confKey, $this->fieldValue, 1); } elseif (preg_match('/emailtemplate:/', $this->type)) { @@ -825,14 +852,22 @@ class FormSetupItem $out.= $this->form->select_produits($selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1); } } else { - if (empty($this->fieldAttr)) { $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth200' : $this->cssClass); } - - $out.= 'fieldAttr).' />'; + $out.= $this->generateInputFieldText(); } return $out; } + /** + * generatec default input field + * @return string + */ + public function generateInputFieldText() + { + if (empty($this->fieldAttr)) { $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth200' : $this->cssClass); } + return 'fieldAttr).' />'; + } + /** * generate input field for textarea * @return string @@ -1029,6 +1064,8 @@ class FormSetupItem $out.= $this->generateOutputFieldSelect(); } elseif ($this->type== 'html') { $out.= $this->fieldValue; + } elseif ($this->type== 'color') { + $out.= $this->generateOutputFieldColor(); } elseif ($this->type == 'yesno') { $out.= ajax_constantonoff($this->confKey); } elseif (preg_match('/emailtemplate:/', $this->type)) { @@ -1102,6 +1139,22 @@ class FormSetupItem return $outPut; } + /** + * @return string + */ + public function generateOutputFieldColor() + { + $this->fieldAttr['disabled']=null; + return $this->generateInputField(); + } + /** + * @return string + */ + public function generateInputFieldColor() + { + $this->fieldAttr['type']= 'color'; + return $this->generateInputFieldText(); + } /** * @return string @@ -1130,6 +1183,16 @@ class FormSetupItem return $this; } + /** + * Set type of input as color + * @return self + */ + public function setAsColor() + { + $this->type = 'color'; + return $this; + } + /** * Set type of input as textarea * @return self diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 69163f94750..10a040ca7e5 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -240,7 +240,7 @@ if ($dirins && $action == 'initmodule' && $modulename) { // Copy last html.formsetup.class.php' to backport folder $tryToCopyFromSetupClass = true; - $backportDest = $destdir .'/backport/v17/core/class'; + $backportDest = $destdir .'/backport/v16/core/class'; $backportFileSrc = DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; $backportFileDest = $backportDest.'/html.formsetup.class.php'; $result = dol_mkdir($backportDest); diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 8128ba7ca52..1c46028b142 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -88,7 +88,7 @@ $useFormSetup = 1; if (!class_exists('FormSetup')) { // For retrocompatibility Dolibarr < 16.0 if (floatval(DOL_VERSION) < 16.0 && !class_exists('FormSetup')) { - require_once __DIR__.'/../backport/v17/core/class/html.formsetup.class.php'; + require_once __DIR__.'/../backport/v16/core/class/html.formsetup.class.php'; } else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; } @@ -104,6 +104,7 @@ $item->cssClass = 'minwidth500'; // Setup conf MYMODULE_MYPARAM1 as a simple string input $item = $formSetup->newItem('MYMODULE_MYPARAM1'); +$item->defaultFieldValue = 'default value'; // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title $item = $formSetup->newItem('MYMODULE_MYPARAM2'); @@ -145,6 +146,20 @@ $item->helpText = $langs->transnoentities('MYMODULE_MYPARAM8'); $formSetup->newItem('MYMODULE_MYPARAM9')->setAsSelect($TField); +// Setup conf MYMODULE_MYPARAM10 +$item = $formSetup->newItem('MYMODULE_MYPARAM10'); +$item->setAsColor(); +$item->defaultFieldValue = '#FF0000'; +$item->nameText = $item->getNameText().' more html text '; +$item->fieldInputOverride = ''; +$item->helpText = $langs->transnoentities('AnHelpMessage'); +//$item->fieldValue = ''; +//$item->fieldAttr = array() ; // fields attribute only for compatible fields like input text +//$item->fieldOverride = false; // set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too +//$item->fieldInputOverride = false; // set this var to override field input +//$item->fieldOutputOverride = false; // set this var to override field output + + $setupnotempty =+ count($formSetup->items); From 29dab3b6d10d3f9d675fa725c7ecf2ea35b69e00 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 21 May 2022 17:14:05 +0200 Subject: [PATCH 29/67] Fix : bug on check of main_not_installed --- htdocs/install/check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index e9023b6389c..aba44fbe684 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -440,7 +440,7 @@ if (!file_exists($conffile)) { if (empty($dolibarr_main_db_host)) { // This means install process was not run $allowupgrade = false; } - if (defined("MAIN_NOT_INSTALLED")) { + if (getDolGlobalInt("MAIN_NOT_INSTALLED")) { $allowupgrade = false; } if (GETPOST('allowupgrade')) { From d51b2f9164c19a04e29a6421d4f89d04f2d53138 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 May 2022 17:25:38 +0200 Subject: [PATCH 30/67] Fix migration --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 07a9856a1f9..02c654dd518 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -30,10 +30,20 @@ -- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); -ALTER TABLE llx_holiday ADD COLUMN nb_open_day double(24,8) DEFAULT NULL; -- Missing in v15 or lower +-- VMYSQL4.3 ALTER TABLE llx_c_civility CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; + +ALTER TABLE llx_c_transport_mode ADD UNIQUE INDEX uk_c_transport_mode (code, entity); + +ALTER TABLE llx_c_shipment_mode MODIFY COLUMN tracking varchar(255) NULL; + +ALTER TABLE llx_holiday ADD COLUMN nb_open_day double(24,8) DEFAULT NULL; + +ALTER TABLE llx_element_tag ADD COLUMN fk_categorie INTEGER; + + insert into llx_c_type_resource (code, label, active) values ('RES_ROOMS', 'Rooms', 1); insert into llx_c_type_resource (code, label, active) values ('RES_CARS', 'Cars', 1); From 28540a85f21de86c6d730d191e5d678d8350f38b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 21 May 2022 17:27:52 +0200 Subject: [PATCH 31/67] FIX php8 compatibility --- htdocs/compta/facture/card.php | 6 +++--- htdocs/compta/facture/contact.php | 2 +- htdocs/compta/facture/info.php | 2 +- htdocs/compta/facture/list.php | 4 ++-- htdocs/compta/facture/note.php | 2 +- htdocs/core/class/html.form.class.php | 12 ++++++------ 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f2e57c8b536..adf76b0991e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -142,9 +142,9 @@ if (!empty($conf->global->INVOICE_DISALLOW_REOPEN)) { $usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate))); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); -$usercancreatemargin = $user->rights->margins->creer; -$usercanreadallmargin = $user->rights->margins->liretous; -$usercancreatewithdrarequest = $user->rights->prelevement->bons->creer; +$usercancreatemargin = (!empty($user->rights->margins->creer) ? $user->rights->margins->creer : 0); +$usercanreadallmargin = (!empty($user->rights->margins->liretous) ? $user->rights->margins->liretous : 0); +$usercancreatewithdrarequest = (!empty($user->rights->prelevement->bons->creer) ? $user->rights->prelevement->bons->creer : 0); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 43897172779..f726baa4934 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -52,7 +52,7 @@ if ($user->socid) { $object = new Facture($db); // Load object if ($id > 0 || !empty($ref)) { - $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); + $ret = $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0)); } $result = restrictedArea($user, 'facture', $object->id); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 60efaf36e3d..33dde25ca97 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -47,7 +47,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object if ($id > 0 || !empty($ref)) { - $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); + $ret = $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0)); } // Security check diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 5937eda916c..6fd1e2a7322 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -245,7 +245,7 @@ $arrayfields = array( 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>292), 'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>295), 'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>296), // Not enabled by default because slow - 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), + 'total_pa' => array('label' => ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), @@ -1112,7 +1112,7 @@ if ($resql) { if (!empty($user->rights->facture->paiement)) { $arrayofmassactions['makepayment'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakePaymentAndClassifyPayed"); } - if ($conf->prelevement->enabled && !empty($user->rights->prelevement->bons->creer)) { + if (!empty($conf->prelevement->enabled) && !empty($user->rights->prelevement->bons->creer)) { $langs->load("withdrawals"); $arrayofmassactions['withdrawrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeWithdrawRequest"); } diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 6f699774d32..887a0281184 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -44,7 +44,7 @@ $action = GETPOST('action', 'aZ09'); $object = new Facture($db); // Load object if ($id > 0 || !empty($ref)) { - $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); + $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0)); } $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2df4f491105..e5aa1175dcc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8640,12 +8640,12 @@ class Form 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."contrat as t, ".$this->db->prefix()."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier' ), - 'fichinter'=>array('enabled'=>!empty($conf->ficheinter->enabled) ? $conf->ficheinter->enabled : 0, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), - 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), - 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), - 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('facture_fourn').')'), - 'ticket'=>array('enabled'=>$conf->ticket->enabled, 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('ticket').')'), - 'mo'=>array('enabled'=>$conf->mrp->enabled, 'perms'=>1, 'label'=>'LinkToMo', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.rowid, '0' as total_ht FROM ".$this->db->prefix()."societe as s INNER JOIN ".$this->db->prefix()."mrp_mo as t ON t.fk_soc = s.rowid WHERE t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('mo').')') + 'fichinter'=>array('enabled'=>(!empty($conf->ficheinter->enabled) ? $conf->ficheinter->enabled : 0), 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), + 'supplier_proposal'=>array('enabled'=>(!empty($conf->supplier_proposal->enabled) ? $conf->supplier_proposal->enabled : 0), 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), + 'order_supplier'=>array('enabled'=>(!empty($conf->supplier_order->enabled) ? $conf->supplier_order->enabled : 0), 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), + 'invoice_supplier'=>array('enabled'=>(!empty($conf->supplier_invoice->enabled) ? $conf->supplier_invoice->enabled : 0), 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('facture_fourn').')'), + 'ticket'=>array('enabled'=>(!empty($conf->ticket->enabled) ? $conf->ticket->enabled : 0), 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('ticket').')'), + 'mo'=>array('enabled'=>(!empty($conf->mrp->enabled) ? $conf->mrp->enabled : 0), 'perms'=>1, 'label'=>'LinkToMo', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.rowid, '0' as total_ht FROM ".$this->db->prefix()."societe as s INNER JOIN ".$this->db->prefix()."mrp_mo as t ON t.fk_soc = s.rowid WHERE t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('mo').')') ); } From 426d8912a7926229a37cab016d2f66a38e3b719e Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 21 May 2022 17:40:14 +0200 Subject: [PATCH 32/67] fix : The property chid does not seem to exist on PaymentSocialContribution --- .../sociales/class/paymentsocialcontribution.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index b6a611a47ee..c6a4851fac1 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -100,6 +100,11 @@ class PaymentSocialContribution extends CommonObject */ public $fk_user_modif; + /** + * @var int ID + */ + public $chid; + /** * Constructor * From c9e812d5ef4f67c24b2c97ebd33f928605ed8554 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 21 May 2022 17:47:25 +0200 Subject: [PATCH 33/67] fix : The property datepaye does not exist on PaymentSocialContribution --- .../sociales/class/paymentsocialcontribution.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index c6a4851fac1..23b180da103 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -105,6 +105,12 @@ class PaymentSocialContribution extends CommonObject */ public $chid; + /** + * @var integer|string datepaye + */ + public $datepaye; + + /** * Constructor * From 604a4670e083b12ccc2066089e4bc6e082b75129 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 21 May 2022 17:50:43 +0200 Subject: [PATCH 34/67] fix : The property does not exist on PaymentSocialContribution --- .../sociales/class/paymentsocialcontribution.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 23b180da103..1b83915714d 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -110,6 +110,11 @@ class PaymentSocialContribution extends CommonObject */ public $datepaye; + /** + * @var integer|string paiementtype + */ + public $paiementtype; + /** * Constructor From bff81ce9bb493e066f555cdb99da00a758896867 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 21 May 2022 18:02:48 +0200 Subject: [PATCH 35/67] fix : The property does not exist on ChargeSociales --- htdocs/compta/sociales/class/chargesociales.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 70d8da4c27b..41e036ae937 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -113,6 +113,11 @@ class ChargeSociales extends CommonObject */ public $fk_user; + /** + * @var double total + */ + public $total; + const STATUS_UNPAID = 0; const STATUS_PAID = 1; From 8ba445b27c08ad8e4fc53fdc8f649d72d82755cb Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 21 May 2022 18:11:34 +0200 Subject: [PATCH 36/67] fix : The property am does not seem to exist on ChargeSociales --- htdocs/compta/paiement_charge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 640ffc78d99..db48b2767f2 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -291,7 +291,7 @@ if ($action == 'create') { print "\n"; $total += $objp->total; $total_ttc += $objp->total_ttc; - $totalrecu += $objp->am; + $totalrecu += $objp->amount; $i++; } if ($i > 1) { From 7cf97cfb93bc5677854f0cd4f4ee43a78a6f9e35 Mon Sep 17 00:00:00 2001 From: Nicolas SILOBRE <45969285+ns-info90@users.noreply.github.com> Date: Sat, 21 May 2022 18:15:44 +0200 Subject: [PATCH 37/67] FIX: warning Php 8 --- htdocs/core/class/html.formfile.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index cbaf59bd311..0e622f897f0 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1330,7 +1330,7 @@ class FormFile if ($file['name'] != '.' && $file['name'] != '..' && !preg_match('/\.meta$/i', $file['name'])) { - if ($filearray[$key]['rowid'] > 0) { + if (array_key_exists('rowid',$filearray[$key]) && $filearray[$key]['rowid'] > 0) { $lastrowid = $filearray[$key]['rowid']; } $filepath = $relativepath.$file['name']; @@ -1339,8 +1339,8 @@ class FormFile $nboflines++; print ''."\n"; // Do we have entry into database ? - print ''."\n"; - print ''; + print ''."\n"; + print ''; // File name print ''; From cc7cc8bb5f1cd734df668cb1a447c71607b272f9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 21 May 2022 18:18:31 +0200 Subject: [PATCH 38/67] FIX avoid stickler error : Line exceeds 500 characters --- htdocs/core/class/html.form.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e5aa1175dcc..e97fea1d4cb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8641,9 +8641,18 @@ class Form FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."contrat as t, ".$this->db->prefix()."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier' ), 'fichinter'=>array('enabled'=>(!empty($conf->ficheinter->enabled) ? $conf->ficheinter->enabled : 0), 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), - 'supplier_proposal'=>array('enabled'=>(!empty($conf->supplier_proposal->enabled) ? $conf->supplier_proposal->enabled : 0), 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), - 'order_supplier'=>array('enabled'=>(!empty($conf->supplier_order->enabled) ? $conf->supplier_order->enabled : 0), 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), - 'invoice_supplier'=>array('enabled'=>(!empty($conf->supplier_invoice->enabled) ? $conf->supplier_invoice->enabled : 0), 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('facture_fourn').')'), + 'supplier_proposal'=>array( + 'enabled'=>(!empty($conf->supplier_proposal->enabled) ? $conf->supplier_proposal->enabled : 0), + 'perms'=>1, 'label'=>'LinkToSupplierProposal', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), + 'order_supplier'=>array( + 'enabled'=>(!empty($conf->supplier_order->enabled) ? $conf->supplier_order->enabled : 0), + 'perms'=>1, 'label'=>'LinkToSupplierOrder', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), + 'invoice_supplier'=>array( + 'enabled'=>(!empty($conf->supplier_invoice->enabled) ? $conf->supplier_invoice->enabled : 0), + 'perms'=>1, 'label'=>'LinkToSupplierInvoice', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('facture_fourn').')'), 'ticket'=>array('enabled'=>(!empty($conf->ticket->enabled) ? $conf->ticket->enabled : 0), 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('ticket').')'), 'mo'=>array('enabled'=>(!empty($conf->mrp->enabled) ? $conf->mrp->enabled : 0), 'perms'=>1, 'label'=>'LinkToMo', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.rowid, '0' as total_ht FROM ".$this->db->prefix()."societe as s INNER JOIN ".$this->db->prefix()."mrp_mo as t ON t.fk_soc = s.rowid WHERE t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('mo').')') ); From 019a68b3bb656edb9dbbaa8e0a2b1fbb79c746c5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 21 May 2022 18:25:07 +0200 Subject: [PATCH 39/67] FIX clean code --- htdocs/core/class/html.form.class.php | 48 ++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e97fea1d4cb..31f69878dda 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8629,10 +8629,26 @@ class Form } $possiblelinks = array( - 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('propal').')'), - 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande').')'), - 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), - 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), + 'propal'=>array( + 'enabled'=>$conf->propal->enabled, + 'perms'=>1, + 'label'=>'LinkToProposal', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('propal').')'), + 'order'=>array( + 'enabled'=>$conf->commande->enabled, + 'perms'=>1, + 'label'=>'LinkToOrder', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande').')'), + 'invoice'=>array( + 'enabled'=>$conf->facture->enabled, + 'perms'=>1, + 'label'=>'LinkToInvoice', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), + 'invoice_template'=>array( + 'enabled'=>$conf->facture->enabled, + 'perms'=>1, + 'label'=>'LinkToTemplateInvoice', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), 'contrat'=>array( 'enabled'=>$conf->contrat->enabled, 'perms'=>1, @@ -8640,21 +8656,35 @@ class Form 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."contrat as t, ".$this->db->prefix()."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier' ), - 'fichinter'=>array('enabled'=>(!empty($conf->ficheinter->enabled) ? $conf->ficheinter->enabled : 0), 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), + 'fichinter'=>array( + 'enabled'=>(!empty($conf->ficheinter->enabled) ? $conf->ficheinter->enabled : 0), + 'perms'=>1, + 'label'=>'LinkToIntervention', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array( 'enabled'=>(!empty($conf->supplier_proposal->enabled) ? $conf->supplier_proposal->enabled : 0), - 'perms'=>1, 'label'=>'LinkToSupplierProposal', + 'perms'=>1, + 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), 'order_supplier'=>array( 'enabled'=>(!empty($conf->supplier_order->enabled) ? $conf->supplier_order->enabled : 0), - 'perms'=>1, 'label'=>'LinkToSupplierOrder', + 'perms'=>1, + 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), 'invoice_supplier'=>array( 'enabled'=>(!empty($conf->supplier_invoice->enabled) ? $conf->supplier_invoice->enabled : 0), 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('facture_fourn').')'), - 'ticket'=>array('enabled'=>(!empty($conf->ticket->enabled) ? $conf->ticket->enabled : 0), 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('ticket').')'), - 'mo'=>array('enabled'=>(!empty($conf->mrp->enabled) ? $conf->mrp->enabled : 0), 'perms'=>1, 'label'=>'LinkToMo', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.rowid, '0' as total_ht FROM ".$this->db->prefix()."societe as s INNER JOIN ".$this->db->prefix()."mrp_mo as t ON t.fk_soc = s.rowid WHERE t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('mo').')') + 'ticket'=>array( + 'enabled'=>(!empty($conf->ticket->enabled) ? $conf->ticket->enabled : 0), + 'perms'=>1, + 'label'=>'LinkToTicket', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('ticket').')'), + 'mo'=>array( + 'enabled'=>(!empty($conf->mrp->enabled) ? $conf->mrp->enabled : 0), + 'perms'=>1, + 'label'=>'LinkToMo', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.rowid, '0' as total_ht FROM ".$this->db->prefix()."societe as s INNER JOIN ".$this->db->prefix()."mrp_mo as t ON t.fk_soc = s.rowid WHERE t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('mo').')') ); } From aa313f23ad5362dc1b3e8dab6c08dd0ffd9b08a0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 21 May 2022 16:26:20 +0000 Subject: [PATCH 40/67] Fixing style errors. --- htdocs/core/class/html.formfile.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 0e622f897f0..cb8c70f6e49 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1330,7 +1330,7 @@ class FormFile if ($file['name'] != '.' && $file['name'] != '..' && !preg_match('/\.meta$/i', $file['name'])) { - if (array_key_exists('rowid',$filearray[$key]) && $filearray[$key]['rowid'] > 0) { + if (array_key_exists('rowid', $filearray[$key]) && $filearray[$key]['rowid'] > 0) { $lastrowid = $filearray[$key]['rowid']; } $filepath = $relativepath.$file['name']; @@ -1339,8 +1339,8 @@ class FormFile $nboflines++; print ''."\n"; // Do we have entry into database ? - print ''."\n"; - print ''; + print ''."\n"; + print ''; // File name print ''; From 51041bbea1523c424a504eeafda80fa167abe7a0 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 21 May 2022 18:46:41 +0200 Subject: [PATCH 41/67] Fix : php 8.0 warnings --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/fourn/facture/card.php | 30 ++++++++++++------------ htdocs/projet/card.php | 2 ++ htdocs/projet/tasks.php | 2 +- htdocs/user/list.php | 1 + 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 14bca386018..13bf93e2de4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8819,7 +8819,7 @@ abstract class CommonObject } } } else { - $this->{$field} = $obj->{$field}; + $this->{$field} = !empty($obj->{$field}) ? $obj->{$field} : null; } } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 287327f2a6a..408d70f3468 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1974,10 +1974,10 @@ if ($action == 'create') { $objectsrc->fetch_optionals(); $object->array_options = $objectsrc->array_options; } else { - $cond_reglement_id = $societe->cond_reglement_supplier_id; - $mode_reglement_id = $societe->mode_reglement_supplier_id; - $transport_mode_id = $societe->transport_mode_supplier_id; - $fk_account = $societe->fk_account; + $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0; + $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0; + $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0; + $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0; $datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); $datetmp = dol_mktime(12, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int')); @@ -2004,7 +2004,7 @@ if ($action == 'create') { print '
    '; print ''; print ''; - if ($societe->id > 0) { + if (!empty($societe->id) && $societe->id > 0) { print ''."\n"; } print ''; @@ -2030,12 +2030,12 @@ if ($action == 'create') { print ''.$langs->trans('Supplier').''; print ''; - if ($societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) { + if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) { $absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1); print $societe->getNomUrl(1, 'supplier'); print ''; } else { - print img_picto('', 'company').$form->select_company($societe->id, 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); + print img_picto('', 'company').$form->select_company(!empty($societe->id) ? $societe->id : 0, 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); // reload page to retrieve supplier informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { print '