diff --git a/htdocs/includes/boxes/box_actions.php b/htdocs/includes/boxes/box_actions.php index aecbc203b7d..ad92b510609 100644 --- a/htdocs/includes/boxes/box_actions.php +++ b/htdocs/includes/boxes/box_actions.php @@ -71,7 +71,7 @@ class box_actions extends ModeleBoxes { if ($user->rights->agenda->myactions->read) { - $sql = "SELECT a.id, a.label, ".$db->pdate("a.datep")." as dp , a.percent as percentage,"; + $sql = "SELECT a.id, a.label, a.datep as dp , a.percent as percentage,"; $sql.= " ta.code,"; $sql.= " s.nom, s.rowid as socid"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; @@ -99,8 +99,9 @@ class box_actions extends ModeleBoxes { { $late = ''; $objp = $db->fetch_object($result); - - if (date("U",$objp->dp) < (time() - $conf->global->MAIN_DELAY_ACTIONS_TODO)) $late=img_warning($langs->trans("Late")); + $datelimite=$db->jdate($obj->dp); + + if ($datelimite < (time() - $conf->global->MAIN_DELAY_ACTIONS_TODO)) $late=img_warning($langs->trans("Late")); $label=($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label); @@ -118,7 +119,7 @@ class box_actions extends ModeleBoxes { 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="left"', - 'text' => dolibarr_print_date($objp->dp, "dayhour")); + 'text' => dolibarr_print_date($datelimite, "dayhour")); $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => $objp->percentage. "%"); diff --git a/htdocs/includes/boxes/box_clients.php b/htdocs/includes/boxes/box_clients.php index 4969c3e3b25..23f56090f1d 100644 --- a/htdocs/includes/boxes/box_clients.php +++ b/htdocs/includes/boxes/box_clients.php @@ -67,7 +67,7 @@ class box_clients extends ModeleBoxes { if ($user->rights->societe->lire) { - $sql = "SELECT s.nom, s.rowid as socid, ".$db->pdate("s.datec")." as dc"; + $sql = "SELECT s.nom, s.rowid as socid, s.datec as dc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -85,13 +85,15 @@ class box_clients extends ModeleBoxes { if ($result) { $num = $db->num_rows($result); - + $datec=$db->jdate($objp->dc); + $i = 0; //$customerstatic=new Client($db); while ($i < $num) { $objp = $db->fetch_object($result); - + $datec=$db->jdate($objp->dc); + $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); @@ -101,7 +103,7 @@ class box_clients extends ModeleBoxes { 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][2] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->dc, "day")); + 'text' => dolibarr_print_date($datec, "day")); $i++; } diff --git a/htdocs/includes/boxes/box_commandes.php b/htdocs/includes/boxes/box_commandes.php index 0160abd7077..e8221fea5df 100644 --- a/htdocs/includes/boxes/box_commandes.php +++ b/htdocs/includes/boxes/box_commandes.php @@ -89,8 +89,9 @@ class box_commandes extends ModeleBoxes { if ($result) { - $num = $db->num_rows(); - + $num = $db->num_rows($result); + $datem=$db->jdate($objp->tms); + $i = 0; while ($i < $num) @@ -110,7 +111,7 @@ class box_commandes extends ModeleBoxes { 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->tms,'day'), + 'text' => dolibarr_print_date($datem,'day'), ); $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', diff --git a/htdocs/includes/boxes/box_energie_releve.php b/htdocs/includes/boxes/box_energie_releve.php index ff62e885d03..6d3388884e3 100644 --- a/htdocs/includes/boxes/box_energie_releve.php +++ b/htdocs/includes/boxes/box_energie_releve.php @@ -62,9 +62,9 @@ class box_energie_releve extends ModeleBoxes { $this->info_box_head = array('text' => $text,$max); - $sql = "SELECT ec.libelle, ".$db->pdate("date_releve")." as date_releve, ecr.valeur, ec.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr"; - $sql .= " , ".MAIN_DB_PREFIX."energie_compteur as ec"; + $sql = "SELECT ec.libelle, ecr.valeur, ec.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr,"; + $sql .= " ".MAIN_DB_PREFIX."energie_compteur as ec"; $sql .= " WHERE ecr.fk_compteur = ec.rowid"; $sql .= " ORDER BY ecr.date_releve DESC LIMIT 5"; $resql = $db->query($sql); diff --git a/htdocs/includes/boxes/box_factures.php b/htdocs/includes/boxes/box_factures.php index dcd64f2a91e..26a37d5a4d4 100644 --- a/htdocs/includes/boxes/box_factures.php +++ b/htdocs/includes/boxes/box_factures.php @@ -16,144 +16,143 @@ * 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/includes/boxes/box_factures.php - \ingroup factures - \brief Module de génération de l'affichage de la box factures -*/ + \file htdocs/includes/boxes/box_factures.php + \ingroup factures + \brief Module de génération de l'affichage de la box factures + \version $Id$ + */ include_once(DOL_DOCUMENT_ROOT."/includes/boxes/modules_boxes.php"); class box_factures extends ModeleBoxes { - var $boxcode="lastcustomerbills"; - var $boximg="object_bill"; - var $boxlabel; - var $depends = array("facture"); + var $boxcode="lastcustomerbills"; + var $boximg="object_bill"; + var $boxlabel; + var $depends = array("facture"); var $db; var $param; - var $info_box_head = array(); - var $info_box_contents = array(); + var $info_box_head = array(); + var $info_box_contents = array(); - /** - * \brief Constructeur de la classe - */ - function box_factures() - { - global $langs; - $langs->load("boxes"); + /** + * \brief Constructeur de la classe + */ + function box_factures() + { + global $langs; + $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastCustomerBills"); - } + $this->boxlabel=$langs->trans("BoxLastCustomerBills"); + } - /** - * \brief Charge les données en mémoire pour affichage ultérieur - * \param $max Nombre maximum d'enregistrements à charger - */ - function loadBox($max=5) - { - global $user, $langs, $db; + /** + * \brief Charge les données en mémoire pour affichage ultérieur + * \param $max Nombre maximum d'enregistrements à charger + */ + function loadBox($max=5) + { + global $user, $langs, $db; $this->max=$max; - + include_once(DOL_DOCUMENT_ROOT."/facture.class.php"); - $facturestatic=new Facture($db); - - $text = $langs->trans("BoxTitleLastCustomerBills",$max); - $this->info_box_head = array( + $facturestatic=new Facture($db); + + $text = $langs->trans("BoxTitleLastCustomerBills",$max); + $this->info_box_head = array( 'text' => $text, 'limit'=> strlen($text) - ); - - if ($user->rights->facture->lire) - { - $sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.amount, ".$db->pdate("f.datef")." as df,"; - $sql.= " f.paye, f.fk_statut, f.datec,"; - $sql.= " s.nom, s.rowid as socid, "; - $sql.= $db->pdate('f.date_lim_reglement')." as datelimite "; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) - { - $sql.= " AND s.rowid = ".$user->societe_id; - } - $sql.= " ORDER BY f.datef DESC, f.facnumber DESC "; - $sql.= $db->plimit($max, 0); - - $result = $db->query($sql); - - if ($result) - { - $num = $db->num_rows(); - - $i = 0; - $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)'; - - while ($i < $num) - { - $objp = $db->fetch_object($result); - - $picto='bill'; - if ($objp->type == 1) $picto.='r'; - if ($objp->type == 2) $picto.='a'; - $late = ''; - if($objp->paye == 0 && $objp->datelimite < (time() - $conf->facture->warning_delay)) { $late = img_warning(sprintf($l_due_date,dolibarr_print_date($objp->datelimite,'day')));} - - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', + ); + + if ($user->rights->facture->lire) + { + $sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.datef as df,"; + $sql.= " f.paye, f.fk_statut, f.datec,"; + $sql.= " s.nom, s.rowid as socid,"; + $sql.= " f.date_lim_reglement as datelimite "; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE f.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->societe_id) + { + $sql.= " AND s.rowid = ".$user->societe_id; + } + $sql.= " ORDER BY f.datef DESC, f.facnumber DESC "; + $sql.= $db->plimit($max, 0); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + + $i = 0; + $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)'; + + while ($i < $num) + { + $objp = $db->fetch_object($result); + $datelimite=$db->jdate($objp->datelimite); + $datec=$db->jdate($objp->datec); + + $picto='bill'; + if ($objp->type == 1) $picto.='r'; + if ($objp->type == 2) $picto.='a'; + $late = ''; + if($objp->paye == 0 && $datelimite < (time() - $conf->facture->warning_delay)) { $late = img_warning(sprintf($l_due_date,dolibarr_print_date($datelimite,'day')));} + + $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $picto, 'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid); - - $this->info_box_contents[$i][1] = array('td' => 'align="left"', + + $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->facnumber, 'text2'=> $late, 'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid); - - $this->info_box_contents[$i][2] = array('td' => 'align="left"', + + $this->info_box_contents[$i][2] = array('td' => 'align="left"', 'text' => $objp->nom, 'maxlength'=>40, 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); - $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->datec,'day'), - ); - - $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', + $this->info_box_contents[$i][3] = array('td' => 'align="right"', + 'text' => dolibarr_print_date($datec,'day'), + ); + + $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3)); - $i++; - } - - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices")); - } - else - { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', + $i++; + } + + if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices")); + } + else + { + $this->info_box_contents[0][0] = array( 'td' => 'align="left"', 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql)); - } - - } - else { - $this->info_box_contents[0][0] = array('td' => 'align="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed")); - } - } + } - function showBox() - { - parent::showBox($this->info_box_head, $this->info_box_contents); - } + } + else { + $this->info_box_contents[0][0] = array('td' => 'align="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed")); + } + } + + function showBox() + { + parent::showBox($this->info_box_head, $this->info_box_contents); + } } diff --git a/htdocs/includes/boxes/box_factures_fourn.php b/htdocs/includes/boxes/box_factures_fourn.php index e216bc49cce..c05be17953a 100644 --- a/htdocs/includes/boxes/box_factures_fourn.php +++ b/htdocs/includes/boxes/box_factures_fourn.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +18,11 @@ */ /** - \file htdocs/includes/boxes/box_factures_fourn.php - \ingroup fournisseur - \brief Fichier de gestion d'une box des factures fournisseurs - \version $Id$ -*/ + * \file htdocs/includes/boxes/box_factures_fourn.php + * \ingroup supplier + * \brief Fichier de gestion d'une box des factures fournisseurs + * \version $Id$ + */ include_once(DOL_DOCUMENT_ROOT."/includes/boxes/modules_boxes.php"); @@ -71,9 +71,11 @@ class box_factures_fourn extends ModeleBoxes { if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom, s.rowid as socid,"; - $sql.= " f.rowid as facid, f.facnumber, f.amount,".$db->pdate("f.datef")." as df,"; - $sql.= " f.paye, f.fk_statut, f.datec,"; - $sql.= ' '.$db->pdate('f.date_lim_reglement').' as datelimite '; + $sql.= " f.rowid as facid, f.facnumber, f.amount,"; + $sql.= " f.paye, f.fk_statut,"; + $sql.= ' f.datef as df,'; + $sql.= ' f.datec as datec,'; + $sql.= ' f.date_lim_reglement as datelimite '; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -87,7 +89,6 @@ class box_factures_fourn extends ModeleBoxes { $sql .= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) { $num = $db->num_rows($result); @@ -98,8 +99,11 @@ class box_factures_fourn extends ModeleBoxes { while ($i < $num) { $objp = $db->fetch_object($result); + $datelimite=$db->jdate($obj->datelimite); + $datec=$db->jdate($objp->datec); + $late = ''; - if ($objp->paye == 0 && $objp->datelimite < (time() - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date, dolibarr_print_date($objp->datelimite,'day'))); + if ($objp->paye == 0 && $datelimite < (time() - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date, dolibarr_print_date($datelimite,'day'))); $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, @@ -115,7 +119,7 @@ class box_factures_fourn extends ModeleBoxes { 'url' => DOL_URL_ROOT."/fourn/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->datec,'day')); + 'text' => dolibarr_print_date($datec,'day')); $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3)); diff --git a/htdocs/includes/boxes/box_factures_fourn_imp.php b/htdocs/includes/boxes/box_factures_fourn_imp.php index 57028e78873..39c44df026a 100644 --- a/htdocs/includes/boxes/box_factures_fourn_imp.php +++ b/htdocs/includes/boxes/box_factures_fourn_imp.php @@ -68,10 +68,9 @@ class box_factures_fourn_imp extends ModeleBoxes { if ($user->rights->fournisseur->facture->lire) { - $sql = "SELECT s.nom, s.rowid as socid,"; - $sql.= " f.facnumber,".$db->pdate("f.date_lim_reglement")." as datelimite,"; - $sql.= " f.amount,".$db->pdate("f.datef")." as df,"; + $sql.= " f.facnumber, f.date_lim_reglement as datelimite,"; + $sql.= " f.amount, f.datef as df,"; $sql.= " f.paye, f.fk_statut, f.rowid as facid"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f"; @@ -96,9 +95,10 @@ class box_factures_fourn_imp extends ModeleBoxes { while ($i < $num) { $objp = $db->fetch_object($result); - + $datelimite=$db->jdate($objp->datelimite); + $late=''; - if ($objp->datelimite < (time() - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date,dolibarr_print_date($objp->datelimite,'day'))); + if ($datelimite < (time() - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date,dolibarr_print_date($datelimite,'day'))); $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, @@ -114,7 +114,7 @@ class box_factures_fourn_imp extends ModeleBoxes { 'url' => DOL_URL_ROOT."/fourn/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->datelimite,'day')); + 'text' => dolibarr_print_date($datelimite,'day')); $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3)); diff --git a/htdocs/includes/boxes/box_factures_imp.php b/htdocs/includes/boxes/box_factures_imp.php index c029cb5763a..b9f92ad121d 100644 --- a/htdocs/includes/boxes/box_factures_imp.php +++ b/htdocs/includes/boxes/box_factures_imp.php @@ -72,8 +72,8 @@ class box_factures_imp extends ModeleBoxes { if ($user->rights->facture->lire) { $sql = "SELECT s.nom, s.rowid as socid,"; - $sql.= " f.facnumber,".$db->pdate("f.date_lim_reglement")." as datelimite,"; - $sql.= " f.amount,".$db->pdate("f.datef")." as df,"; + $sql.= " f.facnumber, f.date_lim_reglement as datelimite,"; + $sql.= " f.amount, f.datef as df,"; $sql.= " f.paye, f.fk_statut, f.rowid as facid"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; @@ -99,9 +99,10 @@ class box_factures_imp extends ModeleBoxes { while ($i < $num) { $objp = $db->fetch_object($result); - + $datelimite=$db->jdate($objp->datelimite); + $late=''; - if ($objp->datelimite < (time() - $conf->facture->warning_delay)) $late = img_warning(sprintf($l_due_date,dolibarr_print_date($objp->datelimite,'day'))); + if ($datelimite < (time() - $conf->facture->warning_delay)) $late = img_warning(sprintf($l_due_date,dolibarr_print_date($datelimite,'day'))); $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, @@ -118,10 +119,10 @@ class box_factures_imp extends ModeleBoxes { 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->datelimite,'day'), + 'text' => dolibarr_print_date($datelimite,'day'), ); - $this->info_box_contents[$i][3] = array('td' => 'align="right" width="18"', + $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3)); $i++; diff --git a/htdocs/includes/boxes/box_fournisseurs.php b/htdocs/includes/boxes/box_fournisseurs.php index fee084e7dad..a4b8416ea78 100644 --- a/htdocs/includes/boxes/box_fournisseurs.php +++ b/htdocs/includes/boxes/box_fournisseurs.php @@ -66,7 +66,7 @@ class box_fournisseurs extends ModeleBoxes { if ($user->rights->societe->lire) { - $sql = "SELECT s.nom, s.rowid as socid, ".$db->pdate("s.datec")." as dc"; + $sql = "SELECT s.nom, s.rowid as socid, s.datec as dc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -80,7 +80,6 @@ class box_fournisseurs extends ModeleBoxes { $sql .= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) { $num = $db->num_rows($result); @@ -90,7 +89,8 @@ class box_fournisseurs extends ModeleBoxes { while ($i < $num) { $objp = $db->fetch_object($result); - + $datec=$db->jdate($objp->dc); + $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT."/fourn/fiche.php?socid=".$objp->socid); @@ -100,7 +100,7 @@ class box_fournisseurs extends ModeleBoxes { 'url' => DOL_URL_ROOT."/fourn/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][2] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->dc, "day")); + 'text' => dolibarr_print_date($datec, "day")); $i++; } diff --git a/htdocs/includes/boxes/box_produits.php b/htdocs/includes/boxes/box_produits.php index 14a09b19f7e..5d1573e9c06 100644 --- a/htdocs/includes/boxes/box_produits.php +++ b/htdocs/includes/boxes/box_produits.php @@ -89,6 +89,7 @@ class box_produits extends ModeleBoxes { while ($i < $num) { $objp = $db->fetch_object($result); + $datem=$db->jdate($obj->tms); // Multilangs if ($conf->global->MAIN_MULTILANGS) // si l'option est active @@ -130,7 +131,7 @@ class box_produits extends ModeleBoxes { 'text' => $price_base_type); $this->info_box_contents[$i][4] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->tms,'day')); + 'text' => dolibarr_print_date($datem,'day')); $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 'text' => $productstatic->LibStatut($objp->envente,3)); diff --git a/htdocs/includes/boxes/box_propales.php b/htdocs/includes/boxes/box_propales.php index 37aa40f8e97..07e723cbffe 100644 --- a/htdocs/includes/boxes/box_propales.php +++ b/htdocs/includes/boxes/box_propales.php @@ -73,7 +73,7 @@ class box_propales extends ModeleBoxes { { $sql = "SELECT s.nom, s.rowid as socid,"; - $sql.= " p.rowid, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp, p.datec"; + $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -90,14 +90,15 @@ class box_propales extends ModeleBoxes { if ($result) { - $num = $db->num_rows(); + $num = $db->num_rows($result); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); - + $datec=$db->jdate($objp->datec); + $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT."/comm/propal.php?propalid=".$objp->rowid); @@ -111,7 +112,7 @@ class box_propales extends ModeleBoxes { 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->datec,'day')); + 'text' => dolibarr_print_date($datec,'day')); $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut,3)); diff --git a/htdocs/includes/boxes/box_prospect.php b/htdocs/includes/boxes/box_prospect.php index 499cba97579..211f958783e 100644 --- a/htdocs/includes/boxes/box_prospect.php +++ b/htdocs/includes/boxes/box_prospect.php @@ -71,7 +71,7 @@ class box_prospect extends ModeleBoxes { if ($user->rights->societe->lire) { - $sql = "SELECT s.nom, s.rowid as socid, s.fk_stcomm, ".$db->pdate("s.datec")." as dc"; + $sql = "SELECT s.nom, s.rowid as socid, s.fk_stcomm, s.datec as dc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -95,7 +95,8 @@ class box_prospect extends ModeleBoxes { while ($i < $num) { $objp = $db->fetch_object($resql); - + $datec=$db->jdate($objp->dc); + $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT."/comm/prospect/fiche.php?socid=".$objp->socid); @@ -105,7 +106,7 @@ class box_prospect extends ModeleBoxes { 'url' => DOL_URL_ROOT."/comm/prospect/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][2] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->dc, "day")); + 'text' => dolibarr_print_date($datec, "day")); $this->info_box_contents[$i][3] = array('td' => 'align="right" width="18"', 'text' => eregi_replace('img ','img height="14px" ',$prospectstatic->LibStatut($objp->fk_stcomm,3))); diff --git a/htdocs/includes/boxes/box_services_vendus.php b/htdocs/includes/boxes/box_services_vendus.php index a4d0618f9b6..87d9c399948 100644 --- a/htdocs/includes/boxes/box_services_vendus.php +++ b/htdocs/includes/boxes/box_services_vendus.php @@ -104,7 +104,8 @@ class box_services_vendus extends ModeleBoxes { while ($i < $num) { $objp = $db->fetch_object($result); - + $datem=$db->jdate($objp->datem); + // Multilangs if ($conf->global->MAIN_MULTILANGS) // si l'option est active { @@ -135,7 +136,7 @@ class box_services_vendus extends ModeleBoxes { 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => dolibarr_print_date($objp->datem,'day')); + 'text' => dolibarr_print_date($datem,'day')); $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $contratlignestatic->LibStatut($objp->statut,3) diff --git a/htdocs/includes/boxes/modules_boxes.php b/htdocs/includes/boxes/modules_boxes.php index 534fc692163..d97bfe08f56 100644 --- a/htdocs/includes/boxes/modules_boxes.php +++ b/htdocs/includes/boxes/modules_boxes.php @@ -103,6 +103,8 @@ class ModeleBoxes $bcx[1] = 'class="box_impair"'; $var = true; + dolibarr_syslog("modules_box::showBox ".get_Class($this)); + // Define nbcol and nblines of the box to show $nbcol=0; if (isset($contents[0])) $nbcol=sizeof($contents[0]); diff --git a/htdocs/lib/databases/mssql.lib.php b/htdocs/lib/databases/mssql.lib.php index 075901604f8..8b6c7ba9d40 100644 --- a/htdocs/lib/databases/mssql.lib.php +++ b/htdocs/lib/databases/mssql.lib.php @@ -46,9 +46,9 @@ class DoliDb var $forcecollate='latin1_swedish_ci'; //! Version min database var $versionmin=array(2000); - //! Resultset de la derni�re requete + //! Resultset de la derni�re requete var $results; - //! 1 si connect�, 0 sinon + //! 1 si connect�, 0 sinon var $connected; //! 1 si base s�lectionn�, 0 sinon var $database_selected; @@ -80,7 +80,7 @@ class DoliDb \param name Nom de la database \param port Port of database server \return int 1 en cas de succ�s, 0 sinon - */ + */ function DoliDb($type='mssql', $host, $user, $pass, $name='', $port=0) { global $conf,$langs; @@ -165,7 +165,7 @@ class DoliDb * \brief Selectionne une database. * \param database Nom de la database * \return boolean true si ok, false si ko - */ + */ function select_db($database) { return mssql_select_db($database, $this->db); @@ -180,7 +180,7 @@ class DoliDb \param port Port of database server \return resource handler d'acc�s � la bas \seealso close - */ + */ function connect($host, $login, $passwd, $name, $port=0) { dolibarr_syslog("DoliDB::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name"); @@ -198,7 +198,7 @@ class DoliDb /** \brief Renvoie la version du serveur \return string Chaine version - */ + */ function getVersion() { $resql=$this->query("SELECT @@VERSION"); @@ -210,7 +210,7 @@ class DoliDb /** \brief Renvoie la version du serveur dans un tableau \return array Tableau de chaque niveau de version - */ + */ function getVersionArray() { return split('\.',$this->getVersion()); @@ -221,7 +221,7 @@ class DoliDb \brief Fermeture d'une connexion vers une database. \return resource \seealso connect - */ + */ function close() { return mssql_close($this->db); @@ -277,7 +277,7 @@ class DoliDb /** \brief Annulation d'une transaction et retour aux anciennes valeurs \return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur - */ + */ function rollback() { if ($this->transaction_opened<=1) @@ -298,7 +298,7 @@ class DoliDb \brief Effectue une requete et renvoi le resultset de r�ponse de la base \param query Contenu de la query \return resource Resultset de la reponse - */ + */ function query($query) { $query = trim($query); @@ -371,7 +371,7 @@ class DoliDb $result = mssql_query("SELECT @@ERROR as code", $this->db); $row = mssql_fetch_array($result); - + $this->lasterror = $this->error(); $this->lasterrno = $row["code"]; } @@ -533,24 +533,37 @@ 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. - \param param Date TMS � convertir - \return date Date au format texte YYYYMMDDHHMMSS. + * \brief Formatage (par PHP) d'une date vers format texte pour insertion dans champ date. + * Fonction a utiliser pour generer les INSERT. + * \param param Date TMS a convertir + * \return date Date au format texte YYYYMMDDHHMMSS. */ function idate($param) { //return "dbo.from_unixtime(".$param.")"; - return adodb_strftime("%d/%m/%Y %H:%M:%S",$param); + return adodb_strftime("%Y-%m-%d %H:%M:%S",$param); } + /** + * \brief Convert a GM string date into a GM Timestamps date + * \param string Date in a string (YYYYMMDD, YYYYMMDDHHMMSS, YYYY-MM-DD HH:MM:SS) + * \return date Date + * \example 19700101020000 -> 7200 + */ + function jdate($string) + { + $string=eregi_replace('[^0-9]','',$string); + $tmp=$string.'000000'; + $date=dolibarr_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),1); + return $date; + } /** - \brief Formatage d'un if SQL - \param test chaine test - \param resok resultat si test egal - \param resko resultat si test non egal - \return string chaine format� SQL + * \brief Formatage d'un if SQL + * \param test chaine test + * \param resok resultat si test egal + * \param resko resultat si test non egal + * \return string chaine format� SQL */ function ifsql($test,$resok,$resko) { @@ -559,8 +572,8 @@ class DoliDb /** - \brief Renvoie la derniere requete soumise par la methode query() - \return lastquery + * \brief Renvoie la derniere requete soumise par la methode query() + * \return lastquery */ function lastquery() { @@ -632,8 +645,8 @@ class DoliDb 1216 => 'DB_ERROR_NO_PARENT', 1217 => 'DB_ERROR_CHILD_EXISTS', 1451 => 'DB_ERROR_CHILD_EXISTS' - ); - + ); + if (isset($errorcode_map[$this->lasterrno])) { return $errorcode_map[$this->lasterrno]; diff --git a/htdocs/lib/databases/mysql.lib.php b/htdocs/lib/databases/mysql.lib.php index 8686bc38f22..f07b03dbaa9 100644 --- a/htdocs/lib/databases/mysql.lib.php +++ b/htdocs/lib/databases/mysql.lib.php @@ -514,12 +514,12 @@ class DoliDb /** - * \brief Formatage (par la base de donn�es) d'un champ de la base au format TMS ou Date (YYYY-MM-DD HH:MM:SS) - * afin de retourner une donn�e toujours au format universel date TMS unix. - * Fonction � utiliser pour g�n�rer les SELECT. + * \brief Formatage (par la base de donn�es) d'un champ de la base au format TMS ou Date (YYYY-MM-DD HH:MM:SS) + * afin de retourner une donn�e toujours au format universel date TMS unix. + * Fonction � utiliser pour g�n�rer les SELECT. * \param param Nom champ base de type date ou chaine 'YYYY-MM-DD HH:MM:SS' - * \return date Date au format TMS. - * \TODO Remove unix_timestamp functions + * \return date Date au format TMS. + * \TODO Remove unix_timestamp functions so use jdate instead */ function pdate($param) { @@ -527,23 +527,37 @@ 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, UPDATE ou les clauses WHERE - * \param param Date TMS � convertir - * \return date Date au format texte YYYYMMDDHHMMSS. + * \brief Convert (by PHP) a GM Timestamp date into a GM string date to insert into a date field. + * Function to use to build INSERT, UPDATE or WHERE predica + * \param param Date TMS to convert + * \return string Date in a string YYYYMMDDHHMMSS */ function idate($param) { return adodb_strftime("%Y%m%d%H%M%S",$param); } + /** + * \brief Convert (by PHP) a GM string date into a GM Timestamps date + * \param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) + * \return date Date TMS + * \example 19700101020000 -> 7200 + */ + function jdate($string) + { + $string=eregi_replace('[^0-9]','',$string); + $tmp=$string.'000000'; + $date=dolibarr_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),1); + return $date; + } + /** - \brief Formatage d'un if SQL - \param test chaine test - \param resok resultat si test egal - \param resko resultat si test non egal - \return string chaine format� SQL + * \brief Formatage d'un if SQL + * \param test chaine test + * \param resok resultat si test egal + * \param resko resultat si test non egal + * \return string chaine format� SQL */ function ifsql($test,$resok,$resko) { @@ -552,8 +566,8 @@ class DoliDb /** - \brief Renvoie la derniere requete soumise par la methode query() - \return lastquery + * \brief Renvoie la derniere requete soumise par la methode query() + * \return lastquery */ function lastquery() { @@ -561,8 +575,8 @@ class DoliDb } /** - \brief Renvoie la derniere requete en erreur - \return string lastqueryerror + * \brief Renvoie la derniere requete en erreur + * \return string lastqueryerror */ function lastqueryerror() { @@ -570,8 +584,8 @@ class DoliDb } /** - \brief Renvoie le libelle derniere erreur - \return string lasterror + * \brief Renvoie le libelle derniere erreur + * \return string lasterror */ function lasterror() { @@ -579,8 +593,8 @@ class DoliDb } /** - \brief Renvoie le code derniere erreur - \return string lasterrno + * \brief Renvoie le code derniere erreur + * \return string lasterrno */ function lasterrno() { @@ -588,8 +602,8 @@ class DoliDb } /** - \brief Renvoie le code erreur generique de l'operation precedente. - \return error_num (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) + * \brief Renvoie le code erreur generique de l'operation precedente. + * \return error_num (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ function errno() { diff --git a/htdocs/lib/databases/mysqli.lib.php b/htdocs/lib/databases/mysqli.lib.php index 4f13e4ca64b..405d70273fd 100644 --- a/htdocs/lib/databases/mysqli.lib.php +++ b/htdocs/lib/databases/mysqli.lib.php @@ -533,7 +533,7 @@ class DoliDb * Fonction a utiliser pour generer les SELECT. * \param param Nom champ base de type date ou chaine 'YYYY-MM-DD HH:MM:SS' * \return date Date au format TMS. - * \TODO Remove unix_timestamp functions + * \TODO Remove unix_timestamp functions so use jdate instead */ function pdate($param) { @@ -541,23 +541,37 @@ class DoliDb } /** - * \brief Formatage (par PHP) d'une date vers format texte pour insertion dans champ date. - * Fonction a utiliser pour generer les INSERT, UPDATE ou les clauses WHERE + * \brief Convert (by PHP) a GM Timestamp date into a GM string date to insert into a date field. + * Function to use to build INSERT, UPDATE or WHERE predica * \param param Date TMS to convert - * \return date Date au format texte YYYYMMDDHHMMSS. + * \return string Date in a string YYYYMMDDHHMMSS */ function idate($param) { return adodb_strftime("%Y%m%d%H%M%S",$param); } + /** + * \brief Convert (by PHP) a GM string date into a GM Timestamps date + * \param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) + * \return date Date TMS + * \example 19700101020000 -> 7200 + */ + function jdate($string) + { + $string=eregi_replace('[^0-9]','',$string); + $tmp=$string.'000000'; + $date=dolibarr_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),1); + return $date; + } + /** - \brief Formatage d'un if SQL - \param test chaine test - \param resok resultat si test egal - \param resko resultat si test non egal - \return string chaine format� SQL + * \brief Formatage d'un if SQL + * \param test chaine test + * \param resok resultat si test egal + * \param resko resultat si test non egal + * \return string chaine formatee SQL */ function ifsql($test,$resok,$resko) { @@ -566,8 +580,8 @@ class DoliDb /** - \brief Renvoie la derniere requete soumise par la methode query() - \return lastquery + * \brief Renvoie la derniere requete soumise par la methode query() + * \return lastquery */ function lastquery() { @@ -575,8 +589,8 @@ class DoliDb } /** - \brief Renvoie la derniere requete en erreur - \return string lastqueryerror + * \brief Renvoie la derniere requete en erreur + * \return string lastqueryerror */ function lastqueryerror() { @@ -584,8 +598,8 @@ class DoliDb } /** - \brief Renvoie le libelle derniere erreur - \return string lasterror + * \brief Renvoie le libelle derniere erreur + * \return string lasterror */ function lasterror() { @@ -593,8 +607,8 @@ class DoliDb } /** - \brief Renvoie le code derniere erreur - \return string lasterrno + * \brief Renvoie le code derniere erreur + * \return string lasterrno */ function lasterrno() { @@ -602,8 +616,8 @@ class DoliDb } /** - \brief Renvoie le code erreur generique de l'operation precedente. - \return error_num (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) + * \brief Renvoie le code erreur generique de l'operation precedente. + * \return error_num (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ function errno() { diff --git a/htdocs/lib/databases/pgsql.lib.php b/htdocs/lib/databases/pgsql.lib.php index 9353c27ca6c..3dbc6772759 100644 --- a/htdocs/lib/databases/pgsql.lib.php +++ b/htdocs/lib/databases/pgsql.lib.php @@ -658,25 +658,38 @@ class DoliDb return "unix_timestamp(".$param.")"; } - /** - \brief Formatage (par PHP) de la date en texte qui s'insere dans champ date. - Fonction � utiliser pour g�n�rer les INSERT. - \param param Date tms � convertir - \return date Date au format text YYYYMMDDHHMMSS. - */ - function idate($param) - { - return adodb_strftime("%Y%m%d%H%M%S",$param); - } + /** + * \brief Convert (by PHP) a GM Timestamp date into a GM string date to insert into a date field. + * Function to use to build INSERT, UPDATE or WHERE predica + * \param param Date TMS to convert + * \return string Date in a string YYYYMMDDHHMMSS + */ + function idate($param) + { + return adodb_strftime("%Y%m%d%H%M%S",$param); + } + /** + * \brief Convert (by PHP) a GM string date into a GM Timestamps date + * \param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) + * \return date Date TMS + * \example 19700101020000 -> 7200 + */ + function jdate($string) + { + $string=eregi_replace('[^0-9]','',$string); + $tmp=$string.'000000'; + $date=dolibarr_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),1); + return $date; + } /** - \brief Formatage d'un if SQL - \param test chaine test - \param resok resultat si test egal - \param resko resultat si test non egal - \return string chaine format� SQL - */ + * \brief Formatage d'un if SQL + * \param test chaine test + * \param resok resultat si test egal + * \param resko resultat si test non egal + * \return string chaine format� SQL + */ function ifsql($test,$resok,$resko) { return 'IF('.$test.','.$resok.','.$resko.')'; @@ -684,18 +697,18 @@ class DoliDb /** - \brief Renvoie la derniere requete soumise par la methode query() - \return lastquery - */ + * \brief Renvoie la derniere requete soumise par la methode query() + * \return lastquery + */ function lastquery() { return $this->lastquery; } /** - \brief Renvoie la derniere requete en erreur - \return string lastqueryerror - */ + * \brief Renvoie la derniere requete en erreur + * \return string lastqueryerror + */ function lastqueryerror() { return $this->lastqueryerror; diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 591904d0498..f93a17f9db0 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -475,7 +475,7 @@ function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='') if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?',$time,$reg)) { // This part of code should not be used. - dolibarr_syslog("Functions.lib::dolibarr_print_date function call with deprecated parameter", LOG_WARNING); + dolibarr_syslog("Functions.lib::dolibarr_print_date function call with deprecated parameter in page ".$_SERVER["PHP_SELF"], LOG_WARNING); // Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' $syear = $reg[1]; $smonth = $reg[2];