From 019575d9edf05b0a2e7672b6534f54845458832e Mon Sep 17 00:00:00 2001 From: Florian HENRY <florian.henry@open-concept.pro> Date: Thu, 12 Nov 2015 13:21:35 +0100 Subject: [PATCH] FIX : better fix for #3805 --- htdocs/compta/facture/class/facture.class.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6a807ffca75..6f8484cbc42 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -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; } } -- GitLab