From 0f410996f74d4f0e1f1a57f723df5bcdb6ce212f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 4 Jun 2012 16:54:20 +0200 Subject: [PATCH 1/6] New box showing the latest supplier orders. --- htdocs/core/boxes/box_supplier_orders.php | 153 +++++++++++++++++++ htdocs/core/modules/modFournisseur.class.php | 3 + htdocs/langs/en_US/boxes.lang | 4 + htdocs/langs/fr_FR/boxes.lang | 4 + 4 files changed, 164 insertions(+) create mode 100644 htdocs/core/boxes/box_supplier_orders.php diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php new file mode 100644 index 00000000000..d0d661bc43d --- /dev/null +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -0,0 +1,153 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2012 Raphaël Doursenaud + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_supplier_orders.php + * \ingroup fournisseurs + * \brief Module that generates the latest supplier orders box + */ +include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"); + +/** + * Class that manages the box showing latest supplier orders + */ +class box_supplier_orders extends ModeleBoxes +{ + + var $boxcode = "latestsupplierorders"; + var $boximg = "object_order"; + var $boxlabel; + var $depends = array("fournisseur"); + var $db; + var $param; + var $info_box_head = array(); + var $info_box_contents = array(); + + /** + * Constructor + */ + function box_supplier_orders() + { + global $langs; + $langs->load("boxes"); + + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLatestSupplierOrders"); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + function loadBox($max = 5) + { + global $conf, $user, $langs, $db; + $langs->load("boxes"); + + $this->max = $max; + + include_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php"); + $supplierorderstatic=new CommandeFournisseur($db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestSupplierOrders", $max)); + + if ($user->rights->fournisseur->commande->lire) + { + $sql = "SELECT s.nom, s.rowid as socid,"; + $sql.= " c.ref, c.tms, c.rowid,"; + $sql.= " c.fk_statut"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + 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 c.date_commande DESC, c.ref DESC "; + $sql.= $db->plimit($max, 0); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $datem=$db->jdate($objp->tms); + + $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'url' => DOL_URL_ROOT."/fourn/commande/fiche.php?id=".$objp->rowid); + + $this->info_box_contents[$i][1] = array('td' => 'align="left"', + 'text' => $objp->ref, + 'url' => DOL_URL_ROOT."/fourn/commande/fiche.php?id=".$objp->rowid); + + $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', + 'logo' => 'company', + 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); + + $this->info_box_contents[$i][3] = array('td' => 'align="left"', + 'text' => $objp->nom, + 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); + + $this->info_box_contents[$i][4] = array('td' => 'align="right"', + 'text' => dol_print_date($datem,'day'), + ); + + $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', + 'text' => $supplierorderstatic->LibStatut($objp->fk_statut,3)); + + $i++; + } + + if ($num == 0) + $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoSupplierOrder")); + } + else + { + dol_print_error($db); + } + } + else + { + $this->info_box_contents[0][0] = array('td' => 'align="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed")); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @return void + */ + function showBox($head = null, $contents = null) + { + parent::showBox($this->info_box_head, $this->info_box_contents); + } + +} + +?> diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 7a7d7fe2323..e7a759cf1c2 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -105,6 +105,9 @@ class modFournisseur extends DolibarrModules $this->boxes[$r][1] = "box_factures_fourn.php"; $r++; + $this->boxes[$r][1] = "box_supplier_orders.php"; + $r++; + // Permissions $this->rights = array(); $this->rights_class = 'fournisseur'; diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 6644af2ece3..d7cbbf3dd2b 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -70,3 +70,7 @@ NoRecordedProducts=No recorded products/services NoRecordedProspects=No recorded prospects NoContractedProducts=No products/services contracted NoRecordedContracts=No recorded contracts +# Latest supplier orders +BoxLatestSupplierOrders=Latest supplier orders +BoxTitleLatestSupplierOrders=%s latest supplier orders +NoSupplierOrder=No recorded supplier order diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index b70f098fc02..9a91af3cdb3 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -70,3 +70,7 @@ NoRecordedProducts=Pas de produit/service enregistré NoRecordedProspects=Pas de prospect enregistré NoContractedProducts=Pas de produit/service contracté NoRecordedContracts=Pas de contrat enregistré +# Dernières commandes fournisseur +BoxLatestSupplierOrders=Dernières commandes fournisseur +BoxTitleLatestSupplierOrders=Les %s dernières commandes fournisseur enregistrées +NoSupplierOrder=Pas de commandes fournisseur enregistrées From 29bfc2f310988553058010cb9ed03ef21220fbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 4 Jun 2012 18:05:19 +0200 Subject: [PATCH 2/6] Fixed supplier url in supplier orders' box --- htdocs/core/boxes/box_supplier_orders.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index d0d661bc43d..aa310118fd9 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -94,22 +94,25 @@ class box_supplier_orders extends ModeleBoxes { $objp = $db->fetch_object($result); $datem=$db->jdate($objp->tms); + + $urlo = DOL_URL_ROOT."/fourn/commande/fiche.php?id=".$objp->rowid; + $urls = DOL_URL_ROOT."/fourn/fiche.php?socid=".$objp->socid; $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/fourn/commande/fiche.php?id=".$objp->rowid); + 'url' => $urlo); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref, - 'url' => DOL_URL_ROOT."/fourn/commande/fiche.php?id=".$objp->rowid); + 'url' => $urlo); $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', - 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); + 'url' => $urls); - $this->info_box_contents[$i][3] = array('td' => 'align="left"', + $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => $objp->nom, - 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); + 'url' => $urls); $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datem,'day'), From 2a8cc5ad60fbccc6c88010d9e127128c9a9b81f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Wed, 6 Jun 2012 16:30:52 +0200 Subject: [PATCH 3/6] Fix a bug preventing module enablement with PostgreSQL --- htdocs/core/class/menubase.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index ecdb8752b8a..39db66216cf 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -114,7 +114,11 @@ class Menubase $obj=$this->db->fetch_object($resqlrowid); $maxrowid=$obj->maxrowid; - $sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")"; + // Max rowid can be empty if there is no record yet + if(empty($maxrowid)) $maxrowid=1; + + $sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")"; + //print $sql; exit; $resqlrowidset=$this->db->query($sql); if (! $resqlrowidset) dol_print_error($this->db); } From a29301d8b5d36198e12cf5fc9210f6730fdf26ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Wed, 6 Jun 2012 16:35:58 +0200 Subject: [PATCH 4/6] Indent --- htdocs/core/class/menubase.class.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 39db66216cf..852be332686 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -107,22 +107,22 @@ class Menubase // an insert with a forced id. if (in_array($this->db->type,array('pgsql'))) { - $sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu"; - $resqlrowid=$this->db->query($sql); - if ($resqlrowid) - { - $obj=$this->db->fetch_object($resqlrowid); - $maxrowid=$obj->maxrowid; + $sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu"; + $resqlrowid=$this->db->query($sql); + if ($resqlrowid) + { + $obj=$this->db->fetch_object($resqlrowid); + $maxrowid=$obj->maxrowid; - // Max rowid can be empty if there is no record yet - if(empty($maxrowid)) $maxrowid=1; + // Max rowid can be empty if there is no record yet + if(empty($maxrowid)) $maxrowid=1; - $sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")"; - //print $sql; exit; - $resqlrowidset=$this->db->query($sql); - if (! $resqlrowidset) dol_print_error($this->db); - } - else dol_print_error($this->db); + $sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")"; + //print $sql; exit; + $resqlrowidset=$this->db->query($sql); + if (! $resqlrowidset) dol_print_error($this->db); + } + else dol_print_error($this->db); } // Insert request From 530743e8b4ddecbbaf105a5728d3a136c93070ca Mon Sep 17 00:00:00 2001 From: simnandez Date: Sun, 10 Jun 2012 11:10:18 +0200 Subject: [PATCH 5/6] Fix: Bad link to propal list into stadistics and dashboard boxes --- htdocs/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 2a157521b50..a3c74111ef0 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2011-2012 Juanjo Menent * * 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 @@ -208,7 +208,7 @@ if ($user->societe_id == 0) DOL_URL_ROOT.'/adherents/liste.php?statut=1&mainmenu=members', DOL_URL_ROOT.'/product/liste.php?type=0&mainmenu=products', DOL_URL_ROOT.'/product/liste.php?type=1&mainmenu=products', - DOL_URL_ROOT.'/comm/propal.php?mainmenu=commercial', + DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial', DOL_URL_ROOT.'/commande/liste.php?mainmenu=commercial', DOL_URL_ROOT.'/compta/facture.php?mainmenu=accountancy', DOL_URL_ROOT.'/contrat/liste.php'); @@ -338,7 +338,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) $board->load_board($user,"opened"); $board->warning_delay=$conf->propal->cloture->warning_delay/60/60/24; $board->label=$langs->trans("PropalsToClose"); - $board->url=DOL_URL_ROOT.'/comm/propal.php?viewstatut=1'; + $board->url=DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1'; $board->img=img_object($langs->trans("Propals"),"propal"); $rowspan++; $dashboardlines[]=$board; @@ -354,7 +354,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) $board->load_board($user,"signed"); $board->warning_delay=$conf->propal->facturation->warning_delay/60/60/24; $board->label=$langs->trans("PropalsToBill"); - $board->url=DOL_URL_ROOT.'/comm/propal.php?viewstatut=2'; + $board->url=DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=2'; $board->img=img_object($langs->trans("Propals"),"propal"); $rowspan++; $dashboardlines[]=$board; From 2540f727c063d55314e9f7677df8739141b8383d Mon Sep 17 00:00:00 2001 From: defrance69 Date: Sun, 10 Jun 2012 13:42:19 +0300 Subject: [PATCH 6/6] if day of week < 7 display 2 times the day : 3 days 3 days add the 's' if they are many days --- htdocs/core/lib/date.lib.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 52368bd634c..d412ec3ea82 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -261,16 +261,23 @@ function convertSecondToTime($iSecond,$format='all',$lengthOfDay=86400,$lengthOf if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks"); $sTime.=$sWeek.' '.$weekTranslate.' '; } - if ($sDay>0) +/* if ($sDay>0) { $dayTranslate = $langs->trans("Day"); if ($sDay > 1) $dayTranslate = $langs->trans("Days"); $sTime.=$sDay.' '.$dayTranslate.' '; } +*/ } } + if ($sDay>0) + { + $dayTranslate = $langs->trans("Day"); + if ($sDay > 1) $dayTranslate = $langs->trans("Days"); + $sTime.=$sDay.' '.$dayTranslate.' '; + } - if ($sDay) $sTime.=$sDay.' '.$dayTranslate.' '; +// if ($sDay) $sTime.=$sDay.' '.$dayTranslate.' '; if ($iSecond || empty($sDay)) { $sTime.= dol_print_date($iSecond,'hourduration',true);