This commit is contained in:
Laurent Destailleur 2022-11-17 12:39:24 +01:00
parent 6d4086fc24
commit 28833e71a1
2 changed files with 16 additions and 6 deletions

View File

@ -270,10 +270,13 @@ if (empty($reshook)) {
if ($ret == -3) {
$error++;
$object->fetch($object->product_id_already_linked);
$productLink = $object->getNomUrl(1, 'supplier');
$tmpobject = new Product($db);
$tmpobject->fetch($object->product_id_already_linked);
$productLink = $tmpobject->getNomUrl(1, 'supplier');
setEventMessages($langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct", $productLink), null, 'errors');
$texttoshow = $langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct", '{s1}');
$texttoshow = str_replace('{s1}', $productLink, $texttoshow);
setEventMessages($texttoshow, null, 'errors');
} elseif ($ret < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');

View File

@ -176,7 +176,6 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'p.ref'=>"Ref",
'pfp.ref_fourn'=>"RefSupplier",
'p.label'=>"ProductLabel",
'p.description'=>"Description",
"p.note"=>"Note",
@ -190,7 +189,6 @@ if (getDolGlobalInt('MAIN_MULTILANGS')) {
}
if (isModEnabled('barcode')) {
$fieldstosearchall['p.barcode'] = 'Gencod';
$fieldstosearchall['pfp.barcode'] = 'GencodBuyPrice';
}
// Personalized search criterias. Example: $conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS = 'p.ref=ProductRef;p.label=ProductLabel;p.description=Description;p.note=Note;'
if (!empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) {
@ -459,7 +457,16 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
$sql .= ' AND (';
$sql .= natural_search(array_keys($fieldstosearchall), $sall, 0, 1);
// Search also into a supplier reference 'pfp.ref_fourn'="RefSupplier"
$sql .= ' OR EXISTS (SELECT rowid FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid';
$sql .= ' AND ('.natural_search('pfp.ref_fourn', $sall, 0, 1);
if (isModEnabled('barcode')) {
// Search also into a supplier barcode 'pfp.barcode'='GencodBuyPrice';
$sql .= ' OR '.natural_search('pfp.barcode', $sall, 0, 1);
}
$sql .= ')))';
}
// if the type is not 1, we show all products (type = 0,2,3)
if (dol_strlen($search_type) && $search_type != '-1') {