From ae913053cbb059c29ef019f8b5fabc4110cba5e9 Mon Sep 17 00:00:00 2001 From: eldy Date: Sun, 11 Sep 2011 03:05:29 +0200 Subject: [PATCH] Fix: pgsql compatibility --- htdocs/install/mysql/migration/3.0.0-3.1.0.sql | 5 ++++- htdocs/install/mysql/tables/llx_societe_prices.sql | 2 +- htdocs/societe/class/societe.class.php | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index f1589cda084..58441034789 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -486,4 +486,7 @@ ALTER TABLE llx_don ADD phone varchar(24) after email; ALTER TABLE llx_user ADD civilite varchar(6) after entity; ALTER TABLE llx_element_element MODIFY sourcetype varchar(32) NOT NULL; -ALTER TABLE llx_element_element MODIFY targettype varchar(32) NOT NULL; \ No newline at end of file +ALTER TABLE llx_element_element MODIFY targettype varchar(32) NOT NULL; + +ALTER TABLE llx_societe_prices MODIFY tms timestamp NULL; +-- ALTER TABLE llx_societe_prices ALTER COLUMN tms DROP NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_societe_prices.sql b/htdocs/install/mysql/tables/llx_societe_prices.sql index ade6a40a80d..5a22d0277f2 100644 --- a/htdocs/install/mysql/tables/llx_societe_prices.sql +++ b/htdocs/install/mysql/tables/llx_societe_prices.sql @@ -21,7 +21,7 @@ create table llx_societe_prices ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_soc integer DEFAULT 0, - tms timestamp NOT NULL, + tms timestamp, datec datetime, fk_user_author integer, price_level tinyint DEFAULT 1 diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 33afee55676..9ce94dec23d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1329,15 +1329,17 @@ class Societe extends CommonObject { if ($this->id) { + $now=dol_now(); + $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; $sql .= " SET price_level = '".$price_level."'"; - $sql .= " WHERE rowid = " . $this->id .";"; + $sql .= " WHERE rowid = " . $this->id; $this->db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_prices "; $sql .= " ( datec, fk_soc, price_level, fk_user_author )"; - $sql .= " VALUES (".$this->db->idate(mktime()).",".$this->id.",'".$price_level."',".$user->id.")"; + $sql .= " VALUES ('".$this->db->idate($now)."',".$this->id.",'".$price_level."',".$user->id.")"; if (! $this->db->query($sql) ) {