From 29d1424413f56414b07536f461aca77862223d3a Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 5 May 2022 11:05:34 +0200 Subject: [PATCH 1/4] fix merge conflict Add missing error translation key --- htdocs/langs/en_US/errors.lang | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 37cc7a1b6fd..66c5d0e240d 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -274,6 +274,7 @@ ErrorExecIdFailed=Can't execute command "id" ErrorBadCharIntoLoginName=Unauthorized character in the login name ErrorInvoiceLoadThirdParty=Can't load third-party object for invoice "%s" ErrorInvoiceLoadThirdPartyKey=Third-party key "%s" no set for invoice "%s" +ErrorDeleteLineNotAllowedByObjectStatus=Delete line is not allowed by actual object status # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. @@ -307,8 +308,5 @@ WarningTheHiddenOptionIsOn=Warning, the hidden option %s is on. WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection. WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. -<<<<<<< HEAD WarningPaypalPaymentNotCompatibleWithStrict=The value 'Strict' makes the online payment features not working correctly. Use 'Lax' instead. -======= ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git From 10e13286d376d3c263e3f1cae5ecedba8027abad Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 5 May 2022 11:04:27 +0200 Subject: [PATCH 2/4] Add missing reception back to draft error handling --- htdocs/reception/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index fda5a3910b7..9a679c067f8 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -197,6 +197,8 @@ if (empty($reshook)) { $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } + } else { + setEventMessages($object->error, $object->errors, 'errors'); } } From 2256f8811dffc6d0046e8968dae105b9efe332db Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 6 May 2022 11:24:53 +0200 Subject: [PATCH 3/4] FIX : in salary stats and payment list, we must check right perms as well as salary list --- htdocs/salaries/class/salariesstats.class.php | 20 +++++++++---------- htdocs/salaries/payments.php | 2 +- htdocs/salaries/stats/index.php | 6 +++++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/htdocs/salaries/class/salariesstats.class.php b/htdocs/salaries/class/salariesstats.class.php index b3e6c20a0ca..41898bb7341 100644 --- a/htdocs/salaries/class/salariesstats.class.php +++ b/htdocs/salaries/class/salariesstats.class.php @@ -23,7 +23,7 @@ * \brief Fichier de la classe de gestion des stats des salaires */ include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +include_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; /** * Classe permettant la gestion des stats des salaires @@ -58,7 +58,7 @@ class SalariesStats extends Stats $this->socid = $socid; $this->userid = $userid; - $object = new PaymentSalary($this->db); + $object = new Salary($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element; $this->field = 'amount'; @@ -81,7 +81,7 @@ class SalariesStats extends Stats */ public function getNbByYear() { - $sql = "SELECT YEAR(datep) as dm, count(*)"; + $sql = "SELECT YEAR(dateep) as dm, count(*)"; $sql .= " FROM ".$this->from; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm DESC"; @@ -99,9 +99,9 @@ class SalariesStats extends Stats */ public function getNbByMonth($year, $format = 0) { - $sql = "SELECT MONTH(datep) as dm, count(*)"; + $sql = "SELECT MONTH(dateep) as dm, count(*)"; $sql .= " FROM ".$this->from; - $sql .= " WHERE YEAR(datep) = ".((int) $year); + $sql .= " WHERE YEAR(dateep) = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -121,9 +121,9 @@ class SalariesStats extends Stats */ public function getAmountByMonth($year, $format = 0) { - $sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")"; + $sql = "SELECT date_format(dateep,'%m') as dm, sum(".$this->field.")"; $sql .= " FROM ".$this->from; - $sql .= " WHERE date_format(datep,'%Y') = '".$this->db->escape($year)."'"; + $sql .= " WHERE date_format(dateep,'%Y') = '".$this->db->escape($year)."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -141,9 +141,9 @@ class SalariesStats extends Stats */ public function getAverageByMonth($year) { - $sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")"; + $sql = "SELECT date_format(dateep,'%m') as dm, avg(".$this->field.")"; $sql .= " FROM ".$this->from; - $sql .= " WHERE date_format(datep,'%Y') = '".$this->db->escape($year)."'"; + $sql .= " WHERE date_format(dateep,'%Y') = '".$this->db->escape($year)."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -158,7 +158,7 @@ class SalariesStats extends Stats */ public function getAllByYear() { - $sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql = "SELECT date_format(dateep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql .= " FROM ".$this->from; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index f129e6304ab..964c2521f3c 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -234,7 +234,7 @@ $sql .= " ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = sal.fk_user"; $sql .= " AND s.entity IN (".getEntity('payment_salaries').")"; if (empty($user->rights->salaries->readall)) { - $sql .= " AND s.fk_user IN (".$db->sanitize(join(',', $childids)).")"; + $sql .= " AND sal.fk_user IN (".$db->sanitize(join(',', $childids)).")"; } // Search criteria diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index ecc62c2a237..bfacd908c12 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -74,6 +74,10 @@ dol_mkdir($dir); $useridtofilter = $userid; // Filter from parameters +if (empty($user->rights->salaries->readall) && empty($useridtofilter)) { + $useridtofilter = $user->getAllChildIds(1); +} + $stats = new SalariesStats($db, $socid, $useridtofilter); @@ -204,7 +208,7 @@ print ''.$langs->tra // User print ''.$langs->trans("Employee").''; print img_picto('', 'user', 'class="pictofixedwidth"'); -print $form->select_dolusers(($userid ? $userid : -1), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); +print $form->select_dolusers(($userid ? $userid : -1), 'userid', 1, '', 0, empty($user->rights->salaries->readall) ? 'hierarchyme' : '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); print ''; // Year print ''.$langs->trans("Year").''; From 08a3ef5bbf5e1aa7b38a9340d183880f1e14ffa1 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 10 May 2022 12:25:38 +0200 Subject: [PATCH 4/4] NEW : method avoid being blocked when entry already exists for import in llx_categorie_product (use update keys) --- htdocs/core/modules/import/import_csv.modules.php | 14 +++++++++++++- .../core/modules/import/import_xlsx.modules.php | 15 ++++++++++++++- htdocs/core/modules/modCategorie.class.php | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 78c8f5e104f..8a99dfe90d2 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -776,11 +776,18 @@ class ImportCsv extends ModeleImports $updatedone = false; $insertdone = false; + $is_table_category_link = false; + $fname = 'rowid'; + if(strpos($tablename, '_categorie_') !== false) { + $is_table_category_link = true; + $fname='*'; + } + if (!empty($updatekeys)) { // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) if (empty($lastinsertid)) { // No insert done yet for a parent table - $sqlSelect = 'SELECT rowid FROM '.$tablename; + $sqlSelect = 'SELECT '.$fname.' FROM '.$tablename; $data = array_combine($listfields, $listvalues); $where = array(); @@ -798,6 +805,7 @@ class ImportCsv extends ModeleImports $res = $this->db->fetch_object($resql); if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; + if($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists $last_insert_id_array[$tablename] = $lastinsertid; } elseif ($resql->num_rows > 1) { $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); @@ -859,6 +867,10 @@ class ImportCsv extends ModeleImports } $sqlend = ' WHERE '.$keyfield.' = '.((int) $lastinsertid); + if($is_table_category_link) { + $sqlend = ' WHERE ' . implode(' AND ', $where); + } + $sql = $sqlstart.$sqlend; // Run update request diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 38c9cd8c56a..c972dcbcb28 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -816,11 +816,19 @@ class ImportXlsx extends ModeleImports if (!empty($listfields)) { $updatedone = false; $insertdone = false; + + $is_table_category_link = false; + $fname = 'rowid'; + if(strpos($tablename, '_categorie_') !== false) { + $is_table_category_link = true; + $fname='*'; + } + if (!empty($updatekeys)) { // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) if (empty($lastinsertid)) { // No insert done yet for a parent table - $sqlSelect = 'SELECT rowid FROM ' . $tablename; + $sqlSelect = 'SELECT '.$fname.' FROM ' . $tablename; $data = array_combine($listfields, $listvalues); $where = array(); @@ -838,6 +846,7 @@ class ImportXlsx extends ModeleImports $res = $this->db->fetch_object($resql); if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; + if($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists $last_insert_id_array[$tablename] = $lastinsertid; } elseif ($resql->num_rows > 1) { $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); @@ -899,6 +908,10 @@ class ImportXlsx extends ModeleImports } $sqlend = ' WHERE ' . $keyfield . ' = '.((int) $lastinsertid); + if($is_table_category_link) { + $sqlend = ' WHERE ' . implode(' AND ', $where); + } + $sql = $sqlstart . $sqlend; // Run update request diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 776c5c76681..ab48a702250 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -481,6 +481,7 @@ class modCategorie extends DolibarrModules 'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_product'=>"rowid or ref"); + $this->import_updatekeys_array[$r] = array('cp.fk_categorie' => 'Category', 'cp.fk_product' => 'ProductRef'); } // 1 Suppliers