Skip to content
Snippets Groups Projects
Commit 019575d9 authored by Florian Henry's avatar Florian Henry
Browse files

FIX : better fix for #3805

parent b0419557
No related branches found
No related tags found
No related merge requests found
......@@ -3677,22 +3677,22 @@ class Facture extends CommonInvoice
*/
function is_last_in_cycle()
{
if (empty($this->situation_cycle_ref)) {
if (!empty($this->situation_cycle_ref)) {
// No point in testing anything if we're not inside a cycle
return false;
}
$sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref;
$resql = $this->db->query($sql);
if ($resql && $resql->num_rows > 0) {
$res = $this->db->fetch_array($resql);
$last = $res['max(situation_counter)'];
return ($last == $this->situation_counter);
$sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref;
$resql = $this->db->query($sql);
if ($resql && $resql->num_rows > 0) {
$res = $this->db->fetch_array($resql);
$last = $res['max(situation_counter)'];
return ($last == $this->situation_counter);
} else {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR);
return false;
}
} else {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR);
return false;
return true;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment