mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Merge branch 'NEW/update_on_categorie_product_link_table' of github.com:atm-gauthier/dolibarr into NEW/develop_update_on_categorie_product_link_table
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->tra
|
||||
// User
|
||||
print '<tr><td>'.$langs->trans("Employee").'</td><td>';
|
||||
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 '</td></tr>';
|
||||
// Year
|
||||
print '<tr><td>'.$langs->trans("Year").'</td><td>';
|
||||
|
||||
Reference in New Issue
Block a user