Facture mass validation: sort by date to avoid conflicts
This commit is contained in:
parent
7c866ce6a2
commit
288663be36
@ -1209,6 +1209,26 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
|
|||||||
setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors');
|
setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
if ($objecttmp->element == 'facture') {
|
||||||
|
if (!empty($toselect) && !empty($conf->global->INVOICE_CHECK_POSTERIOR_DATE)) {
|
||||||
|
// order $toselect by date
|
||||||
|
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture';
|
||||||
|
$sql .= ' WHERE rowid IN ('.$db->escape(implode(', ', $toselect)).')';
|
||||||
|
$sql .= ' ORDER BY datef';
|
||||||
|
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$toselectnew = [];
|
||||||
|
while ( !empty($arr = $db->fetch_row($resql))) {
|
||||||
|
$toselectnew[] = $arr[0];
|
||||||
|
}
|
||||||
|
$toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user