'.$langs->trans('RefSupplier').' '.$langs->trans('RefSupplierBill').' id) && $societe->id > 0) {
print ' autofocus';
}
@@ -2960,7 +2960,7 @@ if ($action == 'create') {
if ($action == 'clone') {
// Create an array for form
$formquestion = array(
- array('type' => 'text', 'name' => 'newsupplierref', 'label' => $langs->trans("RefSupplier"), 'value' => $langs->trans("CopyOf").' '.$object->ref_supplier),
+ array('type' => 'text', 'name' => 'newsupplierref', 'label' => $langs->trans("RefSupplierBill"), 'value' => $langs->trans("CopyOf").' '.$object->ref_supplier),
array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now())
);
// Ask confirmation to clone
@@ -3192,8 +3192,8 @@ if ($action == 'create') {
$morehtmlref = '';
// Ref supplier
- $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', 0, 1);
- $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', null, null, '', 1);
+ $morehtmlref .= $form->editfieldkey("RefSupplierBill", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', 0, 1);
+ $morehtmlref .= $form->editfieldval("RefSupplierBill", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref .= ' '.$object->thirdparty->getNomUrl(1, 'supplier');
if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 63c86001b28..e45de1d3553 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -268,6 +268,8 @@ NoDraftBills=No draft invoices
NoOtherDraftBills=No other draft invoices
NoDraftInvoices=No draft invoices
RefBill=Invoice ref
+RefSupplierBill=Supplier invoice ref
+SupplierOrderCreateBill=Create invoice
ToBill=To bill
RemainderToBill=Remainder to bill
SendBillByMail=Send invoice by email
From a9d39252908e4ef173ecaa4881cdd5ead028a937 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Tue, 19 Dec 2023 15:58:19 +0100
Subject: [PATCH 08/10] Clean code
---
htdocs/fourn/class/fournisseur.facture-rec.class.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php
index 17c852f449d..994c5e89a1d 100644
--- a/htdocs/fourn/class/fournisseur.facture-rec.class.php
+++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php
@@ -1361,9 +1361,9 @@ class FactureFournisseurRec extends CommonInvoice
if (!$error && $facturerec->generate_pdf) {
// We refresh the object in order to have all necessary data (like date_lim_reglement)
- $laststep="Refresh {$new_fac_fourn->id}";
+ $laststep="Refresh ".$new_fac_fourn->id;
$new_fac_fourn->fetch($new_fac_fourn->id);
- $laststep="GenerateDocument {$new_fac_fourn->id}";
+ $laststep="GenerateDocument ".$new_fac_fourn->id;
$result = $new_fac_fourn->generateDocument($facturerec->model_pdf, $langs);
if ($result < 0) {
$this->errors = $new_fac_fourn->errors;
From 27df30b773d082638cc0fee87e2ab0e0d85c32c6 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Tue, 19 Dec 2023 16:22:02 +0100
Subject: [PATCH 09/10] Merge branch 'develop' of
git@github.com:Dolibarr/dolibarr.git into develop
---
htdocs/expedition/list.php | 52 +++++++++++++++++++++++++++-----------
htdocs/reception/list.php | 8 ++++++
2 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php
index 4394f2018e1..0a065a71933 100644
--- a/htdocs/expedition/list.php
+++ b/htdocs/expedition/list.php
@@ -178,7 +178,6 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
- $search_categ = '';
$search_user = '';
$search_sale = '';
$search_product_category = '';
@@ -274,9 +273,6 @@ $sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
$sql .= " e.date_creation as date_creation, e.tms as date_update,";
$sql .= " u.login";
-if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
- $sql .= ", cc.fk_categorie, cc.fk_soc";
-}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
@@ -299,9 +295,6 @@ if ($search_all) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON pd.rowid=ed.fk_origin_line';
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
-if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
-}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
@@ -362,9 +355,6 @@ if ($search_tracking) {
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
$sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
}
-if ($search_sale > 0) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
-}
if ($search_user > 0) {
// The contact on a shipment is also the contact of the order.
$sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = eesource.fk_source AND ec.fk_socpeople = ".((int) $search_user);
@@ -395,11 +385,43 @@ if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) {
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
-if ($search_categ_cus > 0) {
- $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus);
+// Search on sale representative
+if ($search_sale && $search_sale != '-1') {
+ if ($search_sale == -2) {
+ $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = e.fk_soc)";
+ } elseif ($search_sale > 0) {
+ $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = e.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
+ }
}
-if ($search_categ_cus == -2) {
- $sql .= " AND cc.fk_categorie IS NULL";
+// Search for tag/category ($searchCategoryCustomerList is an array of ID)
+$searchCategoryCustomerOperator = -1;
+$searchCategoryCustomerList = array($search_categ_cus);
+if (!empty($searchCategoryCustomerList)) {
+ $searchCategoryCustomerSqlList = array();
+ $listofcategoryid = '';
+ foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
+ if (intval($searchCategoryCustomer) == -2) {
+ $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc)";
+ } elseif (intval($searchCategoryCustomer) > 0) {
+ if ($searchCategoryCustomerOperator == 0) {
+ $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategoryCustomer).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
+ }
+ }
+ }
+ if ($listofcategoryid) {
+ $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ }
+ if ($searchCategoryCustomerOperator == 1) {
+ if (!empty($searchCategoryCustomerSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
+ }
+ } else {
+ if (!empty($searchCategoryCustomerSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
+ }
+ }
}
// Search for tag/category ($searchCategoryProductList is an array of ID)
$searchCategoryProductOperator = -1;
@@ -1179,7 +1201,7 @@ if ($num == 0) {
$colspan++;
}
}
- print ''.$langs->trans("NoRecordFound").' ';
+ print ''.$langs->trans("NoRecordFound").' ';
}
$db->free($resql);
diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php
index a03270f809b..372d8136940 100644
--- a/htdocs/reception/list.php
+++ b/htdocs/reception/list.php
@@ -677,6 +677,14 @@ if ($search_ref_supplier) {
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
+// Search on sale representative
+if ($search_sale && $search_sale != '-1') {
+ if ($search_sale == -2) {
+ $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
+ } elseif ($search_sale > 0) {
+ $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
+ }
+}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
From 70c53b4568de04ac3122ca0f6a3a0b352a6bcb29 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Tue, 19 Dec 2023 16:24:04 +0100
Subject: [PATCH 10/10] Debug v19
---
htdocs/reception/list.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php
index 372d8136940..1239a6dc2c4 100644
--- a/htdocs/reception/list.php
+++ b/htdocs/reception/list.php
@@ -678,6 +678,7 @@ if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
// Search on sale representative
+/*
if ($search_sale && $search_sale != '-1') {
if ($search_sale == -2) {
$sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
@@ -685,7 +686,7 @@ if ($search_sale && $search_sale != '-1') {
$sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
}
}
-
+*/
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks