From 4d0a68d48cf4465f00b468810835a215b1248fc2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Wed, 27 Aug 2008 18:53:27 +0000 Subject: [PATCH] Removed all now() and sysdate() database sql inline function by a date defined by PHP ($db->idate(mktime())). This is to be more portable, to solve problem when database server time differs from PHP server and to prepare for TZ support. --- .../accountancy/accountancyaccount.class.php | 7 ++----- .../accountancy/accountancysystem.class.php | 7 ++----- htdocs/adherents/adherent.class.php | 4 ++-- htdocs/adherents/cartes/carte.php | 2 +- htdocs/adherents/cartes/etiquette.php | 2 +- htdocs/adherents/cotisation.class.php | 2 +- htdocs/adherents/htpasswd.php | 2 +- htdocs/adherents/index.php | 2 +- htdocs/adherents/liste.php | 4 ++-- htdocs/bookmarks/bookmark.class.php | 2 +- htdocs/boutique/index.php | 4 ++-- htdocs/boutique/promotion/promotion.class.php | 2 +- htdocs/chargesociales.class.php | 2 +- htdocs/comm/adresse_livraison.class.php | 2 +- htdocs/comm/index.php | 2 +- htdocs/comm/mailing/mailing.class.php | 8 +++----- htdocs/commande/commande.class.php | 6 +++--- htdocs/companybankaccount.class.php | 2 +- htdocs/compta/bank/account.class.php | 6 +++--- htdocs/compta/charges.php | 2 +- htdocs/compta/comptacompte.class.php | 2 +- .../compta/deplacement/deplacement.class.php | 2 +- .../modules/compta.export.poivre.class.php | 2 +- htdocs/compta/facture/facture-rec.class.php | 2 +- htdocs/compta/index.php | 2 +- .../paiement/cheque/remisecheque.class.php | 2 +- .../prelevement/bon-prelevement.class.php | 4 ++-- .../prelevement/rejet-prelevement.class.php | 2 +- htdocs/contact.class.php | 2 +- htdocs/contrat/contrat.class.php | 6 +++--- htdocs/contrat/index.php | 4 ++-- htdocs/contrat/liste.php | 4 ++-- htdocs/contrat/services.php | 2 +- htdocs/discount.class.php | 2 +- htdocs/docs/document.class.php | 2 +- htdocs/don.class.php | 2 +- htdocs/expedition/expedition.class.php | 4 ++-- htdocs/facture.class.php | 4 ++-- htdocs/fichinter/fichinter.class.php | 4 ++-- htdocs/fourn/facture/paiementfourn.class.php | 2 +- htdocs/fourn/fournisseur.commande.class.php | 6 +++--- htdocs/fourn/fournisseur.facture.class.php | 2 +- htdocs/fourn/fournisseur.product.class.php | 4 ++-- htdocs/fourn/stats.php | 2 +- .../modules/DolibarrModules.class.php | 2 +- .../modules/mailings/fraise.modules.php | 4 ++-- htdocs/index.php | 1 - htdocs/lib/databases/mysql.lib.php | 2 +- htdocs/livraison/livraison.class.php | 4 ++-- htdocs/lolix/cv/cv.class.php | 2 +- htdocs/notify.class.php | 2 +- .../clients/osc_customer.class.php | 2 +- .../commandes/osc_order.class.php | 2 +- .../produits/osc_product.class.php | 2 +- htdocs/paiement.class.php | 2 +- htdocs/product.class.php | 20 +++++++++---------- htdocs/product/stock/entrepot.class.php | 2 +- htdocs/product/stock/mouvementstock.class.php | 18 ++++++++--------- htdocs/project.class.php | 2 +- htdocs/propal.class.php | 6 +++--- htdocs/service.class.php | 6 +++--- htdocs/societe.class.php | 8 ++++---- htdocs/societe/notify/fiche.php | 2 +- htdocs/user.class.php | 3 ++- htdocs/usergroup.class.php | 2 +- scripts/cron/facture-paye-stats.php | 4 ++-- scripts/cron/fournisseur-calcul-ca_genere.php | 6 +++--- scripts/prelevement/prelevement.php | 4 ++-- 68 files changed, 120 insertions(+), 128 deletions(-) diff --git a/htdocs/accountancy/accountancyaccount.class.php b/htdocs/accountancy/accountancyaccount.class.php index eb890d9f99d..44cbaf83edd 100644 --- a/htdocs/accountancy/accountancyaccount.class.php +++ b/htdocs/accountancy/accountancyaccount.class.php @@ -14,16 +14,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** \file htdocs/accountancy/accountancyaccount.class.php \ingroup comptaexpert \brief Fichier de la classe des comptes comptables - \version $Revision$ + \version $Id$ */ @@ -66,7 +63,7 @@ class AccountancyAccount { $sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingaccount"; $sql.= " (date_creation, fk_user_author, numero,intitule)"; - $sql.= " VALUES (now(),".$user->id.",'".$this->numero."','".$this->intitule."')"; + $sql.= " VALUES (".$this->db->idate(mktime()).",".$user->id.",'".$this->numero."','".$this->intitule."')"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/accountancy/accountancysystem.class.php b/htdocs/accountancy/accountancysystem.class.php index 0fe7c44a0a1..a43a767e429 100644 --- a/htdocs/accountancy/accountancysystem.class.php +++ b/htdocs/accountancy/accountancysystem.class.php @@ -14,16 +14,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** \file htdocs/accountancy/accountancysystem.class.php \ingroup comptaexpert \brief Fichier de la classe des plans de comptes comptables - \version $Revision$ + \version $Id$ */ @@ -66,7 +63,7 @@ class AccountancySystem { $sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingsystem"; $sql.= " (date_creation, fk_user_author, numero,intitule)"; - $sql.= " VALUES (now(),".$user->id.",'".$this->numero."','".$this->intitule."')"; + $sql.= " VALUES (".$this->db->idate(mktime()).",".$user->id.",'".$this->numero."','".$this->intitule."')"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 026f2e07356..e61ff31545b 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -1221,7 +1221,7 @@ class Adherent extends CommonObject } /** - * \brief Fonction qui verifie que l'utilisateur est valide + * \brief Function that validate a member * \param user user adherent qui valide * \return int <0 si ko, >0 si ok */ @@ -1230,7 +1230,7 @@ class Adherent extends CommonObject global $langs,$conf; $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " statut=1, datevalid = now(),"; + $sql.= " statut=1, datevalid = ".$this->db->idate(mktime()).","; $sql.= " fk_user_valid=".$user->id; $sql.= " WHERE rowid = ".$this->id; diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 59e73747645..57acd24dc55 100755 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -75,7 +75,7 @@ $sql.= " t.libelle as type,"; $sql.= " p.libelle as pays"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid"; -$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1 AND datefin >= now()"; +$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1 AND datefin >= ".$db->idate(mktime()); $sql.= " ORDER BY d.rowid ASC"; $result = $db->query($sql); diff --git a/htdocs/adherents/cartes/etiquette.php b/htdocs/adherents/cartes/etiquette.php index c1f70d13cc8..a9c1f147019 100755 --- a/htdocs/adherents/cartes/etiquette.php +++ b/htdocs/adherents/cartes/etiquette.php @@ -65,7 +65,7 @@ $sql.= " t.libelle as type,"; $sql.= " p.libelle as pays"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid"; -$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1 AND datefin >= now()"; +$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1 AND datefin >= ".$db->idate(mktime()); $sql.= " ORDER BY d.rowid ASC"; $result = $db->query($sql); diff --git a/htdocs/adherents/cotisation.class.php b/htdocs/adherents/cotisation.class.php index 691e72f7fda..b912b98601a 100644 --- a/htdocs/adherents/cotisation.class.php +++ b/htdocs/adherents/cotisation.class.php @@ -71,7 +71,7 @@ class Cotisation extends CommonObject } $sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, datef, cotisation, note)"; - $sql.= " VALUES (".$this->fk_adherent.", now(),"; + $sql.= " VALUES (".$this->fk_adherent.", ".$this->db->idate(mktime()).","; $sql.= " ".$this->db->idate($this->dateh).","; $sql.= " ".$this->db->idate($this->datef).","; $sql.= " ".$this->amount.",'".$this->note."')"; diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index bce0259a805..2091557cb54 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -51,7 +51,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d "; $sql .= " WHERE d.statut = $statut "; if ($cotis==1) { - $sql .= " AND datefin > now() "; + $sql .= " AND datefin > ".$db->idate(mktime()); } $sql.= " ORDER BY $sortfield $sortorder"; //$sql.=$db->plimit($conf->liste_limit, $offset); diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index c7589a19ef6..6115986a983 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -106,7 +106,7 @@ if ($result) # Liste les cotisants a jour $sql = "SELECT count(*) as somme , d.fk_adherent_type"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; -$sql.= " WHERE d.statut = 1 AND d.datefin >= now()"; +$sql.= " WHERE d.statut = 1 AND d.datefin >= ".$db->idate(mktime()); $sql.= " GROUP BY d.fk_adherent_type"; $result = $db->query($sql); diff --git a/htdocs/adherents/liste.php b/htdocs/adherents/liste.php index 88a55765a4a..2519911c3a5 100644 --- a/htdocs/adherents/liste.php +++ b/htdocs/adherents/liste.php @@ -94,11 +94,11 @@ if ($_GET["search_email"]) } if ($filter == 'uptodate') { - $sql.=" AND datefin >= sysdate()"; + $sql.=" AND datefin >= ".$db->idate(mktime()); } if ($filter == 'outofdate') { - $sql.=" AND datefin < sysdate()"; + $sql.=" AND datefin < ".$db->idate(mktime()); } // Count total nb of records $nbtotalofrecords = 0; diff --git a/htdocs/bookmarks/bookmark.class.php b/htdocs/bookmarks/bookmark.class.php index 216d63de3f6..e158926fba1 100644 --- a/htdocs/bookmarks/bookmark.class.php +++ b/htdocs/bookmarks/bookmark.class.php @@ -100,7 +100,7 @@ class Bookmark $sql.= " ,title,favicon"; if ($this->fk_soc) $sql.=",fk_soc"; $sql.= ")"; - $sql.= " VALUES ('".$this->fk_user."', sysdate(),"; + $sql.= " VALUES ('".$this->fk_user."', ".$this->db->idate(mktime()).","; $sql.= " '".$this->url."', '".$this->target."',"; $sql.= " '".addslashes($this->title)."', '".$this->favicon."'"; if ($this->fk_soc) $sql.=",".$this->fk_soc; diff --git a/htdocs/boutique/index.php b/htdocs/boutique/index.php index 3634dbb38a6..27af2fddf28 100644 --- a/htdocs/boutique/index.php +++ b/htdocs/boutique/index.php @@ -55,7 +55,7 @@ print '<td align="right">'.$langs->trans("Total").'</td></tr>'; $sql = "SELECT sum(t.value) as value, MONTH(o.date_purchased) as mois"; $sql .= " FROM ".OSC_DB_NAME.".orders_total as t"; $sql .= " JOIN ".OSC_DB_NAME.".orders as o ON o.orders_id = t.orders_id"; -$sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR(now()) "; +$sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR(".$dbosc->idate(mktime()).")"; $sql .= " GROUP BY mois ORDER BY mois"; $result=$dbosc->query($sql); @@ -92,7 +92,7 @@ else $sql = "SELECT sum(t.value) as value"; $sql .= " FROM ".OSC_DB_NAME.".orders_total as t"; $sql .= " JOIN ".OSC_DB_NAME.".orders as o ON o.orders_id = t.orders_id"; -$sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR(now()) AND MONTH(o.date_purchased) = MONTH(now())"; +$sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR(".$dbosc->db->idate(mktime()).") AND MONTH(o.date_purchased) = MONTH(".$this->db->idate(mktime()).")"; if ( $dbosc->query($sql) ) { diff --git a/htdocs/boutique/promotion/promotion.class.php b/htdocs/boutique/promotion/promotion.class.php index 86c0b66bf34..3c144a9c2dd 100644 --- a/htdocs/boutique/promotion/promotion.class.php +++ b/htdocs/boutique/promotion/promotion.class.php @@ -61,7 +61,7 @@ class Promotion { $sql = "INSERT INTO ".OSC_DB_NAME.".specials "; $sql .= " (products_id, specials_new_products_price, specials_date_added, specials_last_modified, expires_date, date_status_change, status) "; - $sql .= " VALUES ($pid, $newprice, now(),NULL,'$date_exp',NULL,1)"; + $sql .= " VALUES ($pid, $newprice, ".$this->db->idate(mktime()).", NULL, '$date_exp',NULL,1)"; if ($this->db->query($sql) ) { diff --git a/htdocs/chargesociales.class.php b/htdocs/chargesociales.class.php index 35243274b64..bd78201c2c1 100644 --- a/htdocs/chargesociales.class.php +++ b/htdocs/chargesociales.class.php @@ -389,7 +389,7 @@ class PaiementCharge { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,"; $sql.= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; - $sql.= " VALUES ($this->chid, now(), "; + $sql.= " VALUES ($this->chid, ".$this->db->idate(mktime()).", "; $sql.= $this->db->idate($this->datepaye).", "; $sql.= price2num($total); $sql.= ", ".$this->paiementtype.", '".$this->num_paiement."', '".addslashes($this->note)."', ".$user->id.","; diff --git a/htdocs/comm/adresse_livraison.class.php b/htdocs/comm/adresse_livraison.class.php index 0fd458a2d09..4defc6c70fe 100644 --- a/htdocs/comm/adresse_livraison.class.php +++ b/htdocs/comm/adresse_livraison.class.php @@ -91,7 +91,7 @@ class AdresseLivraison if ($result >= 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_adresse_livraison (label, fk_societe, nom, datec, fk_user_creat) "; - $sql .= " VALUES ('".addslashes($this->label)."', '".$socid."', '".addslashes($this->nom)."', now(), '".$user->id."')"; + $sql .= " VALUES ('".addslashes($this->label)."', '".$socid."', '".addslashes($this->nom)."', ".$this->db->idate(mktime()).", '".$user->id."')"; $result=$this->db->query($sql); if ($result) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 5b5a5e1bc6c..98e8ca19ecb 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -66,7 +66,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark') { dolibarr_print_error($db); } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$_GET["socid"].", now(),".$user->id.");"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$_GET["socid"].", ".$db->idate(mktime()).",".$user->id.");"; if (! $db->query($sql) ) { dolibarr_print_error($db); diff --git a/htdocs/comm/mailing/mailing.class.php b/htdocs/comm/mailing/mailing.class.php index d44760bebfe..e63eb8f6af2 100644 --- a/htdocs/comm/mailing/mailing.class.php +++ b/htdocs/comm/mailing/mailing.class.php @@ -96,7 +96,7 @@ class Mailing $sql = "INSERT INTO ".$this->db_table; $sql .= " (date_creat, fk_user_creat)"; - $sql .= " VALUES (now(), ".$user->id.")"; + $sql .= " VALUES (".$this->db->idate(mktime()).", ".$user->id.")"; if (! $this->titre) { @@ -229,8 +229,7 @@ class Mailing dolibarr_syslog("Mailing::Valid"); $sql = "UPDATE ".MAIN_DB_PREFIX."mailing "; - $sql .= " SET statut = 1, date_valid = now(), fk_user_valid=".$user->id; - + $sql .= " SET statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid=".$user->id; $sql .= " WHERE rowid = ".$this->id." AND statut = 0 ;"; if ($this->db->query($sql) ) @@ -251,8 +250,7 @@ class Mailing function approve($user) { $sql = "UPDATE ".MAIN_DB_PREFIX."mailing "; - $sql .= " SET statut = 2, date_appro = now(), fk_user_appro=".$user->id; - + $sql .= " SET statut = 2, date_appro = ".$this->db->idate(mktime()).", fk_user_appro=".$user->id; $sql .= " WHERE rowid = ".$this->id." AND statut = 1 ;"; if ($this->db->query($sql) ) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 142c112274e..118e451ba30 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -237,7 +237,7 @@ class Commande extends CommonObject $num = $this->ref; } - $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='$num', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id"; + $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='$num', fk_statut = 1, date_valid=".$this->db->idate(mktime()).", fk_user_valid=$user->id"; $sql .= " WHERE rowid = $this->id AND fk_statut = 0"; $resql=$this->db->query($sql); @@ -386,7 +386,7 @@ class Commande extends CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql.= ' SET fk_statut = 3,'; $sql.= ' fk_user_cloture = '.$user->id.','; - $sql.= ' date_cloture = now()'; + $sql.= " date_cloture = ".$this->db->idate(mktime()); $sql.= " WHERE rowid = $this->id AND fk_statut > 0 ;"; if ($this->db->query($sql)) @@ -513,7 +513,7 @@ class Commande extends CommonObject $sql.= ' ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, note_public, ref_client,'; $sql.= ' model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison, fk_adresse_livraison,'; $sql.= ' remise_absolue, remise_percent)'; - $sql.= " VALUES ('".$this->ref."',".$this->socid.', now(), '.$user->id.', '.$this->projetid.','; + $sql.= " VALUES ('".$this->ref."',".$this->socid.", ".$this->db->idate(mktime()).", ".$user->id.', '.$this->projetid.','; $sql.= ' '.$this->db->idate($this->date_commande).','; $sql.= ' '.$this->source.', '; $sql.= " '".addslashes($this->note)."', "; diff --git a/htdocs/companybankaccount.class.php b/htdocs/companybankaccount.class.php index aaf4d3b685f..7a587a30a59 100644 --- a/htdocs/companybankaccount.class.php +++ b/htdocs/companybankaccount.class.php @@ -56,7 +56,7 @@ class CompanyBankAccount */ function create() { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socid, now());"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socid, ".$this->db->idate(mktime()).")"; if ($this->db->query($sql)) { if ($this->db->affected_rows()) diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index f093aafa9f4..c192f43fe44 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -226,7 +226,7 @@ class Account extends CommonObject $datev = $date; $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, dateo, datev, label, amount, fk_user_author, num_chq, fk_account, fk_type,emetteur,banque)"; - $sql.= " VALUES (now(), '".$this->db->idate($date)."', '".$this->db->idate($datev)."', "; + $sql.= " VALUES (".$this->db->idate(mktime()).", '".$this->db->idate($date)."', '".$this->db->idate($datev)."', "; $sql.= " '".addslashes($label)."', " . price2num($amount).", '".$user->id."', "; $sql.= " ".($num_chq?"'".$num_chq."'":"null").", "; $sql.= " '".$this->rowid."', "; @@ -293,7 +293,7 @@ class Account extends CommonObject $sql.= "rappro, min_allowed, min_desired, "; $sql.= "comment"; $sql.= ") values ("; - $sql.= "now(),'" . addslashes($this->ref) . "', '" . addslashes($this->label) . "', "; + $sql.= "".$this->db->idate(mktime()).",'" . addslashes($this->ref) . "', '" . addslashes($this->label) . "', "; $sql.= "'".addslashes($this->account_number) . "', '".$this->currency_code."', "; $sql.= $this->rappro.", ".price2num($this->min_allowed).", ".price2num($this->min_desired).", "; $sql.= "'".addslashes($this->comment)."'"; @@ -309,7 +309,7 @@ class Account extends CommonObject if ( $this->update() ) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, label, amount, fk_account, datev, dateo, fk_type, rappro) "; - $sql .= " VALUES (now(),'(".$langs->trans("InitialBankBalance").")'," . price2num($this->solde) . ",'$this->id','".$this->db->idate($this->date_solde)."','".$this->db->idate($this->date_solde)."','SOLD',1);"; + $sql .= " VALUES (".$this->db->idate(mktime()).",'(".$langs->trans("InitialBankBalance").")'," . price2num($this->solde) . ",'$this->id','".$this->db->idate($this->date_solde)."','".$this->db->idate($this->date_solde)."','SOLD',1);"; $this->db->query($sql); } return $this->id; diff --git a/htdocs/compta/charges.php b/htdocs/compta/charges.php index 97a3d4cc45a..72c1fca1772 100644 --- a/htdocs/compta/charges.php +++ b/htdocs/compta/charges.php @@ -36,7 +36,7 @@ $langs->load("tax"); * Action ajout en bookmark */ if ($action == 'add_bookmark') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socid, now(),".$user->id.");"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$socid.", ".$db->idate(mktime()).",".$user->id.");"; if (! $db->query($sql) ) { print $db->error(); } diff --git a/htdocs/compta/comptacompte.class.php b/htdocs/compta/comptacompte.class.php index 1ec69c1192b..3cd4328196d 100644 --- a/htdocs/compta/comptacompte.class.php +++ b/htdocs/compta/comptacompte.class.php @@ -69,7 +69,7 @@ class ComptaCompte if ($row[0] == 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."compta_compte_generaux (date_creation, fk_user_author, numero,intitule)"; - $sql .= " VALUES (now(),".$user->id.",'".$this->numero."','".$this->intitule."')"; + $sql .= " VALUES (".$this->db->idate(mktime()).",".$user->id.",'".$this->numero."','".$this->intitule."')"; $resql = $this->db->query($sql); if ( $resql ) diff --git a/htdocs/compta/deplacement/deplacement.class.php b/htdocs/compta/deplacement/deplacement.class.php index 5ca602d523b..d386b9037b5 100644 --- a/htdocs/compta/deplacement/deplacement.class.php +++ b/htdocs/compta/deplacement/deplacement.class.php @@ -76,7 +76,7 @@ class Deplacement extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement"; $sql.= " (datec, fk_user_author, fk_user, type)"; - $sql.= " VALUES (now(), ".$user->id.", ".$this->fk_user.", '".$this->type."')"; + $sql.= " VALUES (".$this->db->idate(mktime()).", ".$user->id.", ".$this->fk_user.", '".$this->type."')"; dolibarr_syslog("Deplacement::create sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/export/modules/compta.export.poivre.class.php b/htdocs/compta/export/modules/compta.export.poivre.class.php index 458723cc53e..c6d91d99a8b 100644 --- a/htdocs/compta/export/modules/compta.export.poivre.class.php +++ b/htdocs/compta/export/modules/compta.export.poivre.class.php @@ -127,7 +127,7 @@ class ComptaExportPoivre extends ComptaExport $this->ref = $dt . substr("000".$cc, -2); $sql = "INSERT INTO ".MAIN_DB_PREFIX."export_compta (ref, date_export, fk_user)"; - $sql .= " VALUES ('".$this->ref."', now(),".$this->user->id.")"; + $sql .= " VALUES ('".$this->ref."', ".$this->db->idate(mktime()).",".$this->user->id.")"; if ($this->db->query($sql)) { diff --git a/htdocs/compta/facture/facture-rec.class.php b/htdocs/compta/facture/facture-rec.class.php index 90254be65e7..1d0163e07d8 100644 --- a/htdocs/compta/facture/facture-rec.class.php +++ b/htdocs/compta/facture/facture-rec.class.php @@ -101,7 +101,7 @@ class FactureRec extends Facture $this->brouillon = 1; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (titre, fk_soc, datec, amount, remise, note, fk_user_author,fk_projet, fk_cond_reglement, fk_mode_reglement) "; - $sql.= " VALUES ('$this->titre', '$facsrc->socid', now(), '$facsrc->amount', '$facsrc->remise', '".addslashes($this->note)."','$user->id',"; + $sql.= " VALUES ('$this->titre', '$facsrc->socid', ".$this->db->idate(mktime()).", '$facsrc->amount', '$facsrc->remise', '".addslashes($this->note)."','$user->id',"; $sql.= " ".($facsrc->projetid?"'".$facsrc->projetid."'":"null").", "; $sql.= " '".$facsrc->cond_reglement_id."',"; $sql.= " '".$facsrc->mode_reglement_id."')"; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 2497b51bee2..34d61f6540a 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -64,7 +64,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark') { dolibarr_print_error($db); } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socid, now(),".$user->id.");"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$socid.", ".$db->idate(mktime()).",".$user->id.");"; if (! $db->query($sql) ) { dolibarr_print_error($db); diff --git a/htdocs/compta/paiement/cheque/remisecheque.class.php b/htdocs/compta/paiement/cheque/remisecheque.class.php index 69c4e9dfbb5..5bddea51926 100644 --- a/htdocs/compta/paiement/cheque/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/remisecheque.class.php @@ -125,7 +125,7 @@ class RemiseCheque extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bordereau_cheque (datec, date_bordereau, fk_user_author, fk_bank_account, amount, number, nbcheque)"; - $sql.= " VALUES (now(),now(),".$user->id.",".$account_id.",0,0,0)"; + $sql.= " VALUES (".$this->db->idate(mktime()).",".$this->db->idate(mktime()).",".$user->id.",".$account_id.",0,0,0)"; dolibarr_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/prelevement/bon-prelevement.class.php b/htdocs/compta/prelevement/bon-prelevement.class.php index dcef3bae321..23679be5072 100644 --- a/htdocs/compta/prelevement/bon-prelevement.class.php +++ b/htdocs/compta/prelevement/bon-prelevement.class.php @@ -837,7 +837,7 @@ class BonPrelevement */ $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (ref,datec)"; - $sql .= " VALUES ('".$ref."',now())"; + $sql .= " VALUES ('".$ref."',".$this->db->idate(mktime()).")"; $resql = $this->db->query($sql); @@ -921,7 +921,7 @@ class BonPrelevement */ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande"; $sql .= " SET traite = 1"; - $sql .= ", date_traite=now()"; + $sql .= ", date_traite=".$this->db->idate(mktime()); $sql .= ", fk_prelevement_bons = ".$prev_id; $sql .= " WHERE rowid=".$fac[1]; diff --git a/htdocs/compta/prelevement/rejet-prelevement.class.php b/htdocs/compta/prelevement/rejet-prelevement.class.php index 7440aed104a..a0c816508cb 100644 --- a/htdocs/compta/prelevement/rejet-prelevement.class.php +++ b/htdocs/compta/prelevement/rejet-prelevement.class.php @@ -80,7 +80,7 @@ class RejetPrelevement $sql .= " , motif , fk_user_creation, date_creation, afacturer)"; $sql .= " VALUES (".$id; $sql .= " ,'".$this->db->idate($date_rejet)."'"; - $sql .= " ,".$motif.",". $user->id.", now(),".$facturation.");"; + $sql .= " ,".$motif.",". $user->id.", ".$this->db->idate(mktime()).",".$facturation.");"; $result=$this->db->query($sql); diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 83e25f7a0f3..3b4bf9a40b4 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -94,7 +94,7 @@ class Contact extends CommonObject if (! $this->priv) $this->priv = 0; $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople (datec, fk_soc, name, fk_user_creat, priv)"; - $sql.= " VALUES (now(),"; + $sql.= " VALUES (".$this->db->idate(mktime()).","; if ($this->socid > 0) $sql.= " ".$this->socid.","; else $sql.= "null,"; $sql.= "'".addslashes($this->name)."',"; diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index cda7e0ceb9e..6290f6265c1 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -178,7 +178,7 @@ class Contrat extends CommonObject function cloture($user,$langs='',$conf='') { $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 2"; - $sql .= " , date_cloture = now(), fk_user_cloture = ".$user->id; + $sql .= " , date_cloture = ".$this->db->idate(mktime()).", fk_user_cloture = ".$user->id; $sql .= " WHERE rowid = ".$this->id . " AND statut = 1"; $resql = $this->db->query($sql) ; @@ -243,7 +243,7 @@ class Contrat extends CommonObject function annule($user,$langs='',$conf='') { $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 0"; - $sql .= " , date_cloture = now(), fk_user_cloture = ".$user->id; + $sql .= " , date_cloture = ".$this->db->idate(mktime()).", fk_user_cloture = ".$user->id; $sql .= " WHERE rowid = ".$this->id . " AND statut = 1"; $resql = $this->db->query($sql) ; @@ -493,7 +493,7 @@ class Contrat extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat"; $sql.= ", fk_commercial_signature, fk_commercial_suivi"; $sql.= " , ref)"; - $sql.= " VALUES (now(),".$this->socid.",".$user->id; + $sql.= " VALUES (".$this->db->idate(mktime()).",".$this->socid.",".$user->id; $sql.= ",".$this->db->idate($this->date_contrat); $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); $sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL"); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 9349e1dd03d..d09f9b5a65e 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -163,8 +163,8 @@ print '</td><td width="70%" valign="top" class="notopnoleftnoright">'; $max=5; $sql = 'SELECT '; $sql.= ' sum('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,'; -$sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > sysdate()",1,0).') as nb_running,'; -$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= sysdate())",1,0).') as nb_late,'; +$sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > ".$db->idate(mktime()),1,0).') as nb_running,'; +$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= ".$db->idate(mktime()).")",1,0).') as nb_late,'; $sql.= ' sum('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,'; $sql.= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut, s.nom, s.rowid as socid"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index 50274b7dc72..4da91923eda 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -64,8 +64,8 @@ llxHeader(); $sql = 'SELECT'; $sql.= ' sum('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,'; -$sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > sysdate()",1,0).') as nb_running,'; -$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= sysdate())",1,0).') as nb_late,'; +$sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > ".$db->idate(mktime()),1,0).') as nb_running,'; +$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= ".$db->idate(mktime()).")",1,0).') as nb_late,'; $sql.= ' sum('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,'; $sql.= " c.rowid as cid, c.ref, c.datec, c.date_contrat, c.statut, s.nom, s.rowid as socid"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 5b13beca034..0a07c5acd1f 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -82,7 +82,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc if ($mode == "0") $sql.= " AND cd.statut = 0"; if ($mode == "4") $sql.= " AND cd.statut = 4"; if ($mode == "5") $sql.= " AND cd.statut = 5"; -if ($filter == "expired") $sql.= " AND date_fin_validite < sysdate()"; +if ($filter == "expired") $sql.= " AND date_fin_validite < ".$this->db->idate(mktime()); if ($search_nom) $sql.= " AND s.nom like '%".addslashes($search_nom)."%'"; if ($search_contract) $sql.= " AND c.rowid = '".addslashes($search_contract)."'"; if ($search_service) $sql.= " AND (p.ref like '%".addslashes($search_service)."%' OR p.description like '%".addslashes($search_service)."%')"; diff --git a/htdocs/discount.class.php b/htdocs/discount.class.php index 2d2138fc49a..7255f4dff82 100644 --- a/htdocs/discount.class.php +++ b/htdocs/discount.class.php @@ -144,7 +144,7 @@ class DiscountAbsolute $sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,"; $sql.= " fk_facture_source"; $sql.= ")"; - $sql.= " VALUES (now(), ".$this->fk_soc.", ".$user->id.", '".addslashes($this->desc)."',"; + $sql.= " VALUES (".$this->db->idate(mktime()).", ".$this->fk_soc.", ".$user->id.", '".addslashes($this->desc)."',"; $sql.= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.","; $sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null"); $sql.= ")"; diff --git a/htdocs/docs/document.class.php b/htdocs/docs/document.class.php index e2103352af2..cb5d8bff8b1 100644 --- a/htdocs/docs/document.class.php +++ b/htdocs/docs/document.class.php @@ -83,7 +83,7 @@ class Document $sql = "INSERT INTO ".MAIN_DB_PREFIX."document"; $sql.= " (name,file_name,file_extension,date_generation) VALUES"; - $sql.= " ('".$obj->name."','".$obj->file."','".$obj->extension."',now());"; + $sql.= " ('".$obj->name."','".$obj->file."','".$obj->extension."',".$this->db->idate(mktime()).")"; $resql=$this->db->query($sql); diff --git a/htdocs/don.class.php b/htdocs/don.class.php index 94779805a05..ac8d3f63265 100644 --- a/htdocs/don.class.php +++ b/htdocs/don.class.php @@ -295,7 +295,7 @@ class Don $sql .= " fk_don_projet,"; } $sql .= " note, fk_user_author, datedon, email)"; - $sql .= " VALUES (now(),".price2num($this->amount).", $this->modepaiementid,'$this->prenom','$this->nom','$this->societe','$this->adresse', '$this->cp','$this->ville','$this->pays',$this->public, "; + $sql .= " VALUES (".$this->db->idate(mktime()).",".price2num($this->amount).", $this->modepaiementid,'$this->prenom','$this->nom','$this->societe','$this->adresse', '$this->cp','$this->ville','$this->pays',$this->public, "; if ($this->projetid) { $sql .= " $this->projetid,"; diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index 5600ddcf778..8c6aea8c79b 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -90,7 +90,7 @@ class Expedition extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (ref, date_creation, fk_user_author, date_expedition"; $sql.= ", fk_soc"; $sql.= ")"; - $sql.= " VALUES ('(PROV)', now(), $user->id, ".$this->db->idate($this->date_expedition); + $sql.= " VALUES ('(PROV)', ".$this->db->idate(mktime()).", $user->id, ".$this->db->idate($this->date_expedition); $sql.= ", ".$this->socid; $sql.= ")"; @@ -328,7 +328,7 @@ class Expedition extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; - $sql.= " SET ref='".$this->ref."', fk_statut = 1, date_valid = now(), fk_user_valid = ".$user->id; + $sql.= " SET ref='".$this->ref."', fk_statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; dolibarr_syslog("Expedition::valid update expedition sql=".$sql); diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 92cff7258d7..a80f0185062 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -198,7 +198,7 @@ class Facture extends CommonObject $sql.= ' fk_facture_source, fk_user_author, fk_projet,'; $sql.= ' fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf)'; $sql.= ' VALUES ('; - $sql.= "'(PROV)', '".$this->type."', '".$socid."', now(), '".$totalht."'"; + $sql.= "'(PROV)', '".$this->type."', '".$socid."', ".$this->db->idate(mktime()).", '".$totalht."'"; $sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL'); $sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL'); $sql.= ",".$this->db->idate($this->date); @@ -2259,7 +2259,7 @@ class Facture extends CommonObject $sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)'; $sql .= ' VALUES ('.$this->id; $sql .= ",'".price2num($this->total_ttc)."'"; - $sql .= ',now(),'.$user->id; + $sql .= ",".$this->db->idate(mktime()).",".$user->id; $sql .= ",'".$soc->bank_account->code_banque."'"; $sql .= ",'".$soc->bank_account->code_guichet."'"; $sql .= ",'".$soc->bank_account->number."'"; diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index 1d50bc9b1b9..b6e34324a7a 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -107,7 +107,7 @@ class Fichinter extends CommonObject $sql.= ") "; $sql.= " VALUES (".$this->socid.","; $sql.= " ".$this->db->idate($this->date).","; - $sql.= " now(), '".$this->ref."', ".$this->author; + $sql.= " ".$this->db->idate(mktime()).", '".$this->ref."', ".$this->author; $sql.= ", '".addslashes($this->description)."', '".$this->modelpdf."'"; if ($this->projet_id) $sql .= ", ".$this->projet_id; $sql.= ")"; @@ -222,7 +222,7 @@ class Fichinter extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; - $sql.= " SET fk_statut = 1, date_valid=now(), fk_user_valid=".$user->id; + $sql.= " SET fk_statut = 1, date_valid=".$this->db->idate(mktime()).", fk_user_valid=".$user->id; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; dolibarr_syslog("Fichinter::valid sql=".$sql); diff --git a/htdocs/fourn/facture/paiementfourn.class.php b/htdocs/fourn/facture/paiementfourn.class.php index 4c2af51ef7e..16d77fbbb18 100644 --- a/htdocs/fourn/facture/paiementfourn.class.php +++ b/htdocs/fourn/facture/paiementfourn.class.php @@ -141,7 +141,7 @@ class PaiementFourn { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn ('; $sql.= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; - $sql.= ' VALUES (now(),'; + $sql.= ' VALUES (".$this->db->idate(mktime()).",'; $sql.= " ".$this->db->idate($this->datepaye).", '".$this->total."', ".$this->paiementid.", '".$this->num_paiement."', '".addslashes($this->note)."', ".$user->id.", 0)"; dolibarr_syslog("PaiementFourn::create sql=".$sql); diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index 9ba240097af..4b278d5fe44 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -232,7 +232,7 @@ class CommandeFournisseur extends Commande $num = $this->ref; } - $sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur SET ref='$num', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id"; + $sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur SET ref='$num', fk_statut = 1, date_valid=".$this->db->idate(mktime()).", fk_user_valid=$user->id"; $sql .= " WHERE rowid = $this->id AND fk_statut = 0"; $resql=$this->db->query($sql); @@ -622,7 +622,7 @@ class CommandeFournisseur extends Commande $this->brouillon = 1; $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur (ref, fk_soc, date_creation, fk_user_author, fk_statut, source, model_pdf) "; - $sql .= " VALUES ('',".$this->socid.", now(), ".$user->id.",0,0,'".$conf->global->COMMANDE_SUPPLIER_ADDON_PDF."')"; + $sql .= " VALUES ('',".$this->socid.", ".$this->db->idate(mktime()).", ".$user->id.",0,0,'".$conf->global->COMMANDE_SUPPLIER_ADDON_PDF."')"; if ( $this->db->query($sql) ) { @@ -837,7 +837,7 @@ class CommandeFournisseur extends Commande $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_dispatch "; $sql.= " (fk_commande,fk_product, qty, fk_entrepot, fk_user, datec) VALUES "; - $sql.= " ('".$this->id."','".$product."','".$qty."','".$entrepot."','".$user->id."',now() );"; + $sql.= " ('".$this->id."','".$product."','".$qty."','".$entrepot."','".$user->id."',".$this->db->idate(mktime()).")"; $resql = $this->db->query($sql); if (! $resql) diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index d0cde2db6e1..2c80f7af030 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -117,7 +117,7 @@ class FactureFournisseur extends Facture $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn (facnumber, libelle, fk_soc, datec, datef, note, fk_user_author, date_lim_reglement) '; $sql .= " VALUES ('".addslashes($number)."','".addslashes($this->libelle)."',"; - $sql .= $this->socid.", now(),'".$this->db->idate($this->date)."','".addslashes($this->note)."', ".$user->id.",'".$this->db->idate($this->date_echeance)."');"; + $sql .= $this->socid.", ".$this->db->idate(mktime()).",'".$this->db->idate($this->date)."','".addslashes($this->note)."', ".$user->id.",'".$this->db->idate($this->date_echeance)."');"; $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/fourn/fournisseur.product.class.php b/htdocs/fourn/fournisseur.product.class.php index d63a32f38bd..59f69ca26eb 100644 --- a/htdocs/fourn/fournisseur.product.class.php +++ b/htdocs/fourn/fournisseur.product.class.php @@ -180,7 +180,7 @@ class ProductFournisseur extends Product // Ajoute prix courant du fournisseur pour cette quantit� $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " SET datec = now()"; + $sql.= " SET datec = ".$this->db->idate(mktime()); $sql.= " ,fk_product_fournisseur = ".$this->product_fourn_id; $sql.= " ,fk_user = ".$user->id; $sql.= " ,price = ".price2num($buyprice); @@ -197,7 +197,7 @@ class ProductFournisseur extends Product { // Ajoute modif dans table log $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log "; - $sql .= " SET datec = now()"; + $sql .= " SET datec = ".$this->db->idate(mktime()); $sql .= " ,fk_product_fournisseur = ".$this->product_fourn_id; $sql .= " ,fk_user = ".$user->id; $sql .= " ,price = ".price2num($buyprice); diff --git a/htdocs/fourn/stats.php b/htdocs/fourn/stats.php index 1bfc57d2b23..616dd634d26 100644 --- a/htdocs/fourn/stats.php +++ b/htdocs/fourn/stats.php @@ -85,7 +85,7 @@ if ($search_ville) { $sql .= " AND s.ville LIKE '%".$search_ville."%'"; } -$sql .= " AND ca.year > (date_format(now(),'%Y') - 5)"; +$sql .= " AND ca.year > (date_format(".$db->idate(mktime()).",'%Y') - 5)"; $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index f97bd7f4d81..423dd52e85c 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -355,7 +355,7 @@ class DolibarrModules $sql ="INSERT INTO ".MAIN_DB_PREFIX."dolibarr_modules (numero,active,active_date,active_version)"; $sql .= " VALUES ("; - $sql .= $this->numero.",1,now(),'".$this->version."')"; + $sql .= $this->numero.",1,".$this->db->idate(mktime()).",'".$this->version."')"; $this->db->query($sql); diff --git a/htdocs/includes/modules/mailings/fraise.modules.php b/htdocs/includes/modules/mailings/fraise.modules.php index a69d8c4bfcb..c9869b0c229 100644 --- a/htdocs/includes/modules/mailings/fraise.modules.php +++ b/htdocs/includes/modules/mailings/fraise.modules.php @@ -130,8 +130,8 @@ class mailing_fraise extends MailingTargets foreach($filtersarray as $key) { if ($key == '-1') $sql.= " AND a.statut=-1"; - if ($key == '1a') $sql.= " AND a.statut=1 AND datefin >= sysdate()"; - if ($key == '1b') $sql.= " AND a.statut=1 AND datefin < sysdate()"; + if ($key == '1a') $sql.= " AND a.statut=1 AND datefin >= ".$this->db->idate(mktime()); + if ($key == '1b') $sql.= " AND a.statut=1 AND datefin < ".$this->db->idate(mktime()); if ($key == '0') $sql.= " AND a.statut=0"; } $sql.= " ORDER BY a.email"; diff --git a/htdocs/index.php b/htdocs/index.php index 118d991030d..e8a7ff309f2 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -42,7 +42,6 @@ $infobox=new InfoBox($db); llxHeader(); - print_fiche_titre($langs->trans("HomeArea")); if (! empty($conf->global->MAIN_MOTD)) diff --git a/htdocs/lib/databases/mysql.lib.php b/htdocs/lib/databases/mysql.lib.php index a6e6bd71a47..bd2d23cf2d1 100644 --- a/htdocs/lib/databases/mysql.lib.php +++ b/htdocs/lib/databases/mysql.lib.php @@ -548,7 +548,7 @@ class DoliDb /** \brief Formatage (par PHP) d'une date vers format texte pour insertion dans champ date. - Fonction � utiliser pour g�n�rer les INSERT. + Fonction � utiliser pour g�n�rer les INSERT ou UPDATE. \param param Date TMS � convertir \return date Date au format texte YYYYMMDDHHMMSS. */ diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index a2b2d3d0efb..538ef2cdacd 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -94,7 +94,7 @@ class Livraison extends CommonObject $sql.= " fk_adresse_livraison"; if ($this->expedition_id) $sql.= ", fk_expedition"; $sql.= ")"; - $sql.= " VALUES ('(PROV)', ".$this->socid.", now(), $user->id,"; + $sql.= " VALUES ('(PROV)', ".$this->socid.", ".$this->db->idate(mktime()).", $user->id,"; $sql.= " ".($this->adresse_livraison_id > 0?$this->adresse_livraison_id:"null"); if ($this->expedition_id) $sql.= ", $this->expedition_id"; $sql.= ")"; @@ -369,7 +369,7 @@ class Livraison extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."livraison "; - $sql.= " SET ref='".addslashes($this->ref)."', fk_statut = 1, date_valid = now(), fk_user_valid = ".$user->id; + $sql.= " SET ref='".addslashes($this->ref)."', fk_statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/lolix/cv/cv.class.php b/htdocs/lolix/cv/cv.class.php index 3b585273090..aa4c78c2bc8 100644 --- a/htdocs/lolix/cv/cv.class.php +++ b/htdocs/lolix/cv/cv.class.php @@ -75,7 +75,7 @@ class Cv { $result = $this->db->query($sql); $sql = "INSERT INTO lolixfr.res_statutlog (datel, fk_cand, fk_statut,author)"; - $sql .= " VALUES (now(),$this->id,0,'bots')"; + $sql .= " VALUES (".$this->db->idate(mktime()).",$this->id,0,'bots')"; $result = $this->db->query($sql); $header = "From: webmaster@lolix.org\r\nReply-To: webmaster@lolix.org\r\nX-Mailer: Dolibarr"; diff --git a/htdocs/notify.class.php b/htdocs/notify.class.php index 9bf7acd8121..4b8fd2c35e9 100644 --- a/htdocs/notify.class.php +++ b/htdocs/notify.class.php @@ -157,7 +157,7 @@ class Notify $sendto = htmlentities($sendto); $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_contact, objet_type, objet_id)"; - $sql .= " VALUES (now(), ".$action." ,".$obj->rowid." , '".$objet_type."', ".$objet_id.");"; + $sql.= " VALUES (".$this->db->idate(mktime()).", ".$action." ,".$obj->rowid." , '".$objet_type."', ".$objet_id.");"; if (! $this->db->query($sql) ) { dolibarr_print_error($db); diff --git a/htdocs/oscommerce_ws/clients/osc_customer.class.php b/htdocs/oscommerce_ws/clients/osc_customer.class.php index 9719692f501..195c9470a09 100644 --- a/htdocs/oscommerce_ws/clients/osc_customer.class.php +++ b/htdocs/oscommerce_ws/clients/osc_customer.class.php @@ -153,7 +153,7 @@ class Osc_customer // $this->db->rollback(); // return -1; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_customer VALUES (".$oscid." , now() , ".$socid.") ;"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_customer VALUES (".$oscid.", ".$this->db->idate(mktime()).", ".$socid.") ;"; $result=$this->db->query($sql); if ($result) diff --git a/htdocs/oscommerce_ws/commandes/osc_order.class.php b/htdocs/oscommerce_ws/commandes/osc_order.class.php index 8cb5341fc68..9cf623926d5 100644 --- a/htdocs/oscommerce_ws/commandes/osc_order.class.php +++ b/htdocs/oscommerce_ws/commandes/osc_order.class.php @@ -212,7 +212,7 @@ class Osc_order // $this->db->rollback(); // return -1; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_order VALUES (".$osc_orderid." , now() , ".$doli_orderid.") ;"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_order VALUES (".$osc_orderid.", ".$this->db->idate(mktime()).", ".$doli_orderid.") ;"; $result=$this->db->query($sql); if ($result) diff --git a/htdocs/oscommerce_ws/produits/osc_product.class.php b/htdocs/oscommerce_ws/produits/osc_product.class.php index 87f6317128a..5c354bb6360 100644 --- a/htdocs/oscommerce_ws/produits/osc_product.class.php +++ b/htdocs/oscommerce_ws/produits/osc_product.class.php @@ -170,7 +170,7 @@ class Osc_product // $this->db->rollback(); // return -1; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_product VALUES (".$oscid." , now() , ".$prodid.") ;"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_product VALUES (".$oscid.", ".$this->db->idate(mktime()).", ".$prodid.") ;"; $result=$this->db->query($sql); if ($result) diff --git a/htdocs/paiement.class.php b/htdocs/paiement.class.php index 4f2f94dd693..96801add4f9 100644 --- a/htdocs/paiement.class.php +++ b/htdocs/paiement.class.php @@ -141,7 +141,7 @@ class Paiement if ($this->total <> 0) // On accepte les montants n�gatifs pour les rejets de pr�l�vement { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_creat)'; - $sql.= ' VALUES (now(), '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.addslashes($this->note).'\', '.$user->id.')'; + $sql.= ' VALUES ('.$this->db->idate(mktime()).', '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.addslashes($this->note).'\', '.$user->id.')'; $resql = $this->db->query($sql); dolibarr_syslog("Paiement::Create insert paiement sql=".$sql); diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 2ce6007f3a0..60effaced27 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -205,7 +205,7 @@ class Product extends CommonObject if ($this->ref) $sql.= "ref, "; $sql.= "label, "; $sql.= "fk_user_author, fk_product_type, price, price_ttc, price_base_type, canvas)"; - $sql.= " VALUES (now(), "; + $sql.= " VALUES (".$this->db->idate(mktime()).", "; if ($this->ref) $sql.= "'".$this->ref."',"; $sql.= " ".($this->libelle?"'".addslashes($this->libelle)."'":"null").","; $sql.= $user->id.","; @@ -644,8 +644,8 @@ class Product extends CommonObject // On ajoute nouveau tarif $sql_multiprix = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price_level,price,price_ttc,price_base_type,tva_tx) "; - $sql_multiprix .= " VALUES(now(),".$this->id.",".$user->id.",".$i.",".price2num($multiprice_ht).",'".price2num($multiprice_ttc)."','".$this->multiprices_base_type["$i"]."',".$this->tva_tx; - $sql_multiprix .= ")"; + $sql_multiprix.= " VALUES(".$this->db->idate(mktime()).",".$this->id.",".$user->id.",".$i.",".price2num($multiprice_ht).",'".price2num($multiprice_ttc)."','".$this->multiprices_base_type["$i"]."',".$this->tva_tx; + $sql_multiprix.= ")"; if (! $this->db->query($sql_multiprix) ) { $queryError = true; @@ -656,7 +656,7 @@ class Product extends CommonObject { // On ajoute nouveau tarif $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,envente,tva_tx) "; - $sql .= " VALUES(now(),".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx; + $sql .= " VALUES(".$this->db->idate(mktime()).",".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx; $sql .= ")"; if (! $this->db->query($sql) ) $queryError = true; @@ -673,7 +673,7 @@ class Product extends CommonObject { // On ajoute nouveau tarif $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,envente,tva_tx) "; - $sql .= " VALUES(now(),".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx; + $sql .= " VALUES(".$this->db->idate(mktime()).",".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx; $sql .= ")"; dolibarr_syslog("Product::_log_price sql=".$sql); @@ -1590,7 +1590,7 @@ class Product extends CommonObject { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur "; $sql .= " (datec, fk_product, fk_soc, ref_fourn, fk_user_author)"; - $sql .= " VALUES (now(), ".$this->id.", ".$id_fourn.", '".$ref_fourn."', ".$user->id.")"; + $sql .= " VALUES (".$this->db->idate(mktime()).", ".$this->id.", ".$id_fourn.", '".$ref_fourn."', ".$user->id.")"; if ($this->db->query($sql)) { @@ -1740,7 +1740,7 @@ class Product extends CommonObject // les fournisseurs $sql = "insert ".MAIN_DB_PREFIX."product_fournisseur (" . " datec, fk_product, fk_soc, ref_fourn, fk_user_author )" - . " select now(), ".$toId.", fk_soc, ref_fourn, fk_user_author" + . " select '".$this->db->idate(mktime())."', ".$toId.", fk_soc, ref_fourn, fk_user_author" . " from ".MAIN_DB_PREFIX."product_fournisseur " . " where fk_product = ".$fromId .";" ; if ( ! $db->query($sql ) ) { @@ -1750,7 +1750,7 @@ class Product extends CommonObject // les prix de fournisseurs. $sql = "insert ".MAIN_DB_PREFIX."product_fournisseur_price (" . " datec, fk_product, fk_soc, price, quantity, fk_user )" - . " select now(), ".$toId. ", fk_soc, price, quantity, fk_user" + . " select '".$this->db->idate(mktime())."', ".$toId. ", fk_soc, price, quantity, fk_user" . " from ".MAIN_DB_PREFIX."product_fournisseur_price" . " where fk_product = ".$fromId.";"; if ( ! $db->query($sql ) ) { @@ -2017,7 +2017,7 @@ class Product extends CommonObject if ($resql) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author)"; - $sql .= " VALUES (now(), ".$this->id.", ".$id_entrepot.", ".$nbpiece.", 0, ".$user->id.")"; + $sql .= " VALUES (".$this->db->idate(mktime()).", ".$this->id.", ".$id_entrepot.", ".$nbpiece.", 0, ".$user->id.")"; dolibarr_syslog("Product::create_stock sql=".$sql); $resql=$this->db->query($sql); @@ -2102,7 +2102,7 @@ class Product extends CommonObject if ($resql) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author)"; - $sql .= " VALUES (now(), ".$this->id.", ".$id_entrepot.", ".$op[$mouvement].", 0, ".$user->id.")"; + $sql .= " VALUES (".$this->db->idate(mktime()).", ".$this->id.", ".$id_entrepot.", ".$op[$mouvement].", 0, ".$user->id.")"; dolibarr_syslog("Product::ajust_stock sql=".$sql); $resql=$this->db->query($sql); diff --git a/htdocs/product/stock/entrepot.class.php b/htdocs/product/stock/entrepot.class.php index 4891fcd6e60..d4be94bb2de 100644 --- a/htdocs/product/stock/entrepot.class.php +++ b/htdocs/product/stock/entrepot.class.php @@ -77,7 +77,7 @@ class Entrepot $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (datec, fk_user_author, label)"; - $sql .= " VALUES (now(),".$user->id.",'".addslashes($this->libelle)."')"; + $sql .= " VALUES (".$this->db->idate(mktime()).",".$user->id.",'".addslashes($this->libelle)."')"; dolibarr_syslog("Entrepot::create sql=".$sql); $result=$this->db->query($sql); diff --git a/htdocs/product/stock/mouvementstock.class.php b/htdocs/product/stock/mouvementstock.class.php index d0c31adaadc..119734a659b 100644 --- a/htdocs/product/stock/mouvementstock.class.php +++ b/htdocs/product/stock/mouvementstock.class.php @@ -54,7 +54,7 @@ class MouvementStock $sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement"; $sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, price)"; - $sql.= " VALUES (now(), ".$fk_product.", ".$entrepot_id.", ".$qty.", ".$type.", ".$user->id; + $sql.= " VALUES (".$this->db->idate(mktime()).", ".$fk_product.", ".$entrepot_id.", ".$qty.", ".$type.", ".$user->id; $sql.= ",'".price2num($price)."')"; if ($resql = $this->db->query($sql)) @@ -230,7 +230,7 @@ class MouvementStock { $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot_valorisation"; $sql.= " (date_calcul, fk_entrepot, valo_pmp)"; - $sql.= " VALUES (now(), $entrepot_id"; + $sql.= " VALUES (".$this->db->idate(mktime()).", ".$entrepot_id; $sql.= ",'".ereg_replace(",",".",$new_value)."');"; } @@ -351,13 +351,13 @@ class MouvementStock { $sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_valorisation"; $sql.= " (date_valo, fk_product, fk_stock_mouvement, qty_ope, price_ope, valo_ope, price_pmp, qty_stock, valo_pmp)"; - $sql.= " VALUES (now(), $fk_product, $mvid"; - $sql.= ",'".ereg_replace(",",".",$qty)."'"; - $sql.= ",'".ereg_replace(",",".",$price)."'"; - $sql.= ",'".ereg_replace(",",".",$value_ope)."'"; - $sql.= ",'".ereg_replace(",",".",$new_pmp)."'"; - $sql.= ",'".ereg_replace(",",".",$new_stock_qty)."'"; - $sql.= ",'".ereg_replace(",",".",$new_stock_value_pmp)."');"; + $sql.= " VALUES (".$this->db->idate(mktime()).", $fk_product, $mvid"; + $sql.= ",'".price2num($qty)."'"; + $sql.= ",'".price2num($price)."'"; + $sql.= ",'".price2num($value_ope)."'"; + $sql.= ",'".price2num($new_pmp)."'"; + $sql.= ",'".price2num($new_stock_qty)."'"; + $sql.= ",'".price2num($new_stock_value_pmp)."')"; if ($this->db->query($sql)) { diff --git a/htdocs/project.class.php b/htdocs/project.class.php index 4d147002962..3ffa6f365b2 100644 --- a/htdocs/project.class.php +++ b/htdocs/project.class.php @@ -69,7 +69,7 @@ class Project extends CommonObject $sql.= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."',"; $sql.= " ".($this->socid > 0?$this->socid:"null").","; $sql.= " ".$user->id.","; - $sql.= " ".$this->user_resp_id.", now(), 0)"; + $sql.= " ".$this->user_resp_id.", ".$this->db->idate(mktime()).", 0)"; dolibarr_syslog("Project::create sql=".$sql); $resql=$this->db->query($sql); diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 1b941dff72b..e507bc6b180 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -530,7 +530,7 @@ class Propal extends CommonObject $sql.= ") "; $sql.= " VALUES (".$this->socid.", 0,"; $sql.= " ".$this->remise.", ".($this->remise_percent?$this->remise_percent:'null').", ".($this->remise_absolue?$this->remise_absolue:'null').","; - $sql.= " 0,0,".$this->db->idate($this->datep).", now(), '".$this->ref."', "; + $sql.= " 0,0,".$this->db->idate($this->datep).", ".$this->db->idate(mktime()).", '".$this->ref."', "; $sql.= ($user->id > 0 ? "'".$user->id."'":"null").","; $sql.= "'".addslashes($this->note)."',"; $sql.= "'".addslashes($this->note_public)."',"; @@ -829,7 +829,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_statut = 1, date_valid=now(), fk_user_valid=".$user->id; + $sql.= " SET fk_statut = 1, date_valid=".$this->db->idate(mktime()).", fk_user_valid=".$user->id; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; if ($this->db->query($sql)) @@ -1051,7 +1051,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_statut = ".$statut.", note = '".addslashes($note)."', date_cloture=now(), fk_user_cloture=".$user->id; + $sql.= " SET fk_statut = ".$statut.", note = '".addslashes($note)."', date_cloture=".$this->db->idate(mktime()).", fk_user_cloture=".$user->id; $sql.= " WHERE rowid = ".$this->id; $resql=$this->db->query($sql); diff --git a/htdocs/service.class.php b/htdocs/service.class.php index 29b0d8bf7d5..d2264bd9e45 100644 --- a/htdocs/service.class.php +++ b/htdocs/service.class.php @@ -64,7 +64,7 @@ class Service function create($user) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."service (datec, fk_user_author) VALUES (now(), ".$user->id.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."service (datec, fk_user_author) VALUES (".$this->db->idate(mktime()).", ".$user->id.")"; if ($this->db->query($sql) ) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."service"); @@ -114,7 +114,7 @@ class Service if ($datedeb) { $sql .= " SET debut_comm = '$datedeb'"; } else { - $sql .= " SET debut_comm = now()"; + $sql .= " SET debut_comm = ".$this->db->idate(mktime()); } $sql .= ",fk_user_modif = " . $user->id ; @@ -139,7 +139,7 @@ class Service if ($datefin) { $sql .= " SET fin_comm = '$datefin'"; } else { - $sql .= " SET fin_comm = now()"; + $sql .= " SET fin_comm = ".$this->db->idate(mktime()); } $sql .= ",fk_user_modif = " . $user->id ; diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index a6de7b8718d..2f83e3616c9 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -151,7 +151,7 @@ class Societe extends CommonObject if ($result >= 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, datec, datea, fk_user_creat)"; - $sql.= " VALUES ('".addslashes($this->nom)."', now(), now(),"; + $sql.= " VALUES ('".addslashes($this->nom)."', ".$this->db->idate(mktime()).", ".$this->db->idate(mktime()).","; $sql.= " ".($user->id > 0 ? "'".$user->id."'":"null"); $sql.= ")"; @@ -356,7 +356,7 @@ class Societe extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; $sql.= " SET nom = '" . addslashes($this->nom) ."'"; // Champ obligatoire - $sql.= ",datea = now()"; + $sql.= ",datea = ".$this->db->idate(mktime()); $sql.= ",address = '" . addslashes($this->adresse) ."'"; $sql.= ",cp = ".($this->cp?"'".$this->cp."'":"null"); @@ -933,7 +933,7 @@ class Societe extends CommonObject // Ecrit trace dans historique des remises $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise "; $sql.= " (datec, fk_soc, remise_client, note, fk_user_author)"; - $sql.= " VALUES (now(), ".$this->id.", '".$remise."',"; + $sql.= " VALUES (".$this->db->idate(mktime()).", ".$this->id.", '".$remise."',"; $sql.= " '".addslashes($note)."',"; $sql.= " ".$user->id; $sql.= ")"; @@ -1066,7 +1066,7 @@ class Societe extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_prices "; $sql .= " ( datec, fk_soc, price_level, fk_user_author )"; - $sql .= " VALUES (now(),".$this->id.",'".$price_level."',".$user->id.")"; + $sql .= " VALUES (".$this->db->idate(mktime()).",".$this->id.",'".$price_level."',".$user->id.")"; if (! $this->db->query($sql) ) { diff --git a/htdocs/societe/notify/fiche.php b/htdocs/societe/notify/fiche.php index 8d70e5087af..36e5a7f1a54 100644 --- a/htdocs/societe/notify/fiche.php +++ b/htdocs/societe/notify/fiche.php @@ -58,7 +58,7 @@ if ($_POST["action"] == 'add') if ($db->query($sql)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)"; - $sql .= " VALUES (now(),$socid,".$_POST["contactid"].",".$_POST["actionid"].")"; + $sql .= " VALUES (".$db->idate(mktime()).",".$socid.",".$_POST["contactid"].",".$_POST["actionid"].")"; if ($db->query($sql)) { diff --git a/htdocs/user.class.php b/htdocs/user.class.php index 22da6ad8038..9da41cfd39e 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -717,7 +717,8 @@ class User extends CommonObject } else { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."user (datec,login,ldap_sid) VALUES(now(),'".addslashes($this->login)."','".$this->ldap_sid."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."user (datec,login,ldap_sid)"; + $sql.= " VALUES(".$this->db->idate(mktime()).",'".addslashes($this->login)."','".$this->ldap_sid."')"; $result=$this->db->query($sql); dolibarr_syslog("User::Create sql=".$sql, LOG_DEBUG); diff --git a/htdocs/usergroup.class.php b/htdocs/usergroup.class.php index f5d01860a80..9efa95113c3 100644 --- a/htdocs/usergroup.class.php +++ b/htdocs/usergroup.class.php @@ -390,7 +390,7 @@ class UserGroup global $user,$conf,$langs; $sql = "INSERT into ".MAIN_DB_PREFIX."usergroup (datec,nom)"; - $sql .= " VALUES(now(),'".addslashes($this->nom)."')"; + $sql .= " VALUES(".$this->db->idate(mktime()).",'".addslashes($this->nom)."')"; $result=$this->db->query($sql); if ($result) diff --git a/scripts/cron/facture-paye-stats.php b/scripts/cron/facture-paye-stats.php index b22c06d493c..c693647ee9e 100644 --- a/scripts/cron/facture-paye-stats.php +++ b/scripts/cron/facture-paye-stats.php @@ -75,7 +75,7 @@ if ($resql) while ($row = $db->fetch_row($resql)) { $sqli = "INSERT INTO ".MAIN_DB_PREFIX."facture_stats"; - $sqli .= " VALUES (now(),now(),'paye $row[0]',$row[1])"; + $sqli .= " VALUES (".$db->idate(mktime()).",".$this->db->idate(mktime()).",'paye $row[0]',$row[1])"; $resqli = $db->query($sqli); } @@ -93,7 +93,7 @@ if ($resql) while ($row = $db->fetch_row($resql)) { $sqli = "INSERT INTO ".MAIN_DB_PREFIX."facture_stats"; - $sqli .= " VALUES (now(),now(),'total $row[0]','$row[1]')"; + $sqli .= " VALUES (".$this->db->idate(mktime()).",".$this->db->idate(mktime()).",'total $row[0]','$row[1]')"; $resqli = $db->query($sqli); } diff --git a/scripts/cron/fournisseur-calcul-ca_genere.php b/scripts/cron/fournisseur-calcul-ca_genere.php index c038921e5cd..3970d2a715f 100644 --- a/scripts/cron/fournisseur-calcul-ca_genere.php +++ b/scripts/cron/fournisseur-calcul-ca_genere.php @@ -194,7 +194,7 @@ foreach($ca_fourns as $key => $value) $resqld = $db->query($sqld); $sqli = "INSERT INTO ".MAIN_DB_PREFIX."fournisseur_ca"; - $sqli .= " VALUES ($key,now(),$year,'".str_replace(',','.',$value)."'"; + $sqli .= " VALUES ($key,".$db->idate(mktime()).",$year,'".price2num($value)."'"; $sqli.= ",'". $fournisseurs_ca_achat[$key][$year] ."');"; $resqli = $db->query($sqli); @@ -206,12 +206,12 @@ foreach($ca_fourns as $key => $value) foreach($ca_products as $key => $value) { $sqld = "DELETE FROM ".MAIN_DB_PREFIX."product_ca"; - $sqld .= " WHERE year = $year AND fk_societe=$key;"; + $sqld .= " WHERE year = ".$year." AND fk_societe=".$key; $resqld = $db->query($sqld); $sqli = "INSERT INTO ".MAIN_DB_PREFIX."product_ca"; - $sqli .= " VALUES ($key,now(),$year,'".str_replace(',','.',$value)."');"; + $sqli .= " VALUES (".$key.",".$db->idate(mktime()).",".$year.",'".price2num($value)."')"; $resqli = $db->query($sqli); } diff --git a/scripts/prelevement/prelevement.php b/scripts/prelevement/prelevement.php index 3c1480a0c0f..5e11714cd08 100644 --- a/scripts/prelevement/prelevement.php +++ b/scripts/prelevement/prelevement.php @@ -211,7 +211,7 @@ if (sizeof($factures_prev) > 0) */ $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (ref,datec)"; - $sql .= " VALUES ('".$ref."',now())"; + $sql .= " VALUES ('".$ref."',".$db->idate(mktime()).")"; if ($db->query($sql)) { @@ -291,7 +291,7 @@ if (sizeof($factures_prev) > 0) */ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande"; $sql .= " SET traite = 1"; - $sql .= ", date_traite=now()"; + $sql .= ", date_traite=".$db->idate(mktime()); $sql .= ", fk_prelevement_bons = ".$prev_id; $sql .= " WHERE rowid=".$fac[1]; -- GitLab