NEW Add import ID in list of products

This commit is contained in:
Laurent Destailleur 2024-02-09 15:02:02 +01:00
parent ac6b230a86
commit f3796f59eb

View file

@ -269,7 +269,8 @@ $arrayfields = array(
'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
'p.tosell'=>array('label'=>$langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Sell").')', 'checked'=>1, 'position'=>1000),
'p.tobuy'=>array('label'=>$langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Buy").')', 'checked'=>1, 'position'=>1000)
'p.tobuy'=>array('label'=>$langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Buy").')', 'checked'=>1, 'position'=>1000),
'p.import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'checked'=>-1, 'position'=>1100),
);
/*foreach ($object->fields as $key => $val) {
// If $val['visible']==0, then we never show the field
@ -447,7 +448,9 @@ if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
$sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
}
$sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock, p.cost_price,';
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, fk_country, fk_state,';
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units,';
$sql .= ' p.fk_country, p.fk_state,';
$sql .= ' p.import_key,';
if (getDolGlobalString('PRODUCT_USE_UNITS')) {
$sql .= ' p.fk_unit, cu.label as cu_label,';
}
@ -629,7 +632,9 @@ if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
} else {
$sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
}
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.fk_country, p.fk_state';
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units,';
$sql .= ' p.fk_country, p.fk_state,';
$sql .= ' p.import_key';
if (getDolGlobalString('PRODUCT_USE_UNITS')) {
$sql .= ', p.fk_unit, cu.label';
}
@ -1225,6 +1230,10 @@ if (!empty($arrayfields['p.tms']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
if (!empty($arrayfields['p.import_key']['checked'])) {
print '<td class="liste_titre center">';
print '</td>';
}
if (!empty($arrayfields['p.tosell']['checked'])) {
print '<td class="liste_titre center parentonrightofpage">';
print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'), '1'=>$langs->trans('ProductStatusOnSellShort')), $search_tosell, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
@ -1456,6 +1465,10 @@ if (!empty($arrayfields['p.tms']['checked'])) {
print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.import_key']['checked'])) {
print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.tosell']['checked'])) {
print_liste_field_titre($arrayfields['p.tosell']['label'], $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
@ -1542,6 +1555,7 @@ while ($i < $imaxinloop) {
if (getDolGlobalString('PRODUCT_USE_UNITS')) {
$product_static->fk_unit = $obj->fk_unit;
}
$product_static->import_key = $obj->import_key;
// STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock.
if ((isModEnabled('stock') && $user->hasRight('stock', 'lire') && $search_type != 1) || getDolGlobalString('STOCK_DISABLE_OPTIM_LOAD')) { // To optimize call of load_stock
@ -2181,6 +2195,16 @@ while ($i < $imaxinloop) {
}
}
// Import ID
if (!empty($arrayfields['p.import_key']['checked'])) {
print '<td class="center nowrap">';
print dol_escape_htmltag($product_static->import_key);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Status (to sell)
if (!empty($arrayfields['p.tosell']['checked'])) {
print '<td class="center nowrap">';