From 1872f6b12d329e5c73363c8aca1a8fb9cfc3a3ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Jul 2011 10:44:36 +0000 Subject: [PATCH] Fix: pgql compatibility --- htdocs/compta/bank/class/account.class.php | 77 +++++++++++----------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4c71c9c956f..d25fc241d5b 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -24,7 +24,7 @@ * \file htdocs/compta/bank/class/account.class.php * \ingroup banque * \brief File of class to manage bank accounts - * \version $Id: account.class.php,v 1.31 2011/07/04 09:01:38 eldy Exp $ + * \version $Id: account.class.php,v 1.32 2011/07/04 10:44:36 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); @@ -769,51 +769,54 @@ class Account extends CommonObject } /** - * + * @param rowid + * @param sign 1 or -1 + */ + function datev_change($rowid,$sign=1) + { + $sql = "SELECT datev FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; + $resql = $this->db->query($sql); + if ($resql) + { + $obj=$this->db->fetch_object($resql); + $newdate=$this->db->jdate($obj->datev)+(3600*24*$sign); + + $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET "; + $sql.= " datev = '".$this->db->idate($newdate)."'"; + $sql.= " WHERE rowid = ".$rowid; + + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->affected_rows($result)) + { + return 1; + } + } + else + { + dol_print_error($this->db); + return 0; + } + } + else dol_print_error($this->db); + return 0; + } + + /** + * @param rowid */ function datev_next($rowid) { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET "; - $sql.= " datev = adddate(datev, interval 1 day)"; - $sql.= " WHERE rowid = ".$rowid; - - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->affected_rows($result)) - { - return 1; - } - } - else - { - dol_print_error($this->db); - return 0; - } + return $this->datev_change($rowid,1); } /** - * + * @param rowid */ function datev_previous($rowid) { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET "; - $sql.= " datev = adddate(datev, interval -1 day)"; - $sql.= " WHERE rowid = ".$rowid; - - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->affected_rows($result)) - { - return 1; - } - } - else - { - dol_print_error($this->db); - return 0; - } + return $this->datev_change($rowid,-1); } /**