From 0abeea059ebd0594a2d4a490a95122bcb7da1fbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 27 Oct 2014 21:48:28 +0100 Subject: [PATCH] Uniformize and clean boxes behaviour and translation. --- htdocs/admin/boxes.php | 12 +- htdocs/core/boxes/box_commandes.php | 41 +++++-- htdocs/core/boxes/box_factures.php | 18 ++- htdocs/core/boxes/box_factures_fourn.php | 12 +- htdocs/core/boxes/box_ficheinter.php | 7 +- htdocs/core/boxes/box_propales.php | 135 ++++++++++++---------- htdocs/core/boxes/box_supplier_orders.php | 12 +- htdocs/core/class/infobox.class.php | 30 ++--- htdocs/core/modules/modCommande.class.php | 6 +- htdocs/langs/en_US/boxes.lang | 25 ++-- htdocs/langs/fr_FR/boxes.lang | 31 ++--- htdocs/user/class/user.class.php | 2 +- 12 files changed, 189 insertions(+), 142 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index c88d7717084..c12e913e9c1 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -65,8 +65,9 @@ if ($action == 'add') $sql.= " FROM ".MAIN_DB_PREFIX."user_param"; $sql.= " WHERE param = 'MAIN_BOXES_".$db->escape(GETPOST("pos","alpha"))."' AND value = '1'"; $sql.= " AND entity = ".$conf->entity; - $resql = $db->query($sql); + dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -227,8 +228,8 @@ $actives = array(); $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,"; $sql.= " bd.rowid as boxid"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd"; -$sql.= " WHERE b.entity = ".$conf->entity; -$sql.= " AND b.box_id = bd.rowid"; +$sql.= " WHERE b.box_id = bd.rowid"; +$sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND b.fk_user=0"; $sql.= " ORDER by b.position, b.box_order"; @@ -237,6 +238,8 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + + // Check record to know if we must recalculate sort order $i = 0; $decalage=0; $var=false; @@ -310,7 +313,6 @@ if ($resql) $db->free($resql); } - // Available boxes to activate $boxtoadd=InfoBox::listBoxes($db,'available',-1,null,$actives); @@ -372,7 +374,7 @@ print ''; // Activated boxes $boxactivated=InfoBox::listBoxes($db,'activated',-1,null); - +//var_dump($boxactivated); print "
\n\n"; print_titre($langs->trans("BoxesActivated")); diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index a89fca4acc0..1bb6fe9b27a 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -58,22 +58,25 @@ class box_commandes extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $commandestatic=new Commande($db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerOrders",$max)); + $userstatic = new User($db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerOrders",$max)); if ($user->rights->commande->lire) { - $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " c.ref, c.tms, c.rowid,"; - $sql.= " c.fk_statut, c.facture"; + $sql.= " c.ref, c.tms, c.rowid, c.date_commande,"; + $sql.= " c.fk_statut, c.fk_user_valid, c.facture, c.total_ht"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande 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 (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1"; 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 "; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; $sql.= $db->plimit($max, 0); $result = $db->query($sql); @@ -86,29 +89,43 @@ class box_commandes extends ModeleBoxes while ($i < $num) { $objp = $db->fetch_object($result); + $date=$db->jdate($objp->date_commande); $datem=$db->jdate($objp->tms); - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', + $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', + $this->info_box_contents[$i][] = array('td' => 'align="left"', 'text' => $objp->ref, 'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid); - $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', + $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); - $this->info_box_contents[$i][3] = array('td' => 'align="left"', + $this->info_box_contents[$i][] = array('td' => 'align="left"', 'text' => $objp->name, 'url' => DOL_URL_ROOT."/comm/card.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][] = array('td' => 'align="right"', + 'text' => price($objp->total_ht), + ); + + if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) + { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$i][] = array('td' => 'align="right"', + 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'url' => (($objp->fk_user_valid > 0)?DOL_URL_ROOT.'/user/card.php?id='.$objp->fk_user_valid:'') + ); + } + + $this->info_box_contents[$i][] = array('td' => 'align="right"', + 'text' => dol_print_date($date,'day'), ); - $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', + $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3)); $i++; diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index ee5326250b3..b0fdd6d9d09 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -56,7 +56,7 @@ class box_factures extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $facturestatic=new Facture($db); - $text = $langs->trans("BoxTitleLastCustomerBills",$max); + $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max); $this->info_box_head = array( 'text' => $text, 'limit'=> dol_strlen($text) @@ -64,7 +64,7 @@ class box_factures extends ModeleBoxes if ($user->rights->facture->lire) { - $sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.datef as df"; + $sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.total as total_ht, f.datef as df"; $sql.= ", f.paye, f.fk_statut, f.datec, f.tms"; $sql.= ", s.nom as name, s.rowid as socid"; $sql.= ", f.date_lim_reglement as datelimite"; @@ -75,7 +75,8 @@ class box_factures extends ModeleBoxes $sql.= " AND f.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 f.tms DESC"; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.facnumber DESC "; + else $sql.= " ORDER BY f.tms DESC, f.facnumber DESC "; $sql.= $db->plimit($max, 0); $result = $db->query($sql); @@ -91,7 +92,8 @@ class box_factures extends ModeleBoxes { $objp = $db->fetch_object($result); $datelimite=$db->jdate($objp->datelimite); - $datec=$db->jdate($objp->datec); + $date=$db->jdate($objp->df); + $datem=$db->jdate($objp->tms); $picto='bill'; if ($objp->type == 1) $picto.='r'; @@ -118,10 +120,14 @@ class box_factures extends ModeleBoxes 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); $this->info_box_contents[$i][4] = array('td' => 'align="right"', - 'text' => dol_print_date($datec,'day'), + 'text' => price($objp->total_ht), ); - $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', + $this->info_box_contents[$i][5] = array('td' => 'align="right"', + 'text' => dol_print_date($date,'day'), + ); + + $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3)); $i++; diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 441c9f743fe..914f442bea4 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -58,13 +58,13 @@ class box_factures_fourn extends ModeleBoxes $facturestatic=new FactureFournisseur($db); $this->info_box_head = array( - 'text' => $langs->trans("BoxTitleLastSupplierBills",$max) + 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills",$max) ); if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.amount,"; + $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.total_ht,"; $sql.= " f.paye, f.fk_statut,"; $sql.= ' f.datef as df,'; $sql.= ' f.datec as datec,'; @@ -76,7 +76,8 @@ class box_factures_fourn extends ModeleBoxes $sql.= " AND f.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 f.tms DESC"; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; $sql.= $db->plimit($max, 0); $result = $db->query($sql); @@ -92,7 +93,8 @@ class box_factures_fourn extends ModeleBoxes { $objp = $db->fetch_object($result); $datelimite=$db->jdate($objp->datelimite); - $datec=$db->jdate($objp->datec); + $date=$db->jdate($objp->df); + $datem=$db->jdate($objp->tms); $late = ''; if ($objp->paye == 0 && $datelimite && $datelimite < ($now - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); @@ -119,7 +121,7 @@ class box_factures_fourn extends ModeleBoxes 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid); $this->info_box_contents[$i][5] = array('td' => 'align="right"', - 'text' => dol_print_date($datec,'day')); + 'text' => dol_print_date($date,'day')); $fac = new FactureFournisseur($db); $fac->fetch($objp->facid); diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index fdebad2f38a..9cce737eb9a 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -67,15 +67,12 @@ class box_ficheinter extends ModeleBoxes $sql.= " f.tms as datem,"; $sql.= " s.nom as name, s.rowid as socid, s.client"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir) - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; $sql.= " WHERE f.fk_soc = s.rowid "; $sql.= " AND f.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->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.tms DESC"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index b548e90671b..e9bd47b2a9e 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -56,84 +56,93 @@ class box_propales extends ModeleBoxes $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propalstatic=new Propal($db); + $propalstatic=new Propal($db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastPropals",$max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."Propals",$max)); - if ($user->rights->propale->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.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 p.datep DESC, p.ref DESC "; - $sql.= $db->plimit($max, 0); + if ($user->rights->propale->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tms"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE p.fk_soc = s.rowid"; + $sql.= " AND p.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; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC "; + else $sql.= " ORDER BY p.tms DESC, p.ref DESC "; + $sql.= $db->plimit($max, 0); - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $now=dol_now(); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $now=dol_now(); - $i = 0; + $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $datec=$db->jdate($objp->datec); - $dateterm=$db->jdate($objp->fin_validite); - $dateclose=$db->jdate($objp->date_cloture); + while ($i < $num) + { + $objp = $db->fetch_object($result); + $date=$db->jdate($objp->dp); + $datec=$db->jdate($objp->datec); + $datem=$db->jdate($objp->tms); + $dateterm=$db->jdate($objp->fin_validite); + $dateclose=$db->jdate($objp->date_cloture); - $late = ''; - if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } + $late = ''; + if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { + $late = img_warning($langs->trans("Late")); + } - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/comm/propal.php?id=".$objp->rowid); + $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'url' => DOL_URL_ROOT."/comm/propal.php?id=".$objp->rowid); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => $objp->ref, - 'text2'=> $late, - 'url' => DOL_URL_ROOT."/comm/propal.php?id=".$objp->rowid); + $this->info_box_contents[$i][1] = array('td' => 'align="left"', + 'text' => $objp->ref, + 'text2'=> $late, + 'url' => DOL_URL_ROOT."/comm/propal.php?id=".$objp->rowid); - $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', - 'logo' => 'company', - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); + $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', + 'logo' => 'company', + 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); - $this->info_box_contents[$i][3] = array('td' => 'align="left"', - 'text' => dol_trunc($objp->name,40), - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); + $this->info_box_contents[$i][3] = array('td' => 'align="left"', + 'text' => dol_trunc($objp->name,40), + 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); - $this->info_box_contents[$i][4] = array('td' => 'align="right"', - 'text' => dol_print_date($datec,'day')); + $this->info_box_contents[$i][4] = array('td' => 'align="right"', + 'text' => price($objp->total_ht), + ); - $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', - 'text' => $propalstatic->LibStatut($objp->fk_statut,3)); + $this->info_box_contents[$i][5] = array('td' => 'align="right"', + 'text' => dol_print_date($date,'day')); - $i++; - } + $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"', + 'text' => $propalstatic->LibStatut($objp->fk_statut,3)); - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedProposals")); + $i++; + } - $db->free($result); - } - 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")); - } + if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedProposals")); + + $db->free($result); + } + 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")); + } } /** diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 876b50c849f..d14bf1a539f 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -58,12 +58,12 @@ class box_supplier_orders extends ModeleBoxes 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)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max)); if ($user->rights->fournisseur->commande->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " c.ref, c.tms, c.rowid,"; + $sql.= " c.ref, c.tms, c.rowid, c.date_commande,"; $sql.= " c.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; @@ -72,7 +72,8 @@ class box_supplier_orders extends ModeleBoxes $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 "; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; $sql.= $db->plimit($max, 0); $result = $db->query($sql); @@ -84,7 +85,8 @@ class box_supplier_orders extends ModeleBoxes while ($i < $num) { $objp = $db->fetch_object($result); - $datem=$db->jdate($objp->tms); + $date=$db->jdate($objp->date_commande); + $datem=$db->jdate($objp->tms); $urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid; $urls = DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid; @@ -106,7 +108,7 @@ class box_supplier_orders extends ModeleBoxes 'url' => $urls); $this->info_box_contents[$i][4] = array('td' => 'align="right"', - 'text' => dol_print_date($datem,'day'), + 'text' => dol_print_date($date,'day'), ); $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 52d27f82523..ab26ee68317 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -54,7 +54,7 @@ class InfoBox $boxes=array(); $confuserzone='MAIN_BOXES_'.$zone; - if ($mode == 'activated') + if ($mode == 'activated') // activated { $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,"; $sql.= " d.rowid as box_id, d.file, d.note, d.tms"; @@ -66,18 +66,11 @@ class InfoBox else $sql.= " AND b.fk_user = 0"; $sql.= " ORDER BY b.box_order"; } - else + else // available { $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) - { - $sql.= " WHERE entity IN (1,".$conf->entity.")"; // TODO add method for define another master entity - } - else - { - $sql.= " WHERE entity = ".$conf->entity; - } + $sql.= " WHERE d.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; } dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); @@ -92,6 +85,7 @@ class InfoBox if (! in_array($obj->box_id, $excludelist)) { + if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs)) { $boxname = preg_replace('/\.php$/i','',$regs[1]); @@ -104,9 +98,11 @@ class InfoBox $relsourcefile = "/core/boxes/".$boxname.".php"; } + //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'
'; + // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then // the "enabled" condition for modules forbidden for external users and the depends condition can be done. - // Goal is to avoid making a new instance for each boxes returned by select. + // Goal is to avoid making a "new" done for each boxes returned by select. dol_include_once($relsourcefile); if (class_exists($boxname)) { @@ -161,15 +157,19 @@ class InfoBox //print 'xx module='.$module.' enabled='.$enabled; if ($enabled) $boxes[]=$box; else unset($box); - } + } + else + { + dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING); + } } $j++; } } else - { - //dol_print_error($db); - $error=$db->lasterror(); + { + dol_syslog($db->lasterror(),LOG_ERR); + return array('error'=>$db->lasterror()); } return $boxes; diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 545ae1b03a0..4a2f0bc20b4 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -98,8 +98,10 @@ class modCommande extends DolibarrModules $this->const[$r][4] = 0; // Boxes - $this->boxes = array(); - $this->boxes = array(0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home')); + $this->boxes = array( + 0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'), + 2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home') + ); // Permissions $this->rights = array(); diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index e7e9da7dc1b..bf118b9b88e 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -12,6 +12,7 @@ BoxLastProspects=Last modified prospects BoxLastCustomers=Last modified customers BoxLastSuppliers=Last modified suppliers BoxLastCustomerOrders=Last customer orders +BoxLastValidatedCustomerOrders=Last validated customer orders BoxLastBooks=Last books BoxLastActions=Last actions BoxLastContracts=Last contracts @@ -27,26 +28,29 @@ BoxTitleNbOfCustomers=Number of clients BoxTitleLastRssInfos=Last %s news from %s BoxTitleLastProducts=Last %s modified products/services BoxTitleProductsAlertStock=Products in stock alert -BoxTitleLastCustomerOrders=Last %s modified customer orders +BoxTitleLastCustomerOrders=Last %s customer orders +BoxTitleLastModifiedCustomerOrders=Last %s modified customer orders BoxTitleLastSuppliers=Last %s recorded suppliers BoxTitleLastCustomers=Last %s recorded customers BoxTitleLastModifiedSuppliers=Last %s modified suppliers BoxTitleLastModifiedCustomers=Last %s modified customers -BoxTitleLastCustomersOrProspects=Last %s modified customers or prospects -BoxTitleLastPropals=Last %s recorded proposals +BoxTitleLastCustomersOrProspects=Last %s customers or prospects +BoxTitleLastPropals=Last %s proposals +BoxTitleLastModifiedPropals=Last %s modified proposals BoxTitleLastCustomerBills=Last %s customer's invoices +BoxTitleLastModifiedCustomerBills=Last %s modified customer invoices BoxTitleLastSupplierBills=Last %s supplier's invoices -BoxTitleLastProspects=Last %s recorded prospects +BoxTitleLastModifiedSupplierBills=Last %s modified supplier invoices BoxTitleLastModifiedProspects=Last %s modified prospects BoxTitleLastProductsInContract=Last %s products/services in a contract -BoxTitleLastModifiedMembers=Last %s modified members +BoxTitleLastModifiedMembers=Last %s members BoxTitleLastFicheInter=Last %s modified intervention -BoxTitleOldestUnpaidCustomerBills=Oldest %s unpaid customer's invoices -BoxTitleOldestUnpaidSupplierBills=Oldest %s unpaid supplier's invoices +BoxTitleOldestUnpaidCustomerBills=Oldest %s unpaid customer invoices +BoxTitleOldestUnpaidSupplierBills=Oldest %s unpaid supplier invoices BoxTitleCurrentAccounts=Opened account's balances BoxTitleSalesTurnover=Sales turnover -BoxTitleTotalUnpaidCustomerBills=Unpaid customer's invoices -BoxTitleTotalUnpaidSuppliersBills=Unpaid supplier's invoices +BoxTitleTotalUnpaidCustomerBills=Unpaid customer invoices +BoxTitleTotalUnpaidSuppliersBills=Unpaid supplier invoices BoxTitleLastModifiedContacts=Last %s modified contacts/addresses BoxMyLastBookmarks=My last %s bookmarks BoxOldestExpiredServices=Oldest active expired services @@ -76,7 +80,8 @@ NoContractedProducts=No products/services contracted NoRecordedContracts=No recorded contracts NoRecordedInterventions=No recorded interventions BoxLatestSupplierOrders=Latest supplier orders -BoxTitleLatestSupplierOrders=%s latest supplier orders +BoxTitleLatestSupplierOrders=Last %s supplier orders +BoxTitleLatestModifiedSupplierOrders=Last %s modified supplier orders NoSupplierOrder=No recorded supplier order BoxCustomersInvoicesPerMonth=Customer invoices per month BoxSuppliersInvoicesPerMonth=Supplier invoices per month diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index 252a379ffbc..63890aff6bb 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -12,6 +12,7 @@ BoxLastProspects=Derniers prospects modifiés BoxLastCustomers=Derniers clients modifiés BoxLastSuppliers=Derniers fournisseurs modifiés BoxLastCustomerOrders=Dernières commandes +BoxLastValidatedCustomerOrders=Dernières commandes clients validées BoxLastBooks=Derniers livres BoxLastActions=Derniers événements BoxLastContracts=Derniers contrats @@ -27,26 +28,29 @@ BoxTitleNbOfCustomers=Nombre de clients BoxTitleLastRssInfos=Les %s dernières informations de %s BoxTitleLastProducts=Les %s derniers produits/services enregistrés BoxTitleProductsAlertStock=Produits en alerte stock -BoxTitleLastCustomerOrders=Les %s dernières commandes clients modifiées +BoxTitleLastCustomerOrders=Les %s dernières commandes clients +BoxTitleLastModifiedCustomerOrders=Last %s modified customer orders BoxTitleLastSuppliers=Les %s derniers fournisseurs enregistrés BoxTitleLastCustomers=Les %s derniers clients enregistrés BoxTitleLastModifiedSuppliers=Les %s derniers fournisseurs modifiés BoxTitleLastModifiedCustomers=Les %s derniers clients modifiés -BoxTitleLastCustomersOrProspects=Les %s derniers clients ou prospects modifiés -BoxTitleLastPropals=Les %s dernières propositions enregistrées -BoxTitleLastCustomerBills=Les %s dernières factures clients modifiées -BoxTitleLastSupplierBills=Les %s dernières factures fournisseurs modifiées -BoxTitleLastProspects=Les %s derniers prospects enregistrés +BoxTitleLastCustomersOrProspects=Les %s derniers prospects +BoxTitleLastPropals=Les %s dernières propales +BoxTitleLastModifiedPropals=Last %s modified proposals +BoxTitleLastCustomerBills=Les %s dernières factures clients +BoxTitleLastModifiedCustomerBills=Last %s modified customer invoices +BoxTitleLastSupplierBills=Les %s dernières factures fournisseurs +BoxTitleLastModifiedSupplierBills=Last %s modified supplier invoices BoxTitleLastModifiedProspects=Les %s derniers prospects modifiés BoxTitleLastProductsInContract=Les %s derniers produits/services contractés -BoxTitleLastModifiedMembers=Les %s derniers adhérents modifiés -BoxTitleLastFicheInter=Les %s dernières fiches d'intervention modifiées -BoxTitleOldestUnpaidCustomerBills=Les %s plus anciennes factures clients impayées -BoxTitleOldestUnpaidSupplierBills=Les %s plus anciennes factures fournisseurs impayées +BoxTitleLastModifiedMembers=Les %s derniers adhérents +BoxTitleLastFicheInter=Les %s dernières fiche d'intervention modifiée +BoxTitleOldestUnpaidCustomerBills=Oldest %s unpaid customer invoices +BoxTitleOldestUnpaidSupplierBills=Oldest %s unpaid supplier invoices BoxTitleCurrentAccounts=Soldes des comptes ouverts BoxTitleSalesTurnover=Le chiffre d'affaires réalisé -BoxTitleTotalUnpaidCustomerBills=Impayés clients -BoxTitleTotalUnpaidSuppliersBills=Impayés fournisseurs +BoxTitleTotalUnpaidCustomerBills=Unpaid customer invoices +BoxTitleTotalUnpaidSuppliersBills=Unpaid supplier invoices BoxTitleLastModifiedContacts=Les %s derniers contacts/adresses modifiés BoxMyLastBookmarks=Mes %s derniers marque-pages BoxOldestExpiredServices=Plus anciens services expirés @@ -76,7 +80,8 @@ NoContractedProducts=Pas de produit/service contracté NoRecordedContracts=Pas de contrat enregistré NoRecordedInterventions=Pas fiche d'intervention enregistrée BoxLatestSupplierOrders=Dernières commandes fournisseur -BoxTitleLatestSupplierOrders=Les %s dernières commandes fournisseur enregistrées +BoxTitleLatestSupplierOrders=Les %s dernières commandes fournisseurs +BoxTitleLatestModifiedSupplierOrders=Les %s dernières commandes fournisseurs NoSupplierOrder=Pas de commande fournisseur enregistrée BoxCustomersInvoicesPerMonth=Factures clients par mois BoxSuppliersInvoicesPerMonth=Factures fournisseurs par mois diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ffde48c2ada..6f15bf82faa 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1792,7 +1792,7 @@ class User extends CommonObject $result.=($lien.img_object($langs->trans("ShowUser"),'user').$lienfin); if ($withpicto != 2) $result.=' '; } - $result.=$lien.$this->getFullName($langs).$lienfin; + $result.=$lien.$this->getFullName($langs,'','',16).$lienfin; return $result; }