Invoice php 8 issue and warnings.

Seems if ("" < 0) is true in php 8
This commit is contained in:
Francis Appels 2021-06-29 16:33:24 +02:00
parent b8f5dc74d7
commit e4f61d430f

View File

@ -112,7 +112,12 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || !empty($ref)) {
if ($action != 'add') {
$ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION);
if (empty($conf->global->INVOICE_USE_SITUATION)) {
$fetch_situation = false;
} else {
$fetch_situation = true;
}
$ret = $object->fetch($id, $ref, '', '', $fetch_situation);
}
}
@ -607,7 +612,7 @@ if (empty($reshook)) {
}
// Check for mandatory fields in invoice
$array_to_check = array('REF_CUSTOMER'=>'RefCustomer');
$array_to_check = array('REF_CLIENT'=>'RefCustomer');
foreach ($array_to_check as $key => $val) {
$keymin = strtolower($key);
$vallabel = $object->$keymin;
@ -2362,21 +2367,22 @@ if (empty($reshook)) {
$line = new FactureLigne($db);
$line->fetch(GETPOST('lineid', 'int'));
$percent = $line->get_prev_progress($object->id);
$progress = floatval(GETPOST('progress', 'int'));
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref > 0) {
// in case of situation credit note
if (GETPOST('progress') >= 0) {
if ($progress >= 0) {
$mesg = $langs->trans("CantBeNullOrPositive");
setEventMessages($mesg, null, 'warnings');
$error++;
$result = -1;
} elseif (GETPOST('progress') < $line->situation_percent) { // TODO : use a modified $line->get_prev_progress($object->id) result
} elseif ($progress < $line->situation_percent) { // TODO : use a modified $line->get_prev_progress($object->id) result
$mesg = $langs->trans("CantBeLessThanMinPercent");
setEventMessages($mesg, null, 'warnings');
$error++;
$result = -1;
}
} elseif (GETPOST('progress') < $percent) {
} elseif ($progress < $percent) {
$mesg = '<div class="warning">'.$langs->trans("CantBeLessThanMinPercent").'</div>';
setEventMessages($mesg, null, 'warnings');
$error++;