Fix filter on status of order

This commit is contained in:
Laurent Destailleur
2021-09-05 01:42:15 +02:00
parent 4d314d557d
commit de8db34f43
2 changed files with 18 additions and 25 deletions

View File

@@ -33,7 +33,6 @@
* \brief Page to list orders
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@@ -501,16 +500,13 @@ if ($search_billed != '' && $search_billed >= 0) {
$sql .= ' AND c.facture = '.((int) $search_billed);
}
if ($search_status <> '') {
if ($search_status < 4 && $search_status > -4) {
if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination)
if ($search_status == 1 && empty($conf->expedition->enabled)) {
$sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated'
} else {
$sql .= ' AND c.fk_statut = '.((int) $search_status); // brouillon, validee, en cours, annulee
}
}
if ($search_status == 4) {
$sql .= ' AND c.facture = 1'; // invoice created
}
if ($search_status == -2) { // To process
//$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
$sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
@@ -520,8 +516,6 @@ if ($search_status <> '') {
//$sql.= ' AND c.facture = 0'; // invoice not created
$sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed
}
if ($search_status == -4) { // "validate and in progress"
$sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process
}
@@ -675,9 +669,6 @@ if ($resql) {
if ($search_status == 3) {
$title .= ' - '.$langs->trans('StatusOrderToBillShort');
}
if ($search_status == 4) {
$title .= ' - '.$langs->trans('StatusOrderProcessedShort');
}
if ($search_status == -1) {
$title .= ' - '.$langs->trans('StatusOrderCanceledShort');
}
@@ -1254,10 +1245,10 @@ if ($resql) {
Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"),
Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"),
-3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"),
-4=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"),
-2=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"),
Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort")
);
print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1);
print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1);
print '</td>';
}
// Action column