From 5bae9db0a82292d2eb2c01268cce2b738bc488e3 Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 2 Jun 2020 17:29:55 +0200 Subject: [PATCH 01/39] FIX: Fix detect distached product and set to received completely when the supplier order have services (support STOCK_SUPPORTS_SERVICES) --- htdocs/fourn/class/fournisseur.commande.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 092c3df8dc2..66788cdb126 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3063,6 +3063,7 @@ class CommandeFournisseur extends CommonOrder { if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) { + require_once DOL_DOCUMENT_ROOT.'/htdocs/product/class/product.class.php'; $date_liv = dol_now(); // Build array with quantity deliverd by product @@ -3070,7 +3071,11 @@ class CommandeFournisseur extends CommonOrder $qtydelivered[$line->fk_product]+=$line->qty; } foreach($this->lines as $line) { - $qtywished[$line->fk_product]+=$line->qty; + if ($line->product_type == Product::TYPE_PRODUCT || + ($line->product_type == Product::TYPE_SERVICE && !empty($conf->global->STOCK_SUPPORTS_SERVICES)) + ) { + $qtywished[$line->fk_product] += $line->qty; + } } //Compare array $diff_array=array_diff_assoc($qtydelivered, $qtywished); // Warning: $diff_array is done only on common keys. From e2696d7718f4ef6e344c0c50ff7509af3996d262 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 15 Jan 2021 09:58:04 +0100 Subject: [PATCH 02/39] FIX Societe Merge : "unknow column fk_soc" + "Delivery" label --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_mrp_production.sql | 3 ++- htdocs/societe/card.php | 2 +- 3 files changed, 6 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 309d4d4b170..f1ea3d237a3 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 @@ -555,3 +555,6 @@ ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging varchar(64); ALTER TABLE llx_projet ADD COLUMN fk_opp_status_end integer DEFAULT NULL; +ALTER TABLE llx_mrp_production ADD COLUMN fk_soc integer NOT NULL; + + diff --git a/htdocs/install/mysql/tables/llx_mrp_production.sql b/htdocs/install/mysql/tables/llx_mrp_production.sql index bd0cd722f1a..d2b44427f58 100644 --- a/htdocs/install/mysql/tables/llx_mrp_production.sql +++ b/htdocs/install/mysql/tables/llx_mrp_production.sql @@ -16,7 +16,8 @@ CREATE TABLE llx_mrp_production( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - fk_mo integer NOT NULL, + fk_mo integer NOT NULL, + fk_soc integer NOT NULL, position integer NOT NULL DEFAULT 0, fk_product integer NOT NULL, fk_warehouse integer, diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 356c70baf3d..2f51995c785 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -249,7 +249,7 @@ if (empty($reshook)) 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', - 'Livraison' => '/delivery/class/delivery.class.php', + 'Delivery' => '/delivery/class/delivery.class.php', 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', 'Ticket' => '/ticket/class/ticket.class.php', From 8dfe39258b856e91ee5d3b47c2bf230f323069f3 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Wed, 27 Jan 2021 23:46:09 +0100 Subject: [PATCH 03/39] FIX 11.0 - when a mandatory extrafield of type sellist contains '0' it should be considered empty and trigger an error message upon insertion --- htdocs/core/class/commonobject.class.php | 1 + htdocs/core/class/extrafields.class.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1ff633f46ce..f2c61bc86a3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5238,6 +5238,7 @@ abstract class CommonObject $mandatorypb = false; if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb = true; if ($this->array_options[$key] === '') $mandatorypb = true; + if ($attributeType == 'sellist' && $this->array_options[$key] == '0') $mandatorypb = true; if ($mandatorypb) { dol_syslog("Mandatory extra field ".$key." is empty"); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 57e2bf4284a..ed85a328edc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2060,9 +2060,12 @@ class ExtraFields if ($this->attributes[$object->table_element]['required'][$key]) // Value is required { - // Check if empty without using GETPOST, value can be alpha, int, array, etc... + // check if functionally empty without using GETPOST (depending on the type of extrafield, a + // technically non-empty value may be treated as empty functionally). + // value can be alpha, int, array, etc... if ((!is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] != 'select' && $_POST["options_".$key] != '0') || (!is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'select') + || (!is_array($_POST["options_".$key]) && isset($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'sellist' && $_POST['options_' . $key] == '0') || (is_array($_POST["options_".$key]) && empty($_POST["options_".$key]))) { //print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key]; From 83dc1e8cd088313721487601a8abce3755c3eaea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Jan 2021 23:27:01 +0100 Subject: [PATCH 04/39] Fix responsive --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index a4ad5ec590e..402e85d9b39 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1259,7 +1259,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { // Prospect level - print ''; + print ''; print $companystatic->getLibProspLevel(); print ""; if (!$i) $totalarray['nbfield']++; From 086b23f66c497e0177b658cde41ab12ed8282946 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Jan 2021 23:28:33 +0100 Subject: [PATCH 05/39] Fix responsive --- htdocs/societe/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 402e85d9b39..5b5e9685628 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1259,7 +1259,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { // Prospect level - print ''; + print ''; print $companystatic->getLibProspLevel(); print ""; if (!$i) $totalarray['nbfield']++; @@ -1283,7 +1283,7 @@ while ($i < min($num, $limit)) // Parent company if (!empty($arrayfields['s2.nom']['checked'])) { - print ''; + print ''; if ($companystatic->fk_parent > 0) { $companyparent->fetch($companystatic->fk_parent); From 413fc95f9a3daec0924c5fcd52a8756fd6986cee Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 28 Jan 2021 23:40:15 +0100 Subject: [PATCH 06/39] FIX: Accountancy - label_operation is used instead of label_compte --- htdocs/accountancy/class/bookkeeping.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a700ebecb1b..7e7cd787a56 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -365,7 +365,7 @@ class BookKeeping extends CommonObject $sql .= ", ".(!empty($this->subledger_account) ? ("'".$this->db->escape($this->subledger_account)."'") : "NULL"); $sql .= ", ".(!empty($this->subledger_label) ? ("'".$this->db->escape($this->subledger_label)."'") : "NULL"); $sql .= ", '".$this->db->escape($this->numero_compte)."'"; - $sql .= ", ".(!empty($this->label_operation) ? ("'".$this->db->escape($this->label_operation)."'") : "NULL"); + $sql .= ", ".(!empty($this->label_compte) ? ("'".$this->db->escape($this->label_compte)."'") : "NULL"); $sql .= ", '".$this->db->escape($this->label_operation)."'"; $sql .= ", ".$this->debit; $sql .= ", ".$this->credit; From 77b0075d71a32f44fcc06426cf4f63478e7c6c31 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Fri, 29 Jan 2021 10:50:11 +0100 Subject: [PATCH 07/39] Update pdf_azur.modules.php --- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 3b09d639bf0..a17f8c9a8ac 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -243,7 +243,7 @@ class pdf_azur extends ModelePDFPropales $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; } else { - $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default + $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative } From 215e36bb2ef791d148e1e014c87f9021e983314f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Jan 2021 11:19:33 +0100 Subject: [PATCH 08/39] Fix typo --- htdocs/langs/en_US/errors.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 5634905da6e..a7a7e12db14 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -59,6 +59,7 @@ ErrorDirNotFound=Directory %s not found (Bad path, wrong permissions or a ErrorFunctionNotAvailableInPHP=Function %s is required for this feature but is not available in this version/setup of PHP. ErrorDirAlreadyExists=A directory with this name already exists. ErrorFileAlreadyExists=A file with this name already exists. +ErrorDestinationAlreadyExists=Another file with the name %s already exists. ErrorPartialFile=File not received completely by server. ErrorNoTmpDir=Temporary directy %s does not exists. ErrorUploadBlockedByAddon=Upload blocked by a PHP/Apache plugin. From cfca26a727e1aac64e73cca026f31dc4385cd079 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 29 Jan 2021 16:20:43 +0100 Subject: [PATCH 09/39] Fix fix --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 4 ---- htdocs/install/mysql/tables/llx_mrp_production.sql | 1 - htdocs/mrp/class/mo.class.php | 2 +- 3 files changed, 1 insertion(+), 6 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 f1ea3d237a3..31cdf9c8d62 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 @@ -554,7 +554,3 @@ INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging varchar(64); ALTER TABLE llx_projet ADD COLUMN fk_opp_status_end integer DEFAULT NULL; - -ALTER TABLE llx_mrp_production ADD COLUMN fk_soc integer NOT NULL; - - diff --git a/htdocs/install/mysql/tables/llx_mrp_production.sql b/htdocs/install/mysql/tables/llx_mrp_production.sql index d2b44427f58..36129a54aea 100644 --- a/htdocs/install/mysql/tables/llx_mrp_production.sql +++ b/htdocs/install/mysql/tables/llx_mrp_production.sql @@ -17,7 +17,6 @@ CREATE TABLE llx_mrp_production( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, fk_mo integer NOT NULL, - fk_soc integer NOT NULL, position integer NOT NULL DEFAULT 0, fk_product integer NOT NULL, fk_warehouse integer, diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 274782a14ea..2de6aecc4bf 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1352,7 +1352,7 @@ class Mo extends CommonObject */ public static function replaceThirdparty($db, $origin_id, $dest_id) { - $tables = array('mrp_production'); + $tables = array('mrp_mo'); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } From 2436e7c5b24dc9332e6208056ef3efa4ac0ab88f Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 29 Jan 2021 19:39:50 +0100 Subject: [PATCH 10/39] FIX: 13 create MO, Column 'tms' cannot be null --- 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 274782a14ea..17d4217bbcd 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -106,7 +106,7 @@ class Mo extends CommonObject 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>-1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), 'date_valid' => array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-2, 'position'=>502,), 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), From 1063b97c221bf02387edd8999a784d867c1b65dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jan 2021 12:55:38 +0100 Subject: [PATCH 11/39] Close #16099 Close #16098 --- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 80433eb2201..760e678e839 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -242,7 +242,7 @@ class pdf_cyan extends ModelePDFPropales $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; } else { - $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default + $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative } From ca7738c9b392128b872adb55f73536139e0c952e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jan 2021 13:57:42 +0100 Subject: [PATCH 12/39] FIX #16107 --- htdocs/api/class/api_documents.class.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 2d6a598398c..ebeeac5c5b9 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -425,7 +425,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Error while fetching object: '.$object->error); } - $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product'); } elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a509d3bd7a6..694612bde07 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5652,7 +5652,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart = ' $arrayforoldpath = array('cheque', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment'); if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[] = 'product'; if (!empty($level) && in_array($modulepart, $arrayforoldpath)) { - // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided. + // This part should be removed once all code is using "get_exdir" to forge path, with parameter $object and $modulepart provided. if (empty($alpha)) $num = preg_replace('/([^0-9])/i', '', $num); else $num = preg_replace('/^.*\-/i', '', $num); $num = substr("000".$num, -$level); From 58dec39f94e2edef22855e2c19ccba19a65de196 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jan 2021 17:07:13 +0100 Subject: [PATCH 13/39] Fix start and end month for turnover report. --- htdocs/compta/stats/index.php | 138 ++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 63 deletions(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 0be6659f7b4..03c128e841f 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -44,12 +44,12 @@ $nbofyear = 4; $year = GETPOST('year', 'int'); if (empty($year)) { - $year_current = strftime("%Y", dol_now()); - $month_current = strftime("%m", dol_now()); + $year_current = dol_print_date(dol_now(), "%Y"); + $month_current = dol_print_date(dol_now(), "%m"); $year_start = $year_current - ($nbofyear - 1); } else { $year_current = $year; - $month_current = strftime("%m", dol_now()); + $month_current = dol_print_date(dol_now(), "%m"); $year_start = $year - ($nbofyear - 1); } $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); @@ -58,12 +58,12 @@ $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); // We define date_start and date_end if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q = GETPOST("q") ?GETPOST("q") : 0; + $q = GETPOST("q") ? GETPOST("q") : 0; if ($q == 0) { // We define date_start and date_end $year_end = $year_start + ($nbofyear - 1); - $month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); + $month_start = GETPOSTISSET("month") ? GETPOST("month", 'int') : ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); if (!GETPOST('month')) { if (!GETPOST("year") && $month_start > $month_current) @@ -86,8 +86,10 @@ $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); $tmps = dol_getdate($date_start); +$mothn_start = $tmps['mon']; $year_start = $tmps['year']; $tmpe = dol_getdate($date_end); +$month_end = $tmpe['mon']; $year_end = $tmpe['year']; $nbofyear = ($year_end - $year_start) + 1; @@ -306,7 +308,7 @@ $now = dol_now(); $casenow = dol_print_date($now, "%Y-%m"); // Loop on each month -$nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START - 1) : 0; +$nb_mois_decalage = GETPOSTISSET('date_startmonth') ? (GETPOST('date_startmonth', 'int') - 1) : (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 0 : ($conf->global->SOCIETE_FISCAL_MONTH_START - 1)); for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { $mois_modulo = $mois; // ajout @@ -338,68 +340,75 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) if ($annee >= $year_start) // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output. { if ($modecompta == 'CREANCES-DETTES') { - // Valeur CA du mois w/o VAT + // Value turnover of month w/o VAT print ''; - if ($cum_ht[$case]) - { - $now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre. - print ''.price($cum_ht[$case], 1).''; - } else { - if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print ' '; } + if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) { + if ($cum_ht[$case]) { + $now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre. + print ''.price($cum_ht[$case], 1).''; + } else { + if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print ' '; } + } } print ""; } - // Valeur CA du mois + // Value turnover of month print ''; - if ($cum[$case]) - { - $now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre. - if ($modecompta != 'BOOKKEEPING') print ''; - print price($cum[$case], 1); - if ($modecompta != 'BOOKKEEPING') print ''; - } else { - if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print ' '; } + if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) { + if ($cum[$case]) { + $now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre. + if ($modecompta != 'BOOKKEEPING') print ''; + print price($cum[$case], 1); + if ($modecompta != 'BOOKKEEPING') print ''; + } else { + if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print ' '; } + } } print ""; - // Pourcentage du mois - if ($annee_decalage > $minyear && $case <= $casenow) - { - if ($cum[$caseprev] && $cum[$case]) + // Percentage of month + print ''; + //var_dump($annee.' '.$year_end.' '.$mois.' '.$month_end); + if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) { + if ($annee_decalage > $minyear && $case <= $casenow) { - $percent = (round(($cum[$case] - $cum[$caseprev]) / $cum[$caseprev], 4) * 100); - //print "X $cum[$case] - $cum[$caseprev] - $cum[$caseprev] - $percent X"; - print ''.($percent >= 0 ? "+$percent" : "$percent").'%'; + if ($cum[$caseprev] && $cum[$case]) + { + $percent = (round(($cum[$case] - $cum[$caseprev]) / $cum[$caseprev], 4) * 100); + //print "X $cum[$case] - $cum[$caseprev] - $cum[$caseprev] - $percent X"; + print ($percent >= 0 ? "+$percent" : "$percent").'%'; + } + if ($cum[$caseprev] && !$cum[$case]) + { + print '-100%'; + } + if (!$cum[$caseprev] && $cum[$case]) + { + //print '+Inf%'; + print '-'; + } + if (isset($cum[$caseprev]) && !$cum[$caseprev] && !$cum[$case]) + { + print '+0%'; + } + if (!isset($cum[$caseprev]) && !$cum[$case]) + { + print '-'; + } + } else { + if ($minyearmonth <= $case && $case <= $maxyearmonth) { print '-'; } else { print ' '; } } - if ($cum[$caseprev] && !$cum[$case]) - { - print '-100%'; - } - if (!$cum[$caseprev] && $cum[$case]) - { - //print '+Inf%'; - print '-'; - } - if (isset($cum[$caseprev]) && !$cum[$caseprev] && !$cum[$case]) - { - print '+0%'; - } - if (!isset($cum[$caseprev]) && !$cum[$case]) - { - print '-'; - } - } else { - print ''; - if ($minyearmonth <= $case && $case <= $maxyearmonth) { print '-'; } else { print ' '; } - print ''; } + print ''; if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) print ' '; } - $total_ht[$annee] += ((!empty($cum_ht[$case])) ? $cum_ht[$case] : 0); - $total[$annee] += $cum[$case]; + if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) { + $total_ht[$annee] += ((!empty($cum_ht[$case])) ? $cum_ht[$case] : 0); + $total[$annee] += $cum[$case]; + } } print ''; @@ -470,34 +479,37 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) } */ -// Affiche total +// Show total print ''.$langs->trans("Total").''; for ($annee = $year_start; $annee <= $year_end; $annee++) { if ($modecompta == 'CREANCES-DETTES') { // Montant total HT - if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) - { - print ''.($total_ht[$annee] ?price($total_ht[$annee]) : "0").""; + if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { + print ''; + print ($total_ht[$annee] ?price($total_ht[$annee]) : "0"); + print ""; } else { print ' '; } } - // Montant total - if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) - { - print ''.($total[$annee] ?price($total[$annee]) : "0").""; + // Total amount + if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { + print ''; + print ($total[$annee] ?price($total[$annee]) : "0"); + print ""; } else { print ' '; } // Pourcentage total - if ($annee > $minyear && $annee <= max($nowyear, $maxyear)) - { + if ($annee > $minyear && $annee <= max($nowyear, $maxyear)) { if ($total[$annee - 1] && $total[$annee]) { $percent = (round(($total[$annee] - $total[$annee - 1]) / $total[$annee - 1], 4) * 100); - print ''.($percent >= 0 ? "+$percent" : "$percent").'%'; + print ''; + print ($percent >= 0 ? "+$percent" : "$percent").'%'; + print ''; } if ($total[$annee - 1] && !$total[$annee]) { From 244ee05a9c3a07123b1805e4df0e2797b31fdcf1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jan 2021 18:09:13 +0100 Subject: [PATCH 14/39] FIX #14290 #15900 --- htdocs/comm/propal/list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/expedition/list.php | 17 ++++++++++++----- htdocs/fourn/commande/list.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 76914e2c13a..7a06f7f4a86 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -282,7 +282,7 @@ $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos' //llxHeader('',$langs->trans('Proposal'),$help_url); $sql = 'SELECT'; -if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT'; $sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql .= " typent.code as typent_code,"; $sql .= " ava.rowid as availability,"; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 1e7e0d1d9d7..ef10ffac25f 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -263,7 +263,7 @@ $help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_P // llxHeader('',$title,$help_url); $sql = 'SELECT'; -if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT'; $sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 71184d905b3..f655de32646 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -416,7 +416,7 @@ $formcompany = new FormCompany($db); $thirdpartystatic = new Societe($db); $sql = 'SELECT'; -if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT'; $sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; $sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql .= ' f.fk_user_author,'; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index a7f44bf483e..9bc0b6c0fac 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -213,8 +213,9 @@ $helpurl = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Ex llxHeader('', $langs->trans('ListOfSendings'), $helpurl); $sql = 'SELECT'; -if ($sall || $search_product_category > 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 date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,"; +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 date_livraison, e.fk_statut, e.billed,"; +$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,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; @@ -244,11 +245,12 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON e.fk_user_author = u.rowid'; - +if ($search_user > 0) { // Get link to order to get the order id in eesource.fk_source + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as eesource ON eesource.fk_target = e.rowid AND eesource.targettype = 'shipping' AND eesource.sourcetype = 'commande'"; +} // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -if ($search_user > 0) -{ +if ($search_user > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } @@ -275,6 +277,11 @@ if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; +if ($search_user > 0) +{ + // The contact on a shipment is also the contact of the order. + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = eesource.fk_source AND ec.fk_socpeople = ".$db->escape($search_user); +} if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp); if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv); if ($search_company) $sql .= natural_search('s.nom', $search_company); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index ce638cdffcb..7b5fc220357 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -501,7 +501,7 @@ $help_url = ''; // llxHeader('',$title,$help_url); $sql = 'SELECT'; -if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT'; $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index ded5d9ca2bf..662e0591611 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -255,7 +255,7 @@ $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; //llxHeader('',$langs->trans('CommRequest'),$help_url); $sql = 'SELECT'; -if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT'; $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,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; From 80714d8d6d0deab3a7c13322b4bfadbb9fa954a3 Mon Sep 17 00:00:00 2001 From: "Paul Vincent M. Ancajas" Date: Sun, 31 Jan 2021 16:09:35 +0800 Subject: [PATCH 15/39] Fix/FIX: Show notification in Event box of user in his dashboard if assigned by others --- htdocs/comm/action/class/actioncomm.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 7355040e00c..a79060e6af8 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1201,14 +1201,21 @@ class ActionComm extends CommonObject } $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + if (!$user->rights->agenda->allactions->read) { // If bloack Added by PV + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources AS ar ON a.id = ar.fk_actioncomm"; + } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE 1 = 1"; if (empty($load_state_board)) $sql .= " AND a.percent >= 0 AND a.percent < 100"; $sql .= " AND a.entity IN (".getEntity('agenda').")"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; if ($user->socid) $sql .= " AND a.fk_soc = ".$user->socid; - if (!$user->rights->agenda->allactions->read) $sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id.")"; - + if (!$user->rights->agenda->allactions->read) { + $sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id; + $sql .= " OR ar.fk_element = ".$user->id; // Added by PV + $sql .= ")"; + } + $resql = $this->db->query($sql); if ($resql) { From 726e0ceff043339ef56d479faedaaf48c4fc2c14 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 31 Jan 2021 08:16:59 +0000 Subject: [PATCH 16/39] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index a79060e6af8..143dbf064a9 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1215,7 +1215,7 @@ class ActionComm extends CommonObject $sql .= " OR ar.fk_element = ".$user->id; // Added by PV $sql .= ")"; } - + $resql = $this->db->query($sql); if ($resql) { From 7887d4cc8e8f9e039d72621e472dc13ae957cbdc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Jan 2021 12:48:40 +0100 Subject: [PATCH 17/39] Fix price2num on all GETPOST('remise_percent') --- htdocs/comm/propal/card.php | 10 ++--- htdocs/commande/card.php | 10 ++--- htdocs/compta/facture/card-rec.php | 6 +-- htdocs/compta/facture/card.php | 63 ++++++++++++++---------------- htdocs/contrat/card.php | 12 +++--- htdocs/core/lib/date.lib.php | 4 +- htdocs/core/lib/functions.lib.php | 6 +-- htdocs/fourn/commande/card.php | 12 +++--- htdocs/fourn/facture/card.php | 8 ++-- htdocs/product/card.php | 18 ++++----- htdocs/product/fournisseurs.php | 6 +-- htdocs/product/price.php | 6 +-- htdocs/supplier_proposal/card.php | 18 ++++----- 13 files changed, 87 insertions(+), 92 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8b5054afd7f..e823ec95cdc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -354,8 +354,8 @@ if (empty($reshook)) $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->remise_percent = GETPOST('remise_percent'); - $object->remise_absolue = GETPOST('remise_absolue'); + $object->remise_percent = price2num(GETPOST('remise_percent'), 2); + $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); $object->socid = GETPOST('socid', 'int'); $object->contact_id = GETPOST('contactid', 'int'); $object->fk_project = GETPOST('projectid', 'int'); @@ -812,7 +812,7 @@ if (empty($reshook)) } $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = GETPOST('remise_percent'.$predef); + $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); if (empty($remise_percent)) $remise_percent = 0; // Extrafields @@ -1210,7 +1210,7 @@ if (empty($reshook)) $price_min = $product->multiprices_min [$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent'), 2) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -1243,7 +1243,7 @@ if (empty($reshook)) $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); - $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); + $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, price2num(GETPOST('remise_percent'), 2), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise); if ($result >= 0) { $db->commit(); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 287150e6ca2..1d2f12132e5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -607,9 +607,9 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setremisepercent' && $usercancreate) { - $result = $object->set_remise($user, GETPOST('remise_percent')); + $result = $object->set_remise($user, price2num(GETPOST('remise_percent'), 2)); } elseif ($action == 'setremiseabsolue' && $usercancreate) { - $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); + $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU')); } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) { // Define vat_rate $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); @@ -640,7 +640,7 @@ if (empty($reshook)) } $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha')) : 0); + $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef), 2) : 0); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -1032,7 +1032,7 @@ if (empty($reshook)) $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent'), 2) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -1060,7 +1060,7 @@ if (empty($reshook)) } } } - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise); + $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, price2num(GETPOST('qty'), 'MS'), price2num(GETPOST('remise_percent'), 2), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise); if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 35d70e1edd6..1a125a38147 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -451,7 +451,7 @@ if (empty($reshook)) } $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = GETPOST('remise_percent'.$predef); + $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -801,7 +801,7 @@ if (empty($reshook)) $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent', 2)) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; @@ -837,7 +837,7 @@ if (empty($reshook)) $localtax1_rate, $localtax1_rate, GETPOST('productid'), - GETPOST('remise_percent'), + price2num(GETPOST('remise_percent'), 2), 'HT', $info_bits, 0, diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 16a472d878c..f4f1c5cde1a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -476,19 +476,15 @@ if (empty($reshook)) } } } // Set incoterm - elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) - { + elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } // bank account - elseif ($action == 'setbankaccount' && $usercancreate) - { + elseif ($action == 'setbankaccount' && $usercancreate) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - } elseif ($action == 'setremisepercent' && $usercancreate) - { + } elseif ($action == 'setremisepercent' && $usercancreate) { $object->fetch($id); - $result = $object->set_remise($user, $_POST['remise_percent']); - } elseif ($action == "setabsolutediscount" && $usercancreate) - { + $result = $object->set_remise($user, price2num(GETPOST('remise_percent'), 2)); + } elseif ($action == "setabsolutediscount" && $usercancreate) { // POST[remise_id] or POST[remise_id_for_payment] // We use the credit to reduce amount of invoice @@ -981,7 +977,7 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; - } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + } elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); $action = 'create'; @@ -993,26 +989,25 @@ if (empty($reshook)) $action = 'create'; } - $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); + $date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int')); if (!$error) { // This is a replacement invoice - $result = $object->fetch($_POST['fac_replacement']); + $result = $object->fetch(GETPOST('fac_replacement', 'int')); $object->fetch_thirdparty(); $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'restricthtml')); // We do not copy the private note - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->model_pdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = $_POST['cond_reglement_id']; - $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->ref_client = GETPOST('ref_client', 'alphanohtml'); + $object->model_pdf = GETPOST('model', 'alphanohtml'); + $object->fk_project = GETPOST('projectid', 'int'); + $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); + $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; + $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); + $object->remise_percent = price2num(GETPOST('remise_percent'), 2); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -1067,11 +1062,11 @@ if (empty($reshook)) $object->ref_client = GETPOST('ref_client'); $object->model_pdf = GETPOST('model'); $object->fk_project = GETPOST('projectid', 'int'); - $object->cond_reglement_id = 0; - $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->cond_reglement_id = 0; // No payment term for a credit note + $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->remise_absolue = GETPOST('remise_absolue'); - $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); + $object->remise_percent = price2num(GETPOST('remise_percent'), 2); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -1289,8 +1284,8 @@ if (empty($reshook)) $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); $object->fk_account = GETPOST('fk_account', 'int'); $object->amount = price2num(GETPOST('amount')); - $object->remise_absolue = GETPOST('remise_absolue'); - $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); + $object->remise_percent = price2num(GETPOST('remise_percent'), 2); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -1343,8 +1338,8 @@ if (empty($reshook)) $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); $object->amount = price2num(GETPOST('amount')); - $object->remise_absolue = GETPOST('remise_absolue'); - $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); + $object->remise_percent = price2num(GETPOST('remise_percent'), 2); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -1837,8 +1832,8 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid', 'int'); $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); - $object->remise_absolue = GETPOST('remise_absolue', 'int'); - $object->remise_percent = GETPOST('remise_percent', 'int'); + $object->remise_absolue =price2num(GETPOST('remise_absolue'), 'MU'); + $object->remise_percent = price2num(GETPOST('remise_percent'), 2); // Proprietes particulieres a facture de remplacement @@ -1923,8 +1918,8 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); - $remise_percent = GETPOST('remise_percent'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'MS'); + $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -2314,7 +2309,7 @@ if (empty($reshook)) $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if ($usercanproductignorepricemin && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { + if ($usercanproductignorepricemin && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent'), 2) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -2367,7 +2362,7 @@ if (empty($reshook)) } } - $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, $qty, price2num(GETPOST('remise_percent', 'alpha')), + $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, $qty, price2num(GETPOST('remise_percent'), 2), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line', 'int'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, price2num(GETPOST('progress', 'alpha')), GETPOST('units', 'alpha'), $pu_ht_devise); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index ca03905b834..8d78b410329 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -213,7 +213,7 @@ if (empty($reshook)) $object->note_private = GETPOST('note_private', 'alpha'); $object->note_public = GETPOST('note_public', 'alpha'); $object->fk_project = GETPOST('projectid', 'int'); - $object->remise_percent = GETPOST('remise_percent', 'alpha'); + $object->remise_percent = price2num(GETPOST('remise_percent'), 2); $object->ref = GETPOST('ref', 'alpha'); $object->ref_customer = GETPOST('ref_customer', 'alpha'); $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); @@ -396,7 +396,7 @@ if (empty($reshook)) } $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = ((GETPOST('remise_percent'.$predef) != '') ? GETPOST('remise_percent'.$predef) : 0); + $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef), 2) : 0); if ($qty == '') { @@ -673,10 +673,10 @@ if (empty($reshook)) $objectline->fk_product = GETPOST('idprod', 'int'); $objectline->description = GETPOST('product_desc', 'restricthtml'); - $objectline->price_ht = GETPOST('elprice'); - $objectline->subprice = GETPOST('elprice'); - $objectline->qty = GETPOST('elqty'); - $objectline->remise_percent = GETPOST('elremise_percent'); + $objectline->price_ht = price2num(GETPOST('elprice'), 'MU'); + $objectline->subprice = price2num(GETPOST('elprice'), 'MU'); + $objectline->qty = price2num(GETPOST('elqty'), 'MS'); + $objectline->remise_percent = price2num(GETPOST('elremise_percent'), 2); $objectline->tva_tx = ($txtva ? $txtva : 0); // Field may be disabled, so we use vat rate 0 $objectline->vat_src_code = $vat_src_code; $objectline->localtax1_tx = is_numeric($localtax1_tx) ? $localtax1_tx : 0; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 74b091865ff..b632bf44110 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -514,9 +514,9 @@ function dol_get_last_day($year, $month = 12, $gm = false) } /** - * Return GMT time for last hour of a given GMT date (it removes hours, min and second part) + * Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59) * - * @param int $date Date + * @param int $date Date GMT * @return int Date for last hour of a given date */ function dol_get_last_hour($date) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 68941b92387..5e97eceaaea 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4830,13 +4830,13 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ * should be roundtext2num(). * * @param string|float $amount Amount to convert/clean or round - * @param string $rounding ''=No rounding + * @param string|int $rounding ''=No rounding * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) * 'CU'=Round to Max unit price of foreign currency accuracy * 'CT'=Round to Max for totals with Tax of foreign currency accuracy - * Numeric = Nb of digits for rounding + * Numeric = Nb of digits for rounding (For example 2 for a percentage) * @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done) * Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator). * @return string Amount with universal numeric format (Example: '99.99999'). @@ -4911,7 +4911,7 @@ function price2num($amount, $rounding = '', $option = 0) elseif ($rounding == 'CT') { $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8); // TODO Use param of currency } - elseif (is_numeric($rounding)) $nbofdectoround = $rounding; + elseif (is_numeric($rounding)) $nbofdectoround = (int) $rounding; //print "RR".$amount.' - '.$nbofdectoround.'
'; if (dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0. else return 'ErrorBadParameterProvidedToFunction'; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index c00e1d2d6e2..4238d0ee041 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -372,7 +372,7 @@ if (empty($reshook)) } $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = GETPOST('remise_percent'.$predef); + $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU'); // Extrafields @@ -721,21 +721,21 @@ if (empty($reshook)) $result = $object->updateline( $lineid, - $_POST['product_desc'], + GETPOST('product_desc', 'restricthtml'), $ht, - GETPOST('qty', 'int'), - $_POST['remise_percent'], + price2num(GETPOST('qty'), 'MS'), + price2num(GETPOST('remise_percent'), 2), $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, 0, - isset($_POST["type"]) ? $_POST["type"] : $line->product_type, + GETPOSTISSET("type") ? GETPOST("type") : $line->product_type, false, $date_start, $date_end, $array_options, - $_POST['units'], + GETPOST('units'), $pu_ht_devise, GETPOST('fourn_ref', 'alpha') ); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index bfac45b15ac..9b8d0d959f3 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1137,8 +1137,8 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - $remise_percent = GETPOST('remise_percent'); - $pu_ht_devise = GETPOST('multicurrency_subprice'); + $remise_percent = price2num(GETPOST('remise_percent'), 2); + $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU'); // Extrafields Lines $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -1150,7 +1150,7 @@ if (empty($reshook)) } } - $result = $object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); + $result = $object->updateline(GETPOST('lineid', 'int'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, price2num(GETPOST('qty'), 'MS'), GETPOST('productid', 'int'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, GETPOST('units'), $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); if ($result >= 0) { unset($_POST['label']); @@ -1206,7 +1206,7 @@ if (empty($reshook)) } $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = GETPOST('remise_percent'.$predef); + $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU'); // Extrafields diff --git a/htdocs/product/card.php b/htdocs/product/card.php index c6dfd68d2c4..55c29aa1381 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -743,7 +743,7 @@ if (empty($reshook)) if (GETPOST('propalid') > 0) { // Define cost price for margin calculation $buyprice = 0; - if (($result = $propal->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) + if (($result = $propal->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), 2), $object->id)) < 0) { dol_syslog($langs->trans('FailedToGetCostPrice')); setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors'); @@ -754,12 +754,12 @@ if (empty($reshook)) $result = $propal->addline( $desc, $pu_ht, - GETPOST('qty'), + price2num(GETPOST('qty'), 'MS'), $tva_tx, $localtax1_tx, // localtax1 $localtax2_tx, // localtax2 $object->id, - GETPOST('remise_percent'), + price2num(GETPOST('remise_percent'), 2), $price_base_type, $pu_ttc, 0, @@ -784,7 +784,7 @@ if (empty($reshook)) } elseif (GETPOST('commandeid') > 0) { // Define cost price for margin calculation $buyprice = 0; - if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) + if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0) { dol_syslog($langs->trans('FailedToGetCostPrice')); setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors'); @@ -795,12 +795,12 @@ if (empty($reshook)) $result = $commande->addline( $desc, $pu_ht, - GETPOST('qty'), + price2num(GETPOST('qty'), 'MS'), $tva_tx, $localtax1_tx, // localtax1 $localtax2_tx, // localtax2 $object->id, - GETPOST('remise_percent'), + price2num(GETPOST('remise_percent'), 2), '', '', $price_base_type, @@ -825,7 +825,7 @@ if (empty($reshook)) } elseif (GETPOST('factureid') > 0) { // Define cost price for margin calculation $buyprice = 0; - if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) + if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0) { dol_syslog($langs->trans('FailedToGetCostPrice')); setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors'); @@ -836,12 +836,12 @@ if (empty($reshook)) $result = $facture->addline( $desc, $pu_ht, - GETPOST('qty'), + price2nm(GETPOST('qty'), 'MS'), $tva_tx, $localtax1_tx, $localtax2_tx, $object->id, - GETPOST('remise_percent'), + price2num(GETPOST('remise_percent'), 2), '', '', '', diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 2aadd4b3813..88c5259f48d 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -160,7 +160,7 @@ if (empty($reshook)) if (empty($ref_fourn_old)) $ref_fourn_old = $ref_fourn; $quantity = price2num(GETPOST("qty", 'nohtml'), 'MS'); $remise_percent = price2num(GETPOST('remise_percent', 'alpha')); - $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0; + $npr = preg_match('/\*/', GETPOST('tva_tx', 'alpha')) ? 1 : 0; $tva_tx = str_replace('*', '', GETPOST('tva_tx', 'alpha')); $tva_tx = price2num($tva_tx); $price_expression = GETPOST('eid', 'int') ? GETPOST('eid', 'int') : ''; // Discard expression if not in expression mode @@ -697,14 +697,14 @@ END; print ''.$langs->trans("PriceQtyMin").''; print ''; print ' '; - print $form->selectPriceBaseType((GETPOST('price_base_type') ? GETPOST('price_base_type') : 'HT'), "price_base_type"); // We keep 'HT' here, price_base_type is not yet supported for supplier prices + print $form->selectPriceBaseType((GETPOSTISSET('price_base_type') ? GETPOST('price_base_type') : 'HT'), "price_base_type"); // We keep 'HT' here, price_base_type is not yet supported for supplier prices print ''; } // Discount qty min print ''.$langs->trans("DiscountQtyMin").''; - print ' %'; + print ' %'; print ''; print ''; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 3785f50f213..89695690d38 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -419,10 +419,10 @@ if (empty($reshook)) // Récupération des variables $rowid = GETPOST('rowid', 'int'); $priceid = GETPOST('priceid', 'int'); - $newprice = price2num(GETPOST("price", 'alpha'), 'MU'); + $newprice = price2num(GETPOST("price"), 'MU'); // $newminprice=price2num(GETPOST("price_min"),'MU'); // TODO : Add min price management - $quantity = GETPOST('quantity', 'int'); - $remise_percent = price2num(GETPOST('remise_percent', 'alpha')); + $quantity = price2num(GETPOST('quantity'), 'MS'); + $remise_percent = price2num(GETPOST('remise_percent'), 2); $remise = 0; // TODO : allow discount by amount when available on documents if (empty($quantity)) { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index d7ee97e1b9d..34f9ff78380 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -263,8 +263,8 @@ if (empty($reshook)) $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->remise_percent = GETPOST('remise_percent'); - $object->remise_absolue = GETPOST('remise_absolue'); + $object->remise_percent = price2num(GETPOST('remise_percent'), 2); + $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); $object->socid = GETPOST('socid'); $object->fk_project = GETPOST('projectid', 'int'); $object->model_pdf = GETPOST('model'); @@ -556,7 +556,7 @@ if (empty($reshook)) } $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = GETPOST('remise_percent'.$predef); + $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU'); // Extrafields @@ -929,10 +929,10 @@ if (empty($reshook)) $fk_unit = GETPOST('units'); $result = $object->updateline( - GETPOST('lineid'), + GETPOST('lineid', 'int'), $ht, - GETPOST('qty'), - GETPOST('remise_percent'), + price2num(GETPOST('qty'), 'MS'), + price2num(GETPOST('remise_percent'), 2), $vat_rate, $localtax1_rate, $localtax2_rate, @@ -940,7 +940,7 @@ if (empty($reshook)) $price_base_type, $info_bits, $special_code, - GETPOST('fk_parent_line'), + GETPOST('fk_parent_line', 'int'), 0, $fournprice, $buyingprice, @@ -1018,9 +1018,9 @@ if (empty($reshook)) elseif ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) { - $result = $object->set_remise_percent($user, GETPOST('remise_percent', 'alpha')); + $result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'), 2)); } elseif ($action == 'setremiseabsolue' && $usercancreate) { - $result = $object->set_remise_absolue($user, GETPOST('remise_absolue', 'alpha')); + $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 2)); } // Payment mode From d047cf488dc678c0404e894c3475db77786ed337 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Jan 2021 12:51:11 +0100 Subject: [PATCH 18/39] Fix price2num --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 34f9ff78380..05bc3aec44d 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1020,7 +1020,7 @@ if (empty($reshook)) } elseif ($action == 'setremisepercent' && $usercancreate) { $result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'), 2)); } elseif ($action == 'setremiseabsolue' && $usercancreate) { - $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 2)); + $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU')); } // Payment mode From b349290cd1c515ff678be4202d5b2327023afc30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Jan 2021 12:57:54 +0100 Subject: [PATCH 19/39] Fix test for date in future --- htdocs/compta/facture/card.php | 8 ++++---- htdocs/fourn/facture/card.php | 6 +++--- htdocs/langs/en_US/errors.lang | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f4f1c5cde1a..c0a9a15739a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1040,7 +1040,7 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; - } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + } elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); $action = 'create'; @@ -1260,7 +1260,7 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; - } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + } elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); $action = 'create'; @@ -1313,7 +1313,7 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; - } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + } elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); $action = 'create'; @@ -1737,7 +1737,7 @@ if (empty($reshook)) $error++; $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")); setEventMessages($mesg, null, 'errors'); - } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + } elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); $action = 'create'; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 9b8d0d959f3..4d8d19e8bde 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -666,7 +666,7 @@ if (empty($reshook)) $action = 'create'; $_GET['socid'] = $_POST['socid']; $error++; - } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + } elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); $action = 'create'; @@ -733,7 +733,7 @@ if (empty($reshook)) $action = 'create'; $_GET['socid'] = $_POST['socid']; $error++; - } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + } elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); $action = 'create'; @@ -851,7 +851,7 @@ if (empty($reshook)) $action = 'create'; $_GET['socid'] = $_POST['socid']; $error++; - } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + } elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); $action = 'create'; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index a7a7e12db14..baf04bbe4b8 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -256,6 +256,7 @@ ErrorPublicInterfaceNotEnabled=Public interface was not enabled ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must be defined if it is set as a translation of another page ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother=The language of new page must not be the source language if it is set as a translation of another page ErrorAParameterIsRequiredForThisOperation=A parameter is mandatory for this operation +ErrorDateIsInFuture=Error, the date can't be in the future # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. From dad67785700bf8616d96830c0498478b912b5e0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Jan 2021 13:07:41 +0100 Subject: [PATCH 20/39] Prepare removal of libelle and lib into label --- .../sociales/class/cchargesociales.class.php | 18 ++++++++++-------- .../sociales/class/chargesociales.class.php | 9 +++++++-- .../class/paymentsocialcontribution.class.php | 7 ++++++- htdocs/compta/sociales/list.php | 6 +++--- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index ceace76bba9..c5ec3b24968 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -46,9 +46,15 @@ class Cchargesociales /** * @var string Label + * @deprecated */ public $libelle; + /** + * @var string Label + */ + public $label; + public $deductible; public $active; public $code; @@ -107,7 +113,6 @@ class Cchargesociales // Insert request $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; - $sql .= 'libelle,'; $sql .= 'deductible,'; $sql .= 'active,'; @@ -115,10 +120,7 @@ class Cchargesociales $sql .= 'fk_pays,'; $sql .= 'module'; $sql .= 'accountancy_code'; - - $sql .= ') VALUES ('; - $sql .= ' '.(!isset($this->libelle) ? 'NULL' : "'".$this->db->escape($this->libelle)."'").','; $sql .= ' '.(!isset($this->deductible) ? 'NULL' : $this->deductible).','; $sql .= ' '.(!isset($this->active) ? 'NULL' : $this->active).','; @@ -126,8 +128,6 @@ class Cchargesociales $sql .= ' '.(!isset($this->fk_pays) ? 'NULL' : $this->fk_pays).','; $sql .= ' '.(!isset($this->module) ? 'NULL' : "'".$this->db->escape($this->module)."'").','; $sql .= ' '.(!isset($this->accountancy_code) ? 'NULL' : "'".$this->db->escape($this->accountancy_code)."'"); - - $sql .= ')'; $this->db->begin(); @@ -179,7 +179,7 @@ class Cchargesociales $sql = 'SELECT'; $sql .= " t.id,"; - $sql .= " t.libelle,"; + $sql .= " t.libelle as label,"; $sql .= " t.deductible,"; $sql .= " t.active,"; $sql .= " t.code,"; @@ -201,7 +201,8 @@ class Cchargesociales $this->id = $obj->id; - $this->libelle = $obj->libelle; + $this->libelle = $obj->label; + $this->label = $obj->label; $this->deductible = $obj->deductible; $this->active = $obj->active; $this->code = $obj->code; @@ -501,6 +502,7 @@ class Cchargesociales $this->id = 0; $this->libelle = ''; + $this->label = ''; $this->deductible = ''; $this->active = ''; $this->code = ''; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 95e4bd1df77..34f58969a46 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -108,6 +108,11 @@ class ChargeSociales extends CommonObject */ public $fk_project; + /** + * @var int ID + */ + public $fk_user; + const STATUS_UNPAID = 0; const STATUS_PAID = 1; @@ -135,7 +140,7 @@ class ChargeSociales extends CommonObject $sql = "SELECT cs.rowid, cs.date_ech"; $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; $sql .= ", cs.fk_account, cs.fk_mode_reglement, cs.fk_user"; - $sql .= ", c.libelle"; + $sql .= ", c.libelle as type_label"; $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; @@ -158,7 +163,7 @@ class ChargeSociales extends CommonObject $this->lib = $obj->label; $this->label = $obj->label; $this->type = $obj->fk_type; - $this->type_label = $obj->libelle; + $this->type_label = $obj->type_label; $this->fk_account = $obj->fk_account; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 2f4f772fca0..78cf7e1c22f 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -46,6 +46,11 @@ class PaymentSocialContribution extends CommonObject */ public $picto = 'payment'; + /** + * @var string Label + */ + public $label; + /** * @var int ID */ @@ -679,7 +684,7 @@ class PaymentSocialContribution extends CommonObject $result = ''; - if (empty($this->ref)) $this->ref = $this->lib; + if (empty($this->ref)) $this->ref = $this->label; $label = img_picto('', $this->picto).' '.$langs->trans("SocialContributionPayment").''; $label .= '
'.$langs->trans('Ref').': '.$this->ref; diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index a8a71e3e254..ce65dde989b 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -149,7 +149,7 @@ if (!empty($conf->projet->enabled)) $projectstatic = new Project($db); llxHeader('', $langs->trans("SocialContributions")); $sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user, "; -$sql .= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; +$sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode,"; if (!empty($conf->projet->enabled)) $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; $sql .= " c.libelle as type_label,"; $sql .= " SUM(pc.amount) as alreadypayed"; @@ -381,7 +381,7 @@ while ($i < min($num, $limit)) $chargesociale_static->id = $obj->rowid; $chargesociale_static->ref = $obj->rowid; - $chargesociale_static->label = $obj->libelle; + $chargesociale_static->label = $obj->label; $chargesociale_static->type_label = $obj->type_label; if (!empty($conf->projet->enabled)) { $projectstatic->id = $obj->project_id; @@ -405,7 +405,7 @@ while ($i < min($num, $limit)) // Label if (!empty($arrayfields['cs.libelle']['checked'])) { - print ''.dol_trunc($obj->libelle, 42).''; + print ''.dol_trunc($obj->label, 42).''; if (!$i) $totalarray['nbfield']++; } From 4c9bf1d97ea73127f9382490dd58921798e679e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Jan 2021 13:21:12 +0100 Subject: [PATCH 21/39] Advice for ajax services --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4afde7fb45..3a591059b36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -248,9 +248,9 @@ Following changes may create regressions for some external modules, but were nec * Function showStripePaymentUrl, getStripePaymentUrl, showPaypalPaymentUrl and getPaypalPaymentUrl has been removed. The generic one showOnlinePaymentUrl and getOnlinePaymentUrl are always used. * Context for hook showSocinfoOnPrint has been moved from "showsocinfoonprint" to "main" * Library htdocs/includes/phpoffice/phpexcel as been removed (replaced with htdocs/includes/phpoffice/PhpSpreadsheet) -* Databse transaction in your triggers must be correctly balanced (one close for one open). If not, an error will be returned by the trigger, even if trigger did return error code. +* Database transaction in your triggers must be correctly balanced (one close for one open). If not, an error will be returned by the trigger, even if trigger did return error code. * Dolibarr v13 is still compatible with any PHP version between 5.6.0 and 7.4.*; Unit tests are OK with PHP 8.0 but some warnings or troubles may appears with PHP 8.0. - +* All your Ajax services must contains such a line at begin of file: if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal ***** ChangeLog for 12.0.4 compared to 12.0.3 ***** FIX: make formConfirm an addreplace-type hook From f461bccc02c54cc72c23a8df4c6f545aeeb8bd3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Jan 2021 17:06:42 +0100 Subject: [PATCH 22/39] Fix var not defined --- htdocs/projet/element.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index aa01ef5d3ef..6802d0e84a9 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1361,7 +1361,6 @@ if ($conf->use_javascript_ajax) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox('.elementselect'); - $out .= $comboenhancement; print $comboenhancement; } From 3473e0a5d0b246b04246980193aeef10efdb6ac1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Jan 2021 17:10:31 +0100 Subject: [PATCH 23/39] Exclude include if not required --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e0055890152..370e7ac1278 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -386,7 +386,7 @@ if (!defined('NOLOGIN') && !defined('NOIPCHECK') && !empty($dolibarr_main_restri // Loading of additional presentation includes if (!defined('NOREQUIREHTML')) require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // Need 660ko memory (800ko in 2.2) -require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; // Need 22ko memory +if (!defined('NOREQUIREAJAX')) require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; // Need 22ko memory // If install or upgrade process not done or not completely finished, we call the install page. if (!empty($conf->global->MAIN_NOT_INSTALLED) || !empty($conf->global->MAIN_NOT_UPGRADED)) From 18d222f32f97bd8a3fee6311cf40ebdd4952452f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Jan 2021 18:06:02 +0100 Subject: [PATCH 24/39] Fix code comment --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 64996e4e6c2..4ae71d46309 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1448,7 +1448,7 @@ class Form * @param string $htmlid Html id to use instead of htmlname * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @param integer $disableifempty Set tag 'disabled' on select if there is no choice - * @return int <0 if KO, Nb of contact in list if OK + * @return int|string <0 if KO, HTML with select string if OK. */ public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false, $disableifempty = 0) { From d80709a7b9368b31651e5ef66bad49febc9685af Mon Sep 17 00:00:00 2001 From: "Paul Vincent M. Ancajas" Date: Mon, 1 Feb 2021 01:41:19 +0800 Subject: [PATCH 25/39] Fix/FIX: making sure the return agenda is only specific to user --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 143dbf064a9..9e562173b04 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1201,8 +1201,8 @@ class ActionComm extends CommonObject } $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; - if (!$user->rights->agenda->allactions->read) { // If bloack Added by PV - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources AS ar ON a.id = ar.fk_actioncomm"; + if (!$user->rights->agenda->allactions->read) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources AS ar ON a.id = ar.fk_actioncomm AND ar.element_type ='user' AND ar.fk_element = ".$user->id; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE 1 = 1"; From 582c37c3782790f6968791ce9bf25c632cecdbbd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Jan 2021 18:52:11 +0100 Subject: [PATCH 26/39] Code comment --- .../interface_20_modWorkflow_WorkflowManager.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index d8eda6a8baf..dac1368b8f4 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -271,9 +271,10 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } - //Build array of quantity ordered by product + //Build array of quantity ordered to be shipped if (is_array($order->lines) && count($order->lines) > 0) { foreach ($order->lines as $orderline) { + // Exclude lines not qualified for shipment, similar code is found into calcAndSetStatusDispatch() for vendors if (empty($conf->global->STOCK_SUPPORTS_SERVICES) && $orderline->product_type > 0) continue; $qtyordred[$orderline->fk_product] += $orderline->qty; } From ed258b95da6676d2e5fbfaf7963a48a56533e8bf Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 31 Jan 2021 22:33:07 +0100 Subject: [PATCH 27/39] Clean template code to create after edit in receipt printer module Cleaning template code is more clear to users --- htdocs/admin/receiptprinter.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 3c878c5c664..31f2228d401 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -443,7 +443,6 @@ if ($mode == 'template' && $user->admin) { print ''; print ''; print ''; print ''; print ''; From e6deed1601a2aa36fb56b0ef112b2050e47887b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Feb 2021 15:40:59 +0100 Subject: [PATCH 28/39] Fix collapse --- htdocs/core/class/commonobject.class.php | 12 ++++++------ htdocs/core/class/extrafields.class.php | 15 ++++++++------- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e4c3acb85ed..47bfab139d1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7043,10 +7043,10 @@ abstract class CommonObject $labeltoshow = $langs->trans($label); $helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]); - if ($display_type=='card') { - $out .= ''; + if ($display_type == 'card') { + $out .= ''; $out .= ''; $out .= '
'; - } elseif ($display_type=='line') { + } elseif ($display_type == 'line') { $out .= '
'; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 156c29d7a13..e3870a1ed00 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1955,9 +1955,9 @@ class ExtraFields $collapse_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.(!empty($object->id)?'_'.$object->id:'')]) || GETPOST('ignorecollapsesetup', 'int')) ? ($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.(!empty($object->id)?'_'.$object->id:'')] ? true : false) : ($extrafield_collapse_display_value == 2 ? false : true)); $extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key].(!empty($object->id)?'_'.$object->id:''); - $out .= ''; - $out .= ''; + $out .= ' });'."\n"; + $out .= ' });'."\n"; + $out .= '});'."\n"; + $out .= ''."\n"; } } } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index ed775c21e6c..f8d86f2abee 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -112,7 +112,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] $lastseparatorkeyfound = $tmpkeyextra; } else { - print 'id)?'_'.$object->id:''); /*if ($extrafields_collapse_num && $extrafields_collapse_num_old && $extrafields_collapse_num != $extrafields_collapse_num_old) { print ' trextrafields_collapse_new'; }*/ From 2f5eb2aff7aca3642e360532d0c3a6bb7ea7c1ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Feb 2021 20:09:50 +0100 Subject: [PATCH 29/39] FIX #16131 --- build/debian/dolibarr.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/debian/dolibarr.postinst b/build/debian/dolibarr.postinst index 7684d02ff3d..26a08a55826 100644 --- a/build/debian/dolibarr.postinst +++ b/build/debian/dolibarr.postinst @@ -23,7 +23,7 @@ setup_empty_conf() { mkdir -p /etc/dolibarr touch /etc/dolibarr/conf.php chown root:www-data /etc/dolibarr/conf.php - chmod 664 /etc/dolibarr/conf.php + chmod 660 /etc/dolibarr/conf.php } is_new_upstream_version() { From e2a65ad23105e5182dc9e7bc6b5dbf2f2ed4c958 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Feb 2021 20:09:50 +0100 Subject: [PATCH 30/39] FIX #16131 --- build/debian/dolibarr.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/debian/dolibarr.postinst b/build/debian/dolibarr.postinst index 7684d02ff3d..26a08a55826 100644 --- a/build/debian/dolibarr.postinst +++ b/build/debian/dolibarr.postinst @@ -23,7 +23,7 @@ setup_empty_conf() { mkdir -p /etc/dolibarr touch /etc/dolibarr/conf.php chown root:www-data /etc/dolibarr/conf.php - chmod 664 /etc/dolibarr/conf.php + chmod 660 /etc/dolibarr/conf.php } is_new_upstream_version() { From daf88944f8da802e219d4d2f39d49f482f3636fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 00:19:41 +0100 Subject: [PATCH 31/39] FIX #16118 Timezone problem on some fields --- htdocs/admin/system/dolibarr.php | 36 +++++++++-------- htdocs/comm/action/card.php | 36 ++++++++--------- htdocs/comm/action/list.php | 14 +++---- htdocs/compta/facture/card-rec.php | 3 +- htdocs/core/class/html.form.class.php | 6 +-- htdocs/core/class/html.formactions.class.php | 2 +- htdocs/core/lib/functions.lib.php | 11 ++--- htdocs/core/lib/security.lib.php | 42 +++++++++++--------- htdocs/core/lib/ticket.lib.php | 10 ++--- htdocs/core/modules/modTicket.class.php | 2 + htdocs/install/upgrade2.php | 1 + htdocs/main.inc.php | 8 ++++ htdocs/ticket/card.php | 6 +-- htdocs/ticket/class/ticket.class.php | 15 +++---- htdocs/ticket/list.php | 8 +++- 15 files changed, 114 insertions(+), 86 deletions(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 1100b86f412..2efb2a14a7d 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -202,7 +202,7 @@ if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_S // Localisation print '
'; print ''; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; // Thousands @@ -222,7 +222,22 @@ if (($thousand != ',' && $thousand != '.') || ($thousand != ' ')) print "\n"; } print ''."\n"; -// Timezone + +// Timezones + +// Database timezone +if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') +{ + print ''."\n"; +} $txt = $langs->trans("OSTZ").' (variable system TZ): '.(!empty($_ENV["TZ"]) ? $_ENV["TZ"] : $langs->trans("NotDefined")).'
'."\n"; $txt .= $langs->trans("PHPTZ").' (date_default_timezone_get() / php.ini date.timezone): '.(getServerTimeZoneString()." / ".(ini_get("date.timezone") ? ini_get("date.timezone") : $langs->trans("NotDefined")))."
\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php $txt .= $langs->trans("Dolibarr constant MAIN_SERVER_TZ").': '.(empty($conf->global->MAIN_SERVER_TZ) ? $langs->trans("NotDefined") : $conf->global->MAIN_SERVER_TZ); @@ -238,23 +253,10 @@ $val .= '       '.getServerTimeZoneString(); $val .= '       '.$langs->trans("DaylingSavingTime").': '.($daylight === 'unknown' ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); print $form->textwithtooltip($val, $txt, 2, 1, img_info('')); print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php -print ''."\n"; +print ''."\n"; print ''; print ''; print ''; -// Database timezone -if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') -{ - print ''."\n"; -} // Client $tz = (int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']; print ''."\n"; print ''."\n"; -print ''."\n"; +print ''."\n"; $filesystemencoding = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 print ''."\n"; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6499db671cb..6f1e83103d5 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -228,8 +228,8 @@ if (empty($reshook) && $action == 'add') $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status // Clean parameters - $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); - $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); + $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser'); + $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser'); // Check parameters if (!$datef && $percentage == 100) @@ -479,8 +479,8 @@ if (empty($reshook) && $action == 'update') $object->fetch_userassigned(); $object->oldcopy = clone $object; - $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); - $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); + $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser'); + $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser'); $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm'); $object->label = GETPOST("label", "alphanohtml"); @@ -953,7 +953,7 @@ if ($action == 'create') // Full day print ''; - $datep = ($datep ? $datep : $object->datep); + $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep)); if (GETPOST('datep', 'int', 1)) $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0); $datef = ($datef ? $datef : $object->datef); if (GETPOST('datef', 'int', 1)) $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0); @@ -1324,8 +1324,8 @@ if ($id > 0) { $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status - $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); - $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); + $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser'); + $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser'); $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm'); $object->label = GETPOST("label", "alphanohtml"); @@ -1430,23 +1430,23 @@ if ($id > 0) // Full day event print ''; - + print dol_print_date($object->datep, 'dayhour', 'gmt'); // Date start - end print ''; @@ -1884,16 +1884,16 @@ if ($id > 0) // Date start print ''; print ''; // Date end print ''; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index f5a0a6783da..991e945b16d 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -136,9 +136,9 @@ $arrayfields = array( 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 'a.fk_contact'=>array('label'=>"Contact", 'checked'=>0), 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>1, 'enabled'=>(!empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))), - 'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), - 'a.datec'=>array('label'=>'DateCreation', 'checked'=>0), - 'a.tms'=>array('label'=>'DateModification', 'checked'=>0) + 'a.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>510), + 'a.tms'=>array('label'=>'DateModification', 'checked'=>0, 'position'=>520), + 'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -736,7 +736,7 @@ if ($resql) // Start date if (!empty($arrayfields['a.datep']['checked'])) { print ''; } @@ -834,11 +834,11 @@ if ($resql) // Date creation if (!empty($arrayfields['a.datec']['checked'])) { // Status/Percent - print ''; + print ''; } // Date update if (!empty($arrayfields['a.tms']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['a.percent']['checked'])) { // Status/Percent diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 64b00aaa156..eb7b8c83b34 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -923,7 +923,8 @@ if (empty($reshook)) * View */ -llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-facture-rec'); +$help_url = ''; +llxHeader('', $langs->trans("RepeatableInvoices"), $help_url); $form = new Form($db); $formother = new FormOther($db); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 808a1cd0043..448bdad3cd9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5536,7 +5536,7 @@ class Form * @param int $stepminutes Specify step for minutes between 1 and 30 * @param string $labeladddateof Label to use for the $adddateof parameter. * @param string $placeholder Placeholder - * @param mixed $gm 'auto', 'gmt' or 'tzserver' or 'tzuserrel' + * @param mixed $gm 'auto' (for backward compatibility, avoid this), 'gmt' or 'tzserver' or 'tzuserrel' * @return string Html for selectDate * @see form_date(), select_month(), select_year(), select_dayofweek() */ @@ -5544,8 +5544,8 @@ class Form { global $conf, $langs; - if ($gm == 'auto') { - $gm = $conf->tzuserinputkey; + if ($gm === 'auto') { + $gm = (empty($conf) ? 'tzserver' : $conf->tzuserinputkey); } $retstring = ''; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 843c9ec759f..610b8276790 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -202,7 +202,7 @@ class FormActions $newcardbutton = ''; if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) { - $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')).'&origin='.urlencode($typeelement).'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); + $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog', 'tzuser')).'&origin='.urlencode($typeelement).'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 694612bde07..99a66a9a682 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2209,9 +2209,10 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'auto', { global $conf; //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; + //print 'gm:'.$gm.' gm==auto:'.($gm == 'auto').'
'; - if ($gm == 'auto') { - $gm = $conf->tzuserinputkey; + if ($gm === 'auto') { + $gm = (empty($conf) ? 'tzserver' : $conf->tzuserinputkey); } // Clean parameters @@ -2273,7 +2274,7 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'auto', /** * Return date for now. In most cases, we use this function without parameters (that means GMT time). * - * @param string $mode 'auto' + * @param string $mode 'auto' => for backward compatibility (avoid this), * 'gmt' => we return GMT timestamp, * 'tzserver' => we add the PHP server timezone * 'tzref' => we add the company timezone. Not implemented. @@ -2284,8 +2285,8 @@ function dol_now($mode = 'auto') { $ret = 0; - if ($mode == 'auto') { - $mode = 'tzserver'; + if ($mode === 'auto') { + $mode = 'gmt'; } if ($mode == 'gmt') $ret = time(); // Time for now at greenwich. diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 9667a67d360..2f1e3d5596b 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -444,7 +444,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $checksoc = array('societe'); // Test for societe object $checkother = array('contact', 'agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object - $checktask = array('projet_task'); + $checktask = array('projet_task'); // Test for task object $nocheck = array('barcode', 'stock'); // No test //$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...). @@ -582,29 +582,35 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } - } elseif (!in_array($feature, $nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield - { + } elseif (!in_array($feature, $nocheck)) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield // If external user: Check permission for external users - if ($user->socid > 0) - { + if ($user->socid > 0) { if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); $sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.rowid IN (".$objectid.")"; $sql .= " AND dbt.".$dbt_keyfield." = ".$user->socid; - } // If internal user: Check permission for internal users that are restricted on their objects - elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) - { - if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); - $sql = "SELECT COUNT(sc.fk_soc) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql .= " AND sc.fk_soc = dbt.".$dbt_keyfield; - $sql .= " AND dbt.".$dbt_keyfield." = s.rowid"; - $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; - $sql .= " AND sc.fk_user = ".$user->id; + } elseif (!empty($conf->societe->enabled)) { + // If internal user: Check permission for internal users that are restricted on their objects + if ($feature != 'ticket' && !$user->rights->societe->client->voir) { + if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); + $sql = "SELECT COUNT(sc.fk_soc) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " AND sc.fk_soc = dbt.".$dbt_keyfield; + $sql .= " AND sc.fk_user = ".$user->id; + } + // On ticket, the thirdparty is not mandatory, so we need a special test to accept record with no thirdparties. + if ($feature == 'ticket' && !$user->rights->societe->client->voir) { + $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = dbt.".$dbt_keyfield." AND sc.fk_user = ".$user->id; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " AND (sc.fk_user = ".$user->id." OR sc.fk_user IS NULL)"; + } } // If multicompany and internal users with all permissions, check user is in correct entity elseif (!empty($conf->multicompany->enabled)) { diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 92fdfa21aff..c90892d603c 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -283,7 +283,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out = ''; $histo = array(); $numaction = 0; - $now = dol_now('tzuser'); + $now = dol_now(); // Open DSI -- Fix order by -- Begin $sortfield_list = explode(',', $sortfield); @@ -622,7 +622,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out .= ''; $out .= '
  • '; $out .= ''; - $out .= dol_print_date($histo[$key]['datestart'], 'daytext', 'tzserver', $langs); + $out .= dol_print_date($histo[$key]['datestart'], 'daytext', 'tzuserrel', $langs); $out .= ''; $out .= '
  • '; $out .= ''; @@ -660,14 +660,14 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out .= ''; // Date $out .= ' '; - $out .= dol_print_date($histo[$key]['datestart'], 'dayhour'); + $out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel'); if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) { $tmpa = dol_getdate($histo[$key]['datestart'], true); $tmpb = dol_getdate($histo[$key]['dateend'], true); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { - $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour'); + $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel'); } else { - $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour'); + $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour', 'tzuserrel'); } } $late = 0; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 448d1eb694b..7746bf9ca52 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -177,6 +177,7 @@ class modTicket extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'manage'; + /* Seems not used and in conflict with societe->client->voir (see all thirdparties) $r++; $this->rights[$r][0] = 56005; // id de la permission $this->rights[$r][1] = 'See all tickets, even if not assigned to (not effective for external users, always restricted to the thirdpardy they depends on)'; // libelle de la permission @@ -184,6 +185,7 @@ class modTicket extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'view'; $this->rights[$r][5] = 'all'; + */ // Main menu entries $this->menus = array(); // List of menus to add diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 3a2b8889d96..dabb826149c 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -486,6 +486,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ 'MAIN_MODULE_SYSLOG'=>'newboxdefonly', 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', 'MAIN_MODULE_SERVICE'=>'newboxdefonly', + 'MAIN_MODULE_TICKET'=>'newboxdefonly', 'MAIN_MODULE_TAKEPOS'=>'newboxdefonly', 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) 'MAIN_MODULE_VARIANTS'=>'newboxdefonly', diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e0055890152..3e64482fdc6 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1890,6 +1890,14 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= '
    '.$langs->trans("CurrentMenuManager").': '.$menumanager->name; $langFlag = picto_from_langcode($langs->getDefaultLang()); $dropdownBody .= '
    '.$langs->trans("CurrentUserLanguage").': '.($langFlag ? $langFlag.' ' : '').$langs->getDefaultLang(); + + $tz = (int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']; + $dropdownBody .= '
    '.$langs->trans("ClientTZ").': '.($tz ? ($tz >= 0 ? '+' : '').$tz : ''); + $dropdownBody .= ' ('.$_SESSION['dol_tz_string'].')'; + //$dropdownBody .= '       '.$langs->trans("DaylingSavingTime").': '; + //if ($_SESSION['dol_dst'] > 0) $dropdownBody .= yn(1); + //else $dropdownBody .= yn(0); + $dropdownBody .= '
    '.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; $dropdownBody .= '
    '.$langs->trans("Layout").': '.$conf->browser->layout; $dropdownBody .= '
    '.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 6abb2464394..6d14d29202f 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -938,14 +938,14 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = // Creation date print '
    '; // Read date print ''; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 03e87067d10..306f861097b 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -223,9 +223,10 @@ class Ticket extends CommonObject /** - * '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') + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', '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)" * 'label' the translation key. + * 'picto' is code of a picto to show before value in forms * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). @@ -236,8 +237,8 @@ class Ticket extends CommonObject * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'css' and 'cssview' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. For example: 'maxwidth200', 'wordbreak' - * 'help' is a string visible as a tooltip on field + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200' + * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") @@ -255,16 +256,16 @@ class Ticket extends CommonObject 'track_id' => array('type'=>'varchar(255)', 'label'=>'TicketTrackId', 'visible'=>-2, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"), 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'), 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>'tdoverflowmax150'), - 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth200', 'autofocusoncreate'=>1), - 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth150 tdoverflowmax50'), + 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth200 tdoverflowmax200', 'autofocusoncreate'=>1), + 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth125 tdoverflowmax50'), 'category_code' => array('type'=>'varchar(32)', 'label'=>'TicketCategory', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'), 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty", 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty", 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'), 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'help'=>"LinkToProject"), 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), - 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>1, 'enabled'=>1, 'position'=>501, 'notnull'=>1), + 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-1, 'enabled'=>1, 'position'=>501, 'notnull'=>1), 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1, 'css'=>'tdoverflowmax150'), 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1), diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 8db50076bbf..0c6db4a4a2d 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -428,7 +428,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -llxHeader('', $title, $help_url); +llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'classforhorizontalscrolloftabs'); if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) { @@ -811,6 +811,12 @@ while ($i < min($num, $limit)) if ($cssforfield || $val['css']) print '"'; print '>'; if ($key == 'fk_statut') print $object->getLibStatut(5); + elseif ($key == 'subject') { + $s = $obj->subject; + print ''; + print $s; + print ''; + } elseif ($key == 'type_code') { $s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); print ''; From a19eec779168818db11b045b863f8d32e32dab8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 00:41:44 +0100 Subject: [PATCH 32/39] FIX #16135 --- .../install/mysql/migration/12.0.0-13.0.0.sql | 15 +++++++++++--- .../mysql/tables/llx_c_product_nature.key.sql | 20 ++++++++++++++++++- 2 files changed, 31 insertions(+), 4 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 31cdf9c8d62..96a681d4c56 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 @@ -415,8 +415,10 @@ ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255); DELETE FROM llx_const WHERE name in ('MAIN_INCLUDE_ZERO_VAT_IN_REPORTS'); -UPDATE llx_projet_task_time SET tms = null WHERE tms = 0; -ALTER TABLE llx_projet_task_time MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; + +-- VMYSQL4.1 UPDATE llx_projet_task_time SET tms = null WHERE tms = 0; + +ALTER TABLE llx_projet_task_time CHANGE COLUMN tms tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; ALTER TABLE llx_projet_task_time MODIFY COLUMN datec datetime; @@ -432,12 +434,19 @@ CREATE TABLE llx_c_product_nature ( active tinyint DEFAULT 1 NOT NULL ) ENGINE=innodb; -ALTER TABLE llx_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code, active); + +ALTER TABLE llx_product DROP FOREIGN KEY fk_product_finished; + +-- VMYSQL4.1 DROP INDEX uk_c_product_nature on llx_c_product_nature; +-- VPGSQL8.2 DROP INDEX uk_c_product_nature; + +ALTER TABLE llx_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code); INSERT INTO llx_c_product_nature (code, label, active) VALUES (0, 'RowMaterial', 1); INSERT INTO llx_c_product_nature (code, label, active) VALUES (1, 'Finished', 1); ALTER TABLE llx_product MODIFY COLUMN finished tinyint DEFAULT NULL; + ALTER TABLE llx_product ADD CONSTRAINT fk_product_finished FOREIGN KEY (finished) REFERENCES llx_c_product_nature (code); -- MIGRATION TO DO AFTER RENAMING AN OBJECT diff --git a/htdocs/install/mysql/tables/llx_c_product_nature.key.sql b/htdocs/install/mysql/tables/llx_c_product_nature.key.sql index b6a3d2130bf..e1190e5ab19 100644 --- a/htdocs/install/mysql/tables/llx_c_product_nature.key.sql +++ b/htdocs/install/mysql/tables/llx_c_product_nature.key.sql @@ -1 +1,19 @@ -ALTER TABLE llx_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code, active); +-- ======================================================================== +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) 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 . +-- +-- ======================================================================== + +ALTER TABLE llx_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code); From f5df3b1d695b156f1cf7da0001b072972897e0f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 01:30:23 +0100 Subject: [PATCH 33/39] Clean code to try to fix #16123 --- htdocs/barcode/printsheet.php | 29 +++++++++++++------ .../doc/pdf_standardlabel.class.php | 18 ------------ .../printsheet/doc/pdf_tcpdflabel.class.php | 17 ----------- .../modules/printsheet/modules_labels.php | 21 ++++++++++++++ 4 files changed, 41 insertions(+), 44 deletions(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 8a513034a4a..2a3a13cca69 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -22,6 +22,11 @@ * \ingroup member * \brief Page to print sheets with barcodes using the document templates into core/modules/printsheets */ + +if (!empty($_POST['mode']) && $_POST['mode'] === 'label') { // Page is called to build a PDF and output, we must ne renew the token. + if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +} + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -237,16 +242,22 @@ if ($action == 'builddoc') $outfile = $langs->trans("BarCode").'_sheets_'.dol_print_date(dol_now(), 'dayhourlog').'.pdf'; - if (!$mesg) $result = doc_label_pdf_create($db, $arrayofrecords, $modellabel, $outputlangs, $diroutput, $template, dol_sanitizeFileName($outfile)); + if (!$mesg) { + $outputlangs = $langs; + + // This generates and send PDF to output + // TODO Move + $result = doc_label_pdf_create($db, $arrayofrecords, $modellabel, $outputlangs, $diroutput, $template, dol_sanitizeFileName($outfile)); + } } - if ($result <= 0) - { - dol_print_error('', $result); - } + if ($result <= 0 || $mesg) { + if (empty($mesg)) { + $mesg = 'Error '.$result; + } - if (!$mesg) - { + setEventMessages($mesg, null, 'errors'); + } else { $db->close(); exit; } @@ -275,10 +286,10 @@ dol_htmloutput_errors($mesg); //print img_picto('','puce').' '.$langs->trans("PrintsheetForOneBarCode").'
    '; //print '
    '; -print '
    '; +print ''; // The target is for brothers that open the file instead of downloading it print ''; print ''; -print ''; +print ''; // The page will not renew the token but force download of a file, so we must use here currentToken print '
    '; diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index 90836ca4fd9..0b4db8c2619 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -321,24 +321,6 @@ class pdf_standardlabel extends CommonStickerGenerator if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - // Output to http stream - clearstatcache(); - - $attachment = true; - if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; - $type = dol_mimetype($filename); - - //if ($encoding) header('Content-Encoding: '.$encoding); - if ($type) header('Content-Type: '.$type); - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); - else header('Content-Disposition: inline; filename="'.$filename.'"'); - - // Ajout directives pour resoudre bug IE - header('Cache-Control: Public, must-revalidate'); - header('Pragma: public'); - - readfile($file); - $this->result = array('fullpath'=>$file); return 1; diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index 1540fc29e8e..e4f46d269e2 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -359,23 +359,6 @@ class pdf_tcpdflabel extends CommonStickerGenerator if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - // Output to http stream - clearstatcache(); - - $attachment = true; - if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; - $type = dol_mimetype($filename); - - //if ($encoding) header('Content-Encoding: '.$encoding); - if ($type) header('Content-Type: '.$type); - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); - else header('Content-Disposition: inline; filename="'.$filename.'"'); - - // Ajout directives pour resoudre bug IE - header('Cache-Control: Public, must-revalidate'); - header('Pragma: public'); - - readfile($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/printsheet/modules_labels.php b/htdocs/core/modules/printsheet/modules_labels.php index 3320b4ff928..c04d0acc4ed 100644 --- a/htdocs/core/modules/printsheet/modules_labels.php +++ b/htdocs/core/modules/printsheet/modules_labels.php @@ -150,6 +150,27 @@ function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outp if ($obj->write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir, $filename) > 0) { $outputlangs->charset_output = $sav_charset_output; + + $fullpath = $obj->result['fullpath']; + + // Output to http stream + clearstatcache(); + + $attachment = true; + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; + $type = dol_mimetype($filename); + + //if ($encoding) header('Content-Encoding: '.$encoding); + if ($type) header('Content-Type: '.$type); + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); + else header('Content-Disposition: inline; filename="'.$filename.'"'); + + // Ajout directives pour resoudre bug IE + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); + + readfile($fullpath); + return 1; } else { $outputlangs->charset_output = $sav_charset_output; From 53014486d3c42a6976db877b1420bf99c474ee4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 02:24:21 +0100 Subject: [PATCH 34/39] Fix default fields --- htdocs/product/stock/class/entrepot.class.php | 22 +++---- htdocs/product/stock/list.php | 58 ++++++++----------- 2 files changed, 35 insertions(+), 45 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index d7a52cd1910..f32b2a0e586 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -119,24 +119,24 @@ class Entrepot extends CommonObject public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>10), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>15), - 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'showoncombobox'=>1, 'position'=>25), + 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'showoncombobox'=>1, 'position'=>25, 'searchall'=>1), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30), - 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35), - 'lieu' =>array('type'=>'varchar(64)', 'label'=>'LocationSummary', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'showoncombobox'=>1), + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35, 'searchall'=>1), + 'lieu' =>array('type'=>'varchar(64)', 'label'=>'LocationSummary', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'showoncombobox'=>1, 'searchall'=>1), 'fk_parent' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:1:statut=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ParentWarehouse', 'enabled'=>1, 'visible'=>-2, 'position'=>41), - 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-2, 'position'=>45), - 'zip' =>array('type'=>'varchar(10)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-2, 'position'=>50), - 'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-2, 'position'=>55), + 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-2, 'position'=>45, 'searchall'=>1), + 'zip' =>array('type'=>'varchar(10)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-2, 'position'=>50, 'searchall'=>1), + 'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-2, 'position'=>55, 'searchall'=>1), 'fk_departement' =>array('type'=>'sellist:c_departements:label:rowid::active=1', 'label'=>'State', 'enabled'=>1, 'visible'=>0, 'position'=>60), 'fk_pays' =>array('type'=>'sellist:c_country:label:rowid::active=1', 'label'=>'Country', 'enabled'=>1, 'visible'=>-2, 'position'=>65), - 'phone' =>array('type'=>'varchar(20)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>-2, 'position'=>70), - 'fax' =>array('type'=>'varchar(20)', 'label'=>'Fax', 'enabled'=>1, 'visible'=>-2, 'position'=>75), + 'phone' =>array('type'=>'varchar(20)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>-2, 'position'=>70, 'searchall'=>1), + 'fax' =>array('type'=>'varchar(20)', 'label'=>'Fax', 'enabled'=>1, 'visible'=>-2, 'position'=>75, 'searchall'=>1), //'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-2, 'position'=>82), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>300), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>301), //'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000), //'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>1010), - 'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>200), + 'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>500), ); /** diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index f2c7133618b..6aec9bd2307 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -84,18 +84,6 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -// List of fields to search into when doing a "search in all" -$fieldstosearchall = array( - 't.ref'=>"Ref", - 't.lieu'=>"LocationSummary", - 't.description'=>"Description", - 't.address'=>"Address", - 't.zip'=>'Zip', - 't.town'=>'Town', - 't.phone'=>'Phone', - 't.fax'=>'Fax', -); - // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); @@ -106,37 +94,39 @@ foreach ($object->fields as $key => $val) if (GETPOST('search_'.$search_key, 'alpha') !== '') $search[$search_key] = GETPOST('search_'.$search_key, 'alpha'); } -// Definition of fields for list -$arrayfields = array( - 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70), - 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71), - 'estimatedstockvaluesell'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72), -); +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); foreach ($object->fields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } -// Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) - { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { - $arrayfields["ef.".$key] = array( - 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), - 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) - ); - } + +// Definition of array of fields for columns +$arrayfields = array( + 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'checked'=>0, 'position'=>170), + 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>1, 'checked'=>1, 'position'=>171), + 'estimatedstockvaluesell'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'checked'=>1, 'visible'=>2, 'position'=>172), +); +foreach ($object->fields as $key => $val) { + // If $val['visible']==0, then we never show the field + if (!empty($val['visible'])) { + $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'=>$val['help'] + ); } } +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; + $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); - /* * Actions */ From 9a057386aa820036866f543605ae818edc153bed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 02:38:02 +0100 Subject: [PATCH 35/39] Fix look and feel --- htdocs/product/stock/product.php | 14 +++++++------- htdocs/product/stock/replenish.php | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 89df906feda..d1c1ea99ff7 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -636,13 +636,13 @@ if ($id > 0 || $ref) // Real stock $text_stock_options = $langs->trans("RealStockDesc").'
    '; $text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen").'
    '; - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? $langs->trans("DeStockOnShipment").'
    ' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? $langs->trans("DeStockOnValidateOrder").'
    ' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? $langs->trans("DeStockOnBill").'
    ' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill").'
    ' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder").'
    ' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder").'
    ' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? $langs->trans("StockOnReception").'
    ' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? '- '.$langs->trans("DeStockOnShipment").'
    ' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? '- '.$langs->trans("DeStockOnValidateOrder").'
    ' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? '- '.$langs->trans("DeStockOnBill").'
    ' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? '- '.$langs->trans("ReStockOnBill").'
    ' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? '- '.$langs->trans("ReStockOnValidateOrder").'
    ' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? '- '.$langs->trans("ReStockOnDispatchOrder").'
    ' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? '- '.$langs->trans("StockOnReception").'
    ' : ''); print '
    '; + print ''; + print "\n"; + } + } addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); @@ -236,10 +253,18 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa if ($num > 0) { $i = 0; + $othernb = 0; - while ($i < $nbofloop) { + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); + if ($i >= $max) { + $othernb += 1; + $i++; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); + continue; + } + $supplierproposalstatic->id = $obj->rowid; $supplierproposalstatic->ref = $obj->ref; $supplierproposalstatic->total_ht = $obj->total_ht; @@ -270,6 +295,15 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $i++; $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } + + if ($othernb) { + print ''; + print ''; + print "\n"; + } + } addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); @@ -310,10 +344,18 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { if ($num > 0) { $i = 0; + $othernb = 0; - while ($i < $nbofloop) { + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); + if ($i >= $max) { + $othernb += 1; + $i++; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); + continue; + } + $orderstatic->id = $obj->rowid; $orderstatic->ref = $obj->ref; $orderstatic->ref_client = $obj->ref_client; @@ -345,6 +387,15 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $i++; $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } + + if ($othernb) { + print ''; + print ''; + print "\n"; + } + } addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); @@ -385,10 +436,18 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU if ($num > 0) { $i = 0; + $othernb = 0; - while ($i < $nbofloop) { + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); + if ($i >= $max) { + $othernb += 1; + $i++; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); + continue; + } + $supplierorderstatic->id = $obj->rowid; $supplierorderstatic->ref = $obj->ref; $supplierorderstatic->ref_supplier = $obj->ref_suppliert; @@ -420,6 +479,15 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $i++; $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } + + if ($othernb) { + print ''; + print ''; + print "\n"; + } + } addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 1d4d1a37354..5f5da8f83d9 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -193,11 +193,19 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $companystatic = new Societe($db); $i = 0; + $othernb = 0; $tot_ttc = 0; - while ($i < $num) + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); + if ($i >= $max) { + $othernb += 1; + $i++; + $tot_ttc += $obj->total_ttc; + continue; + } + $tmpinvoice->id = $obj->rowid; $tmpinvoice->ref = $obj->ref; $tmpinvoice->date = $db->jdate($obj->date); @@ -232,6 +240,14 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $i++; } + if ($othernb) { + print ''; + print ''; + print "\n"; + } + print ''; print ''; print ''; @@ -290,11 +306,19 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $companystatic = new Societe($db); $i = 0; + $othernb = 0; $tot_ttc = 0; - while ($i < $num) + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); + if ($i >= $max) { + $othernb += 1; + $i++; + $tot_ttc += $obj->total_ttc; + continue; + } + $facturesupplierstatic->ref = $obj->ref; $facturesupplierstatic->id = $obj->rowid; $facturesupplierstatic->total_ht = $obj->total_ht; @@ -328,6 +352,14 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $i++; } + if ($othernb) { + print ''; + print ''; + print "\n"; + } + print ''; print ''; print '';
    '.$langs->trans("LocalisationDolibarrParameters").''.$langs->trans("Value").'
    '.$langs->trans("LocalisationDolibarrParameters").''.$langs->trans("Value").'
    '.$langs->trans("LanguageBrowserParameter", "HTTP_ACCEPT_LANGUAGE").''.$_SERVER["HTTP_ACCEPT_LANGUAGE"].'
    '.$langs->trans("CurrentUserLanguage").''.$langs->getDefaultLang().'
      => price(1234.56)'.price(1234.56).'
    '.$langs->trans("MySQLTimeZone").' (database)'; // Timezone server base + $sql = "SHOW VARIABLES where variable_name = 'system_time_zone'"; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + print $form->textwithtooltip($obj->Value, $langs->trans('TZHasNoEffect'), 2, 1, img_info('')); + } + print '
      => '.$langs->trans("CurrentHour").''.dol_print_date(dol_now(), 'dayhour', 'tzserver').'
      => '.$langs->trans("CurrentHour").''.dol_print_date(dol_now('gmt'), 'dayhour', 'tzserver').'
      => dol_print_date(0,"dayhourtext")'.dol_print_date(0, "dayhourtext").'
      => dol_get_first_day(1970,1,false)'.dol_get_first_day(1970, 1, false).'     (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970, 1, false), 'dayhour').')
      => dol_get_first_day(1970,1,true)'.dol_get_first_day(1970, 1, true).'     (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970, 1, true), 'dayhour').')
    '.$langs->trans("MySQLTimeZone").' (database)'; // Timezone server base - $sql = "SHOW VARIABLES where variable_name = 'system_time_zone'"; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - print $form->textwithtooltip($obj->Value, $langs->trans('TZHasNoEffect'), 2, 1, img_info('')); - } - print '
    '.$langs->trans("ClientTZ").''.($tz ? ($tz >= 0 ? '+' : '').$tz : '').' ('.($tz >= 0 ? '+' : '').($tz * 60 * 60).')'; @@ -265,7 +267,7 @@ else print yn(0); if (!empty($_SESSION['dol_dst_first'])) print '     ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']), 'dayhour', 'gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']), 'dayhour', 'gmt').')'; print '
      => '.$langs->trans("ClientHour").''.dol_print_date(dol_now(), 'dayhour', 'tzuser').'
      => '.$langs->trans("ClientHour").''.dol_print_date(dol_now('gmt'), 'dayhour', 'tzuser').'
    '.$langs->trans("File encoding").' (php.ini unicode.filesystem_encoding)'.$filesystemencoding.'
    '.$langs->trans("EventOnFullDay").'
    '.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>
    '.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").''; if (GETPOST("afaire") == 1) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart'); + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuser'); } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuser'); } else { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuser'); } print ' - '; if (GETPOST("afaire") == 1) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuser'); } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuser'); } else { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuser'); } print '
    '.$langs->trans("DateActionStart").''; - if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour'); - else print dol_print_date($object->datep, 'day'); + if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour', 'tzuser'); + else print dol_print_date($object->datep, 'day', 'tzuser'); if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
    '.$langs->trans("DateActionEnd").''; - if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); - else print dol_print_date($object->datef, 'day'); + if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour', 'tzuser'); + else print dol_print_date($object->datef, 'day', 'tzuser'); if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
    '; - print dol_print_date($db->jdate($obj->dp), $formatToUse); + print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser'); $late = 0; if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; @@ -749,7 +749,7 @@ if ($resql) // End date if (!empty($arrayfields['a.datep2']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->dp2), $formatToUse); + print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuser'); print ''.dol_print_date($db->jdate($obj->datec), 'dayhour').''.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuser').''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuser').'
    '.$langs->trans("DateCreation").''; - print dol_print_date($object->datec, 'dayhour'); + print dol_print_date($object->datec, 'dayhour', 'tzuser'); print ' - '.$langs->trans("TimeElapsedSince").': '.convertSecondToTime(roundUpToNextMultiple($now - $object->datec, 60)).''; print '
    '.$langs->trans("TicketReadOn").''; if (!empty($object->date_read)) { - print dol_print_date($object->date_read, 'dayhour'); + print dol_print_date($object->date_read, 'dayhour', 'tzuser'); print ' - '.$langs->trans("TicketTimeToRead").': '.convertSecondToTime(roundUpToNextMultiple($object->date_read - $object->datec, 60)).''; print ' - '.$langs->trans("TimeElapsedSince").': '.convertSecondToTime(roundUpToNextMultiple($now - $object->date_read, 60)).''; } @@ -954,7 +954,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = // Close date print '
    '.$langs->trans("TicketCloseOn").''; if (!empty($object->date_close)) { - print dol_print_date($object->date_close, 'dayhour'); + print dol_print_date($object->date_close, 'dayhour', 'tzuser'); } print '
    '; print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index ed537f1bd4e..64dd485671d 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -538,9 +538,9 @@ print dol_get_fiche_head($head, 'replenish', '', -1, ''); print ''.$langs->trans("ReplenishmentStatusDesc").''."\n"; if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { - print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."
    \n"; + print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."\n"; } -print '
    '; +print '

    '; if ($usevirtualstock == 1) { print $langs->trans("CurentSelectionMode").': '; From 01b7b7692d60a2aa3abf1357b14decf55bc9d7c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 03:22:54 +0100 Subject: [PATCH 36/39] Prepare 13.0.1 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 97f02998e83..1cc471e0244 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (!defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE', 'Dolibarr'); -if (!defined('DOL_VERSION')) define('DOL_VERSION', '13.0.0'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (!defined('DOL_VERSION')) define('DOL_VERSION', '13.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (!defined('EURO')) define('EURO', chr(128)); From 3b9bd3cc402fa1fdf0ff7ea5e164c345c5ec20aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 11:15:16 +0100 Subject: [PATCH 37/39] Fix responsive --- htdocs/core/boxes/box_last_ticket.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 268a6861524..dbc453eced6 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -134,7 +134,7 @@ class box_last_ticket extends ModeleBoxes $thirdparty->name = $objp->company_name; $link = $thirdparty->getNomUrl(1); } else { - $link = dol_print_email($objp->origin_email); + $link = ''.dol_print_email($objp->origin_email).''; } $r = 0; @@ -149,15 +149,15 @@ class box_last_ticket extends ModeleBoxes // Subject $this->info_box_contents[$i][$r] = array( - 'td' => '', - 'text' => $objp->subject, // Some event have no ref + 'td' => 'class="tdoverflowmax200"', + 'text' => ''.$objp->subject.'', // Some event have no ref 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, ); $r++; // Customer $this->info_box_contents[$i][$r] = array( - 'td' => '', + 'td' => 'class="tdoverflowmax100"', 'text' => $link, 'asis' => 1, ); From c2db7ccf14d0ec8b8a6de941613ab1d9e13cd167 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 11:15:24 +0100 Subject: [PATCH 38/39] Look and feel v14 --- htdocs/theme/eldy/global.inc.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 3b69dfbc0ba..05b0f1308ec 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3066,6 +3066,9 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd .smallpaddingimp { padding: 4px !important; } +input.button.smallpaddingimp { + font-size: 0.8em; +} .nopaddingleft { padding-: 0px; } @@ -5662,6 +5665,8 @@ a span.select2-chosen } span#select2-boxbookmark-container, span#select2-boxcombo-container { text-align: ; +} +span#select2-boxbookmark-container { opacity: 0.4; } .select2-container .select2-selection--single .select2-selection__rendered { From c94ecb8a42375db322dc34683e86574b4920c65b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 11:34:34 +0100 Subject: [PATCH 39/39] Limit list of draft element in home sections --- htdocs/comm/index.php | 76 ++++++++++++++++++++++++++++++++++++++--- htdocs/compta/index.php | 36 +++++++++++++++++-- 2 files changed, 106 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 384b88655f6..89ca2513ab2 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -161,10 +161,18 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { if ($num > 0) { $i = 0; + $othernb = 0; - while ($i < $nbofloop) { + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); + if ($i >= $max) { + $othernb += 1; + $i++; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); + continue; + } + $propalstatic->id = $obj->rowid; $propalstatic->ref = $obj->ref; $propalstatic->ref_client = $obj->ref_client; @@ -196,6 +204,15 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $i++; $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } + + if ($othernb) { + print '
    '; + print ''.$langs->trans("More").'... ('.$othernb.')'; + print '
    '; + print ''.$langs->trans("More").'... ('.$othernb.')'; + print '
    '; + print ''.$langs->trans("More").'... ('.$othernb.')'; + print '
    '; + print ''.$langs->trans("More").'... ('.$othernb.')'; + print '
    '; + print ''.$langs->trans("More").'... ('.$othernb.')'; + print '
    '.$langs->trans("Total").''.price($tot_ttc).'
    '; + print ''.$langs->trans("More").'... ('.$othernb.')'; + print '
    '.$langs->trans("Total").''.price($tot_ttc).'