diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index e45630df298..58ff558b54b 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -785,11 +785,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(); @@ -807,6 +814,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)); @@ -868,6 +876,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 9fa5cbf2c44..564156e8cc1 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -825,11 +825,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(); @@ -847,6 +855,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)); @@ -908,6 +917,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 c3b7f256b4b..53299d54259 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 diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 9c9f960c3e1..0586f004e20 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -210,6 +210,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'); } } diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 764272a135f..00d3463357c 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 cb8eb14a05b..b3a8fdaa30e 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").'';