From c860c0dc4a72c35b38dfc5aee34ba968a1e1a13b Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Thu, 26 Nov 2020 11:47:45 +0100 Subject: [PATCH 0001/1055] Add default BOM --- htdocs/install/mysql/tables/llx_product.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 2431c884c62..a1ccf065ffa 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -100,5 +100,6 @@ create table llx_product desiredstock float DEFAULT 0, fk_unit integer DEFAULT NULL, price_autogen tinyint DEFAULT 0, + fk_default_bom integer DEFAULT NULL, fk_project integer DEFAULT NULL -- Used when product was generated by a project or is specifif to a project )ENGINE=innodb; From c2bd30a7e92445e10b6ffd0cc90b3121178d8816 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Thu, 26 Nov 2020 11:59:00 +0100 Subject: [PATCH 0002/1055] working progress --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 1 + htdocs/product/class/product.class.php | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index c83755009ae..95d6d208145 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -29,6 +29,7 @@ -- Missing in v12 or lower +ALTER TABLE llx_product ADD COLUMN fk_default_bom integer DEFAULT NULL; ALTER TABLE llx_payment_salary MODIFY COLUMN ref varchar(30) NULL; ALTER TABLE llx_payment_various MODIFY COLUMN ref varchar(30) NULL; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 03d81d4fd64..40d63c4643f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -248,6 +248,13 @@ class Product extends CommonObject */ public $finished; + /** + * fk_default_bom indicates the default bom + * + * @var int + */ + public $fk_default_bom; + /** * We must manage lot/batch number, sell-by date and so on : '1':yes '0':no * @@ -996,6 +1003,7 @@ class Product extends CommonObject $sql .= ", tobuy = ".(int) $this->status_buy; $sql .= ", tobatch = ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : (int) $this->status_batch); $sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? "null" : (int) $this->finished); + $sql .= ", fk_default_bom = ".((!isset($this->fk_default_bom) || $this->fk_default_bom < 0 || $this->fk_default_bom == '') ? "null" : (int) $this->fk_default_bom); $sql .= ", net_measure = ".($this->net_measure != '' ? "'".$this->db->escape($this->net_measure)."'" : 'null'); $sql .= ", net_measure_units = ".($this->net_measure_units != '' ? "'".$this->db->escape($this->net_measure_units)."'" : 'null'); $sql .= ", weight = ".($this->weight != '' ? "'".$this->db->escape($this->weight)."'" : 'null'); @@ -2046,7 +2054,7 @@ class Product extends CommonObject $sql .= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; $sql .= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, net_measure, net_measure_units, weight, weight_units,"; $sql .= " length, length_units, width, width_units, height, height_units,"; - $sql .= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; + $sql .= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,fk_default_bom,"; $sql .= " accountancy_code_buy, accountancy_code_buy_intra, accountancy_code_buy_export,"; $sql .= " accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; $sql .= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; @@ -2107,8 +2115,10 @@ class Product extends CommonObject $this->localtax2_tx = $obj->localtax2_tx; $this->localtax1_type = $obj->localtax1_type; $this->localtax2_type = $obj->localtax2_type; - + $this->finished = $obj->finished; + $this->fk_default_bom = $obj->fk_default_bom; + $this->duration = $obj->duration; $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); $this->duration_unit = substr($obj->duration, -1); From 5b40950f500f5a2de2e3a7bc58c8f12b42bd70af Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Thu, 26 Nov 2020 12:45:06 +0100 Subject: [PATCH 0003/1055] Update card.php add on card --- htdocs/product/card.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 6fdfb82e354..5fed4bc4ca1 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -17,7 +17,7 @@ * Copyright (C) 2016 Meziane Sof * Copyright (C) 2017 Josep Lluís Amador * Copyright (C) 2019 Frédéric France - * Copyright (C) 2019-2020 Thibault FOUCART + * Copyright (C) 2019-2020 Thibault FOUCART * Copyright (C) 2020 Pierre Ardoin * * This program is free software; you can redistribute it and/or modify @@ -59,6 +59,7 @@ if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/command if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->bom->enabled)) require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'other')); @@ -454,6 +455,13 @@ if (empty($reshook)) $object->finished = null; } + $fk_default_bom = GETPOST('fk_default_bom', 'int'); + if ($fk_default_bom >= 0) { + $object->fk_default_bom = $fk_default_bom; + } else { + $object->fk_default_bom = null; + } + $units = GETPOST('units', 'int'); if ($units > 0) { $object->fk_unit = $units; @@ -1567,6 +1575,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print $formproduct->selectProductNature('finished', $object->finished); print ''; + if ($conf->bom->enabled) { + print ''.$form->textwithpicto($langs->trans("DefaultBOM"), $langs->trans("DefaultBOMDesc")).''; + $bomkey = "Bom:bom/class/bom.class.php:0:t.status=1 AND t.fk_product=".$object->id; + print $form->selectForForms($bomkey, 'fk_default_bom', $object->fk_default_bom, 1); + print ''; + } + // Brut Weight print ''.$langs->trans("Weight").''; print ' '; @@ -2059,6 +2074,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print $object->getLibFinished(); print ''; + if ($conf->bom->enabled) { + print ''.$form->textwithpicto($langs->trans("DefaultBOM"), $langs->trans("DefaultBOMDesc")).''; + if ($object->fk_default_bom) { + $bom_static = new BOM($db); + $bom_static->fetch($object->fk_default_bom); + print $bom_static->getNomUrl(1); + } + print ''; + } + // Brut Weight print ''.$langs->trans("Weight").''; if ($object->weight != '') From 5329a1792e37bec9098f73b072860a629bd40cf5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 2 Apr 2021 13:48:27 +0200 Subject: [PATCH 0004/1055] NEW add action trigger for member excluded --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index af32340170e..60005979239 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -359,3 +359,6 @@ ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (f UPDATE llx_propal SET fk_user_signature = fk_user_cloture WHERE fk_user_signature IS NULL AND fk_user_cloture IS NOT NULL; UPDATE llx_propal SET date_signature = date_cloture WHERE date_signature IS NULL AND date_cloture IS NOT NULL; + +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_EXCLUDE','Member excluded','Executed when a member is excluted','member',26); + From cacc785305cbc3824c2dbfd7526fe04c7c89f5cb Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 2 Apr 2021 13:48:51 +0200 Subject: [PATCH 0005/1055] Update 13.0.0-14.0.0.sql --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 60005979239..34a2ffa74fb 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -360,5 +360,5 @@ ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (f UPDATE llx_propal SET fk_user_signature = fk_user_cloture WHERE fk_user_signature IS NULL AND fk_user_cloture IS NOT NULL; UPDATE llx_propal SET date_signature = date_cloture WHERE date_signature IS NULL AND date_cloture IS NOT NULL; -INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_EXCLUDE','Member excluded','Executed when a member is excluted','member',26); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_EXCLUDE','Member excluded','Executed when a member is excluded','member',26); From 8675484d9065a43b4438bd3b74305647cd27eca3 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 3 Apr 2021 10:25:29 +0200 Subject: [PATCH 0006/1055] Update llx_c_action_trigger.sql --- htdocs/install/mysql/data/llx_c_action_trigger.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 34cef4c94d4..a0391f5d841 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -90,6 +90,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION_DELETE','Member subscribtion deleted','Executed when a member subscribtion is deleted','member',24); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_RESILIATE','Member resiliated','Executed when a member is resiliated','member',25); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_DELETE','Member deleted','Executed when a member is deleted','member',26); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_EXCLUDE','Member excluded','Executed when a member is excluded','member',27); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_VALIDATE','Intervention validated','Executed when a intervention is validated','ficheinter',30); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_CLASSIFY_BILLED','Intervention set billed','Executed when a intervention is set to billed (when option FICHINTER_CLASSIFY_BILLED is set)','ficheinter',32); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_CLASSIFY_UNBILLED','Intervention set unbilled','Executed when a intervention is set to unbilled (when option FICHINTER_CLASSIFY_BILLED is set)','ficheinter',33); From 52bad238ff8c8fd95202bb5b1259a0792c664eb4 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 3 Apr 2021 10:25:44 +0200 Subject: [PATCH 0007/1055] Update 13.0.0-14.0.0.sql --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 34a2ffa74fb..5886e3cf33d 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -360,5 +360,5 @@ ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (f UPDATE llx_propal SET fk_user_signature = fk_user_cloture WHERE fk_user_signature IS NULL AND fk_user_cloture IS NOT NULL; UPDATE llx_propal SET date_signature = date_cloture WHERE date_signature IS NULL AND date_cloture IS NOT NULL; -INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_EXCLUDE','Member excluded','Executed when a member is excluded','member',26); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_EXCLUDE','Member excluded','Executed when a member is excluded','member',27); From 1a385052f6e66436784a40d286dc609a7febfa30 Mon Sep 17 00:00:00 2001 From: kastoras Date: Fri, 7 May 2021 23:39:14 +0300 Subject: [PATCH 0008/1055] New Create share link on file upload Create MAIN_CREATE_SHARE_ON_FILE_UPLOAD, when this set to 1 and a file is uploaded a shared link will be created --- htdocs/core/lib/files.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index ce5e7129bcf..1a52102d61d 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1766,7 +1766,7 @@ function dol_remove_file_process($filenb, $donotupdatesession = 0, $donotdeletef */ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uploaded', $setsharekey = 0, $object = null) { - global $db, $user; + global $db, $user, $conf; $result = 0; @@ -1792,6 +1792,9 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } + if(!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1'){ + $setsharekey = 1; + } if ($setsharekey) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $ecmfile->share = getRandomPassword(true); From fc26e5eecfd6faff7dcf9509db1dd1b9597222f2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 7 May 2021 20:42:53 +0000 Subject: [PATCH 0009/1055] Fixing style errors. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1a52102d61d..9bf520d56b5 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1792,7 +1792,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } - if(!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1'){ + if (!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1') { $setsharekey = 1; } if ($setsharekey) { From 76c10f053abeeab7baf8203048cc05e016a87b17 Mon Sep 17 00:00:00 2001 From: kastoras Date: Tue, 11 May 2021 22:29:07 +0300 Subject: [PATCH 0010/1055] Change parameter name to MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1a52102d61d..4232eb78b40 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1792,7 +1792,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } - if(!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1'){ + if(!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE) && $conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE=='1'){ $setsharekey = 1; } if ($setsharekey) { From cd9ea9566b5d27bff62a515efec1329447c0a55c Mon Sep 17 00:00:00 2001 From: kastoras Date: Tue, 11 May 2021 22:31:38 +0300 Subject: [PATCH 0011/1055] Change parameter name to MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 9bf520d56b5..4232eb78b40 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1792,7 +1792,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } - if (!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1') { + if(!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE) && $conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE=='1'){ $setsharekey = 1; } if ($setsharekey) { From b8a3485c4cd73f113c5b011e7faa4b6d37078329 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 11 May 2021 19:33:23 +0000 Subject: [PATCH 0012/1055] Fixing style errors. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 4232eb78b40..7ee3dbee46f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1792,7 +1792,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } - if(!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE) && $conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE=='1'){ + if (!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE) && $conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE=='1') { $setsharekey = 1; } if ($setsharekey) { From 09ab9308065677ff55d55093d3bb8e187c77e942 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Mon, 17 May 2021 18:31:19 +0200 Subject: [PATCH 0013/1055] sale_representative_order_invoice_list --- htdocs/commande/list.php | 55 ++++++++++++++++++++++++++++++++++ htdocs/compta/facture/list.php | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 3747b2107b2..af6fa6e5bf5 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -187,6 +187,7 @@ $arrayfields = array( 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), + 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), @@ -1172,6 +1173,9 @@ if ($resql) { print ''; print ''; } + if (!empty($arrayfields['sale_representative']['checked'])) { + print ''; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook @@ -1329,6 +1333,9 @@ if ($resql) { if (!empty($arrayfields['u.login']['checked'])) { print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); } + if (!empty($arrayfields['sale_representative']['checked'])) { + print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1685,6 +1692,54 @@ if ($resql) { } } + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 14b0383fa8d..ad8ead936be 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -228,6 +228,7 @@ $arrayfields = array( 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140), 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>165), + 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), 'f.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>170), 'f.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>171), 'f.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>180), @@ -1234,6 +1235,9 @@ if ($resql) { print ''; print ''; } + if (!empty($arrayfields['sale_representative']['checked'])) { + print ''; + } if (!empty($arrayfields['f.retained_warranty']['checked'])) { print ''; print ''; @@ -1426,6 +1430,9 @@ if ($resql) { if (!empty($arrayfields['u.login']['checked'])) { print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); } + if (!empty($arrayfields['sale_representative']['checked'])) { + print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); + } if (!empty($arrayfields['f.retained_warranty']['checked'])) { print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); } @@ -1894,6 +1901,54 @@ if ($resql) { } } + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if ($obj->socid > 0) { + $listsalesrepresentatives = $thirdpartystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['f.retained_warranty']['checked'])) { print ''.(!empty($obj->retained_warranty) ?price($obj->retained_warranty).'%' : ' ').''; } From 70a062e2c1da3ed83f59e249ac74554eee95ff6a Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Mon, 17 May 2021 23:59:42 +0200 Subject: [PATCH 0014/1055] change position --- htdocs/commande/list.php | 2 +- htdocs/compta/facture/list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4f68c1d9014..72f5528ec31 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -187,7 +187,7 @@ $arrayfields = array( 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), - 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), + 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'position'=>116), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 6cb2d05a157..c8175300b16 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -228,7 +228,7 @@ $arrayfields = array( 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140), 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>165), - 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), + 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'position'=>166), 'f.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>170), 'f.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>171), 'f.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>180), From c02e3eed6b227123f883ecd607e935dce5d8fcd1 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Tue, 18 May 2021 18:45:07 +0200 Subject: [PATCH 0015/1055] checked --- htdocs/commande/list.php | 2 +- htdocs/compta/facture/list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 72f5528ec31..153250534fd 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -187,7 +187,7 @@ $arrayfields = array( 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), - 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'position'=>116), + 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c8175300b16..9eab570f31b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -228,7 +228,7 @@ $arrayfields = array( 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140), 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>165), - 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'position'=>166), + 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>166), 'f.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>170), 'f.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>171), 'f.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>180), From 8eb8889b176dbdaa43fd5ae24d3eaed55eeb14da Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Wed, 19 May 2021 11:12:34 +0200 Subject: [PATCH 0016/1055] NEW: autocomplete account group when editing an account card --- htdocs/accountancy/admin/card.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index b629e45cf0d..ae1ba5a3ad3 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -257,7 +257,16 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc")); print ''; print ''; - print ''; + print ''; + print ''; + $sql = 'SELECT a.rowid as rowid, a.code as code, a.label FROM '.MAIN_DB_PREFIX.'c_accounting_category as a WHERE a.active=1'; + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + print ''; print ''; // Category From 62bc6e9e1f383db48d7dc7351f1a90fc227c8cc2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 20 May 2021 13:15:32 +0200 Subject: [PATCH 0017/1055] on going --- htdocs/compta/facture/list.php | 23 +++++++++++++--- htdocs/core/class/html.form.class.php | 39 ++++++++++++++++----------- htdocs/langs/en_US/bills.lang | 3 ++- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 282aad95d89..6bf02d5d580 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -363,7 +363,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if ($massaction == 'makepayment') { +if ($massaction == 'makepayment_confirm') { $arrayofselected = is_array($toselect) ? $toselect : array(); $loc = dol_buildpath('/compta/paiement.php', 2).'?action=create&facids='.implode(',', $arrayofselected); @@ -948,8 +948,10 @@ if ($resql) { 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), - //'makepayment'=>$langs->trans("InvoicePaymentsLimits"), TODO Blank page when using this ); + if ($user->rights->facture->paiement) { + $arrayofmassactions['makepayment'] = $langs->trans("RegisterPaymentAndClasiffiedPayed"); + } if ($conf->prelevement->enabled && !empty($user->rights->prelevement->bons->creer)) { $langs->load("withdrawals"); $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); @@ -961,7 +963,7 @@ if ($resql) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } } - if (in_array($massaction, array('presend', 'predelete'))) { + if (in_array($massaction, array('presend', 'predelete' ,'makepayment'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -997,6 +999,21 @@ if ($resql) { $trackid = 'inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + if ($massaction=='makepayment') { + $formconfirm = ''; + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'date', 'name' => 'datepaiment', 'label' => $langs->trans("Date")), + array('type' => 'other', 'name' => 'paiementid', 'label' => $langs->trans("PaymentMode"), 'value' => $form->select_types_paiements(GETPOST('search_paymentmode'), 'paiementid', '', 2, 0, 1, 0, 1, '', 1)), + array('type' => 'other', 'name' => 'bankid', 'label' => $langs->trans("Date"), 'value'=>$form->select_comptes('', 'bankid', 0, '', 0, '', 0, '', 1)), + //array('type' => 'other', 'name' => 'invoicesid', 'label' => '', 'value'=>''), + ); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('RegisterPaymentAndClasiffiedPayed'), $langs->trans('RegisterPaymentAndClasiffiedPayed', $object->ref), 'makepayment_confirm', $formquestion, 1, 0, 200, 500, 1); + print $formconfirm; + } + if ($sall) { foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 57bbbe3a029..763a3da6c57 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3914,13 +3914,16 @@ class Form * @param int $maxlength Max length of label * @param int $active Active or not, -1 = all * @param string $morecss Add more CSS on select tag + * @param int $nooutput 1=Return string, do not send to output * @return void */ - public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') + public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '', $nooutput = 0) { // phpcs:enable global $langs, $user, $conf; + $out = ''; + dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); $filterarray = array(); @@ -3939,9 +3942,9 @@ class Form $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID; } - print ''; if ($empty) { - print ''; + $out .= ''; } foreach ($this->cache_types_paiements as $id => $arraytypes) { // If not good status @@ -3960,25 +3963,25 @@ class Form } if ($format == 0) { - print ''; + $out .= $value ? $value : ' '; + $out .= ''; } - print ''; + $out .= ''; if ($user->admin && !$noadmininfo) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + $out .= ajax_combobox('select'.$htmlname); + + if (empty($nooutput)) { + print $out; + } else { + return $out; } - print ajax_combobox('select'.$htmlname); } diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 940da4e35b4..1ccdd162719 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -589,4 +589,5 @@ FacParentLine=Invoice Line Parent SituationTotalRayToRest=Remainder to pay without taxe PDFSituationTitle=Situation n° %d SituationTotalProgress=Total progress %d %% -SearchUnpaidInvoicesWithDueDate=Search unpaid invoices with a due date = %s \ No newline at end of file +SearchUnpaidInvoicesWithDueDate=Search unpaid invoices with a due date = %s +RegisterPaymentAndClasiffiedPayed=Enter payment and Classify 'Paid' From 7c6ac86d3209d5822672ae7efd58e6cdcc137ef2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 20 May 2021 13:41:23 +0200 Subject: [PATCH 0018/1055] ongoing --- htdocs/compta/facture/list.php | 54 ++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 6bf02d5d580..067a7cb959a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -363,13 +363,53 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if ($massaction == 'makepayment_confirm') { +if ($action == 'makepayment_confirm') { + /*require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $arrayofselected = is_array($toselect) ? $toselect : array(); + if (!empty($invoices_id)) { + $bankid=GETPOST('bankid','int'); + $paiementid=GETPOST('paiementid','int'); + $paiementdate=dol_mktime(12,0,0,GETPOST('datepaimentmonth','int'),GETPOST('datepaimentday','int'),GETPOST('datepaimentyear','year')); + foreach ($arrayofselected as $toselectid) { + $facture = new Facture($db); + $result = $facture->fetch($invoice_id); + if ($result < 0) { + setEventMessage($facture->error, 'errors'); + } else { + if (empty($facture->paye)) { - $loc = dol_buildpath('/compta/paiement.php', 2).'?action=create&facids='.implode(',', $arrayofselected); - - header('Location: '.$loc); - exit; + $paiementAmount = $facture->getSommePaiement(); + $totalcreditnotes = $facture->getSumCreditNotesUsed(); + $totaldeposits = $facture->getSumDepositsUsed(); + $totalpay = $paiementAmount + $totalcreditnotes + $totaldeposits; + $remaintopay = price2num($facture->total_ttc - $totalpay); + if ($remaintopay!=0) { + $resultBank = $facture->setBankAccount($bankid); + if ($resultBank < 0) { + setEventMessage($facture->error, 'errors'); + } else { + $paiement = new Paiement($this->db); + $paiement->datepaye = $paiementdate; + $paiement->amounts[$facture->id] = $remaintopay; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts[$facture->id] = $remaintopay; + $paiement->paiementid = $paiementid; + $paiement_id = $paiement->create($user, 1, $facture->thirdparty); + if ($paiement_id < 0) { + setEventMessage($facture->ref . ' ' . $paiement->error, 'errors'); + } else { + $result = $paiement->addPaymentToBank($user, 'payment', '', $bankid, '', ''); + if ($result < 0) { + setEventMessages($facture->ref . ' ' . $paiement->error, $paiement->errors, 'errors'); + } + } + } + } + } else { + setEventMessage($facture->ref.' Total 0 € Pas de réglement enregistré', 'errors'); + } + } + } + }*/ } elseif ($massaction == 'withdrawrequest') { $langs->load("withdrawals"); @@ -985,7 +1025,9 @@ if ($resql) { } print ''; print ''; - print ''; + if (!in_array($massaction, array('presend', 'predelete' ,'makepayment'))) { + print ''; + } print ''; print ''; print ''; From 4d7b09ff2ae7bde4a4caa3a6935b5552663523fb Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 20 May 2021 14:00:43 +0200 Subject: [PATCH 0019/1055] done --- htdocs/compta/facture/list.php | 37 ++++++++++++++++++++++------------ htdocs/langs/en_US/bills.lang | 4 +++- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 067a7cb959a..677d92e8765 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -363,21 +363,22 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if ($action == 'makepayment_confirm') { - /*require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +if ($action == 'makepayment_confirm' && $user->rights->facture->paiement) { + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $arrayofselected = is_array($toselect) ? $toselect : array(); - if (!empty($invoices_id)) { - $bankid=GETPOST('bankid','int'); - $paiementid=GETPOST('paiementid','int'); - $paiementdate=dol_mktime(12,0,0,GETPOST('datepaimentmonth','int'),GETPOST('datepaimentday','int'),GETPOST('datepaimentyear','year')); + if (!empty($arrayofselected)) { + $bankid=GETPOST('bankid', 'int'); + $paiementid=GETPOST('paiementid', 'int'); + $paiementdate=dol_mktime(12, 0, 0, GETPOST('datepaimentmonth', 'int'), GETPOST('datepaimentday', 'int'), GETPOST('datepaimentyear', 'year')); foreach ($arrayofselected as $toselectid) { + $errorpayment=0; $facture = new Facture($db); - $result = $facture->fetch($invoice_id); + $result = $facture->fetch($toselectid); if ($result < 0) { setEventMessage($facture->error, 'errors'); + $errorpayment++; } else { - if (empty($facture->paye)) { - + if ($facture->type != Facture::TYPE_CREDIT_NOTE && $facture->statut == 1 && $facture->paye == 0) { $paiementAmount = $facture->getSommePaiement(); $totalcreditnotes = $facture->getSumCreditNotesUsed(); $totaldeposits = $facture->getSumDepositsUsed(); @@ -387,8 +388,9 @@ if ($action == 'makepayment_confirm') { $resultBank = $facture->setBankAccount($bankid); if ($resultBank < 0) { setEventMessage($facture->error, 'errors'); + $errorpayment++; } else { - $paiement = new Paiement($this->db); + $paiement = new Paiement($db); $paiement->datepaye = $paiementdate; $paiement->amounts[$facture->id] = $remaintopay; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts[$facture->id] = $remaintopay; @@ -396,20 +398,29 @@ if ($action == 'makepayment_confirm') { $paiement_id = $paiement->create($user, 1, $facture->thirdparty); if ($paiement_id < 0) { setEventMessage($facture->ref . ' ' . $paiement->error, 'errors'); + $errorpayment++; } else { $result = $paiement->addPaymentToBank($user, 'payment', '', $bankid, '', ''); if ($result < 0) { setEventMessages($facture->ref . ' ' . $paiement->error, $paiement->errors, 'errors'); + $errorpayment++; } } } + } else { + setEventMessage($langs->trans('NoPaymentAvailable', $facture->ref), 'warnings'); + $errorpayment++; } } else { - setEventMessage($facture->ref.' Total 0 € Pas de réglement enregistré', 'errors'); + setEventMessage($langs->trans('NoPaymentAvailable', $facture->ref), 'warnings'); + $errorpayment++; } } + if (empty($errorpayment)) { + setEventMessage($langs->trans('RegisterPaymentAndClasiffiedPayedDone', $facture->ref)); + } } - }*/ + } } elseif ($massaction == 'withdrawrequest') { $langs->load("withdrawals"); @@ -1048,7 +1059,7 @@ if ($resql) { // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), array('type' => 'date', 'name' => 'datepaiment', 'label' => $langs->trans("Date")), - array('type' => 'other', 'name' => 'paiementid', 'label' => $langs->trans("PaymentMode"), 'value' => $form->select_types_paiements(GETPOST('search_paymentmode'), 'paiementid', '', 2, 0, 1, 0, 1, '', 1)), + array('type' => 'other', 'name' => 'paiementid', 'label' => $langs->trans("PaymentMode"), 'value' => $form->select_types_paiements(GETPOST('search_paymentmode'), 'paiementid', '', 0, 0, 1, 0, 1, '', 1)), array('type' => 'other', 'name' => 'bankid', 'label' => $langs->trans("Date"), 'value'=>$form->select_comptes('', 'bankid', 0, '', 0, '', 0, '', 1)), //array('type' => 'other', 'name' => 'invoicesid', 'label' => '', 'value'=>''), ); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 1ccdd162719..a43d56217b4 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -590,4 +590,6 @@ SituationTotalRayToRest=Remainder to pay without taxe PDFSituationTitle=Situation n° %d SituationTotalProgress=Total progress %d %% SearchUnpaidInvoicesWithDueDate=Search unpaid invoices with a due date = %s -RegisterPaymentAndClasiffiedPayed=Enter payment and Classify 'Paid' +RegisterPaymentAndClasiffiedPayed=Enter payment and classify 'Paid' +NoPaymentAvailable=No payment available for %s +RegisterPaymentAndClasiffiedPayedDone=Payment registered and classify 'Paid' done for invoice %s From d70bbe29b54e7055043f51f72a47bfc84af90b78 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 20 May 2021 14:03:18 +0200 Subject: [PATCH 0020/1055] fix --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e17e56e4378..850c012a5e7 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1036,7 +1036,7 @@ if ($resql) { } print ''; print ''; - if (!in_array($massaction, array('presend', 'predelete' ,'makepayment'))) { + if (!in_array($massaction, array('makepayment'))) { print ''; } print ''; From e6deab5c859eb9a4a3bbfebb5f5702183c4dde8a Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Fri, 28 May 2021 08:42:38 +0200 Subject: [PATCH 0021/1055] FIX proposed new feature: autocomplete for accounting account groups --- htdocs/accountancy/admin/card.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index ae1ba5a3ad3..1d62fe1d414 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -258,13 +258,13 @@ if ($action == 'create') { print ''; print ''; print ''; + // autosuggest from existing account types if found print ''; - $sql = 'SELECT a.rowid as rowid, a.code as code, a.label FROM '.MAIN_DB_PREFIX.'c_accounting_category as a WHERE a.active=1'; - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) { - print ''; print ''; From a7300d01b050f8cfb68ec08c2cd1040b71460614 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Jun 2021 09:49:07 +0200 Subject: [PATCH 0022/1055] WIP - create validation method for common object --- htdocs/core/class/commonobject.class.php | 189 ++++++++++++++++++++++ htdocs/core/class/validate.class.php | 194 +++++++++++++++++++++++ htdocs/langs/en_US/validate.lang | 12 ++ 3 files changed, 395 insertions(+) create mode 100644 htdocs/core/class/validate.class.php create mode 100644 htdocs/langs/en_US/validate.lang diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3f4b2dd9ee6..12f88fc0a58 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7285,6 +7285,195 @@ abstract class CommonObject return $out; } + /** + * Return validation test for a field + * + * @param array $val Array of properties of field to show + * @param string $key Key of attribute + * @return int >0 if OK, <0 if KO , 0 no test available. + */ + public function validateField($val, $fieldKey, $fieldValue) + { + global $langs; + + if(!class_exists('Validate')){ require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php'; } + + // TODO : ask @eldy to know if need to use another error field to separate error msg + $this->error = ''; // error will be use for form error display so must be clear before + + if(!isset($val[$fieldKey])){ + return false; + } + + $param = array(); + $param['options'] = array(); + $type = $val[$fieldKey]['type']; + + $required = false; + if(isset($val[$fieldKey]['notnull']) && $val[$fieldKey]['notnull'] === 1){ + // 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + $required = true; + } + + $maxSize = 0; + + + // + // PREPARE Elements + // + + // Convert var to be able to share same code than showOutputField of extrafields + if (preg_match('/varchar\((\d+)\)/', $type, $reg)) { + $type = 'varchar'; // convert varchar(xx) int varchar + $maxSize = $reg[1]; + } elseif (preg_match('/varchar/', $type)) { + $type = 'varchar'; // convert varchar(xx) int varchar + } + + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + $type = 'select'; + } + + if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { + $type = 'link'; + } + + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + $param['options'] = $val['arrayofkeyval']; + } + + if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { + $type = 'link'; + $param['options'] = array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); + } elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N'); + $type = 'sellist'; + } elseif (preg_match('/^sellist:(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3] => 'N'); + $type = 'sellist'; + } elseif (preg_match('/^sellist:(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[1].':'.$reg[2] => 'N'); + $type = 'sellist'; + } + + // + // TEST Value + // + + // Use Validate class to allow external Modules to use data validation part instead of concentrate all test here (factoring) + $validate = new Validate($this->db, $langs); + + + if($required && !$validate->isNotEmptyString($fieldValue)){ + $this->error = $validate->error; + return -1; + } + + + if(!empty($maxSize) && !$validate->isMaxLength($fieldValue, $maxSize)){ + $this->error = $validate->error; + return -1; + } + + + + if (in_array($type, array('date', 'datetime', 'timestamp'))) { + if(!$validate->isTimestamp($fieldValue)){ + $this->error = $validate->error; + return -1; + } + } elseif ($type == 'duration') { + // int + } elseif (in_array($type, array('double', 'real', 'price'))) { + // is numeric + } elseif ($type == 'boolean') { + // is bool + } elseif ($type == 'mail') { + if(!$validate->isEmail($fieldValue)){ + $this->error = $validate->error; + return -1; + } + } elseif ($type == 'url') { + if(!$validate->isUrl($fieldValue)){ + $this->error = $validate->error; + return -1; + } + } elseif ($type == 'phone') { + + } elseif ($type == 'select' || $type == 'radio') { + // isset in list + if(!isset($param['options'][$fieldValue])){ + + } + } elseif ($type == 'sellist' || $type == 'chkbxlst') { + $param_list = array_keys($param['options']); + $InfoFieldList = explode(":", $param_list[0]); + $value_arr = explode(',', $fieldValue); + $value_arr = array_map(array($this->db, 'escape'), $value_arr); + + $selectkey = "rowid"; + if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) { + $selectkey = $InfoFieldList[2]; + } + + // TODO tester toute les valeur du tableau séparement + + $sql = 'SELECT '.$selectkey; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; + if ($selectkey == 'rowid' && empty($value)) { + $sql .= " WHERE ".$selectkey."=0"; + } else { + $sql .= " WHERE ".$selectkey." IN ('".implode(',',$value_arr)."')"; + } + + dol_syslog(get_class($this).':validateField:$type=sellist', LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if (empty($num)) { + // error value not found + $this->error = 'error msg'; + return false; + } else { + return true; + } + + } else { + dol_syslog(get_class($this).'::validateField error '.$this->db->lasterror(), LOG_WARNING); + return false; + } + } elseif ($type == 'link') { + + // only if something to display (perf) + if (!empty($fieldValue)) { + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' + $InfoFieldList = explode(":", $param_list[0]); + $classname = $InfoFieldList[0]; + $classpath = $InfoFieldList[1]; + if (!empty($classpath)) { + dol_include_once($InfoFieldList[1]); + if ($classname && class_exists($classname)) { + $object = new $classname($this->db); + if($object->fetch($fieldValue)>0){ + return true; + } + $this->error = 'class not found for validation'; + } else { + $this->error = 'Error bad setup of extrafield'; + } + return false; + } else { + $this->error = 'Error bad setup of extrafield'; + return false; + } + } + else { + // TODO vérifier si requis + } + } + + return 0; + } /** * Function to show lines of extrafields with output datas. diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php new file mode 100644 index 00000000000..fa02018118b --- /dev/null +++ b/htdocs/core/class/validate.class.php @@ -0,0 +1,194 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/validate.class.php + * \ingroup core + * \brief File for Utils class + */ + + +/** + * Class toolbox to validate values + */ +class Validate +{ + + /** + * @var DoliDb Database handler (result of a new DoliDB) + */ + public $db; + + /** + * @var Translate $outputLang + */ + public $outputLang; + + /** + * @var string Error string + * @see $errors + */ + public $error; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param Translate $outputLang + */ + public function __construct($db,$outputLang = false) + { + global $langs; + + if ($outputLang) { + $this->outputLang = $langs; + } else { + $this->outputLang = $outputLang; + } + + $outputLang->load('validate'); + + $this->db = $db; + } + + /** + * Use to clear errors msg or other ghost vars + */ + protected function clear() + { + $this->error = ''; + } + + /** + * Use to clear errors msg or other ghost vars + */ + protected function setError($errMsg) + { + $this->error = ''; + } + + /** + * Check for e-mail validity + * + * @param string $email e-mail address to validate + * @param int $maxLength + * @return boolean Validity is ok or not + */ + public function isEmail($email, $maxLength = false) + { + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + $this->error = $this->outputLang->trans('RequireValidEmail'); + return false; + } + return true; + } + + /** + * Check for price validity + * + * @param string $price Price to validate + * @return boolean Validity is ok or not + */ + public function isPrice($price) + { + if (!preg_match('/^[0-9]{1,10}(\.[0-9]{1,9})?$/ui', $price)) { + $this->error = $this->outputLang->trans('RequireValidValue'); + return false; + } + return true; + } + + /** + * Check for timestamp validity + * + * @param string|int $stamp timestamp to validate + * @return boolean Validity is ok or not + */ + public function isTimestamp($stamp) + { + if (!is_numeric($stamp) && (int)$stamp == $stamp) { + $this->error = $this->outputLang->trans('RequireValideDate'); + return false; + } + return true; + } + + /** + * Check for string max length validity + * + * @param string $string to validate + * @param int $length max length + * @return boolean Validity is ok or not + */ + public function isMaxLength($string, $length) + { + if (strlen($string) > $length) { + $this->error = $this->outputLang->trans('RequireMaxLength', $length); + return false; + } + return true; + } + + /** + * Check for string not empty + * + * @param string $string to validate + * @param int $length max length + * @return boolean Validity is ok or not + */ + public function isNotEmptyString($string) + { + if (!strlen($string)) { + $this->error = $this->outputLang->trans('RequireANotEmptyValue'); + return false; + } + return true; + } + + /** + * Check for string min length validity + * + * @param string $string to validate + * @param int $length max length + * @return boolean Validity is ok or not + */ + public function isMinLength($string, $length) + { + if (!strlen($string) < $length) { + $this->error = $this->outputLang->trans('RequireMinLength', $length); + return false; + } + return true; + } + + /** + * Check url validity + * + * @param string $url to validate + * @return boolean Validity is ok or not + */ + public function isUrl($url) + { + if (!filter_var($url, FILTER_VALIDATE_URL)) { + $this->error = $this->outputLang->trans('RequireValidUrl'); + return false; + } + return true; + } + +} diff --git a/htdocs/langs/en_US/validate.lang b/htdocs/langs/en_US/validate.lang new file mode 100644 index 00000000000..1464805b853 --- /dev/null +++ b/htdocs/langs/en_US/validate.lang @@ -0,0 +1,12 @@ +# Dolibarr language file - Source file is en_US - users +RequireValidValue = Value not valid +RequireAtLeastXString = Requires at least % character(s) +RequireXStringMax = Requires % character(s) max +RequireAtLeastXDigits = Requires at least % digit(s) +RequireXDigitsMax = Requires % digit(s) max +RequireValidEmail = Email address is not valid +RequireMaxLength = Length must be less than %s chars +RequireMinLength = Length must be more than %s char(s) +RequireValidUrl = Require valid URL +RequireValideDate = Require a valid date +RequireANotEmptyValue = Is required From aa94d40ad0ef4325c44b39df8bbb5e6b1dfd73e8 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 6 Jun 2021 21:12:03 +0200 Subject: [PATCH 0023/1055] WIP - create validation method for common object --- htdocs/core/class/commonobject.class.php | 179 ++++++++++++----------- htdocs/core/class/validate.class.php | 114 ++++++++++++++- htdocs/langs/en_US/validate.lang | 9 +- 3 files changed, 215 insertions(+), 87 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 12f88fc0a58..ae5f0d33216 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7286,11 +7286,12 @@ abstract class CommonObject } /** - * Return validation test for a field + * Return validation test result for a field * - * @param array $val Array of properties of field to show - * @param string $key Key of attribute - * @return int >0 if OK, <0 if KO , 0 no test available. + * @param array $val Array of properties of field to show + * @param string $fieldKey Key of attribute + * @param string $fieldValue value of attribute + * @return bool return false if fail true on success, see $this->error for error message */ public function validateField($val, $fieldKey, $fieldValue) { @@ -7301,7 +7302,7 @@ abstract class CommonObject // TODO : ask @eldy to know if need to use another error field to separate error msg $this->error = ''; // error will be use for form error display so must be clear before - if(!isset($val[$fieldKey])){ + if (!isset($val[$fieldKey])) { return false; } @@ -7310,13 +7311,13 @@ abstract class CommonObject $type = $val[$fieldKey]['type']; $required = false; - if(isset($val[$fieldKey]['notnull']) && $val[$fieldKey]['notnull'] === 1){ + if (isset($val[$fieldKey]['notnull']) && $val[$fieldKey]['notnull'] === 1) { // 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). $required = true; } $maxSize = 0; - + $minSize = 0; // // PREPARE Elements @@ -7360,52 +7361,98 @@ abstract class CommonObject // TEST Value // - // Use Validate class to allow external Modules to use data validation part instead of concentrate all test here (factoring) + // Use Validate class to allow external Modules to use data validation part instead of concentrate all test here (factoring) or just for reuse $validate = new Validate($this->db, $langs); + // little trick : to perform tests with good performances sort tests by quick to low + + // + // COMMON TESTS + // + + // Required test and empty value if($required && !$validate->isNotEmptyString($fieldValue)){ $this->error = $validate->error; - return -1; + return false; + } + elseif (!$required && !$validate->isNotEmptyString($fieldValue)) { + // if no value sent and the field is not mandatory, no need to perform tests + return true; } - + // MAX Size test if(!empty($maxSize) && !$validate->isMaxLength($fieldValue, $maxSize)){ $this->error = $validate->error; - return -1; + return false; } + // MIN Size test + if(!empty($minSize) && !$validate->isMinLength($fieldValue, $minSize)){ + $this->error = $validate->error; + return false; + } + // + // TESTS for TYPE + // if (in_array($type, array('date', 'datetime', 'timestamp'))) { - if(!$validate->isTimestamp($fieldValue)){ + if (!$validate->isTimestamp($fieldValue)) { $this->error = $validate->error; - return -1; - } + return false; + } else { return true; } } elseif ($type == 'duration') { - // int - } elseif (in_array($type, array('double', 'real', 'price'))) { + if(!$validate->isDuration($fieldValue)){ + $this->error = $validate->error; + return false; + } else { return true; } + } + elseif (in_array($type, array('double', 'real', 'price'))) + { // is numeric - } elseif ($type == 'boolean') { - // is bool - } elseif ($type == 'mail') { + if(!$validate->isDuration($fieldValue)){ + $this->error = $validate->error; + return false; + } else { return true; } + } + elseif ($type == 'boolean') + { + if(!$validate->isBool($fieldValue)){ + $this->error = $validate->error; + return false; + } else { return true; } + } + elseif ($type == 'mail') + { if(!$validate->isEmail($fieldValue)){ $this->error = $validate->error; - return -1; + return false; } - } elseif ($type == 'url') { + } + elseif ($type == 'url') + { if(!$validate->isUrl($fieldValue)){ $this->error = $validate->error; - return -1; - } - } elseif ($type == 'phone') { - - } elseif ($type == 'select' || $type == 'radio') { - // isset in list - if(!isset($param['options'][$fieldValue])){ - - } - } elseif ($type == 'sellist' || $type == 'chkbxlst') { + return false; + } else { return true; } + } + elseif ($type == 'phone') + { + if (!$validate->isPhone($fieldValue)) { + $this->error = $validate->error; + return false; + } else { return true; } + } + elseif ($type == 'select' || $type == 'radio') + { + if (!isset($param['options'][$fieldValue])) { + $this->error = $langs->trans('RequireValidValue'); + return false; + } else { return true; } + } + elseif ($type == 'sellist' || $type == 'chkbxlst') + { $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); $value_arr = explode(',', $fieldValue); @@ -7416,63 +7463,25 @@ abstract class CommonObject $selectkey = $InfoFieldList[2]; } - // TODO tester toute les valeur du tableau séparement - - $sql = 'SELECT '.$selectkey; - $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; - if ($selectkey == 'rowid' && empty($value)) { - $sql .= " WHERE ".$selectkey."=0"; - } else { - $sql .= " WHERE ".$selectkey." IN ('".implode(',',$value_arr)."')"; - } - - dol_syslog(get_class($this).':validateField:$type=sellist', LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if (empty($num)) { - // error value not found - $this->error = 'error msg'; - return false; - } else { - return true; - } - - } else { - dol_syslog(get_class($this).'::validateField error '.$this->db->lasterror(), LOG_WARNING); + if(!isInDb($value_arr, $InfoFieldList[0], $selectkey)){ + $this->error = $validate->error; return false; - } - } elseif ($type == 'link') { - - // only if something to display (perf) - if (!empty($fieldValue)) { - $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' - $InfoFieldList = explode(":", $param_list[0]); - $classname = $InfoFieldList[0]; - $classpath = $InfoFieldList[1]; - if (!empty($classpath)) { - dol_include_once($InfoFieldList[1]); - if ($classname && class_exists($classname)) { - $object = new $classname($this->db); - if($object->fetch($fieldValue)>0){ - return true; - } - $this->error = 'class not found for validation'; - } else { - $this->error = 'Error bad setup of extrafield'; - } - return false; - } else { - $this->error = 'Error bad setup of extrafield'; - return false; - } - } - else { - // TODO vérifier si requis - } + } else { return true; } + } + elseif ($type == 'link') + { + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' + $InfoFieldList = explode(":", $param_list[0]); + $classname = $InfoFieldList[0]; + $classpath = $InfoFieldList[1]; + if(!$validate->isFetchable($fieldValue, $classname, $classpath)){ + $this->error = $validate->error; + return false; + } else { return true; } } - return 0; + // if no test failled all is ok + return true; } /** diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index fa02018118b..ac01ce76531 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -122,7 +122,22 @@ class Validate public function isTimestamp($stamp) { if (!is_numeric($stamp) && (int)$stamp == $stamp) { - $this->error = $this->outputLang->trans('RequireValideDate'); + $this->error = $this->outputLang->trans('RequireValidDate'); + return false; + } + return true; + } + + /** + * Check for phone validity + * + * @param string $phone Phone string to validate + * @return boolean Validity is ok or not + */ + public function isPhone($phone) + { + if (!preg_match('/^[+0-9. ()-]*$/ui', $phone)) { + $this->error = $this->outputLang->trans('RequireValidPhone'); return false; } return true; @@ -191,4 +206,101 @@ class Validate return true; } + /** + * Check Duration validity + * + * @param string $duration to validate + * @return boolean Validity is ok or not + */ + public function isDuration($duration) + { + if (!is_int($duration) && $duration >= 0) { + $this->error = $this->outputLang->trans('RequireValidDuration'); + return false; + } + return true; + } + + /** + * Check for boolean validity + * + * @param boolean $bool Boolean to validate + * @return boolean Validity is ok or not + */ + public function isBool($bool) + { + if(!(is_null($bool) || is_bool($bool) || preg_match('/^[0|1]{1}$/ui', $bool))){ + $this->error = $this->outputLang->trans('RequireValidBool'); + return false; + } + return true; + } + + /** + * Check for all values in db + * + * @param array $values Boolean to validate + * @param string $table the db table name without MAIN_DB_PREFIX + * @param string $col the target col + * @return boolean Validity is ok or not + * @throws Exception + */ + public function isInDb($values, $table, $col) + { + if (!is_array($values)) { + $value_arr = array($values); + } else { + $value_arr = $values; + } + + if (!count($value_arr)) { + $this->error = $this->outputLang->trans('RequireValue'); + return false; + } + + foreach ($value_arr as $val){ + $val = $this->db->escape($val); + $sql = 'SELECT ' . $col . ' FROM ' . MAIN_DB_PREFIX . $table . " WHERE " . $col ." = '" . $val . "'"; // nore quick than count(*) to check existing of a row + $resql = $this->db->getRow($sql); + if ($resql) { + continue; + } else { + $this->error = $this->outputLang->trans('RequireValidExistingElement'); + return false; + } + } + + return true; + } + + /** + * Check for all values in db + * + * @param array $values Boolean to validate + * @param string $classname the class name + * @param string $classpath the class path + * @return boolean Validity is ok or not + * @throws Exception + */ + public function isFetchable($values, $classname, $classpath) + { + if (!empty($classpath)) { + if (dol_include_once($classpath)) { + if ($classname && class_exists($classname)) { + /** @var CommonObject $object */ + $object = new $classname($this->db); + + if (!is_callable(array($object, 'fetch')) || !is_callable(array($object, 'isExistingObject'))) { + $this->error = $this->outputLang->trans('BadSetupOfFieldFetchNotCallable'); + return false; + } + + if (!empty($object->table_element) && $object->isExistingObject($object->table_element, $values)) { + return true; + } else { $this->error = $this->outputLang->trans('RequireValidExistingElement'); } + } else { $this->error = $this->outputLang->trans('BadSetupOfFieldClassNotFoundForValidation'); } + } else { $this->error = $this->outputLang->trans('BadSetupOfFieldFileNotFound'); } + } else { $this->error = $this->outputLang->trans('BadSetupOfField'); } + return false; + } } diff --git a/htdocs/langs/en_US/validate.lang b/htdocs/langs/en_US/validate.lang index 1464805b853..bd25b6c0c74 100644 --- a/htdocs/langs/en_US/validate.lang +++ b/htdocs/langs/en_US/validate.lang @@ -8,5 +8,12 @@ RequireValidEmail = Email address is not valid RequireMaxLength = Length must be less than %s chars RequireMinLength = Length must be more than %s char(s) RequireValidUrl = Require valid URL -RequireValideDate = Require a valid date +RequireValidDate = Require a valid date RequireANotEmptyValue = Is required +RequireValidDuration = Require a valid duration +RequireValidExistingElement = Require an existing value +RequireValidBool = Require a valid boolean +BadSetupOfField = Error bad setup of field +BadSetupOfFieldClassNotFoundForValidation = Error bad setup of field : Class not found for validation +BadSetupOfFieldFileNotFound = Error bad setup of field : File not found for inclusion +BadSetupOfFieldFetchNotCallable = Error bad setup of field : Fetch not callable on class From f1b1dcd1b145af430a62141e013990dbeb28d795 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 6 Jun 2021 21:53:17 +0200 Subject: [PATCH 0024/1055] WIP - create validation method for common object --- htdocs/core/class/commonobject.class.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ae5f0d33216..f3426608c55 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6376,9 +6376,10 @@ abstract class CommonObject * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. * @param int $nonewbutton Force to not show the new button on field that are links to object + * @param bool $displayValidationResult Display validation results messages for fields, set it to true after form sended to display user mistakes * @return string */ - public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0) + public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0, $displayValidationResult = false) { global $conf, $langs, $form; @@ -6391,6 +6392,25 @@ abstract class CommonObject $val = $this->fields[$key]; } + // This is en experimental validation output TODO : remove this deactivation line + if ($conf->global->MAIN_FEATURES_LEVEL < 2 && empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { $displayValidationResult = false; } + + // Validation tests and output + $fieldValidation = 0; // 0 not tested, -1 error, 1 success + $fieldValidationErrorMesg = ''; + $validationClass = ''; + if ($displayValidationResult) { + if (!$this->validateField($val, $key, $value)) { + $validationClass = ' --error'; // the -- is use as class state in css : .--error can't be be defined alone it must be define with another class like .my-class.--error or input.--error + $fieldValidation = -1; + $fieldValidationErrorMesg = $this->error; + } else { + $validationClass = ' --success'; // the -- is use as class state in css : .--success can't be be defined alone it must be define with another class like .my-class.--success or input.--success + $fieldValidation = 1; + } + } + + $out = ''; $type = ''; $isDependList=0; From 801f6cab2d3bb86554a610fba27b92a649420ebb Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 6 Jun 2021 21:58:59 +0200 Subject: [PATCH 0025/1055] WIP - create validation method for common object --- htdocs/core/class/validate.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index ac01ce76531..3f94da5dbe0 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -259,8 +259,7 @@ class Validate } foreach ($value_arr as $val){ - $val = $this->db->escape($val); - $sql = 'SELECT ' . $col . ' FROM ' . MAIN_DB_PREFIX . $table . " WHERE " . $col ." = '" . $val . "'"; // nore quick than count(*) to check existing of a row + $sql = 'SELECT ' . $col . ' FROM ' . MAIN_DB_PREFIX . $table . " WHERE " . $col ." = '" . $this->db->escape($val) . "'"; // nore quick than count(*) to check existing of a row $resql = $this->db->getRow($sql); if ($resql) { continue; From 578dc9adde74c913962083eb4e129ffec0ed0fc9 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sat, 12 Jun 2021 12:58:20 +0200 Subject: [PATCH 0026/1055] WIP - create validation method for common object --- htdocs/core/actions_addupdatedelete.inc.php | 9 +++ htdocs/core/class/commonobject.class.php | 65 +++++++++++++++---- .../template/class/myobject.class.php | 2 +- 3 files changed, 61 insertions(+), 15 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index f871ed73de8..6c03839a996 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -105,6 +105,15 @@ if ($action == 'add' && !empty($permissiontoadd)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); } + + // Validation of fields values + if ($conf->global->MAIN_FEATURE_LEVEL >= 2 || !empty($conf->global->MAIN_USE_COMMON_VALIDATION)) { + if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) { + if (!$object->validateField($object->fields, $key, $value)) { + $error++; + } + } + } } // Fill array 'array_options' with data from add form diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f3426608c55..39eeae90fc2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -123,6 +123,10 @@ abstract class CommonObject */ protected $table_ref_field = ''; + /** + * @var array $validateFieldsErrors to store error results of ->validateField() + */ + public $validateFieldsErrors = array(); // Following vars are used by some objects only. We keep this property here in CommonObject to be able to provide common method using them. @@ -7305,6 +7309,40 @@ abstract class CommonObject return $out; } + /** + * clear validation message result for a field + * + * @param string $fieldKey Key of attribute to clear + */ + public function clearFieldError($fieldKey) + { + $this->error = ''; + unset($this->validateFieldsErrors[$fieldKey]); + } + + /** + * set validation error message a field + * + * @param string $fieldKey Key of attribute + */ + public function setFieldError($fieldKey, $msg = '') + { + $this->error = $this->validateFieldsErrors[$fieldKey] = $msg; + } + + /** + * get field error message + * + * @param string $fieldKey Key of attribute + */ + public function getFieldError($fieldKey) + { + if (!empty($this->validateFieldsErrors[$fieldKey])) { + return $this->validateFieldsErrors[$fieldKey]; + } + return ''; + } + /** * Return validation test result for a field * @@ -7319,8 +7357,7 @@ abstract class CommonObject if(!class_exists('Validate')){ require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php'; } - // TODO : ask @eldy to know if need to use another error field to separate error msg - $this->error = ''; // error will be use for form error display so must be clear before + $this->clearFieldError($fieldKey); if (!isset($val[$fieldKey])) { return false; @@ -7393,7 +7430,7 @@ abstract class CommonObject // Required test and empty value if($required && !$validate->isNotEmptyString($fieldValue)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } elseif (!$required && !$validate->isNotEmptyString($fieldValue)) { @@ -7403,13 +7440,13 @@ abstract class CommonObject // MAX Size test if(!empty($maxSize) && !$validate->isMaxLength($fieldValue, $maxSize)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } // MIN Size test if(!empty($minSize) && !$validate->isMinLength($fieldValue, $minSize)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } @@ -7419,12 +7456,12 @@ abstract class CommonObject if (in_array($type, array('date', 'datetime', 'timestamp'))) { if (!$validate->isTimestamp($fieldValue)) { - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } } elseif ($type == 'duration') { if(!$validate->isDuration($fieldValue)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } } @@ -7432,35 +7469,35 @@ abstract class CommonObject { // is numeric if(!$validate->isDuration($fieldValue)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } } elseif ($type == 'boolean') { if(!$validate->isBool($fieldValue)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } } elseif ($type == 'mail') { if(!$validate->isEmail($fieldValue)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } } elseif ($type == 'url') { if(!$validate->isUrl($fieldValue)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } } elseif ($type == 'phone') { if (!$validate->isPhone($fieldValue)) { - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } } @@ -7484,7 +7521,7 @@ abstract class CommonObject } if(!isInDb($value_arr, $InfoFieldList[0], $selectkey)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } } @@ -7495,7 +7532,7 @@ abstract class CommonObject $classname = $InfoFieldList[0]; $classpath = $InfoFieldList[1]; if(!$validate->isFetchable($fieldValue, $classname, $classpath)){ - $this->error = $validate->error; + $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index e69c5bc333d..be8736f9d49 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -91,7 +91,7 @@ class MyObject extends CommonObject * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar' * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. * 'comment' is not used. You can store here any text of your choice. It is not used by application. - * + * 'validate' is 1 if need to validate with $this->validateField() * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. */ From 43ecba2e6304496caa6b499c596bbc74634d509a Mon Sep 17 00:00:00 2001 From: ATM john Date: Sat, 12 Jun 2021 14:16:40 +0200 Subject: [PATCH 0027/1055] WIP - create validation method for common object --- htdocs/core/actions_addupdatedelete.inc.php | 11 ++++++++- htdocs/core/class/commonobject.class.php | 25 ++++++++++++++------- htdocs/core/lib/functions.lib.php | 17 ++++++++++++++ 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 6c03839a996..d2d22d74e3c 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -107,7 +107,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { } // Validation of fields values - if ($conf->global->MAIN_FEATURE_LEVEL >= 2 || !empty($conf->global->MAIN_USE_COMMON_VALIDATION)) { + if ($conf->global->MAIN_FEATURE_LEVEL >= 2 || !empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) { if (!$object->validateField($object->fields, $key, $value)) { $error++; @@ -213,6 +213,15 @@ if ($action == 'update' && !empty($permissiontoadd)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); } + + // Validation of fields values + if ($conf->global->MAIN_FEATURE_LEVEL >= 2 || !empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { + if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) { + if (!$object->validateField($object->fields, $key, $value)) { + $error++; + } + } + } } // Fill array 'array_options' with data from add form diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 39eeae90fc2..cfba42e0adf 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6381,9 +6381,10 @@ abstract class CommonObject * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. * @param int $nonewbutton Force to not show the new button on field that are links to object * @param bool $displayValidationResult Display validation results messages for fields, set it to true after form sended to display user mistakes + * @param string $mode 1=Used for search filters * @return string */ - public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0, $displayValidationResult = false) + public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0, $mode = 0) { global $conf, $langs, $form; @@ -6400,17 +6401,14 @@ abstract class CommonObject if ($conf->global->MAIN_FEATURES_LEVEL < 2 && empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { $displayValidationResult = false; } // Validation tests and output - $fieldValidation = 0; // 0 not tested, -1 error, 1 success - $fieldValidationErrorMesg = ''; + $fieldValidationErrorMsg = ''; $validationClass = ''; - if ($displayValidationResult) { - if (!$this->validateField($val, $key, $value)) { + if($mode == 0){ + $fieldValidationErrorMsg = $this->getFieldError($key); + if (!empty($fieldValidationErrorMsg)) { $validationClass = ' --error'; // the -- is use as class state in css : .--error can't be be defined alone it must be define with another class like .my-class.--error or input.--error - $fieldValidation = -1; - $fieldValidationErrorMesg = $this->error; } else { $validationClass = ' --success'; // the -- is use as class state in css : .--success can't be be defined alone it must be define with another class like .my-class.--success or input.--success - $fieldValidation = 1; } } @@ -6506,6 +6504,11 @@ abstract class CommonObject } } + // Add validation state class + if (!empty($validationClass)) { + $morecss.= ' '.$validationClass; + } + if (in_array($type, array('date'))) { $tmp = explode(',', $size); $newsize = $tmp[0]; @@ -6971,6 +6974,12 @@ abstract class CommonObject if ($type == 'date') $out.=' (YYYY-MM-DD)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; */ + + // Display error message for field + if ($mode == 0 && !empty($fieldValidationErrorMsg) && function_exists('getFieldErrorIcon')) { + $out .= ' '.getFieldErrorIcon($fieldValidationErrorMsg); + } + return $out; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 61a3869fe1a..5dd500a26a0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9753,6 +9753,23 @@ function dolGetButtonTitleSeparator($moreClass = "") return ''; } +/** + * get field error icon + * + * @param string $fieldValidationErrorMsg + */ +function getFieldErrorIcon($fieldValidationErrorMsg) +{ + $out = ''; + if (!empty($fieldValidationErrorMesg)) { + $out.= ''; // role alert is used for accessibility + $out.= ''; // For accessibility icon is separated and aria-hidden + $out.= ''; + } + + return $out; +} + /** * Function dolGetButtonTitle : this kind of buttons are used in title in list * From 23765bf459474e30fb213c4086099fb6178cef41 Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 14 Jun 2021 20:59:46 +0200 Subject: [PATCH 0028/1055] WIP - create validation method for common object --- htdocs/core/class/commonobject.class.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cfba42e0adf..9e9333b8962 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6380,8 +6380,7 @@ abstract class CommonObject * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. * @param int $nonewbutton Force to not show the new button on field that are links to object - * @param bool $displayValidationResult Display validation results messages for fields, set it to true after form sended to display user mistakes - * @param string $mode 1=Used for search filters + * @param int $mode 1=Used for search filters * @return string */ public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0, $mode = 0) @@ -6397,9 +6396,6 @@ abstract class CommonObject $val = $this->fields[$key]; } - // This is en experimental validation output TODO : remove this deactivation line - if ($conf->global->MAIN_FEATURES_LEVEL < 2 && empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { $displayValidationResult = false; } - // Validation tests and output $fieldValidationErrorMsg = ''; $validationClass = ''; From be367c589f971f81e6010d5f527c605db3d5f8a0 Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 14 Jun 2021 21:12:48 +0200 Subject: [PATCH 0029/1055] WIP - create validation method for common object --- htdocs/core/class/commonobject.class.php | 65 ++++++++++-------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9e9333b8962..2b83e324ab3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6399,7 +6399,7 @@ abstract class CommonObject // Validation tests and output $fieldValidationErrorMsg = ''; $validationClass = ''; - if($mode == 0){ + if ($mode == 0) { $fieldValidationErrorMsg = $this->getFieldError($key); if (!empty($fieldValidationErrorMsg)) { $validationClass = ' --error'; // the -- is use as class state in css : .--error can't be be defined alone it must be define with another class like .my-class.--error or input.--error @@ -7318,6 +7318,7 @@ abstract class CommonObject * clear validation message result for a field * * @param string $fieldKey Key of attribute to clear + * @return null */ public function clearFieldError($fieldKey) { @@ -7328,7 +7329,9 @@ abstract class CommonObject /** * set validation error message a field * - * @param string $fieldKey Key of attribute + * @param string $fieldKey Key of attribute + * @param string $msg the field error message + * @return null */ public function setFieldError($fieldKey, $msg = '') { @@ -7339,6 +7342,7 @@ abstract class CommonObject * get field error message * * @param string $fieldKey Key of attribute + * @return string */ public function getFieldError($fieldKey) { @@ -7360,7 +7364,7 @@ abstract class CommonObject { global $langs; - if(!class_exists('Validate')){ require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php'; } + if (!class_exists('Validate')) { require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php'; } $this->clearFieldError($fieldKey); @@ -7434,23 +7438,22 @@ abstract class CommonObject // // Required test and empty value - if($required && !$validate->isNotEmptyString($fieldValue)){ + if ($required && !$validate->isNotEmptyString($fieldValue)) { $this->setFieldError($fieldKey, $validate->error); return false; - } - elseif (!$required && !$validate->isNotEmptyString($fieldValue)) { + } elseif (!$required && !$validate->isNotEmptyString($fieldValue)) { // if no value sent and the field is not mandatory, no need to perform tests return true; } // MAX Size test - if(!empty($maxSize) && !$validate->isMaxLength($fieldValue, $maxSize)){ + if (!empty($maxSize) && !$validate->isMaxLength($fieldValue, $maxSize)) { $this->setFieldError($fieldKey, $validate->error); return false; } // MIN Size test - if(!empty($minSize) && !$validate->isMinLength($fieldValue, $minSize)){ + if (!empty($minSize) && !$validate->isMinLength($fieldValue, $minSize)) { $this->setFieldError($fieldKey, $validate->error); return false; } @@ -7465,56 +7468,42 @@ abstract class CommonObject return false; } else { return true; } } elseif ($type == 'duration') { - if(!$validate->isDuration($fieldValue)){ + if (!$validate->isDuration($fieldValue)) { $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } - } - elseif (in_array($type, array('double', 'real', 'price'))) - { + } elseif (in_array($type, array('double', 'real', 'price'))) { // is numeric - if(!$validate->isDuration($fieldValue)){ + if (!$validate->isDuration($fieldValue)) { $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } - } - elseif ($type == 'boolean') - { - if(!$validate->isBool($fieldValue)){ + } elseif ($type == 'boolean') { + if (!$validate->isBool($fieldValue)) { $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } - } - elseif ($type == 'mail') - { - if(!$validate->isEmail($fieldValue)){ + } elseif ($type == 'mail') { + if (!$validate->isEmail($fieldValue)) { $this->setFieldError($fieldKey, $validate->error); return false; } - } - elseif ($type == 'url') - { - if(!$validate->isUrl($fieldValue)){ + } elseif ($type == 'url') { + if (!$validate->isUrl($fieldValue)) { $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } - } - elseif ($type == 'phone') - { + } elseif ($type == 'phone') { if (!$validate->isPhone($fieldValue)) { $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } - } - elseif ($type == 'select' || $type == 'radio') - { + } elseif ($type == 'select' || $type == 'radio') { if (!isset($param['options'][$fieldValue])) { $this->error = $langs->trans('RequireValidValue'); return false; } else { return true; } - } - elseif ($type == 'sellist' || $type == 'chkbxlst') - { + } elseif ($type == 'sellist' || $type == 'chkbxlst') { $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); $value_arr = explode(',', $fieldValue); @@ -7525,18 +7514,16 @@ abstract class CommonObject $selectkey = $InfoFieldList[2]; } - if(!isInDb($value_arr, $InfoFieldList[0], $selectkey)){ + if (!isInDb($value_arr, $InfoFieldList[0], $selectkey)) { $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } - } - elseif ($type == 'link') - { + } elseif ($type == 'link') { $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' $InfoFieldList = explode(":", $param_list[0]); $classname = $InfoFieldList[0]; $classpath = $InfoFieldList[1]; - if(!$validate->isFetchable($fieldValue, $classname, $classpath)){ + if (!$validate->isFetchable($fieldValue, $classname, $classpath)) { $this->setFieldError($fieldKey, $validate->error); return false; } else { return true; } From 82f195dc3057f6eef8fce4b4659f9a3b8c9a0f8d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 14 Jun 2021 19:15:53 +0000 Subject: [PATCH 0030/1055] Fixing style errors. --- htdocs/core/class/validate.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index 3f94da5dbe0..2b9d98ae5e0 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -51,7 +51,7 @@ class Validate * @param DoliDB $db Database handler * @param Translate $outputLang */ - public function __construct($db,$outputLang = false) + public function __construct($db, $outputLang = false) { global $langs; @@ -121,7 +121,7 @@ class Validate */ public function isTimestamp($stamp) { - if (!is_numeric($stamp) && (int)$stamp == $stamp) { + if (!is_numeric($stamp) && (int) $stamp == $stamp) { $this->error = $this->outputLang->trans('RequireValidDate'); return false; } @@ -229,7 +229,7 @@ class Validate */ public function isBool($bool) { - if(!(is_null($bool) || is_bool($bool) || preg_match('/^[0|1]{1}$/ui', $bool))){ + if (!(is_null($bool) || is_bool($bool) || preg_match('/^[0|1]{1}$/ui', $bool))) { $this->error = $this->outputLang->trans('RequireValidBool'); return false; } @@ -258,7 +258,7 @@ class Validate return false; } - foreach ($value_arr as $val){ + foreach ($value_arr as $val) { $sql = 'SELECT ' . $col . ' FROM ' . MAIN_DB_PREFIX . $table . " WHERE " . $col ." = '" . $this->db->escape($val) . "'"; // nore quick than count(*) to check existing of a row $resql = $this->db->getRow($sql); if ($resql) { From 4d043b713cf7c44c34890037592b380f659dd99d Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 21 Jun 2021 21:54:03 +0200 Subject: [PATCH 0031/1055] WIP - create validation method for common object --- htdocs/core/class/commonobject.class.php | 22 +++++++++---------- htdocs/core/lib/functions.lib.php | 7 +++--- .../template/class/myobject.class.php | 20 ++++++++--------- htdocs/theme/eldy/global.inc.php | 8 ++++--- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2b83e324ab3..b9cc03893fd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6380,10 +6380,9 @@ abstract class CommonObject * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. * @param int $nonewbutton Force to not show the new button on field that are links to object - * @param int $mode 1=Used for search filters * @return string */ - public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0, $mode = 0) + public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0) { global $conf, $langs, $form; @@ -6399,16 +6398,13 @@ abstract class CommonObject // Validation tests and output $fieldValidationErrorMsg = ''; $validationClass = ''; - if ($mode == 0) { - $fieldValidationErrorMsg = $this->getFieldError($key); - if (!empty($fieldValidationErrorMsg)) { - $validationClass = ' --error'; // the -- is use as class state in css : .--error can't be be defined alone it must be define with another class like .my-class.--error or input.--error - } else { - $validationClass = ' --success'; // the -- is use as class state in css : .--success can't be be defined alone it must be define with another class like .my-class.--success or input.--success - } + $fieldValidationErrorMsg = $this->getFieldError($key); + if (!empty($fieldValidationErrorMsg)) { + $validationClass = ' --error'; // the -- is use as class state in css : .--error can't be be defined alone it must be define with another class like .my-class.--error or input.--error + } else { + $validationClass = ' --success'; // the -- is use as class state in css : .--success can't be be defined alone it must be define with another class like .my-class.--success or input.--success } - $out = ''; $type = ''; $isDependList=0; @@ -6972,7 +6968,7 @@ abstract class CommonObject */ // Display error message for field - if ($mode == 0 && !empty($fieldValidationErrorMsg) && function_exists('getFieldErrorIcon')) { + if (!empty($fieldValidationErrorMsg) && function_exists('getFieldErrorIcon')) { $out .= ' '.getFieldErrorIcon($fieldValidationErrorMsg); } @@ -7335,6 +7331,9 @@ abstract class CommonObject */ public function setFieldError($fieldKey, $msg = '') { + global $langs; + if (empty($msg)) { $msg = $langs->trans("UnknowError"); } + $this->error = $this->validateFieldsErrors[$fieldKey] = $msg; } @@ -7369,6 +7368,7 @@ abstract class CommonObject $this->clearFieldError($fieldKey); if (!isset($val[$fieldKey])) { + $this->setFieldError($fieldKey, $langs->trans('FieldNotFoundInObject')); return false; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5dd500a26a0..2c5d2144180 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9756,13 +9756,14 @@ function dolGetButtonTitleSeparator($moreClass = "") /** * get field error icon * - * @param string $fieldValidationErrorMsg + * @param string $fieldValidationErrorMsg message to add in tooltip + * @return string html output */ function getFieldErrorIcon($fieldValidationErrorMsg) { $out = ''; - if (!empty($fieldValidationErrorMesg)) { - $out.= ''; // role alert is used for accessibility + if (!empty($fieldValidationErrorMsg)) { + $out.= ''; // role alert is used for accessibility $out.= ''; // For accessibility icon is separated and aria-hidden $out.= ''; } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index be8736f9d49..118c60275f1 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -101,16 +101,16 @@ class MyObject extends CommonObject */ public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object', 'validate'=>1), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>'Help text', 'showoncombobox'=>1), - 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), - 'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1), - 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>'Help text', 'showoncombobox'=>1, 'validate'=>1), + 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount', 'validate'=>1), + 'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp', 'validate'=>1), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty', 'validate'=>1), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1), + 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60, 'validate'=>1), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'validate'=>1), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'validate'=>1), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501), //'date_validation ' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), @@ -120,7 +120,7 @@ class MyObject extends CommonObject 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'notnull'=>0, 'position'=>600), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled'), 'validate'=>1), ); /** diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 4468c36a7da..c14289ba4b3 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -234,10 +234,12 @@ input.button.massactionconfirmed { margin: 4px; } -input:invalid, select:invalid { +input:invalid, select:invalid, input.--error , select.--error { border-color: #ea1212; } +.field-error-icon { color: #ea1212; !important; } + /* Focus definitions must be after standard definition */ textarea:focus { border: 1px solid #aaa !important; @@ -433,7 +435,7 @@ input.pageplusone { transform: scale(-1, 1); } -select:invalid { +select:invalid, select.--error { color: gray; } input:disabled, textarea:disabled, select[disabled='disabled'] @@ -2076,7 +2078,7 @@ span.widthpictotitle.pictotitle { vertical-align: middle; margin-top: -3px } -.pictowarning, .pictoerror, .pictopreview { +.pictowarning, .picto.error, .pictopreview { padding-: 3px; } .pictowarning { From a9a7315ce1037dc732794d4376fc40879883d09f Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 11 Jul 2021 13:30:30 +0200 Subject: [PATCH 0032/1055] WIP - create validation method for common object --- .../template/class/myobject.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index eb263ee5541..f0ecc5e4987 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -102,15 +102,15 @@ class MyObject extends CommonObject public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>10), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>'Help text', 'showoncombobox'=>2), - 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), - 'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1), - 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object', 'validate'=>1), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>'Help text', 'showoncombobox'=>2, 'validate'=>1), + 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount', 'validate'=>1), + 'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp', 'validate'=>1), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty', 'validate'=>1), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1), + 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60, 'validate'=>1), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'validate'=>1), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'validate'=>1), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501), //'date_validation ' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), From dc3f960ce8d1e7900350f0393e126adfc065a1ac Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 11 Jul 2021 14:05:26 +0200 Subject: [PATCH 0033/1055] Add validate to module builder --- htdocs/core/lib/modulebuilder.lib.php | 3 +++ htdocs/langs/en_US/modulebuilder.lang | 3 ++- htdocs/modulebuilder/index.php | 12 +++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 27a4ea7a9ab..a5589679b50 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -176,6 +176,9 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = } $texttoinsert .= "),"; } + if ($val['validate']) { + $texttoinsert .= " 'validate'=>'".$val['validate']."',"; + } if ($val['comment']) { $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\""; } diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 7ba539d3bd4..5d6b51d5fe4 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -143,4 +143,5 @@ AsciiToHtmlConverter=Ascii to HTML converter AsciiToPdfConverter=Ascii to PDF converter TableNotEmptyDropCanceled=Table not empty. Drop has been canceled. ModuleBuilderNotAllowed=The module builder is available but not allowed to your user. -ImportExportProfiles=Import and export profiles \ No newline at end of file +ImportExportProfiles=Import and export profiles +ValidateModBuilderDesc=Put 1 if this field need to be validated with $this->validateField() or 0 if validation required diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index f8ca876eafc..0a05266b6ff 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1303,7 +1303,8 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && 'visible'=>GETPOST('propvisible', 'int'), 'enabled'=>GETPOST('propenabled', 'int'), 'position'=>GETPOST('propposition', 'int'), 'notnull'=>GETPOST('propnotnull', 'int'), 'index'=>GETPOST('propindex', 'int'), 'searchall'=>GETPOST('propsearchall', 'int'), 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha'), - 'css'=>GETPOST('propcss', 'aZ09'), 'cssview'=>GETPOST('propcssview', 'aZ09'), 'csslist'=>GETPOST('propcsslist', 'aZ09') + 'css'=>GETPOST('propcss', 'aZ09'), 'cssview'=>GETPOST('propcssview', 'aZ09'), 'csslist'=>GETPOST('propcsslist', 'aZ09'), + 'validate' => GETPOST('propvalidate', 'int') ); if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { @@ -2680,6 +2681,7 @@ if ($module == 'initmodule') { print ''.$langs->trans("KeyForTooltip").''; print ''.$langs->trans("ShowOnCombobox").''; //print ''.$langs->trans("Disabled").''; + print ''.$form->textwithpicto($langs->trans("Validate"), $langs->trans("ValidateModBuilderDesc")).''; print ''.$langs->trans("Comment").''; print ''; print ''; @@ -2712,6 +2714,7 @@ if ($module == 'initmodule') { print ''; print ''; //print ''; + print ''; print ''; print ''; print ''; @@ -2753,6 +2756,7 @@ if ($module == 'initmodule') { $prophelp = $propval['help']; $propshowoncombobox = $propval['showoncombobox']; //$propdisabled=$propval['disabled']; + $propvalidate = $propval['validate']; $propcomment = $propval['comment']; print ''; @@ -2823,6 +2827,9 @@ if ($module == 'initmodule') { print ''; print ''; print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -2888,6 +2895,9 @@ if ($module == 'initmodule') { /*print ''; print $propdisabled?$propdisabled:''; print '';*/ + print ''; + print $propvalidate ? dol_escape_htmltag($propvalidate) : ''; + print ''; print ''; print ''; print dol_escape_htmltag($propcomment); From 19ab5ce4201fccd6ec3a815e960abd341fd3ffeb Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 11 Jul 2021 14:13:24 +0200 Subject: [PATCH 0034/1055] Fix comments --- htdocs/core/class/validate.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index 2b9d98ae5e0..e0fae76703d 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -49,7 +49,8 @@ class Validate * Constructor * * @param DoliDB $db Database handler - * @param Translate $outputLang + * @param Translate $outputLang output lang for error + * @return null */ public function __construct($db, $outputLang = false) { @@ -68,6 +69,7 @@ class Validate /** * Use to clear errors msg or other ghost vars + * @return null */ protected function clear() { @@ -76,6 +78,9 @@ class Validate /** * Use to clear errors msg or other ghost vars + * + * @param string $errMsg your error message + * @return null */ protected function setError($errMsg) { @@ -86,7 +91,7 @@ class Validate * Check for e-mail validity * * @param string $email e-mail address to validate - * @param int $maxLength + * @param int $maxLength string max length * @return boolean Validity is ok or not */ public function isEmail($email, $maxLength = false) @@ -163,7 +168,6 @@ class Validate * Check for string not empty * * @param string $string to validate - * @param int $length max length * @return boolean Validity is ok or not */ public function isNotEmptyString($string) From 7ad1738944c6bd0aac0b1a208204fd70f1dea4b8 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 11 Jul 2021 15:58:34 +0200 Subject: [PATCH 0035/1055] Fix setError --- htdocs/core/class/validate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index e0fae76703d..1738034545d 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -84,7 +84,7 @@ class Validate */ protected function setError($errMsg) { - $this->error = ''; + $this->error = $errMsg; } /** From f68f98cbdd8b7315de16b2358bbbb7e8c7ca1ec6 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 16 Jul 2021 09:59:15 +0200 Subject: [PATCH 0036/1055] New : language support for knowledgemanagement module --- .../install/mysql/migration/13.0.0-14.0.0.sql | 1 + ...lx_knowledgemanagement_knowledgerecord.sql | 1 + .../class/knowledgerecord.class.php | 2 ++ .../knowledgerecord_card.php | 25 +++++++++++++++++++ .../knowledgerecord_list.php | 21 +++++++++++++++- 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 26a1c238c86..268fbb7562e 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -596,3 +596,4 @@ create table llx_onlinesignature pathoffile varchar(255) )ENGINE=innodb; +ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD default_lang varchar(6) diff --git a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql index 65c8add25c4..0e3d7f3b9dc 100644 --- a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql +++ b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql @@ -21,6 +21,7 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord( date_creation datetime NOT NULL, tms timestamp, last_main_doc varchar(255), + default_lang varchar(6), fk_user_creat integer NOT NULL, fk_user_modif integer, fk_user_valid integer, diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 550ef976aba..07c28eaa661 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -115,6 +115,7 @@ class KnowledgeRecord extends CommonObject //'url' => array('type'=>'varchar(255)', 'label'=>'URL', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflow200', 'help'=>'UrlForInfoPage'), 'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php', 'label'=>'GroupOfTicket', 'enabled'=>'$conf->ticket->enabled', 'position'=>512, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory'), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Valid'),), + 'default_lang' => array('type'=>'varchar(6)', 'label'=>'Language', 'enabled'=>'1', 'position'=>51, 'notnull'=>0, 'visible'=>0,), ); public $rowid; public $ref; @@ -130,6 +131,7 @@ class KnowledgeRecord extends CommonObject public $answer; public $url; public $status; + public $default_lang; // END MODULEBUILDER PROPERTIES diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index dbab7ec0528..cb9264c8428 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -28,6 +28,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php'; require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php'; @@ -156,6 +157,7 @@ if ($action == 'confirm_validate') { $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); +$formadmin = new FormAdmin($db); $title = $langs->trans("KnowledgeRecord"); $help_url = ''; @@ -185,6 +187,13 @@ if ($action == 'create') { // Common attributes include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + //Language of question/response + print ''.$langs->trans("Language").''; + print img_picto('', 'language', 'class="pictofixedwidth"'); + print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); + print ''; + print ''; + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; @@ -225,6 +234,13 @@ if (($id || $ref) && $action == 'edit') { // Common attributes include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + //Language of question/response + print ''.$langs->trans("Language").''; + print img_picto('', 'language', 'class="pictofixedwidth"'); + print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); + print ''; + print ''; + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; @@ -332,6 +348,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //unset($object->fields['fk_soc']); // Hide field already shown in banner include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + //Language of question/response + print ''.$langs->trans("Language").''; + $langs->load("languages"); + $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); + print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); + print $labellang; + print ''; + print ''; + // Other attributes. Fields from hook formObjectOptions and Extrafields. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index f54959024a2..cfaab78d4c1 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -26,6 +26,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -117,6 +118,15 @@ foreach ($object->fields as $key => $val) { 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); + }else if ($key = 'default_lang'){ + $visible = (int) dol_eval($val['visible'], 1); + $arrayfields['t.'.$key] = array( + 'label'=>$val['label'], + 'checked'=>(($visible < 0) ? 0 : 1), + 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)), + 'position'=>$val['position'], + 'help'=> isset($val['help']) ? $val['help'] : '' + ); } } // Extra fields @@ -197,6 +207,7 @@ if (empty($reshook)) { $form = new Form($db); $user_temp = new User($db); +$formadmin = new FormAdmin($db); $now = dol_now(); @@ -455,7 +466,11 @@ foreach ($object->fields as $key => $val) { } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print ''; + if($key == 'default_lang'){ + print $formadmin->select_language($search[$key], 'search_default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); + }else{ + print ''; + } } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
'; print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -592,6 +607,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } print $user_temp->getNomUrl(-1); } + }else if($key == 'lang'){ + $labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : ''); + print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"'); + print $labellang; } else { print $object->showOutputField($val, $key, $object->$key, ''); } From cad84b1e0be3e5da6b97d988710976e9cff1298d Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 16 Jul 2021 10:10:59 +0200 Subject: [PATCH 0037/1055] Update language support knowledge record --- htdocs/knowledgemanagement/knowledgerecord_card.php | 4 ++-- htdocs/knowledgemanagement/knowledgerecord_list.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index cb9264c8428..545a028e80e 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -190,7 +190,7 @@ if ($action == 'create') { //Language of question/response print ''.$langs->trans("Language").''; print img_picto('', 'language', 'class="pictofixedwidth"'); - print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); + print $formadmin->select_language('', 'default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); print ''; print ''; @@ -237,7 +237,7 @@ if (($id || $ref) && $action == 'edit') { //Language of question/response print ''.$langs->trans("Language").''; print img_picto('', 'language', 'class="pictofixedwidth"'); - print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); + print $formadmin->select_language($object->default_lang, 'default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); print ''; print ''; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index cfaab78d4c1..4e82253027b 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -607,9 +607,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } print $user_temp->getNomUrl(-1); } - }else if($key == 'lang'){ - $labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : ''); - print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"'); + }else if($key == 'default_lang'){ + $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); + print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); print $labellang; } else { print $object->showOutputField($val, $key, $object->$key, ''); From 2fd520cadce2c66ecd1d3ce341a27d9dd98ed14b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 16 Jul 2021 08:15:36 +0000 Subject: [PATCH 0038/1055] Fixing style errors. --- htdocs/knowledgemanagement/knowledgerecord_list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 4e82253027b..4833a36d1f1 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -118,7 +118,7 @@ foreach ($object->fields as $key => $val) { 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); - }else if ($key = 'default_lang'){ + } elseif ($key = 'default_lang') { $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], @@ -466,9 +466,9 @@ foreach ($object->fields as $key => $val) { } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - if($key == 'default_lang'){ + if ($key == 'default_lang') { print $formadmin->select_language($search[$key], 'search_default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); - }else{ + } else { print ''; } } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { @@ -607,7 +607,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } print $user_temp->getNomUrl(-1); } - }else if($key == 'default_lang'){ + } elseif ($key == 'default_lang') { $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); print $labellang; From 1fb99a3185ddd17c2f9ab178290a0c6788c7b0da Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 16 Jul 2021 15:47:17 +0200 Subject: [PATCH 0039/1055] Update to match eldy changes --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- .../llx_knowledgemanagement_knowledgerecord.sql | 2 +- .../class/knowledgerecord.class.php | 4 ++-- htdocs/knowledgemanagement/knowledgerecord_card.php | 13 +++++++++---- htdocs/knowledgemanagement/knowledgerecord_list.php | 12 ++++++------ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 268fbb7562e..a275105cb31 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -596,4 +596,4 @@ create table llx_onlinesignature pathoffile varchar(255) )ENGINE=innodb; -ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD default_lang varchar(6) +ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD lang varchar(6); diff --git a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql index 0e3d7f3b9dc..5bb4a0ea648 100644 --- a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql +++ b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql @@ -21,7 +21,7 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord( date_creation datetime NOT NULL, tms timestamp, last_main_doc varchar(255), - default_lang varchar(6), + lang varchar(6), fk_user_creat integer NOT NULL, fk_user_modif integer, fk_user_valid integer, diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 07c28eaa661..af752cfea7f 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -115,7 +115,7 @@ class KnowledgeRecord extends CommonObject //'url' => array('type'=>'varchar(255)', 'label'=>'URL', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflow200', 'help'=>'UrlForInfoPage'), 'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php', 'label'=>'GroupOfTicket', 'enabled'=>'$conf->ticket->enabled', 'position'=>512, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory'), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Valid'),), - 'default_lang' => array('type'=>'varchar(6)', 'label'=>'Language', 'enabled'=>'1', 'position'=>51, 'notnull'=>0, 'visible'=>0,), + 'lang' => array('type'=>'varchar(6)', 'label'=>'Language', 'enabled'=>'1', 'position'=>51, 'notnull'=>0, 'visible'=>0,), ); public $rowid; public $ref; @@ -131,7 +131,7 @@ class KnowledgeRecord extends CommonObject public $answer; public $url; public $status; - public $default_lang; + public $lang; // END MODULEBUILDER PROPERTIES diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index 545a028e80e..96aef48dde2 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -118,6 +118,11 @@ if (empty($reshook)) { $triggermodname = 'KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_MODIFY'; // Name of trigger action code to execute when we modify record + // Upadate / add for lang + if (($action == 'update' || $action == 'add') && !empty($permissiontoadd)) { + $object->lang = GETPOSTISSET('langkm', 'aZ09')?GETPOST('langkm', 'aZ09'):$object->lang; + } + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -190,7 +195,7 @@ if ($action == 'create') { //Language of question/response print ''.$langs->trans("Language").''; print img_picto('', 'language', 'class="pictofixedwidth"'); - print $formadmin->select_language('', 'default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); + print $formadmin->select_language('', 'langkm', 0, null, 1, 0, 0, 'minwidth300', 2); print ''; print ''; @@ -237,7 +242,7 @@ if (($id || $ref) && $action == 'edit') { //Language of question/response print ''.$langs->trans("Language").''; print img_picto('', 'language', 'class="pictofixedwidth"'); - print $formadmin->select_language($object->default_lang, 'default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); + print $formadmin->select_language($object->lang, 'langkm', 0, null, 1, 0, 0, 'minwidth300', 2); print ''; print ''; @@ -351,8 +356,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //Language of question/response print ''.$langs->trans("Language").''; $langs->load("languages"); - $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); - print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); + $labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : ''); + print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"'); print $labellang; print ''; print ''; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 4833a36d1f1..4c7a8948cf4 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -118,7 +118,7 @@ foreach ($object->fields as $key => $val) { 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); - } elseif ($key = 'default_lang') { + } elseif ($key = 'lang') { $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], @@ -466,8 +466,8 @@ foreach ($object->fields as $key => $val) { } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - if ($key == 'default_lang') { - print $formadmin->select_language($search[$key], 'search_default_lang', 0, null, 1, 0, 0, 'minwidth300', 2); + if ($key == 'lang') { + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth300', 2); } else { print ''; } @@ -607,9 +607,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } print $user_temp->getNomUrl(-1); } - } elseif ($key == 'default_lang') { - $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); - print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); + } elseif ($key == 'lang') { + $labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : ''); + print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"'); print $labellang; } else { print $object->showOutputField($val, $key, $object->$key, ''); From 3440994e8ef812a097cafb96e6948cfaa86348f0 Mon Sep 17 00:00:00 2001 From: trekmorris <78349579+trekmorris@users.noreply.github.com> Date: Fri, 16 Jul 2021 23:40:18 +0800 Subject: [PATCH 0040/1055] Update opensurvey.lang Update the translation manually . This file is not auto sync from transifex . --- htdocs/langs/zh_TW/opensurvey.lang | 120 ++++++++++++++--------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/htdocs/langs/zh_TW/opensurvey.lang b/htdocs/langs/zh_TW/opensurvey.lang index 51a4283c721..ff927bfc863 100644 --- a/htdocs/langs/zh_TW/opensurvey.lang +++ b/htdocs/langs/zh_TW/opensurvey.lang @@ -1,61 +1,61 @@ # Dolibarr language file - Source file is en_US - opensurvey -Survey=Poll -Surveys=Polls -OrganizeYourMeetingEasily=Organize your meetings and polls easily. First select the type of poll... -NewSurvey=New poll -OpenSurveyArea=Polls area -AddACommentForPoll=You can add a comment into poll... -AddComment=Add comment -CreatePoll=Create poll -PollTitle=Poll title -ToReceiveEMailForEachVote=Receive an email for each vote -TypeDate=Type date -TypeClassic=Type standard -OpenSurveyStep2=Select your dates among the free days (grey). The selected days are green. You can unselect a day previously selected by clicking again on it -RemoveAllDays=Remove all days -CopyHoursOfFirstDay=Copy hours of first day -RemoveAllHours=Remove all hours -SelectedDays=Selected days -TheBestChoice=The best choice currently is -TheBestChoices=The best choices currently are -with=with -OpenSurveyHowTo=If you agree to vote in this poll, you have to give your name, choose the values that fit best for you and validate with the plus button at the end of the line. -CommentsOfVoters=Comments of voters -ConfirmRemovalOfPoll=Are you sure you want to remove this poll (and all votes) -RemovePoll=Remove poll -UrlForSurvey=URL to communicate to get a direct access to poll -PollOnChoice=You are creating a poll to make a multi-choice for a poll. First enter all possible choices for your poll: -CreateSurveyDate=Create a date poll -CreateSurveyStandard=Create a standard poll -CheckBox=Simple checkbox -YesNoList=List (empty/yes/no) -PourContreList=List (empty/for/against) -AddNewColumn=Add new column -TitleChoice=Choice label -ExportSpreadsheet=Export result spreadsheet -ExpireDate=極限日期 -NbOfSurveys=Number of polls -NbOfVoters=No. of voters -SurveyResults=Results -PollAdminDesc=You are allowed to change all vote lines of this poll with button "Edit". You can, as well, remove a column or a line with %s. You can also add a new column with %s. -5MoreChoices=5 more choices -Against=Against -YouAreInivitedToVote=You are invited to vote for this poll -VoteNameAlreadyExists=This name was already used for this poll -AddADate=Add a date -AddStartHour=Add start hour -AddEndHour=Add end hour -votes=vote(s) -NoCommentYet=No comments have been posted for this poll yet -CanComment=Voters can comment in the poll -CanSeeOthersVote=Voters can see other people's vote -SelectDayDesc=For each selected day, you can choose, or not, meeting hours in the following format:
- empty,
- "8h", "8H" or "8:00" to give a meeting's start hour,
- "8-11", "8h-11h", "8H-11H" or "8:00-11:00" to give a meeting's start and end hour,
- "8h15-11h15", "8H15-11H15" or "8:15-11:15" for the same thing but with minutes. -BackToCurrentMonth=Back to current month -ErrorOpenSurveyFillFirstSection=You haven't filled the first section of the poll creation -ErrorOpenSurveyOneChoice=Enter at least one choice -ErrorInsertingComment=There was an error while inserting your comment -MoreChoices=Enter more choices for the voters -SurveyExpiredInfo=The poll has been closed or voting delay has expired. -EmailSomeoneVoted=%s has filled a line.\nYou can find your poll at the link: \n%s -ShowSurvey=Show survey -UserMustBeSameThanUserUsedToVote=You must have voted and use the same user name that the one used to vote, to post a comment +Survey=調查 +Surveys=調查 +OrganizeYourMeetingEasily=輕鬆組織會議和調查。首先選擇調查的類型... +NewSurvey=新調查 +OpenSurveyArea=調查區 +AddACommentForPoll=您可以在調查中加入評論... +AddComment=增加評論 +CreatePoll=建立調查 +PollTitle=調查標題 +ToReceiveEMailForEachVote=每次投票都會收到一封電子郵件 +TypeDate=日期類型 +TypeClassic=標準類型 +OpenSurveyStep2=在空閒日中選擇日期(灰色)。所選的日期為綠色。您可以通過再次點擊來取消先前選擇的日期 +RemoveAllDays=全部刪除 +CopyHoursOfFirstDay=複制第一天的時間 +RemoveAllHours=刪除所有時間 +SelectedDays=已選擇的日子 +TheBestChoice=目前最好的選擇是 +TheBestChoices=目前最好的選擇是 +with=與 +OpenSurveyHowTo=如果您同意在此次調查中投票,則必須給出自己的名字,選擇最適合您的值,並使用該行末尾的加號按鈕進行驗證。 +CommentsOfVoters=投票人的評論 +ConfirmRemovalOfPoll=您確定要刪除此調查(以及所有投票)嗎? +RemovePoll=刪除調查 +UrlForSurvey=調查的直接網址 +PollOnChoice=您正在建立多項選擇的調查。首先為您的調查輸入所有可能的選擇: +CreateSurveyDate=建立日期調查 +CreateSurveyStandard=建立標準調查 +CheckBox=簡易勾選框 +YesNoList=清單(空/是/否) +PourContreList=清單(空/支持/反對) +AddNewColumn=增加新欄位 +TitleChoice=選擇標籤 +ExportSpreadsheet=匯出結果表格 +ExpireDate=調查截止日 +NbOfSurveys=投票次數 +NbOfVoters=投票人數 +SurveyResults=結果 +PollAdminDesc=您可以使用“編輯”按鈕更改此民意調查的所有投票行。您也可以使用%s刪除列或行。您也可以使用%s增加新列。 +5MoreChoices=再多5個選項 +Against=反對 +YouAreInivitedToVote=您被邀請參加此項調查 +VoteNameAlreadyExists=此名稱已用於此調查 +AddADate=增加日期 +AddStartHour=增加開始時間 +AddEndHour=增加結束時間 +votes=投票 +NoCommentYet=尚未有此調查的評論 +CanComment=投票者可以在調查中發表評論 +CanSeeOthersVote=投票者可以看到其他人的投票 +SelectDayDesc=對於每個選定的日期,您可以依照以下格式選擇是否選擇開會時間:
-空的
-“ 8h”,“ 8H”或“ 8:00”指定會議的開始時間,
-“ 8-11”,“ 8h-11h”,“ 8H-11H”或“ 8:00-11:00”給出會議的開始和結束時間,
-同樣的用“ 8h15-11h15”,“ 8H15-11H15”或“ 8:15-11:15”表示,但要加上分鐘。 +BackToCurrentMonth=回到目前月份 +ErrorOpenSurveyFillFirstSection=您尚未填寫建立調查的第一部分 +ErrorOpenSurveyOneChoice=輸入至少一個選項 +ErrorInsertingComment=插入您的評論時出錯 +MoreChoices=為投票者輸入更多選項 +SurveyExpiredInfo=投票已關閉或投票已到期。 +EmailSomeoneVoted=%s已填滿一行。\n您可以在以下連結找到您的調查:\n%s +ShowSurvey=顯示調查 +UserMustBeSameThanUserUsedToVote=您必須已投票並使用與投票時相同的用戶名來發表評論 From 4eeaac5ee77c5a1e8d970891afe45360fbc2d211 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 19 Jul 2021 09:45:47 +0200 Subject: [PATCH 0041/1055] warning error on PHP 8 --- htdocs/societe/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index f5a4392a0c0..2e9e0fcb3f3 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2006 Rodolphe Quiedeville * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2014 Charles-Fr Benke + * Copyright (C) 2014-2021 Charlene Benke * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2019 Nicolas ZABOURI @@ -185,6 +185,7 @@ $thirdpartygraph .= ''; $thirdpartygraph .= ''; $thirdpartygraph .= '
'; +$thirdpartycateggraph = ""; if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $elementtype = 'societe'; @@ -283,6 +284,7 @@ $sql .= $db->order("s.tms", "DESC"); $sql .= $db->plimit($max, 0); //print $sql; +$lastmodified=""; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); From 1a23cfc6f982d8f39e1bb58c1bcbbd90bc5172eb Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 19 Jul 2021 10:01:11 +0200 Subject: [PATCH 0042/1055] Update list.php --- htdocs/compta/bank/list.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index c1b446a9dd0..657b1cb8577 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -67,6 +67,8 @@ $socid = 0; if ($user->socid) { $socid = $user->socid; } + +$allowed = 0; if (!empty($user->rights->accounting->chartofaccount)) { $allowed = 1; // Dictionary with list of banks accounting account allowed to manager of chart account } @@ -191,7 +193,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; } @@ -333,12 +335,12 @@ $objecttmp = new Account($db); $trackid = 'bank'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - } - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; -} +//if ($sall) { +// foreach ($fieldstosearchall as $key => $val) { +// $fieldstosearchall[$key] = $langs->trans($val); +// } +// print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; +//} $moreforfilter = ''; From 29bdbe02f284c3fa80a1f82fde026ed0e53111cd Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 19 Jul 2021 10:21:18 +0200 Subject: [PATCH 0043/1055] Update index.php --- htdocs/comm/action/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index c87af9558e8..9fac243ac86 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -525,6 +525,7 @@ $viewmode .= ''; // To add a space before t $newcardbutton = ''; +$newparam = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { $tmpforcreatebutton = dol_getdate(dol_now(), true); From 49a74c2b3b23845107bd6388dd5e46d42be97ade Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 19 Jul 2021 10:42:11 +0200 Subject: [PATCH 0044/1055] Update index.php --- htdocs/ticket/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index c3027e5044b..756f8e10879 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -50,6 +50,7 @@ $socid = 0; if ($user->socid) { $socid = $user->socid; } +$userid = $user->id; // Security check $result = restrictedArea($user, 'ticket', 0, '', '', '', ''); @@ -96,7 +97,7 @@ if (in_array('DOLUSERCOOKIE_ticket_by_status', $autosetarray)) { $endyear = GETPOST($param_year, 'int'); $shownb = GETPOST($param_shownb, 'alpha'); $showtot = GETPOST($param_showtot, 'alpha'); -} else { +} elseif (!empty($_COOKIE['DOLUSERCOOKIE_ticket_by_status'])) { $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_ticket_by_status'], true); $endyear = $tmparray['year']; $shownb = $tmparray['shownb']; @@ -104,6 +105,7 @@ if (in_array('DOLUSERCOOKIE_ticket_by_status', $autosetarray)) { } if (empty($shownb) && empty($showtot)) { $showtot = 1; + $shownb = 0; } $nowarray = dol_getdate(dol_now(), true); From 09954a304767bc8b23f240bd8d7e3b120585cb35 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 19 Jul 2021 11:01:06 +0200 Subject: [PATCH 0045/1055] Update html.formcompany.class.php --- htdocs/core/class/html.formcompany.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index bb99b2a32e9..57bedd2807a 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -1077,7 +1077,7 @@ class FormCompany extends Form $out .= ''; $out .= ''; } else { - if ($selected) { + if ($selected > 0) { $arr = $this->typent_array(0); $typent = $arr[$selected]; $out .= $typent; From acdac32845cdfe7a5ca1026cac46024e588bdee4 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 19 Jul 2021 13:46:50 +0200 Subject: [PATCH 0046/1055] FIX : "disabled" field missing on definition --- htdocs/core/modules/DolibarrModules.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 3b7cc0d1184..f5fbdd9ac34 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -266,6 +266,11 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it */ public $always_enabled; + /** + * @var bool Module is disabled + */ + public $disabled; + /** * @var int Module is enabled globally (Multicompany support) */ From 97287af9879675b3b4580c4ac3cc005e020ad06f Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 19 Jul 2021 14:03:03 +0200 Subject: [PATCH 0047/1055] add field to object product, add sql --- .../install/mysql/migration/14.0.0-15.0.0.sql | 1 + htdocs/install/mysql/tables/llx_product.sql | 4 +++- htdocs/langs/fr_FR/products.lang | 1 + htdocs/product/card.php | 23 ++++++++++++++++++- htdocs/product/class/product.class.php | 15 ++++++++++-- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 95de2ab7ba6..1a38da5237f 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -36,4 +36,5 @@ -- v15 +ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0 AFTER fk_project; diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 4aad3393137..09b71c9c5c4 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -103,5 +103,7 @@ create table llx_product desiredstock float DEFAULT 0, fk_unit integer DEFAULT NULL, price_autogen tinyint DEFAULT 0, - fk_project integer DEFAULT NULL -- Used when product was generated by a project or is specifif to a project + fk_project integer DEFAULT NULL, -- Used when product was generated by a project or is specifif to a project + mandatory_period tinyint DEFAULT 0 -- is used to signal to the user that the start and end dates are mandatory for this type of product the fk_product_type == 1 (service) (non-blocking action) + )ENGINE=innodb; diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index dc308c95af2..af80e0c67a2 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -399,3 +399,4 @@ ProductSupplierExtraFields=Attributs supplémentaires (Prix fournisseur) DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison PMPValue=Prix moyen pondéré (PMP) PMPValueShort=PMP +mandatoryperiod=Période obligatoires diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 2472c764d7e..55589a967d4 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -551,7 +551,7 @@ if (empty($reshook)) { $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); - + $checkmandatory = GETPOST('mandatoryperiod', 'alpha'); if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; } else { @@ -582,6 +582,11 @@ if (empty($reshook)) { } else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; } + if ($object->isService()){ + $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ; + } + + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -1981,6 +1986,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("ProductAccountancyBuyExportCode").''; print ''; print ''; + + if ($object->isService()) { + // Mandatory period + print ''.$langs->trans("mandatoryperiod").''; + print 'mandatory_period == 1 ? ' checked="checked"' : '').' /> '; + print ''; + } + + + } } print ''; @@ -2259,6 +2274,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; print ''; + + // Mandatory period + + print ''.$langs->trans("mandatoryperiod").''; + print 'mandatory_period == 1 ? ' checked="checked"' : '').' disabled/> '; + print ''; } else { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { // Nature diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 28bf0288c7b..5222bc1a01c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -426,6 +426,13 @@ class Product extends CommonObject public $is_object_used; + /** + * + * + * + */ + public $mandatory_period; + /** * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" @@ -476,6 +483,8 @@ class Product extends CommonObject 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), + 'mandatory_period' =>array('type'=>'integer', 'label'=>'mandatory_period', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000), + ); /** @@ -1141,7 +1150,7 @@ class Product extends CommonObject $sql .= ", price_autogen = ".(!$this->price_autogen ? 0 : 1); $sql .= ", fk_price_expression = ".($this->fk_price_expression != 0 ? (int) $this->fk_price_expression : 'NULL'); $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); - + $sql .= ", mandatory_period = ".($this->mandatory_period ); // stock field is not here because it is a denormalized value from product_stock. $sql .= " WHERE rowid = ".((int) $id); @@ -2244,7 +2253,7 @@ class Product extends CommonObject $sql .= " p.price_min, p.price_min_ttc, p.price_base_type, p.cost_price, p.default_vat_code, p.tva_tx, p.recuperableonly as tva_npr, p.localtax1_tx, p.localtax2_tx, p.localtax1_type, p.localtax2_type, p.tosell,"; $sql .= " p.tobuy, p.fk_product_type, p.duration, p.fk_default_warehouse, p.seuil_stock_alerte, p.canvas, p.net_measure, p.net_measure_units, p.weight, p.weight_units,"; $sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,"; - $sql .= " p.surface, p.surface_units, p.volume, p.volume_units, p.barcode, p.fk_barcode_type, p.finished,"; + $sql .= " p.surface, p.surface_units, p.volume, p.volume_units, p.barcode, p.fk_barcode_type, p.finished,p.mandatory_period,"; if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; } else { @@ -2416,6 +2425,8 @@ class Product extends CommonObject $this->price_autogen = $obj->price_autogen; $this->model_pdf = $obj->model_pdf; + $this->mandatory_period = $obj->mandatory_period; + $this->db->free($resql); // fetch optionals attributes and labels From 98a2c35ab51cfe42ad6aed43fd1976026fd7f82c Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 19 Jul 2021 17:51:06 +0200 Subject: [PATCH 0048/1055] PHP V8 warning error, use of not declared array --- htdocs/core/modules/DolibarrModules.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 3b7cc0d1184..2d5b62ae3f9 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1263,7 +1263,11 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it if (is_array($this->boxes)) { foreach ($this->boxes as $key => $value) { //$titre = $this->boxes[$key][0]; - $file = $this->boxes[$key]['file']; + if (empty($this->boxes[$key]['file'])) { + $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility + } else + $file = $this->boxes[$key]['file']; + //$note = $this->boxes[$key][2]; // TODO If the box is also included by another module and the other module is still on, we should not remove it. @@ -1276,10 +1280,6 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } } - if (empty($file)) { - $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility - } - if ($this->db->type == 'sqlite3') { // sqlite doesn't support "USING" syntax. // TODO: remove this dependency. From e11afb7da05cb0ad90c9169e5c42996d61f4d2f9 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 20 Jul 2021 11:23:35 +0200 Subject: [PATCH 0049/1055] add color on date dield and warning on line --- htdocs/core/tpl/objectline_create.tpl.php | 23 +++++++++++++++++++++-- htdocs/core/tpl/objectline_edit.tpl.php | 18 ++++++++++++++++++ htdocs/core/tpl/objectline_view.tpl.php | 15 +++++++++++++++ htdocs/langs/fr_FR/products.lang | 1 + htdocs/product/ajax/products.php | 3 ++- htdocs/product/class/product.class.php | 10 ++++++++++ 6 files changed, 67 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f978a436354..2a96880e04a 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -678,10 +678,10 @@ if (!empty($usemargins) && $user->rights->margins->creer) { /* When changing predefined product, we reload list of supplier prices required for margin combo */ $("#idprod, #idprodfournprice").change(function() { - console.log("Call method change() after change on #idprod or #idprodfournprice (senderissupplier=). this.val = "+$(this).val()); + console.log("Call method change() 1 after change on #idprod or #idprodfournprice (senderissupplier=). this.val = "+$(this).val()); setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva - + setColorToDateSelector($(this).val()); jQuery('#trlinefordates').show(); rights->margins->creer) { { 'id': $(this).val(), 'socid': socid; ?> }, function(data) { console.log("Load unit price end, we got value "+data.price_ht); + + + console.log(data); + console.log(jQuery("#date_start").val()); + console.log(jQuery("#date_end").val()); + // service and we setted mandatory_period to true + if (data.mandatory_period == 1 && data.type == 1 ) { + console.log("we are good to color date input"); + jQuery("#date_start").css("background-color","#f2cf87"); + jQuery("#date_end").css("background-color","#f2cf87"); + }else{ + jQuery("#date_start").css("background-color","#FFF"); + jQuery("#date_end").css("background-color","#FFF"); + } + jQuery("#price_ht").val(data.price_ht); global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) { @@ -984,6 +999,10 @@ if (!empty($usemargins) && $user->rights->margins->creer) { jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); jQuery("#fournprice_predef").hide(); } + function setColorToDateSelector(val){ + console.log("from function "+val); + } + function setforpredef() { console.log("Call setforpredef. We hide some fields and show dates"); jQuery("#select_type").val(-1); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 9094daaa2d1..ea6133f8684 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -333,9 +333,19 @@ $coldisplay++; if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) { print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");'; } + + if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) { print 'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.'");'; } + + $res = $line->fetch_product(); + // on doit fetch le product là !!! pour connaître le type + if ($res > 0 ){ + if ($line->product->isMandatoryPeriod() && $line->product->isService()) { + print 'jQuery("#date_start").css("background-color","#f2cf87");'; + } + } } if (!$line->date_end) { if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) { @@ -344,6 +354,14 @@ $coldisplay++; if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) { print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");'; } + + $res = $line->fetch_product(); + // on doit fetch le product là !!! pour connaître le type + if ($res > 0 ){ + if ($line->product->isMandatoryperiod() && $line->product->isService()) { + print 'jQuery("#date_end").css("background-color","#f2cf87");'; + } + } } print '' ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 3e8ef7ea411..50575c19dc2 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -180,7 +180,22 @@ if (($line->info_bits & 2) == 2) { } else { if ($line->date_start || $line->date_end) { print '
'.get_date_range($line->date_start, $line->date_end, $format).'
'; + } + if ((!$line->date_start && !$line->date_end) || (!$line->date_start || !$line->date_end) ){ // pas de date + // show warning under line + // we need to fetch product associated to line for some test + $res = $line->fetch_product(); + if ($res > 0 ){ + if ($line->product->isService() && $line->product->isMandatoryPeriod()){ + print '
'.$langs->trans("mandatoryPeriodNeedTobeSet").'
'; + } + } + } + + + + //print get_date_range($line->date_start, $line->date_end, $format); } diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index af80e0c67a2..7e70e5ca186 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -400,3 +400,4 @@ DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison PMPValue=Prix moyen pondéré (PMP) PMPValueShort=PMP mandatoryperiod=Période obligatoires +mandatoryPeriodNeedTobeSet=Attention périodes non saisies et obligatoires diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 77acafbbd55..9ba8d9cec09 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -91,7 +91,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { $outtype = $object->type; $outqty = 1; $outdiscount = 0; - + $mandatory_period = $object->mandatory_period; $found = false; $price_level = 1; @@ -203,6 +203,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { 'tva_tx' => $outtva_tx, 'qty' => $outqty, 'discount' => $outdiscount, + 'mandatory_period' => $mandatory_period, 'array_options'=>$object->array_options); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5222bc1a01c..1c27671ba00 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5642,6 +5642,16 @@ class Product extends CommonObject return ($this->type == Product::TYPE_SERVICE ? true : false); } + + /** + * Return if object have a constraint on mandatory_period + * + * @return boolean True if mandatory_period setted to 1 + */ + public function isMandatoryPeriod() + { + return ($this->mandatory_period == 1 ? true : false); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get a barcode from the module to generate barcode values. From 367e83923909802529e670723e343e613cb8b942 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 20 Jul 2021 13:56:30 +0200 Subject: [PATCH 0050/1055] change class css and behavior js --- htdocs/core/tpl/objectline_create.tpl.php | 27 +++++++++++-------- htdocs/core/tpl/objectline_edit.tpl.php | 14 +++++++--- htdocs/core/tpl/objectline_view.tpl.php | 4 +-- .../install/mysql/migration/14.0.0-15.0.0.sql | 2 +- htdocs/langs/fr_FR/products.lang | 2 +- htdocs/theme/eldy/global.inc.php | 2 +- 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 2a96880e04a..ecd8a47fc86 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -674,6 +674,15 @@ if (!empty($usemargins) && $user->rights->margins->creer) { + $("#date_start, #date_end").focusout(function() + { + + if ( $(this).val() == '' && !$(this).hasClass("error") ) { + $(this).addClass('error'); + }else{ + $(this).removeClass('error'); + } + }); /* When changing predefined product, we reload list of supplier prices required for margin combo */ $("#idprod, #idprodfournprice").change(function() @@ -681,7 +690,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) { console.log("Call method change() 1 after change on #idprod or #idprodfournprice (senderissupplier=). this.val = "+$(this).val()); setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva - setColorToDateSelector($(this).val()); jQuery('#trlinefordates').show(); rights->margins->creer) { console.log("Load unit price end, we got value "+data.price_ht); - console.log(data); - console.log(jQuery("#date_start").val()); - console.log(jQuery("#date_end").val()); + // service and we setted mandatory_period to true if (data.mandatory_period == 1 && data.type == 1 ) { console.log("we are good to color date input"); - jQuery("#date_start").css("background-color","#f2cf87"); - jQuery("#date_end").css("background-color","#f2cf87"); + + jQuery("#date_start").addClass("error"); + jQuery("#date_end").addClass("error"); }else{ - jQuery("#date_start").css("background-color","#FFF"); - jQuery("#date_end").css("background-color","#FFF"); + jQuery("#date_start").removeClass("error"); + jQuery("#date_end").removeClass("error"); } jQuery("#price_ht").val(data.price_ht); @@ -733,6 +740,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?> if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") { + var editor = CKEDITOR.instances['dp_desc']; var editor = CKEDITOR.instances['dp_desc']; if (editor) { editor.setData(proddesc); @@ -999,9 +1007,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) { jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); jQuery("#fournprice_predef").hide(); } - function setColorToDateSelector(val){ - console.log("from function "+val); - } function setforpredef() { console.log("Call setforpredef. We hide some fields and show dates"); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index ea6133f8684..8ef08b60660 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -340,10 +340,9 @@ $coldisplay++; } $res = $line->fetch_product(); - // on doit fetch le product là !!! pour connaître le type if ($res > 0 ){ if ($line->product->isMandatoryPeriod() && $line->product->isService()) { - print 'jQuery("#date_start").css("background-color","#f2cf87");'; + print 'jQuery("#date_start").addClass("error");'; } } } @@ -359,7 +358,7 @@ $coldisplay++; // on doit fetch le product là !!! pour connaître le type if ($res > 0 ){ if ($line->product->isMandatoryperiod() && $line->product->isService()) { - print 'jQuery("#date_end").css("background-color","#f2cf87");'; + print 'jQuery("#date_end").addClass("error");'; } } } @@ -469,6 +468,15 @@ jQuery(document).ready(function() } }); + $("#date_start, #date_end").focusout(function() + { + + if ( $(this).val() == '' && !$(this).hasClass("error") ) { + $(this).addClass('error'); + }else{ + $(this).removeClass('error'); + } + }); margin->enabled)) { ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 50575c19dc2..42453df6e31 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -182,13 +182,13 @@ if (($line->info_bits & 2) == 2) { print '
'.get_date_range($line->date_start, $line->date_end, $format).'
'; } - if ((!$line->date_start && !$line->date_end) || (!$line->date_start || !$line->date_end) ){ // pas de date + if (!$line->date_start || !$line->date_end){ // show warning under line // we need to fetch product associated to line for some test $res = $line->fetch_product(); if ($res > 0 ){ if ($line->product->isService() && $line->product->isMandatoryPeriod()){ - print '
'.$langs->trans("mandatoryPeriodNeedTobeSet").'
'; + print '
'.$langs->trans("mandatoryPeriodNeedTobeSet").'
'; } } } diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 1a38da5237f..b2f690c1d89 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -36,5 +36,5 @@ -- v15 -ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0 AFTER fk_project; +ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0; diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 7e70e5ca186..168bdf07fcf 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -399,5 +399,5 @@ ProductSupplierExtraFields=Attributs supplémentaires (Prix fournisseur) DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison PMPValue=Prix moyen pondéré (PMP) PMPValueShort=PMP -mandatoryperiod=Période obligatoires +mandatoryperiod=Périodes obligatoires mandatoryPeriodNeedTobeSet=Attention périodes non saisies et obligatoires diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index ab9ab624801..2ab774f70eb 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -234,7 +234,7 @@ input.button.massactionconfirmed { margin: 4px; } -input:invalid, select:invalid { +input:invalid, select:invalid , input.error{ border-color: #ea1212; } From 1237c5ba5544e4f570d30fb001616a48c3d69324 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 20 Jul 2021 14:46:56 +0200 Subject: [PATCH 0051/1055] add msg to formconfirm on propal invoice and commande --- htdocs/comm/propal/card.php | 16 ++++++++++++++++ htdocs/commande/card.php | 15 +++++++++++++++ htdocs/compta/facture/card.php | 15 +++++++++++++++ htdocs/langs/en_US/products.lang | 3 +++ htdocs/langs/fr_FR/products.lang | 1 + 5 files changed, 50 insertions(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3c0d8dd9a28..1c83e7ed962 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1958,8 +1958,24 @@ if ($action == 'create') { $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('PROPAL_VALIDATE', $object->socid, $object); + } + // mandatoryPeriod + $nbMandated = 0; + foreach ($object->lines as $line){ + $res = $line->fetch_product(); + if ($res > 0 ){ + if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )){ + $nbMandated++; + break; + } + } + } + if ($nbMandated > 0 ) $text .= '
'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'
'; + + + if (!$error) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1); } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 8420a5e7f87..f6ecf217a0d 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1910,6 +1910,21 @@ if ($action == 'create' && $usercancreate) { ); } + // mandatoryPeriod + $nbMandated = 0; + foreach ($object->lines as $line){ + $res = $line->fetch_product(); + if ($res > 0 ){ + if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )){ + $nbMandated++; + break; + } + } + } + if ($nbMandated > 0 ) $text .= '
'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'
'; + + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 699a10d3ef5..60f025efbae 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4001,6 +4001,21 @@ if ($action == 'create') { if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->total_ttc < 0) { // Can happen only if $conf->global->FACTURE_ENABLE_NEGATIVE is on $text .= '
'.img_warning().' '.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive"); } + + // mandatoryPeriod + $nbMandated = 0; + foreach ($object->lines as $line){ + $res = $line->fetch_product(); + if ($res > 0 ){ + if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )){ + $nbMandated++; + break; + } + } + } + if ($nbMandated > 0 ) $text .= '
'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'
'; + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, (($object->type != Facture::TYPE_CREDIT_NOTE && $object->total_ttc < 0) ? "no" : "yes"), 2); } diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index bf34efe3f79..5a24c2d56f8 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -399,3 +399,6 @@ ProductSupplierExtraFields=Additional Attributes (Supplier Prices) DeleteLinkedProduct=Delete the child product linked to the combination PMPValue=Weighted average price PMPValueShort=WAP +mandatoryperiod=Mandatory periods +mandatoryPeriodNeedTobeSet=Attention periods not entered and mandatory +mandatoryPeriodNeedTobeSetMsgValidate=A service requires a start and end period diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 168bdf07fcf..aa8b5a5c462 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -401,3 +401,4 @@ PMPValue=Prix moyen pondéré (PMP) PMPValueShort=PMP mandatoryperiod=Périodes obligatoires mandatoryPeriodNeedTobeSet=Attention périodes non saisies et obligatoires +mandatoryPeriodNeedTobeSetMsgValidate=Un service nécessite une période de début et de fin From dc90a62d906dde5239f88f86eb13fff118a927d8 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 20 Jul 2021 15:18:14 +0200 Subject: [PATCH 0052/1055] add tooltips helper on product card --- htdocs/langs/en_US/products.lang | 1 + htdocs/langs/fr_FR/products.lang | 1 + htdocs/product/card.php | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 5a24c2d56f8..2531dd919d9 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -402,3 +402,4 @@ PMPValueShort=WAP mandatoryperiod=Mandatory periods mandatoryPeriodNeedTobeSet=Attention periods not entered and mandatory mandatoryPeriodNeedTobeSetMsgValidate=A service requires a start and end period +mandatoryHelper=Message to the user on the need to enter a start date and an end date on a service when creating / validating an invoice, commercial proposal, sales order.
This action is not blocking in the process of confirmation diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index aa8b5a5c462..e2acf31eb4d 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -402,3 +402,4 @@ PMPValueShort=PMP mandatoryperiod=Périodes obligatoires mandatoryPeriodNeedTobeSet=Attention périodes non saisies et obligatoires mandatoryPeriodNeedTobeSetMsgValidate=Un service nécessite une période de début et de fin +mandatoryHelper=Message à l'utilisateur sur la necessité de saisir une date de début et une date de fin sur un service lors de la création/validation de facture, proposition commerciale , commande client.
Cette action n'est pas bloquante dans le processus de validation diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 55589a967d4..277fec6e78f 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2279,7 +2279,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("mandatoryperiod").''; print 'mandatory_period == 1 ? ' checked="checked"' : '').' disabled/> '; + print ''; + + $htmltooltip = '
'.$langs->trans("mandatoryHelper"); + + + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; + } else { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { // Nature From 2f0ba41a531cece5b8e42b4c49d0deb91d7b25a5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 20 Jul 2021 13:35:10 +0000 Subject: [PATCH 0053/1055] Fixing style errors. --- htdocs/comm/propal/card.php | 7 +++---- htdocs/commande/card.php | 6 +++--- htdocs/compta/facture/card.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 4 ++-- htdocs/core/tpl/objectline_view.tpl.php | 7 +++---- htdocs/product/card.php | 6 +----- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 1c83e7ed962..5cf3c640563 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1958,15 +1958,14 @@ if ($action == 'create') { $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('PROPAL_VALIDATE', $object->socid, $object); - } // mandatoryPeriod $nbMandated = 0; - foreach ($object->lines as $line){ + foreach ($object->lines as $line) { $res = $line->fetch_product(); - if ($res > 0 ){ - if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )){ + if ($res > 0 ) { + if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )) { $nbMandated++; break; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f6ecf217a0d..4a8818113d5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1912,10 +1912,10 @@ if ($action == 'create' && $usercancreate) { // mandatoryPeriod $nbMandated = 0; - foreach ($object->lines as $line){ + foreach ($object->lines as $line) { $res = $line->fetch_product(); - if ($res > 0 ){ - if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )){ + if ($res > 0 ) { + if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )) { $nbMandated++; break; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 60f025efbae..e4391b126b7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4004,10 +4004,10 @@ if ($action == 'create') { // mandatoryPeriod $nbMandated = 0; - foreach ($object->lines as $line){ + foreach ($object->lines as $line) { $res = $line->fetch_product(); - if ($res > 0 ){ - if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )){ + if ($res > 0 ) { + if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )) { $nbMandated++; break; } diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 8ef08b60660..642bb90403d 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -340,7 +340,7 @@ $coldisplay++; } $res = $line->fetch_product(); - if ($res > 0 ){ + if ($res > 0 ) { if ($line->product->isMandatoryPeriod() && $line->product->isService()) { print 'jQuery("#date_start").addClass("error");'; } @@ -356,7 +356,7 @@ $coldisplay++; $res = $line->fetch_product(); // on doit fetch le product là !!! pour connaître le type - if ($res > 0 ){ + if ($res > 0 ) { if ($line->product->isMandatoryperiod() && $line->product->isService()) { print 'jQuery("#date_end").addClass("error");'; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 42453df6e31..7d5e02f82ea 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -180,14 +180,13 @@ if (($line->info_bits & 2) == 2) { } else { if ($line->date_start || $line->date_end) { print '
'.get_date_range($line->date_start, $line->date_end, $format).'
'; - } - if (!$line->date_start || !$line->date_end){ + if (!$line->date_start || !$line->date_end) { // show warning under line // we need to fetch product associated to line for some test $res = $line->fetch_product(); - if ($res > 0 ){ - if ($line->product->isService() && $line->product->isMandatoryPeriod()){ + if ($res > 0 ) { + if ($line->product->isService() && $line->product->isMandatoryPeriod()) { print '
'.$langs->trans("mandatoryPeriodNeedTobeSet").'
'; } } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 277fec6e78f..45b5e87121d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -582,7 +582,7 @@ if (empty($reshook)) { } else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; } - if ($object->isService()){ + if ($object->isService()) { $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ; } @@ -1993,9 +1993,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print 'mandatory_period == 1 ? ' checked="checked"' : '').' /> '; print ''; } - - - } } print ''; @@ -2287,7 +2284,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; - } else { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { // Nature From f16eba1811b8b762be109449dd1f96c17e5b1b2e Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 20 Jul 2021 16:04:12 +0200 Subject: [PATCH 0054/1055] quick fix create product --- htdocs/product/class/product.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1c27671ba00..f9b046e341c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -636,7 +636,7 @@ class Product extends CommonObject // Barcode value $this->barcode = trim($this->barcode); - + $this->mandatory_period = empty($this->mandatory_period) ? 0 : $this->mandatory_period; // Check parameters if (empty($this->label)) { $this->error = 'ErrorMandatoryParametersNotProvided'; @@ -718,6 +718,7 @@ class Product extends CommonObject $sql .= ", tobatch"; $sql .= ", batch_mask"; $sql .= ", fk_unit"; + $sql .= ", mandatory_period"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($now)."'"; $sql .= ", ".$conf->entity; @@ -746,6 +747,7 @@ class Product extends CommonObject $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); $sql .= ", '".$this->db->escape($this->batch_mask)."'"; $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ", '".$this->mandatory_period."'"; $sql .= ")"; dol_syslog(get_class($this)."::Create", LOG_DEBUG); From 875167d5937368627c5b053a8369c9a92279c526 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 20 Jul 2021 16:17:17 +0200 Subject: [PATCH 0055/1055] add escape to sql --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f9b046e341c..18413b89c30 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -747,7 +747,7 @@ class Product extends CommonObject $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); $sql .= ", '".$this->db->escape($this->batch_mask)."'"; $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql .= ", '".$this->mandatory_period."'"; + $sql .= ", '".$this->db->escape($this->mandatory_period)."'"; $sql .= ")"; dol_syslog(get_class($this)."::Create", LOG_DEBUG); From 3df4cd885785eed45387c2d1cb401fa854e94d8f Mon Sep 17 00:00:00 2001 From: Givriz Date: Tue, 20 Jul 2021 20:28:04 +0200 Subject: [PATCH 0056/1055] Compatibility phpv8 --- htdocs/adherents/card.php | 4 ++-- htdocs/adherents/type.php | 8 ++++---- htdocs/core/actions_massactions.inc.php | 2 +- htdocs/core/tpl/extrafields_edit.tpl.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 7c5d074d51e..42e0b84228f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -535,7 +535,7 @@ if (empty($reshook)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); } - if ($conf->global->ADHERENT_MAIL_REQUIRED && !isValidEMail($email)) { + if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($email)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors'); @@ -1032,7 +1032,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // EMail - print ''.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').''; + print ''.(!empty($conf->global->ADHERENT_MAIL_REQUIRED) ? '' : '').$langs->trans("EMail").(!empty($conf->global->ADHERENT_MAIL_REQUIRED) ? '' : '').''; print ''.img_picto('', 'object_email').' '; // Website diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 033592a9afc..c27a4adeeac 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -379,12 +379,12 @@ if ($action == 'create') { print ''.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('comment', $object->note, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('comment', $object->note, '', 200, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print ''.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print ''; @@ -812,12 +812,12 @@ if ($rowid > 0) { print ''.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print ""; print ''.$langs->trans("WelcomeEMail").''; - $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print ""; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index e5d4de26278..d945efb6e34 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1547,7 +1547,7 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == $parameters['toselect'] = $toselect; $parameters['uploaddir'] = $uploaddir; $parameters['massaction'] = $massaction; -$parameters['diroutputmassaction'] = $diroutputmassaction; +$parameters['diroutputmassaction'] = empty($diroutputmassaction) ? '' : $diroutputmassaction; $reshook = $hookmanager->executeHooks('doMassActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/core/tpl/extrafields_edit.tpl.php b/htdocs/core/tpl/extrafields_edit.tpl.php index 5915fb8a633..16a90025a7a 100644 --- a/htdocs/core/tpl/extrafields_edit.tpl.php +++ b/htdocs/core/tpl/extrafields_edit.tpl.php @@ -43,7 +43,7 @@ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, print $hookmanager->resPrint; if (empty($reshook)) { $params = array(); - $params['cols'] = $parameters['colspanvalue']; + $params['cols'] = empty($parameters['colspanvalue']) ? '' : $parameters['colspanvalue']; print $object->showOptionals($extrafields, 'edit', $params); } From d61b831737b585b60d0125e68c58e0f57e21da49 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 20 Jul 2021 22:39:30 +0200 Subject: [PATCH 0057/1055] add field in create product --- htdocs/core/tpl/objectline_create.tpl.php | 2 -- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- htdocs/product/card.php | 12 +++++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index ecd8a47fc86..34b6fe9ec44 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -716,8 +716,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) { // service and we setted mandatory_period to true if (data.mandatory_period == 1 && data.type == 1 ) { - console.log("we are good to color date input"); - jQuery("#date_start").addClass("error"); jQuery("#date_end").addClass("error"); }else{ diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 642bb90403d..e15c489a5b6 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -341,7 +341,7 @@ $coldisplay++; $res = $line->fetch_product(); if ($res > 0 ) { - if ($line->product->isMandatoryPeriod() && $line->product->isService()) { + if ( $line->product->isMandatoryPeriod() && $line->product->isService()) { print 'jQuery("#date_start").addClass("error");'; } } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 45b5e87121d..4b5e178733d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -106,6 +106,7 @@ $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); +$checkmandatory = GETPOST('accountancy_code_buy_export', 'alpha'); // by default 'alphanohtml' (better security); hidden conf MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML allows basic html $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ? 'alphanohtml' : 'restricthtml'; @@ -264,7 +265,7 @@ if (empty($reshook)) { $object->ref = $ref; $object->label = GETPOST('label', $label_security_check); $object->price_base_type = GETPOST('price_base_type', 'aZ09'); - + $object->mandatory_period = !empty(GETPOST("mandatoryperiod",'alpha')) ? 1 : 0; if ($object->price_base_type == 'TTC') { $object->price_ttc = GETPOST('price'); } else { @@ -1401,6 +1402,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); print ''; + if (!empty($conf->service->enabled)){ + if ($object->isService()){ + // Mandatory period + print ''.$langs->trans("mandatoryperiod").''; + print ' '; + print ''; + + } + } print ''; print '
'; From 191163c7e7ec9509c1d388afe8aae654f7932e04 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 20 Jul 2021 20:41:49 +0000 Subject: [PATCH 0058/1055] Fixing style errors. --- htdocs/product/card.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 4b5e178733d..0f7b061fb54 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -265,7 +265,7 @@ if (empty($reshook)) { $object->ref = $ref; $object->label = GETPOST('label', $label_security_check); $object->price_base_type = GETPOST('price_base_type', 'aZ09'); - $object->mandatory_period = !empty(GETPOST("mandatoryperiod",'alpha')) ? 1 : 0; + $object->mandatory_period = !empty(GETPOST("mandatoryperiod", 'alpha')) ? 1 : 0; if ($object->price_base_type == 'TTC') { $object->price_ttc = GETPOST('price'); } else { @@ -1402,13 +1402,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); print ''; - if (!empty($conf->service->enabled)){ - if ($object->isService()){ + if (!empty($conf->service->enabled)) { + if ($object->isService()) { // Mandatory period print ''.$langs->trans("mandatoryperiod").''; print ' '; print ''; - } } print ''; From 32f9b1a55640449211d11bfc284ffd55429f4f00 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 21 Jul 2021 08:26:41 +0200 Subject: [PATCH 0059/1055] fix cmd fourn no msg --- htdocs/core/tpl/objectline_create.tpl.php | 8 ++++---- htdocs/core/tpl/objectline_view.tpl.php | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 34b6fe9ec44..ac4bbca05a0 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -68,6 +68,7 @@ if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf- if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier'))) { $colspan++; // With this, there is a column move button } + //print $object->element; // Lines for extrafield $objectline = null; @@ -674,16 +675,17 @@ if (!empty($usemargins) && $user->rights->margins->creer) { + +table_element_line != 'commande_fournisseurdet' || $this->table_element_line == 'facture_fourn_det') { ?> $("#date_start, #date_end").focusout(function() { - if ( $(this).val() == '' && !$(this).hasClass("error") ) { $(this).addClass('error'); }else{ $(this).removeClass('error'); } }); - + /* When changing predefined product, we reload list of supplier prices required for margin combo */ $("#idprod, #idprodfournprice").change(function() { @@ -712,8 +714,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) { function(data) { console.log("Load unit price end, we got value "+data.price_ht); - - // service and we setted mandatory_period to true if (data.mandatory_period == 1 && data.type == 1 ) { jQuery("#date_start").addClass("error"); diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 7d5e02f82ea..d4a4f6a0573 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -184,12 +184,15 @@ if (($line->info_bits & 2) == 2) { if (!$line->date_start || !$line->date_end) { // show warning under line // we need to fetch product associated to line for some test + if ($object->element != 'order_supplier'){ $res = $line->fetch_product(); if ($res > 0 ) { if ($line->product->isService() && $line->product->isMandatoryPeriod()) { print '
'.$langs->trans("mandatoryPeriodNeedTobeSet").'
'; } } + } + } From c93e2cda0dea8c175c4fe1132405012b7c4ae2cc Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 21 Jul 2021 06:31:07 +0000 Subject: [PATCH 0060/1055] Fixing style errors. --- htdocs/core/tpl/objectline_view.tpl.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index d4a4f6a0573..5c955c56ff3 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -184,15 +184,14 @@ if (($line->info_bits & 2) == 2) { if (!$line->date_start || !$line->date_end) { // show warning under line // we need to fetch product associated to line for some test - if ($object->element != 'order_supplier'){ - $res = $line->fetch_product(); - if ($res > 0 ) { - if ($line->product->isService() && $line->product->isMandatoryPeriod()) { - print '
'.$langs->trans("mandatoryPeriodNeedTobeSet").'
'; + if ($object->element != 'order_supplier') { + $res = $line->fetch_product(); + if ($res > 0 ) { + if ($line->product->isService() && $line->product->isMandatoryPeriod()) { + print '
'.$langs->trans("mandatoryPeriodNeedTobeSet").'
'; + } } } - } - } From 62d007e232b44fb9beb968fad698bc5fb98763b4 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 21 Jul 2021 08:56:40 +0200 Subject: [PATCH 0061/1055] add focusout constraint --- htdocs/core/tpl/objectline_create.tpl.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index ac4bbca05a0..9a87d89189a 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -679,10 +679,13 @@ if (!empty($usemargins) && $user->rights->margins->creer) { table_element_line != 'commande_fournisseurdet' || $this->table_element_line == 'facture_fourn_det') { ?> $("#date_start, #date_end").focusout(function() { - if ( $(this).val() == '' && !$(this).hasClass("error") ) { - $(this).addClass('error'); - }else{ - $(this).removeClass('error'); + type = $(this).attr('type'); + if (type == 1){ + if ( $(this).val() == '' && !$(this).hasClass("error") ) { + $(this).addClass('error'); + }else{ + $(this).removeClass('error'); + } } }); @@ -714,6 +717,11 @@ if (!empty($usemargins) && $user->rights->margins->creer) { function(data) { console.log("Load unit price end, we got value "+data.price_ht); + $( '#date_start').removeAttr( "type" ); + $( '#date_end' ).removeAttr( "type" ); + $('#date_start').attr('type', data.type); + $('#date_end').attr('type', data.type); + // service and we setted mandatory_period to true if (data.mandatory_period == 1 && data.type == 1 ) { jQuery("#date_start").addClass("error"); From 0396573b91f5d340779eb89b6aab0e805cce1ddf Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 21 Jul 2021 09:46:38 +0200 Subject: [PATCH 0062/1055] fix focusout on mandatoryPeriod only --- htdocs/core/tpl/objectline_create.tpl.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 9a87d89189a..5d3d9de4ea4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -679,8 +679,9 @@ if (!empty($usemargins) && $user->rights->margins->creer) { table_element_line != 'commande_fournisseurdet' || $this->table_element_line == 'facture_fourn_det') { ?> $("#date_start, #date_end").focusout(function() { - type = $(this).attr('type'); - if (type == 1){ + let type = $(this).attr('type'); + let mandatoryP = $(this).attr('mandatoryperiod'); + if (type == 1 && mandatoryP == 1 ){ if ( $(this).val() == '' && !$(this).hasClass("error") ) { $(this).addClass('error'); }else{ @@ -722,6 +723,11 @@ if (!empty($usemargins) && $user->rights->margins->creer) { $('#date_start').attr('type', data.type); $('#date_end').attr('type', data.type); + $( '#date_start').removeAttr( "mandatoryperiod" ); + $( '#date_end' ).removeAttr( "mandatoryperiod" ); + $('#date_start').attr('mandatoryperiod', data.mandatory_period); + $('#date_end').attr('mandatoryperiod', data.mandatory_period); + // service and we setted mandatory_period to true if (data.mandatory_period == 1 && data.type == 1 ) { jQuery("#date_start").addClass("error"); From 252765303eadfdc39dde40fc010ca3edc423e2f2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 21 Jul 2021 07:48:57 +0000 Subject: [PATCH 0063/1055] Fixing style errors. --- htdocs/core/tpl/objectline_create.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 5d3d9de4ea4..d09a3257d87 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -679,8 +679,8 @@ if (!empty($usemargins) && $user->rights->margins->creer) { table_element_line != 'commande_fournisseurdet' || $this->table_element_line == 'facture_fourn_det') { ?> $("#date_start, #date_end").focusout(function() { - let type = $(this).attr('type'); - let mandatoryP = $(this).attr('mandatoryperiod'); + let type = $(this).attr('type'); + let mandatoryP = $(this).attr('mandatoryperiod'); if (type == 1 && mandatoryP == 1 ){ if ( $(this).val() == '' && !$(this).hasClass("error") ) { $(this).addClass('error'); From 8dc316797f5e1f6c8133f2928fe4a6db620afcb3 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 26 Jul 2021 09:15:23 +0200 Subject: [PATCH 0064/1055] move info to the left --- htdocs/product/card.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 0f7b061fb54..c5507180548 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2282,16 +2282,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // Mandatory period - - print ''.$langs->trans("mandatoryperiod").''; - print 'mandatory_period == 1 ? ' checked="checked"' : '').' disabled/> '; - print ''; - $htmltooltip = '
'.$langs->trans("mandatoryHelper"); - - - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''.$langs->trans("mandatoryperiod"); + print $form->textwithpicto('', $htmltooltip, 1, 0).''; + print 'mandatory_period == 1 ? ' checked="checked"' : '').' disabled/> '; print ''; } else { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { From ca6dd8850ab3cab0a6e70b1e851106f72c7d5653 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 29 Jul 2021 15:24:08 +0200 Subject: [PATCH 0065/1055] FIX: Manage credit note on situation invoice for calculate margin --- htdocs/core/class/html.formmargin.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 83923ffa6c7..e571f7cc68c 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -98,7 +98,8 @@ class FormMargin $pv = $line->total_ht; $pa_ht = ($pv < 0 ? -$line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign - if ($object->element == 'facture' && $object->type == $object::TYPE_SITUATION) { + if ($object->element == 'facture' && $object->type == $object::TYPE_SITUATION + || $object->element == 'facture' && $object->type == $object::TYPE_CREDIT_NOTE && $conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE && $object->situation_counter > 0) { $pa = $line->qty * $pa_ht * ($line->situation_percent / 100); } else { $pa = $line->qty * $pa_ht; From 1cef6d31e89108f5cb96596208657befebf7ee9a Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 2 Aug 2021 15:45:55 +0200 Subject: [PATCH 0066/1055] Close #18302 : Mass action leave requests --- htdocs/core/actions_massactions.inc.php | 120 ++++++++++++++++++++++++ htdocs/core/tpl/massactions_pre.tpl.php | 4 + htdocs/holiday/list.php | 4 + htdocs/langs/en_US/main.lang | 4 + htdocs/langs/fr_FR/main.lang | 4 + 5 files changed, 136 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 8d70f7c3042..c986a2e5ac1 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1544,6 +1544,126 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == } } +if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $confirm == 'yes')) && $permissiontoapprove) { + $db->begin(); + + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result>0) { + if ($objecttmp->statut == Holiday::STATUS_VALIDATED && $user->id == $objecttmp->fk_validator) { + $objecttmp->oldcopy = dol_clone($objecttmp); + + $objecttmp->date_valid = dol_now(); + $objecttmp->fk_user_valid = $user->id; + $objecttmp->statut = Holiday::STATUS_APPROVED; + + $db->begin(); + + $verif = $objecttmp->approve($user); + if ($verif <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + } + + // If no SQL error, we redirect to the request form + if (!$error) { + // Calculcate number of days consummed + $nbopenedday = num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday); + $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type); + $newSolde = ($soldeActuel - $nbopenedday); + + // The modification is added to the LOG + $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv("Holidays"), $newSolde, $objecttmp->fk_type); + if ($result < 0) { + $error++; + setEventMessages(null, $objecttmp->errors, 'errors'); + } + + // Update balance + $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type); + if ($result < 0) { + $error++; + setEventMessages(null, $objecttmp->errors, 'errors'); + } + } + + if (!$error) { + // To + $destinataire = new User($db); + $destinataire->fetch($objecttmp->fk_user); + $emailTo = $destinataire->email; + + if (!$emailTo) { + dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); + } else { + // From + $expediteur = new User($db); + $expediteur->fetch($objecttmp->fk_validator); + //$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email. + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; + + // Subject + $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $societeName = $conf->global->MAIN_APPLICATION_TITLE; + } + + $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated"); + + // Content + $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; + $message .= "\n"; + + $message .= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($objecttmp->date_debut, 'day'), dol_print_date($objecttmp->date_fin, 'day'))."\n"; + + $message .= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + + $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$objecttmp->id."\n\n"; + $message .= "\n"; + + $trackid = 'leav'.$objecttmp->id; + + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + + // Sending email + $result = $mail->sendfile(); + + if (!$result) { + setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1 + $action = ''; + } + } + } + + if (!$error) { + $db->commit(); + $nbok++; + } else { + $db->rollback(); + $action = ''; + } + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsApproved", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordAproved"), null, 'mesgs'); + } + $db->commit(); + } else { + $db->rollback(); + } +} + $parameters['toselect'] = $toselect; $parameters['uploaddir'] = $uploaddir; $parameters['massaction'] = $massaction; diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index e2e56e1a060..4d715ed8797 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -202,6 +202,10 @@ if ($massaction == 'predisable') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDisabling"), $langs->trans("ConfirmMassDisablingQuestion", count($toselect)), "disable", null, '', 0, 200, 500, 1); } +if ($massaction == 'preapproveleave') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassLeaveApproval"), $langs->trans("ConfirmMassLeaveApprovalQuestion", count($toselect)), "approveleave", null, '', 0, 200, 500, 1); +} + // Allow Pre-Mass-Action hook (eg for confirmation dialog) $parameters = array( 'toselect' => $toselect, diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index e7a09abea6e..334f68da404 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -213,6 +213,7 @@ if (empty($reshook)) { $objectlabel = 'Holiday'; $permissiontoread = $user->rights->holiday->read; $permissiontodelete = $user->rights->holiday->delete; + $permissiontoapprove = $user->rights->holiday->approve; $uploaddir = $conf->holiday->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -441,6 +442,9 @@ if ($resql) { if (!empty($user->rights->holiday->delete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } + if (!empty($user->rights->holiday->approve)) { + $arrayofmassactions['preapproveleave'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Approve"); + } if (in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 6c1ef6aa659..569c709e169 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1149,3 +1149,7 @@ RecordEnabled=Record enabled RecordDisabled=Record disabled Forthcoming=Forthcoming Currently=Currently +ConfirmMassLeaveApprovalQuestion=Are you sure you want to approve the %s selected record(s)? +ConfirmMassLeaveApproval=Mass leave approval confirmation +RecordAproved=Record approved +RecordsApproved=%s Record(s) approved diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 2453fab1e16..9aecafe3f34 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -1147,3 +1147,7 @@ RecordsEnabled=%s enregistrement(s) activé(s) RecordsDisabled=%s enregistrement(s) désactivé(s) RecordEnabled=Enregistrement activé RecordDisabled=Enregistrement désactivé +ConfirmMassLeaveApprovalQuestion=Êtes-vous sur de vouloir approuver les %s enregistrement(s) sélectionné(s) ? +ConfirmMassLeaveApproval=Confirmation d'approbation de congé en masse +RecordAproved=Enregistrement approuvé +RecordsApproved=%s enregistrement(s) approuvé(s) From 2998c948844592056be74c7c9951379e8a04ba6c Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 3 Aug 2021 11:12:19 +0200 Subject: [PATCH 0067/1055] NEW : add constant PROPAL_NOT_BILLABLE --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3c0d8dd9a28..83f28af1d15 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2579,7 +2579,7 @@ if ($action == 'create') { } // Create an invoice and classify billed - if ($object->statut == Propal::STATUS_SIGNED) { + if ($object->statut == Propal::STATUS_SIGNED && empty($conf->global->PROPAL_NOT_BILLABLE)) { if (!empty($conf->facture->enabled) && $usercancreateinvoice) { print ''.$langs->trans("AddBill").''; } From f00694470fab4a3b38ac415eb18c9b429048ec0e Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 3 Aug 2021 15:40:01 +0200 Subject: [PATCH 0068/1055] rename constant to PROPOSAL_ARE_NOT_BILLABLE --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 83f28af1d15..9b58b35c4a7 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2579,7 +2579,7 @@ if ($action == 'create') { } // Create an invoice and classify billed - if ($object->statut == Propal::STATUS_SIGNED && empty($conf->global->PROPAL_NOT_BILLABLE)) { + if ($object->statut == Propal::STATUS_SIGNED && empty($conf->global->PROPOSAL_ARE_NOT_BILLABLE)) { if (!empty($conf->facture->enabled) && $usercancreateinvoice) { print ''.$langs->trans("AddBill").''; } From 4873a91afc624486f856baa4ac09705cd9cbfbe9 Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Tue, 3 Aug 2021 17:33:06 +0400 Subject: [PATCH 0069/1055] CLOSE #18326 Workflow: Close order on shipment closing. Allow an order to be closed automatically when all linked shipment have been closed and all products / items have been shipped. --- htdocs/admin/workflow.php | 10 ++++++++-- htdocs/core/modules/modWorkflow.class.php | 1 + .../interface_20_modWorkflow_WorkflowManager.class.php | 10 ++++++++-- htdocs/langs/en_US/workflow.lang | 1 + htdocs/langs/fr_FR/workflow.lang | 1 + 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 09156e08588..1b6fa5bebe7 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -91,15 +91,21 @@ $workflowcodes = array( ), // Automatic classification of order - 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array( + 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array( // when shipping validated 'family'=>'classify_order', 'position'=>40, 'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)), 'picto'=>'order' ), - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array( + 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED'=>array( // when shipping closed 'family'=>'classify_order', 'position'=>41, + 'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order' + ), + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array( + 'family'=>'classify_order', + 'position'=>42, 'enabled'=>(!empty($conf->facture->enabled) && !empty($conf->commande->enabled)), 'picto'=>'order', 'warning'=>'' diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index fbf7927ed1c..eaaf15d40a1 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -87,6 +87,7 @@ class modWorkflow extends DolibarrModules 0=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 0, 'current', 0), 1=>array('WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 0, 'current', 0), 2=>array('WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 0, 'current', 0), + 3=>array('WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED', 0, 'current', 0), 4=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 0, 'current', 0), 5=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 0, 'current', 0), 6=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0), diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 72a08d22494..c47965c7d52 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -256,10 +256,15 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } - if ($action == 'SHIPPING_VALIDATE') { + if (($action == 'SHIPPING_VALIDATE') || ($action == 'SHIPPING_CLOSED')) { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING)) { + if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && + ( + (!empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING) && ($action == 'SHIPPING_VALIDATE')) || + (!empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED) && ($action == 'SHIPPING_CLOSED')) + ) + ) { $qtyshipped = array(); $qtyordred = array(); require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -318,6 +323,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } } + // classify billed reception if ($action == 'BILL_SUPPLIER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG); diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index 15fd8ef07c2..fafbc6e8d8a 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -13,6 +13,7 @@ descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal as b descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source sales order as billed when customer invoice is validated (and if the amount of the invoice is the same as the total amount of the linked order) descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source sales order as billed when customer invoice is set to paid (and if the amount of the invoice is the same as the total amount of the linked order) descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify linked source sales order as shipped when a shipment is validated (and if the quantity shipped by all shipments is the same as in the order to update) +descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED=Classify linked source sales order as shipped when a shipment is closed (and if the quantity shipped by all shipments is the same as in the order to update) # Autoclassify purchase order descWORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL=Classify linked source vendor proposal as billed when vendor invoice is validated (and if the amount of the invoice is the same as the total amount of the linked proposal) descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER=Classify linked source purchase order as billed when vendor invoice is validated (and if the amount of the invoice is the same as the total amount of the linked order) diff --git a/htdocs/langs/fr_FR/workflow.lang b/htdocs/langs/fr_FR/workflow.lang index 2af480afa83..13fbbace793 100644 --- a/htdocs/langs/fr_FR/workflow.lang +++ b/htdocs/langs/fr_FR/workflow.lang @@ -13,6 +13,7 @@ descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classer la/les proposition(s) commer descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classer la/les commande(s) client(s) source(s) facturée(s) à la validation de la facture client (et si le montant de la facture est le même que le montant total des commandes liées) descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classer la/les commande(s) client(s) source(s) à Facturée quand une facture client est passée à Payé (et si le montant de la facture est identique à la somme des commandes sources) descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classer la commande source à expédiée à la validation d'une expédition (et si les quantités expédiées dans le bon d'expédition sont les même que dans la commande mise à jour) +descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED=Classer la commande source à expédiée à la cloture d'une expédition (et si les quantités expédiées dans le bon d'expédition sont les même que dans la commande mise à jour) # Autoclassify purchase order descWORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL=Classer la ou les proposition(s) commerciale(s) fournisseur sources facturées quand une facture fournisseur est validée (et si le montant de la facture est le même que le total des propositions sources liées) descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER=Classer la ou les commande(s) fournisseur(s) de source(s) à facturée(s) lorsque la facture fournisseur est validée (et si le montant de la facture est le même que le montant total des commandes liées) From 1da9829d61bfa48aa6e0506f1e5a62db413bb799 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 3 Aug 2021 14:08:23 +0000 Subject: [PATCH 0070/1055] Fixing style errors. --- .../interface_20_modWorkflow_WorkflowManager.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index c47965c7d52..8235348f21f 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -259,10 +259,10 @@ class InterfaceWorkflowManager extends DolibarrTriggers if (($action == 'SHIPPING_VALIDATE') || ($action == 'SHIPPING_CLOSED')) { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && + if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && ( (!empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING) && ($action == 'SHIPPING_VALIDATE')) || - (!empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED) && ($action == 'SHIPPING_CLOSED')) + (!empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED) && ($action == 'SHIPPING_CLOSED')) ) ) { $qtyshipped = array(); From d3515253b2a11e76523c5608f7dcedc2817c952e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Aug 2021 17:15:13 +0200 Subject: [PATCH 0071/1055] Update 13.0.0-14.0.0.sql --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index a275105cb31..7641215dc91 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -595,5 +595,3 @@ create table llx_onlinesignature ip varchar(128), pathoffile varchar(255) )ENGINE=innodb; - -ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD lang varchar(6); From 26ba153169909456d381d28f7f824ac3a374a82c Mon Sep 17 00:00:00 2001 From: Daniel Mietchen Date: Wed, 4 Aug 2021 00:21:04 -0400 Subject: [PATCH 0072/1055] typo fix and copyedits --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7878f6270a7..834cc09236e 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ If you don't have time to install it yourself, you can try some commercial 'read ## UPGRADING -Dolibarr supports upgrading usually wihtout the need for any (commercial) support (depending on if you use any commercial extensions) and supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate! +Dolibarr supports upgrading, usually without the need for any (commercial) support (depending on if you use any commercial extensions). It supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate! - At first make a backup of your Dolibarr files & than [see](https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr) - Check that your installed PHP version is supported by the new version [see PHP support](./doc/phpmatrix.md). From 8c7b6e66662f7d3629208aeeecd21254b9362395 Mon Sep 17 00:00:00 2001 From: Daniel Mietchen Date: Wed, 4 Aug 2021 00:34:29 -0400 Subject: [PATCH 0073/1055] typo fixes --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 035387834bd..84deea18f00 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,7 +3,7 @@ *Please:* - *only keep the "Fix", "Close" or "New" section* - *follow the project [contributing guidelines](/.github/CONTRIBUTING.md)* -- *replace the bracket enclosed textswith meaningful informations* +- *replace the bracket enclosed texts with meaningful information* # Fix #[*issue_number Short description*] From 8cbbcc01a957e232762a6263eb735658acd10e93 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 4 Aug 2021 11:25:23 +0200 Subject: [PATCH 0074/1055] Update to make lan field common --- htdocs/core/actions_addupdatedelete.inc.php | 20 ++++++++++++++---- htdocs/core/tpl/commonfields_add.tpl.php | 9 +++++++- htdocs/core/tpl/commonfields_edit.tpl.php | 9 +++++++- htdocs/core/tpl/commonfields_view.tpl.php | 9 +++++++- .../class/knowledgerecord.class.php | 2 +- .../knowledgerecord_card.php | 21 ------------------- 6 files changed, 41 insertions(+), 29 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index f871ed73de8..44865ee00d2 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -57,7 +57,9 @@ if ($action == 'add' && !empty($permissiontoadd)) { } } else { if (!GETPOSTISSET($key)) { - continue; // The field was not submited to be edited + if ($key != 'lang' || !GETPOSTISSET($key.'object')) { + continue; // The field was not submited to be edited + } } } // Ignore special fields @@ -87,7 +89,11 @@ if ($action == 'add' && !empty($permissiontoadd)) { $tmparraykey = array_keys($object->param_list); $value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2'); } else { - $value = GETPOST($key, 'alphanohtml'); + if ($key == 'lang') { + $value = GETPOST($key.'object', 'aZ09'); + } else { + $value = GETPOST($key, 'alphanohtml'); + } } if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') { $value = ''; // This is an implicit foreign key field @@ -152,7 +158,9 @@ if ($action == 'update' && !empty($permissiontoadd)) { } } else { if (!GETPOSTISSET($key)) { - continue; // The field was not submited to be edited + if ($key != 'lang' || !GETPOSTISSET($key.'object')) { + continue; // The field was not submited to be edited + } } } // Ignore special fields @@ -190,7 +198,11 @@ if ($action == 'update' && !empty($permissiontoadd)) { } elseif ($object->fields[$key]['type'] == 'reference') { $value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2'); } else { - $value = GETPOST($key, 'alpha'); + if ($key == 'lang') { + $value = GETPOST($key.'object', 'aZ09'); + } else { + $value = GETPOST($key, 'alphanohtml'); + } } if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') { $value = ''; // This is an implicit foreign key field diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index cd07c0b8191..a0e83c6eb5e 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -79,13 +79,20 @@ foreach ($object->fields as $key => $val) { $value = (GETPOST($key) == 'on' ? 1 : 0); } elseif ($val['type'] == 'price') { $value = price2num(GETPOST($key)); + } elseif ($key == 'lang') { + $value = GETPOST($key.'object', 'aZ09'); } else { $value = GETPOST($key, 'alphanohtml'); } if (!empty($val['noteditable'])) { print $object->showOutputField($val, $key, $value, '', '', '', 0); } else { - print $object->showInputField($val, $key, $value, '', '', '', 0); + if ($key == 'lang') { + print img_picto('', 'language', 'class="pictofixedwidth"'); + print $formadmin->select_language($value, $key.'object', 0, null, 1, 0, 0, 'minwidth300', 2); + } else { + print $object->showInputField($val, $key, $value, '', '', '', 0); + } } print ''; print ''; diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index 9670271d1a4..a3d70117fea 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -79,6 +79,8 @@ foreach ($object->fields as $key => $val) { $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key; } elseif ($val['type'] == 'price') { $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key); + } elseif ($key == 'lang') { + $value = GETPOSTISSET($key.'object', 'aZ09')?GETPOST($key.'object', 'aZ09'):$object->lang; } else { $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key; } @@ -86,7 +88,12 @@ foreach ($object->fields as $key => $val) { if ($val['noteditable']) { print $object->showOutputField($val, $key, $value, '', '', '', 0); } else { - print $object->showInputField($val, $key, $value, '', '', '', 0); + if ($key == 'lang') { + print img_picto('', 'language', 'class="pictofixedwidth"'); + print $formadmin->select_language($value, $key.'object', 0, null, 1, 0, 0, 'minwidth300', 2); + } else { + print $object->showInputField($val, $key, $value, '', '', '', 0); + } } print ''; print ''; diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index f9da77c5894..b58d0526356 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -81,7 +81,14 @@ foreach ($object->fields as $key => $val) { if (in_array($val['type'], array('text', 'html'))) { print '
'; } - print $object->showOutputField($val, $key, $value, '', '', '', 0); + if ($key == 'lang') { + $langs->load("languages"); + $labellang = ($value ? $langs->trans('Language_'.$value) : ''); + print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"'); + print $labellang; + } else { + print $object->showOutputField($val, $key, $value, '', '', '', 0); + } //print dol_escape_htmltag($object->$key, 1, 1); if (in_array($val['type'], array('text', 'html'))) { print '
'; diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index af752cfea7f..f3d6d81aaec 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -115,7 +115,7 @@ class KnowledgeRecord extends CommonObject //'url' => array('type'=>'varchar(255)', 'label'=>'URL', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflow200', 'help'=>'UrlForInfoPage'), 'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php', 'label'=>'GroupOfTicket', 'enabled'=>'$conf->ticket->enabled', 'position'=>512, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory'), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Valid'),), - 'lang' => array('type'=>'varchar(6)', 'label'=>'Language', 'enabled'=>'1', 'position'=>51, 'notnull'=>0, 'visible'=>0,), + 'lang' => array('type'=>'varchar(6)', 'label'=>'Language', 'enabled'=>'1', 'position'=>51, 'notnull'=>0, 'visible'=>1), ); public $rowid; public $ref; diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index 96aef48dde2..99e8e97ecc6 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -192,12 +192,6 @@ if ($action == 'create') { // Common attributes include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - //Language of question/response - print ''.$langs->trans("Language").''; - print img_picto('', 'language', 'class="pictofixedwidth"'); - print $formadmin->select_language('', 'langkm', 0, null, 1, 0, 0, 'minwidth300', 2); - print ''; - print ''; // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; @@ -239,12 +233,6 @@ if (($id || $ref) && $action == 'edit') { // Common attributes include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - //Language of question/response - print ''.$langs->trans("Language").''; - print img_picto('', 'language', 'class="pictofixedwidth"'); - print $formadmin->select_language($object->lang, 'langkm', 0, null, 1, 0, 0, 'minwidth300', 2); - print ''; - print ''; // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; @@ -353,15 +341,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //unset($object->fields['fk_soc']); // Hide field already shown in banner include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; - //Language of question/response - print ''.$langs->trans("Language").''; - $langs->load("languages"); - $labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : ''); - print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"'); - print $labellang; - print ''; - print ''; - // Other attributes. Fields from hook formObjectOptions and Extrafields. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; From 803722e323801bbc4e3d5b79651bd666cb0835ad Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 4 Aug 2021 14:48:10 +0200 Subject: [PATCH 0075/1055] Fix : we only want employee users for holidays --- htdocs/holiday/class/holiday.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 2637f3c0eaa..3cd649e11ac 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1630,6 +1630,7 @@ class Holiday extends CommonObject $sql .= " WHERE u.entity IN (".getEntity('user').")"; } $sql .= " AND u.statut > 0"; + $sql .= " AND u.employee = 1"; // We only want employee users for holidays if ($filters) $sql .= $filters; $resql = $this->db->query($sql); @@ -1720,6 +1721,7 @@ class Holiday extends CommonObject } $sql .= " AND u.statut > 0"; + $sql .= " AND u.employee = 1"; // We only want employee users for holidays if ($filters) $sql .= $filters; $resql = $this->db->query($sql); From 8c8a542127ac8590cb551040813a533a01c351db Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 4 Aug 2021 15:06:08 +0200 Subject: [PATCH 0076/1055] fix error with lang search --- .../knowledgemanagement/knowledgerecord_list.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 4c7a8948cf4..d67a3c43e74 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -89,7 +89,11 @@ $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alph $search = array(); foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') { - $search[$key] = GETPOST('search_'.$key, 'alpha'); + if ($key == "lang") { + $search[$key] = GETPOST('search_'.$key, 'alpha')!='0' ? GETPOST('search_'.$key, 'alpha') : ''; + } else { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); @@ -118,15 +122,6 @@ foreach ($object->fields as $key => $val) { 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); - } elseif ($key = 'lang') { - $visible = (int) dol_eval($val['visible'], 1); - $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); } } // Extra fields From a5d11a1ccfed1da3591ae8c92715ca6a7871b85e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Aug 2021 15:46:00 +0200 Subject: [PATCH 0077/1055] Fix warning --- htdocs/admin/system/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index b745ad75818..1ca4b95856e 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -249,7 +249,7 @@ if (empty($dolibarr_main_prod)) { } print '
'; -print '$dolibarr_nocsrfcheck: '.$dolibarr_nocsrfcheck; +print '$dolibarr_nocsrfcheck: '.(empty($dolibarr_nocsrfcheck) ? '0' : $dolibarr_nocsrfcheck); if (!empty($dolibarr_nocsrfcheck)) { print '   '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 0); } From 7b702d19d45ef51b2403167e1ddf1878820a122d Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 4 Aug 2021 17:47:40 +0200 Subject: [PATCH 0078/1055] NEW : display shipping method and tracking url on shipemnt list --- htdocs/expedition/list.php | 58 +++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 5a110d33f2a..7640d94cf2b 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -58,6 +58,7 @@ $search_ref_exp = GETPOST("search_ref_exp", 'alpha'); $search_ref_liv = GETPOST('search_ref_liv', 'alpha'); $search_ref_customer = GETPOST('search_ref_customer', 'alpha'); $search_company = GETPOST("search_company", 'alpha'); +$search_shipping_method_id = GETPOST('search_shipping_method_id'); $search_tracking = GETPOST("search_tracking", 'alpha'); $search_town = GETPOST('search_town', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); @@ -115,6 +116,7 @@ $fieldstosearchall = array( 'e.ref'=>"Ref", 's.nom'=>"ThirdParty", 'e.note_public'=>'NotePublic', + 'e.shipping_method_id'=>'SendingMethod', 'e.tracking_number'=>"TrackingNumber", ); if (empty($user->socid)) { @@ -123,17 +125,18 @@ if (empty($user->socid)) { $checkedtypetiers = 0; $arrayfields = array( - 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), - 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), - 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), - 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), - 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), - 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), - 'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1), - 'e.tracking_number'=>array('label'=>$langs->trans("TrackingNumber"), 'checked'=>1), - 'e.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0), + 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1, 'position'=>1), + 'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1, 'position'=>2), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>3), + 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1, 'position'=>4), + 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1, 'position'=>5), + 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0, 'position'=>6), + 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0, 'position'=>7), + 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers, 'position'=>8), + 'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1, 'position'=>9), + 'e.shipping_method_id'=>array('label'=>$langs->trans('SendingMethod'), 'checked'=>1, 'position'=>10), + 'e.tracking_number'=>array('label'=>$langs->trans("TrackingNumber"), 'checked'=>1, 'position'=>11), + 'e.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'position'=>12), 'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), @@ -185,6 +188,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_type = ''; $search_country = ''; $search_tracking = ''; + $search_shipping_method_id = ''; $search_type_thirdparty = ''; $search_billed = ''; $search_datedelivery_start = ''; @@ -228,7 +232,7 @@ $sql = 'SELECT'; if ($sall || $search_product_category > 0 || $search_user > 0) { $sql = 'SELECT DISTINCT'; } -$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as delivery_date, e.fk_statut, e.billed, e.tracking_number,"; +$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as delivery_date, e.fk_statut, e.billed, e.tracking_number, e.fk_shipping_method,"; $sql .= " l.date_delivery as date_reception,"; $sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, "; $sql .= " typent.code as typent_code,"; @@ -315,6 +319,9 @@ if ($search_state) { if ($search_country) { $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; } +if ($search_shipping_method_id > 0) { + $sql .= " AND e.fk_shipping_method = ".$search_shipping_method_id; +} if ($search_tracking) { $sql .= natural_search("e.tracking_number", $search_tracking); } @@ -422,6 +429,9 @@ if ($search_sale > 0) { if ($search_company) { $param .= "&search_company=".urlencode($search_company); } +if ($search_shipping_method_id) { + $param .= "&search_shipping_method_id=".urlencode($search_shipping_method_id); +} if ($search_tracking) { $param .= "&search_tracking=".urlencode($search_tracking); } @@ -628,6 +638,14 @@ if (!empty($arrayfields['e.date_delivery']['checked'])) { print ''; print ''; } +if (!empty($arrayfields['e.shipping_method_id']['checked'])) +{ + // Delivery method + print ''; + $shipment->fetch_delivery_methods(); + print $form->selectarray("search_shipping_method_id", $shipment->meths, $search_shipping_method_id, 1, 0, 0, "", 1); + print "\n"; +} // Tracking number if (!empty($arrayfields['e.tracking_number']['checked'])) { print ''; @@ -718,6 +736,9 @@ if (!empty($arrayfields['e.weight']['checked'])) { if (!empty($arrayfields['e.date_delivery']['checked'])) { print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); } +if (!empty($arrayfields['e.shipping_method_id']['checked'])) { + print_liste_field_titre($arrayfields['e.shipping_method_id']['label'], $_SERVER["PHP_SELF"], "e.fk_shipping_method", "", $param, '', $sortfield, $sortorder, 'center '); +} if (!empty($arrayfields['e.tracking_number']['checked'])) { print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center '); } @@ -756,6 +777,7 @@ while ($i < min($num, $limit)) { $shipment->id = $obj->rowid; $shipment->ref = $obj->ref; + $shipment->shipping_method_id=$obj->fk_shipping_method; $companystatic->id = $obj->socid; $companystatic->ref = $obj->name; @@ -863,9 +885,19 @@ while ($i < min($num, $limit)) { print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); print "\n"; } + if (!empty($arrayfields['e.shipping_method_id']['checked'])) + { + // Get code using getLabelFromKey + $code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + print ''; + if($shipment->shipping_method_id > 0) print $langs->trans("SendingMethod".strtoupper($code)); + print ''; + } // Tracking number if (!empty($arrayfields['e.tracking_number']['checked'])) { - print ''.$obj->tracking_number."\n"; + $shipment->getUrlTrackingStatus($obj->tracking_number); + print ''.$shipment->tracking_url."\n"; + //print $form->editfieldval("TrackingNumber", 'tracking_number', $obj->tracking_url, $obj, $user->rights->expedition->creer, 'string', $obj->tracking_number); if (!$i) { $totalarray['nbfield']++; } From ee55a7de5a362fb8889a82c62ce612a522447910 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 4 Aug 2021 15:50:59 +0000 Subject: [PATCH 0079/1055] Fixing style errors. --- htdocs/expedition/list.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 7640d94cf2b..16963f3fb51 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -638,8 +638,7 @@ if (!empty($arrayfields['e.date_delivery']['checked'])) { print ''; print ''; } -if (!empty($arrayfields['e.shipping_method_id']['checked'])) -{ +if (!empty($arrayfields['e.shipping_method_id']['checked'])) { // Delivery method print ''; $shipment->fetch_delivery_methods(); @@ -885,12 +884,11 @@ while ($i < min($num, $limit)) { print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); print "\n"; } - if (!empty($arrayfields['e.shipping_method_id']['checked'])) - { + if (!empty($arrayfields['e.shipping_method_id']['checked'])) { // Get code using getLabelFromKey $code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); print ''; - if($shipment->shipping_method_id > 0) print $langs->trans("SendingMethod".strtoupper($code)); + if ($shipment->shipping_method_id > 0) print $langs->trans("SendingMethod".strtoupper($code)); print ''; } // Tracking number From 965bdbb34260f0d4b27a13966b0464492b73d1ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Aug 2021 23:08:57 +0200 Subject: [PATCH 0080/1055] Trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 76f5c18b70b..d4047e654d3 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1780,7 +1780,7 @@ ClickToDialSetup=Click To Dial module setup ClickToDialUrlDesc=Url called when a click on phone picto is done. In URL, you can use tags
__PHONETO__ that will be replaced with the phone number of person to call
__PHONEFROM__ that will be replaced with phone number of calling person (yours)
__LOGIN__ that will be replaced with clicktodial login (defined on user card)
__PASS__ that will be replaced with clicktodial password (defined on user card). ClickToDialDesc=This module change phone numbers, when using a desktop computer, into clickable links. A click will call the number. This can be used to start the phone call when using a soft phone on your desktop or when using a CTI system based on SIP protocol for example. Note: When using a smartphone, phone numbers are always clickable. ClickToDialUseTelLink=Use just a link "tel:" on phone numbers -ClickToDialUseTelLinkDesc=Use this method if your users have a softphone or a software interface, installed on the same computer as the browser, and called when you click on a link starting with "tel:" in your browser. If you need link that start with "sip:" or a full server solution (no need of local software installation), you must set this to "No" and fill next field. +ClickToDialUseTelLinkDesc=Use this method if your users have a softphone or a software interface, installed on the same computer as the browser, and called when you click on a link starting with "tel:" in your browser. If you need a link that start with "sip:" or a full server solution (no need of local software installation), you must set this to "No" and fill the next field. ##### Point Of Sale (CashDesk) ##### CashDesk=Point of Sale CashDeskSetup=Point of Sales module setup From 0a31f3dc1a77ef4468360629382e3231a59f4594 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Aug 2021 23:11:59 +0200 Subject: [PATCH 0081/1055] FIX #18341 lang not loaded --- htdocs/admin/agenda_reminder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index b3a85d1fe4b..2b2da673202 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -226,6 +226,7 @@ if (empty($conf->cron->enabled)) { // Get the max frequency of reminder if ($job->id > 0) { if ($job->status != $job::STATUS_ENABLED) { + $langs->load("cron"); print ''.$langs->trans("JobXMustBeEnabled", $langs->transnoentitiesnoconv("sendEmailsReminder")).''; } else { print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; From 04d406bd39963ea27307bf9316c7db8734f7b189 Mon Sep 17 00:00:00 2001 From: jpb Date: Thu, 5 Aug 2021 09:09:11 +0200 Subject: [PATCH 0082/1055] remove useless boolean statment --- htdocs/core/tpl/objectline_create.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index d09a3257d87..1b5cfff66f2 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -676,11 +676,11 @@ if (!empty($usemargins) && $user->rights->margins->creer) { } ?> -table_element_line != 'commande_fournisseurdet' || $this->table_element_line == 'facture_fourn_det') { ?> +table_element_line != 'commande_fournisseurdet') { ?> $("#date_start, #date_end").focusout(function() { let type = $(this).attr('type'); - let mandatoryP = $(this).attr('mandatoryperiod'); + let mandatoryP = $(this).attr('mandatoryperiod'); if (type == 1 && mandatoryP == 1 ){ if ( $(this).val() == '' && !$(this).hasClass("error") ) { $(this).addClass('error'); From 5d717113be3586694ea199316c843363f9b8ca64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Aug 2021 11:20:43 +0200 Subject: [PATCH 0083/1055] Add language key --- htdocs/langs/en_US/languages.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/languages.lang b/htdocs/langs/en_US/languages.lang index 373fdf2eab5..e3b6bed94c8 100644 --- a/htdocs/langs/en_US/languages.lang +++ b/htdocs/langs/en_US/languages.lang @@ -2,6 +2,7 @@ Language_am_ET=Ethiopian Language_ar_AR=Arabic Language_ar_EG=Arabic (Egypt) +Language_ar_MA=Arabic (Moroco) Language_ar_SA=Arabic Language_ar_TN=Arabic (Tunisia) Language_ar_IQ=Arabic (Iraq) From 047bbbb298a1da8393f07e1385fb13042751b2a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Aug 2021 14:42:28 +0200 Subject: [PATCH 0084/1055] NEW Can set/unset the usual working day of the week --- htdocs/admin/holiday.php | 376 +++++++++++++++++------------ htdocs/core/ajax/constantonoff.php | 8 +- htdocs/core/js/lib_head.js.php | 23 +- htdocs/core/lib/ajax.lib.php | 15 +- htdocs/core/lib/date.lib.php | 12 +- htdocs/langs/en_US/holiday.lang | 1 + 6 files changed, 265 insertions(+), 170 deletions(-) diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index f6ac529466e..c9214742d13 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -274,147 +274,141 @@ print ''; print '
'; -if ($conf->global->MAIN_FEATURES_LEVEL < 2) { - print dol_get_fiche_end(); - // End of page - llxFooter(); - $db->close(); - exit; -} - /* * Documents models for Holidays */ -print load_fiche_titre($langs->trans("TemplatePDFHolidays"), '', ''); +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + print load_fiche_titre($langs->trans("TemplatePDFHolidays"), '', ''); -// Defined model definition table -$def = array(); -$sql = "SELECT nom"; -$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql .= " WHERE type = '".$db->escape($type)."'"; -$sql .= " AND entity = ".$conf->entity; -$resql = $db->query($sql); -if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; + // Defined model definition table + $def = array(); + $sql = "SELECT nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; + $sql .= " WHERE type = '".$db->escape($type)."'"; + $sql .= " AND entity = ".$conf->entity; + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } + } else { + dol_print_error($db); } -} else { - dol_print_error($db); -} -print '
'; -print ''; -print ''; -print ''; -print ''; -print '\n"; -print '\n"; -print ''; -print ''; -print "\n"; + print '
'; + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print ''; + print ''; + print ''; + print '\n"; + print '\n"; + print ''; + print ''; + print "\n"; -clearstatcache(); + clearstatcache(); -foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) { - $realpath = $reldir."core/modules/holiday".$valdir; - $dir = dol_buildpath($realpath); + foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { + $realpath = $reldir."core/modules/holiday".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) { - $handle = opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { - $modulequalified = 0; - } - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { - $modulequalified = 0; - } - - if ($modulequalified) { - print ''; - // Active - if (in_array($name, $def)) { - print ''; - } else { - print '"; + + // Active + if (in_array($name, $def)) { + print ''; + } else { + print '"; + } + + // Default + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + + + print ''; + + // Preview + print ''; + + print "\n"; } - - // Default - print ''; - - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - - - print ''; - - // Preview - print ''; - - print "\n"; } } } @@ -422,11 +416,11 @@ foreach ($dirmodels as $reldir) { } } } -} -print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) { - print $module->info($langs); - } else { - print $module->description; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; } - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; + if ($modulequalified) { + print '
'; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; + if ($conf->global->HOLIDAY_ADDON_PDF == $name) { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + if ($module->type == 'pdf') { + print ''.img_object($langs->trans("Preview"), 'pdf').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; - if ($conf->global->HOLIDAY_ADDON_PDF == $name) { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'pdf').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print '
'; -print '
'; -print "
"; + print ''; + print ''; + print "
"; +} /* @@ -446,34 +440,118 @@ print ''.$langs->trans("Parameter").''; print ''.$langs->trans("Value").''; print "\n"; -$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); -$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach ($substitutionarray as $key => $val) { - $htmltext .= $key.'
'; +/*var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); +var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); +var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); +var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); +*/ +if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) { + $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 1; } -$htmltext .= '
'; +if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY)) { + $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY = 1; +} +/* +var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); +var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); +var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); +var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); +*/ -print ''; -print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); -print '
'; -$variablename = 'HOLIDAY_FREE_TEXT'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; +// Set working days +print ''; +print "".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Monday")).""; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY', array(), null, 0); } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + if (!empty($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY)) { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } } -print ''."\n"; +print ""; +print ""; -//Use draft Watermark +// Set working days +print ''; +print "".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Friday")).""; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY', array(), null, 0); +} else { + if (!empty($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY)) { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } +} +print ""; +print ""; -print ''; -print $form->textwithpicto($langs->trans("WatermarkOnDraftHolidayCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; -print ''; -print ''; -print ''."\n"; +// Set working days +print ''; +print "".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Saturday")).""; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', array(), null, 0, 0, 0, 2, 0, 1); +} else { + if (!empty($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } +} +print ""; +print ""; + +// Set working days +print ''; +print "".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Sunday")).""; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', array(), null, 0, 0, 0, 2, 0, 1); +} else { + if (!empty($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY)) { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } +} +print ""; +print ""; + +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + $substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); + $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); + $htmltext = ''.$langs->trans("AvailableVariables").':
'; + foreach ($substitutionarray as $key => $val) { + $htmltext .= $key.'
'; + } + $htmltext .= '
'; + + print ''; + print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); + print '
'; + $variablename = 'HOLIDAY_FREE_TEXT'; + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { + print ''; + } else { + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); + } + print ''."\n"; + + //Use draft Watermark + + print ''; + print $form->textwithpicto($langs->trans("WatermarkOnDraftHolidayCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; + print ''; + print ''; + print ''."\n"; +} print ''; print ''; diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index 60684c1520b..b8beec3111a 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2011-2015 Regis Houssin + * Copyright (C) 2021 Laurent Destailleur * * 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 @@ -47,6 +48,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $action = GETPOST('action', 'aZ09'); // set or del $name = GETPOST('name', 'alpha'); +$entity = GETPOST('entity', 'int'); +$value = ((GETPOST('value', 'int') || GETPOST('value', 'int') == '0') ? GETPOST('value', 'int') : 1); /* @@ -64,9 +67,6 @@ top_httphead(); // Registering the new value of constant if (!empty($action) && !empty($name)) { - $entity = GETPOST('entity', 'int'); - $value = (GETPOST('value') ?GETPOST('value') : 1); - if ($user->admin) { if ($action == 'set') { dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index db63b1a75d4..0d5905b4351 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -549,20 +549,27 @@ function hideMessage(fieldId,message) { * @param int strict Strict * @param int forcereload Force reload * @param int userid User id + * @param int value Value to set * @param string token Token */ -function setConstant(url, code, input, entity, strict, forcereload, userid, token) { +function setConstant(url, code, input, entity, strict, forcereload, userid, token, value) { var saved_url = url; /* avoid undefined url */ $.post( url, { action: "set", name: code, entity: entity, - token: token + token: token, + value: value }, function() { /* handler for success of post */ - console.log("url request success forcereload="+forcereload); - $("#set_" + code).hide(); - $("#del_" + code).show(); + console.log("url request success forcereload="+forcereload+" value="+value); + if (value == 0) { + $("#set_" + code).show(); + $("#del_" + code).hide(); + } else { + $("#set_" + code).hide(); + $("#del_" + code).show(); + } $.each(input, function(type, data) { // Enable another element if (type == "disabled" && strict != 1) { @@ -610,7 +617,7 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke if (forcereload) { location.reload(); } - }).fail(function(error) { location.reload(); }); /* When it fails, we always force reload to have setEventErrorMEssage in session visible */ + }).fail(function(error) { location.reload(); }); /* When it fails, we always force reload to have setEventErrorMessages in session visible */ } /* @@ -681,7 +688,7 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke if (forcereload) { location.reload(); } - }).fail(function(error) { location.reload(); }); /* When it fails, we always force reload to have setEventErrorMEssage in session visible */ + }).fail(function(error) { location.reload(); }); /* When it fails, we always force reload to have setEventErrorMessages in session visible */ } /* @@ -716,7 +723,7 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton, text : yesButton, click : function() { if (action == "set") { - setConstant(url, code, input, entity, strict, 0, userid, token); + setConstant(url, code, input, entity, strict, 0, userid, token, 1); } else if (action == "del") { delConstant(url, code, input, entity, strict, 0, userid, token); } diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 99cf4e4f8d1..b59b40b8c9d 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -540,14 +540,15 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = * @param string $code Name of constant * @param array $input Array of complementary actions to do if success ("disabled"|"enabled'|'set'|'del') => CSS element to switch, 'alert' => message to show, ... Example: array('disabled'=>array(0=>'cssid')) * @param int $entity Entity. Current entity is used if null. - * @param int $revertonoff Revert on/off + * @param int $revertonoff 1=Revert on/off * @param int $strict Use only "disabled" with delConstant and "enabled" with setConstant * @param int $forcereload Force to reload page if we click/change value (this is supported only when there is no 'alert' option in input) * @param string $marginleftonlyshort 1 = Add a short left margin on picto, 2 = Add a larger left margin on picto, 0 = No left margin. Works for fontawesome picto only. * @param int $forcenoajax 1 = Force to use a ahref link instead of ajax code. + * @param int $setzeroinsteadofdel 1 = Set constantto '0' instead of deleting it * @return string */ -function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0) +function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0, $setzeroinsteadofdel = 0) { global $conf, $langs, $user; @@ -593,9 +594,13 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof if (input.alert.del.yesButton) yesButton = input.alert.del.yesButton; if (input.alert.del.noButton) noButton = input.alert.del.noButton; confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton, strict, userid, token); - } else { - delConstant(url, code, input, entity, 0, '.$forcereload.', userid, token); - } + } else {'; + if (empty($setzeroinsteadofdel)) { + $out .=' delConstant(url, code, input, entity, 0, '.$forcereload.', userid, token);'; + } else { + $out .=' setConstant(url, code, input, entity, 0, '.$forcereload.', userid, token, 0);'; + } + $out .= ' } }); }); '."\n"; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index fe21071901a..8fe9352457b 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -668,15 +668,16 @@ function getGMTEasterDatetime($year) * * @param int $timestampStart Timestamp start (UTC with hour, min, sec = 0) * @param int $timestampEnd Timestamp end (UTC with hour, min, sec = 0) - * @param string $country_code Country code - * @param int $lastday Last day is included, 0: no, 1:yes + * @param string $country_code Country code + * @param int $lastday Last day is included, 0: no, 1:yes * @param int $includesaturday Include saturday as non working day (-1=use setup, 0=no, 1=yes) * @param int $includesunday Include sunday as non working day (-1=use setup, 0=no, 1=yes) * @param int $includefriday Include friday as non working day (-1=use setup, 0=no, 1=yes) - * @return int|string Number of non working days or error message string if error + * @param int $includemonday Include monday as non working day (-1=use setup, 0=no, 1=yes) + * @return int|string Number of non working days or error message string if error * @see num_between_day(), num_open_day() */ -function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $lastday = 0, $includesaturday = -1, $includesunday = -1, $includefriday = -1) +function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $lastday = 0, $includesaturday = -1, $includesunday = -1, $includefriday = -1, $includemonday = -1) { global $db, $conf, $mysoc; @@ -690,6 +691,9 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', if (empty($country_code)) { $country_code = $mysoc->country_code; } + if ($includemonday < 0) { + $includemonday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY : 0); + } if ($includefriday < 0) { $includefriday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY : 0); } diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 0e6b1d69b36..dfbd97cdbdc 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -133,3 +133,4 @@ WatermarkOnDraftHolidayCards=Watermarks on draft leave requests HolidaysToApprove=Holidays to approve NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays HolidayBalanceMonthlyUpdate=Monthly update of holiday balance +XIsAUsualNonWorkingDay=%s is usualy a NON working day \ No newline at end of file From fca3980dce3b2a5fa0b07340155786158f49ff84 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Aug 2021 15:15:03 +0200 Subject: [PATCH 0085/1055] FIX Can't remove a permission of a group --- htdocs/user/group/perms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 9fc4426ecac..3ccbcf94d05 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -315,7 +315,7 @@ if ($object->id > 0) { if (in_array($obj->id, $permsgroupbyentity[$entity])) { // Own permission by group if ($caneditperms) { - print 'id.'">'; + print 'id.'&token='.newToken().'">'; //print img_edit_remove($langs->trans("Remove")); print img_picto($langs->trans("Remove"), 'switch_on'); print ''; From 591b8acd513eb75483e336f8a1c871bbf20b1853 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Aug 2021 15:57:51 +0200 Subject: [PATCH 0086/1055] FIX show info of company into user dropdown --- htdocs/main.inc.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2ceb2175799..e4677499bd6 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2015,27 +2015,25 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= ' '.$langs->trans("ShowCompanyInfos").''; $dropdownBody .= '
'; - if (!empty($conf->global->MAIN_INFO_SIREN)) { - $dropdownBody .= '
'.$langs->transcountry("ProfId1Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIREN).''; + if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { + $dropdownBody .= '
'.$langs->transcountry("ProfId1", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIREN).''; } - if (!empty($conf->global->MAIN_INFO_SIRET)) { - $dropdownBody .= '
'.$langs->transcountry("ProfId2Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIRET).''; + if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { + $dropdownBody .= '
'.$langs->transcountry("ProfId2", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIRET).''; } - if (!empty($conf->global->MAIN_INFO_APE)) { - $dropdownBody .= '
'.$langs->transcountry("ProfId3Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_APE).''; + if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { + $dropdownBody .= '
'.$langs->transcountry("ProfId3", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_APE).''; } - if (!empty($conf->global->MAIN_INFO_RCS)) { - $dropdownBody .= '
'.$langs->transcountry("ProfId4Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_RCS).''; + if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { + $dropdownBody .= '
'.$langs->transcountry("ProfId4", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_RCS).''; } - if (!empty($conf->global->MAIN_INFO_PROFID5)) { - $dropdownBody .= '
'.$langs->transcountry("ProfId5Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID5).''; + if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { + $dropdownBody .= '
'.$langs->transcountry("ProfId5", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID5).''; } - if (!empty($conf->global->MAIN_INFO_PROFID6)) { - $dropdownBody .= '
'.$langs->transcountry("ProfId6Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID6).''; - } - if (!empty($conf->global->MAIN_INFO_TVAINTRA)) { - $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_TVAINTRA).''; + if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { + $dropdownBody .= '
'.$langs->transcountry("ProfId6", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID6).''; } + $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_TVAINTRA).''; $dropdownBody .= '
'; From 6b20b32f07852c990367a3830c23d5d6a746af51 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 5 Aug 2021 16:31:21 +0200 Subject: [PATCH 0087/1055] Fix lang error on hrm/index.php --- htdocs/hrm/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index fe2c42b0d1b..8a294a47e2c 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -234,7 +234,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { print ''; print ''.$holidaystatic->getNomUrl(1).''; print ''.$userstatic->getNomUrl(-1, 'leave').''; - print ''.dol_escape_htmltag($typeleaves[$obj->fk_type]['label']).''; + print ''.dol_escape_htmltag($langs->trans($typeleaves[$obj->fk_type]['code'])).''; $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; From d249ffd5adf97f9498ffba3840bf8e1d0d9cc925 Mon Sep 17 00:00:00 2001 From: Erik van Berkum Date: Fri, 6 Aug 2021 13:40:19 +0900 Subject: [PATCH 0088/1055] Fix: Change French word to English in English array. --- htdocs/mrp/class/mo.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index ee4b64471c3..df5dcba60ad 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -118,7 +118,7 @@ class Mo extends CommonObject 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>1010), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'StatusMOProduced', '9'=>'Canceled')), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'InProgress', '3'=>'StatusMOProduced', '9'=>'Canceled')), ); public $rowid; public $ref; From 80c63cae5e6ddaffead1a5c8c14346b7bed22c36 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Fri, 6 Aug 2021 08:32:40 +0200 Subject: [PATCH 0089/1055] add GETPOST to 'target' value on new bookmarks -> allows to set default value --- htdocs/bookmarks/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 1094eabf0c6..8ac05863ed0 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -40,7 +40,7 @@ $action = GETPOST("action", "alpha"); $title = (string) GETPOST("title", "alpha"); $url = (string) GETPOST("url", "alpha"); $urlsource = GETPOST("urlsource", "alpha"); -$target = GETPOST("target", "alpha"); +$target = GETPOST("target", "int"); $userid = GETPOST("userid", "int"); $position = GETPOST("position", "int"); $backtopage = GETPOST('backtopage', 'alpha'); @@ -169,7 +169,7 @@ if ($action == 'create') { // Target print ''.$langs->trans("BehaviourOnClick").''; $liste = array(0=>$langs->trans("ReplaceWindow"), 1=>$langs->trans("OpenANewWindow")); - print $form->selectarray('target', $liste, 1); + print $form->selectarray('target', $liste, GETPOST('target', 'int')); print ''.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").''; // Owner From 470eec7f5086723e5f7a1bb723db1fb018dc1206 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Aug 2021 11:32:39 +0200 Subject: [PATCH 0090/1055] Remove (hide) not used field "deductible" on social contributions. --- htdocs/admin/dict.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 1bfc3611439..6835ce82e60 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -202,7 +202,7 @@ $tabsql[3] = "SELECT r.rowid as rowid, r.code_region as state_code, r.nom as lib $tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite FROM ".MAIN_DB_PREFIX."c_country AS c"; $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c"; $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a"; -$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1"; +$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1"; $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.position, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid"; $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c"; $tabsql[10] = "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; @@ -294,7 +294,7 @@ $tabfield[3] = "code,libelle,country_id,country"; $tabfield[4] = "code,label"; $tabfield[5] = "code,label"; $tabfield[6] = "code,libelle,type,color,position"; -$tabfield[7] = "code,libelle,country,accountancy_code,deductible"; +$tabfield[7] = "code,libelle,country,accountancy_code"; $tabfield[8] = "code,libelle,country_id,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfield[9] = "code,label,unicode"; $tabfield[10] = "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; @@ -340,7 +340,7 @@ $tabfieldvalue[3] = "code,libelle,country"; $tabfieldvalue[4] = "code,label"; $tabfieldvalue[5] = "code,label"; $tabfieldvalue[6] = "code,libelle,type,color,position"; -$tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible"; +$tabfieldvalue[7] = "code,libelle,country,accountancy_code"; $tabfieldvalue[8] = "code,libelle,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfieldvalue[9] = "code,label,unicode"; $tabfieldvalue[10] = "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; @@ -386,7 +386,7 @@ $tabfieldinsert[3] = "code_region,nom,fk_pays"; $tabfieldinsert[4] = "code,label"; $tabfieldinsert[5] = "code,label"; $tabfieldinsert[6] = "code,libelle,type,color,position"; -$tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible"; +$tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code"; $tabfieldinsert[8] = "code,libelle,fk_country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfieldinsert[9] = "code_iso,label,unicode"; $tabfieldinsert[10] = "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; From 6cefd0a756429f77f957f1fd89ca0523fda33764 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Aug 2021 12:18:51 +0200 Subject: [PATCH 0091/1055] FIX Link of download main doc on vat list --- htdocs/compta/tva/list.php | 10 +++++++++- htdocs/core/class/html.formfile.class.php | 5 +++-- htdocs/core/lib/files.lib.php | 9 ++++++--- htdocs/theme/eldy/global.inc.php | 3 +++ htdocs/theme/md/style.css.php | 6 ++++++ 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 69ce8ae8ae5..1dc0180bd60 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -31,6 +31,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; @@ -135,6 +136,7 @@ if (empty($reshook)) { $form = new Form($db); $formother = new FormOther($db); +$formfile = new FormFile($db); $tva_static = new Tva($db); $bankstatic = new Account($db); $accountingjournal = new AccountingJournal($db); @@ -445,7 +447,13 @@ while ($i < min($num, $limit)) { // Ref if (!empty($arrayfields['t.rowid']['checked'])) { - print ''.$tva_static->getNomUrl(1).''; + print ''; + print $tva_static->getNomUrl(1); + $filename = dol_sanitizeFileName($tva_static->ref); + $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id; + print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp'); + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 2b8a2d15aff..3a5cff5ea9e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -985,9 +985,10 @@ class FormFile * @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module. * @param string $filedir Full path to directory to scan * @param string $filter Filter filenames on this regex string (Example: '\.pdf$') + * @param string $morecss Add more css to the download picto * @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles */ - public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '') + public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '', $morecss = 'valignmiddle') { global $conf, $langs; @@ -1019,7 +1020,7 @@ class FormFile $out .= ''."\n"; if (!empty($file_list)) { $out = '