From f84ea6f960d621c9a8dc143064efb30c8741b64a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 4 May 2015 13:10:45 +0200 Subject: [PATCH] Uniformize code of boxes --- htdocs/core/boxes/box_commandes.php | 2 +- htdocs/core/boxes/box_factures.php | 20 ++++---- htdocs/core/boxes/box_factures_fourn.php | 39 +++++++++------- htdocs/core/boxes/box_factures_fourn_imp.php | 48 ++++++++++---------- htdocs/core/boxes/box_factures_imp.php | 21 +++++---- htdocs/core/boxes/box_fournisseurs.php | 37 ++++++++------- htdocs/core/boxes/box_propales.php | 2 +- htdocs/core/boxes/box_supplier_orders.php | 46 +++++++++++-------- 8 files changed, 115 insertions(+), 100 deletions(-) diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 53e3aaf2861..6eb5006182c 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -128,7 +128,7 @@ class box_commandes extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'align="right"', - 'text' => price($objp->total_ht), + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index dd1059cf9d2..d04c3e48a3b 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -94,10 +94,10 @@ class box_factures extends ModeleBoxes $num = $db->num_rows($result); $now=dol_now(); - $i = 0; + $line = 0; $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)'; - while ($i < $num) { + while ($line < $num) { $objp = $db->fetch_object($result); $datelimite = $db->jdate($objp->datelimite); $date = $db->jdate($objp->df); @@ -115,39 +115,39 @@ class box_factures extends ModeleBoxes $late = ''; if ($objp->paye == 0 && ($objp->fk_statut != 2 && $objp->fk_statut != 3) && $datelimite < ($now - $conf->facture->client->warning_delay)) { $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));} - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', 'text' => $facturestatic->getNomUrl(1), 'text2'=> $late, 'asis' => 1, ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', 'text' => $societestatic->getNomUrl(1, '', 40), 'asis' => 1, ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right"', - 'text' => price($objp->total_ht), + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right"', 'text' => dol_print_date($date,'day'), ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3), ); - $i++; + $line++; } if ($num==0) - $this->info_box_contents[$i][0] = array( + $this->info_box_contents[$line][0] = array( 'td' => 'align="center"', 'text'=>$langs->trans("NoRecordedInvoices"), ); diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index f48d2ab43d3..2f31fa61f78 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -56,10 +56,10 @@ class box_factures_fourn extends ModeleBoxes $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $facturestatic = new FactureFournisseur($db); - $societestatic = new Societe($db); + $thirdpartytmp = new Fournisseur($db); $this->info_box_head = array( 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills",$max) @@ -95,10 +95,10 @@ class box_factures_fourn extends ModeleBoxes $num = $db->num_rows($result); $now=dol_now(); - $i = 0; + $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)'; - while ($i < $num) { + while ($line < $num) { $objp = $db->fetch_object($result); $datelimite=$db->jdate($objp->datelimite); $date=$db->jdate($objp->df); @@ -108,36 +108,41 @@ class box_factures_fourn extends ModeleBoxes $facturestatic->total_ht = $objp->total_ht; $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->fournisseur = 1; - $societestatic->code_fournisseur = $objp->code_fournisseur; - $societestatic->logo = $objp->logo; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $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'))); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', 'text' => $facturestatic->getNomUrl(1), 'text2'=> $late, 'asis' => 1, ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', 'text' => $objp->ref_supplier, 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', - 'text' => $societestatic->getNomUrl(1, 'supplier'), + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), 'asis' => 1, ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( + 'td' => 'align="right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); + + $this->info_box_contents[$line][] = array( 'td' => 'align="right"', 'text' => dol_print_date($date,'day'), ); @@ -145,16 +150,16 @@ class box_factures_fourn extends ModeleBoxes $fac = new FactureFournisseur($db); $fac->fetch($objp->facid); $alreadypaid=$fac->getSommePaiement(); - $this->info_box_contents[$i][6] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type), ); - $i++; + $line++; } if ($num==0) - $this->info_box_contents[$i][0] = array( + $this->info_box_contents[$line][0] = array( 'td' => 'align="center"', 'text'=>$langs->trans("NoModifiedSupplierBills"), ); diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index a82af75332a..ecea4a27fd1 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -56,6 +56,8 @@ class box_factures_fourn_imp extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $facturestatic=new FactureFournisseur($db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp=new Fournisseur($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills",$max)); @@ -64,6 +66,9 @@ class box_factures_fourn_imp extends ModeleBoxes $sql = "SELECT s.nom as name, s.rowid as socid,"; $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; $sql.= " f.amount, f.datef as df,"; + $sql.= " f.total_ht as total_ht,"; + $sql.= " f.tva as total_tva,"; + $sql.= " f.total_ttc,"; $sql.= " f.paye, f.fk_statut, f.type"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ",".MAIN_DB_PREFIX."facture_fourn as f"; @@ -83,26 +88,30 @@ class box_factures_fourn_imp extends ModeleBoxes $num = $db->num_rows($result); $now=dol_now(); - $i = 0; + $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)'; - while ($i < $num) + while ($line < $num) { $objp = $db->fetch_object($result); $datelimite=$db->jdate($objp->datelimite); + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->logo = $objp->logo; $late=''; if ($datelimite && $datelimite < ($now - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day'))); $tooltip = $langs->trans('SupplierInvoice') . ': ' . ($objp->ref?$objp->ref:$objp->facid) . '<br>' . $langs->trans('RefSupplier') . ': ' . $objp->ref_supplier; - $this->info_box_contents[$i][0] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left" width="16"', 'logo' => $this->boximg, 'tooltip' => $tooltip, 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, ); - $this->info_box_contents[$i][1] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', 'text' => ($objp->ref?$objp->ref:$objp->facid), 'text2'=> $late, @@ -110,29 +119,18 @@ class box_factures_fourn_imp extends ModeleBoxes 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, ); - $this->info_box_contents[$i][2] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', - 'text' => $objp->ref_supplier, - 'tooltip' => $tooltip, - 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, ); - $tooltip = $langs->trans('Supplier') . ': '. $objp->name; - $this->info_box_contents[$i][3] = array( - 'td' => 'align="left" width="16"', - 'logo' => 'company', - 'tooltip' => $tooltip, - 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid, - ); - - $this->info_box_contents[$i][4] = array( - 'td' => 'align="left"', - 'text' => $objp->name, - 'tooltip' => $tooltip, - 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid, + $this->info_box_contents[$line][] = array( + 'td' => 'align="right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); - $this->info_box_contents[$i][5] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right"', 'text' => dol_print_date($datelimite,'day'), ); @@ -140,16 +138,16 @@ class box_factures_fourn_imp extends ModeleBoxes $fac = new FactureFournisseur($db); $fac->fetch($objp->facid); $alreadypaid=$fac->getSommePaiement(); - $this->info_box_contents[$i][6] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type), ); - $i++; + $line++; } if ($num==0) - $this->info_box_contents[$i][0] = array( + $this->info_box_contents[$line][0] = array( 'td' => 'align="center"', 'text'=>$langs->trans("NoUnpaidSupplierBills"), ); diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index d7817d134d3..42e889138cc 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -95,10 +95,10 @@ class box_factures_imp extends ModeleBoxes $num = $db->num_rows($result); $now=dol_now(); - $i = 0; + $line = 0; $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)'; - while ($i < $num) + while ($line < $num) { $objp = $db->fetch_object($result); $datelimite=$db->jdate($objp->datelimite); @@ -117,33 +117,38 @@ class box_factures_imp extends ModeleBoxes $late=''; if ($datelimite < ($now - $conf->facture->client->warning_delay)) $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day'))); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', 'text' => $facturestatic->getNomUrl(1), 'text2'=> $late, 'asis' => 1, ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', 'text' => $societestatic->getNomUrl(1, '', 44), 'asis' => 1, ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( + 'td' => 'align="right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); + + $this->info_box_contents[$line][] = array( 'td' => 'align="right"', 'text' => dol_print_date($datelimite,'day'), ); - $this->info_box_contents[$i][] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3), ); - $i++; + $line++; } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); $db->free($result); } diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index e9c21da739f..e3e6061d803 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -58,12 +58,16 @@ class box_fournisseurs extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $thirdpartystatic=new Societe($db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp=new Fournisseur($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers",$max)); if ($user->rights->societe->lire) { - $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; + $sql.= " s.code_fournisseur,"; + $sql.= " s.logo"; $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"; $sql.= " WHERE s.fournisseur = 1"; @@ -78,42 +82,37 @@ class box_fournisseurs extends ModeleBoxes { $num = $db->num_rows($result); - $i = 0; - while ($i < $num) + $line = 0; + while ($line < $num) { $objp = $db->fetch_object($result); $datec=$db->jdate($objp->datec); $datem=$db->jdate($objp->tms); + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->logo = $objp->logo; - $tooltip = $langs->trans('Supplier') . ': ' . $objp->name; - $this->info_box_contents[$i][0] = array( - 'td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'tooltip' => $tooltip, - 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid, - ); - - $this->info_box_contents[$i][1] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', - 'text' => $objp->name, - 'tooltip' => $tooltip, - 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid, + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, ); - $this->info_box_contents[$i][2] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right"', 'text' => dol_print_date($datem, "day"), ); - $this->info_box_contents[$i][3] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', 'text' => $thirdpartystatic->LibStatut($objp->status,3), ); - $i++; + $line++; } - if ($num==0) $this->info_box_contents[$i][0] = array( + if ($num==0) $this->info_box_contents[$line][0] = array( 'td' => 'align="center"', 'text'=>$langs->trans("NoRecordedSuppliers"), ); diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 4e8b47aa0d4..c14cf07a51c 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -123,7 +123,7 @@ class box_propales extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'align="right"', - 'text' => price($objp->total_ht), + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index d435e5ca3dc..84521bf4ee0 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -58,13 +58,20 @@ class box_supplier_orders extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $supplierorderstatic=new CommandeFournisseur($db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp = new Fournisseur($db); $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.= " s.code_client, s.code_fournisseur,"; + $sql.= " s.logo,"; $sql.= " c.ref, c.tms, c.rowid, c.date_commande,"; + $sql.= " c.total_ht,"; + $sql.= " c.tva as total_tva,"; + $sql.= " c.total_ttc,"; $sql.= " c.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; @@ -82,60 +89,61 @@ class box_supplier_orders extends ModeleBoxes { $num = $db->num_rows($result); - $i = 0; - while ($i < $num) { + $line = 0; + while ($line < $num) { $objp = $db->fetch_object($result); $date=$db->jdate($objp->date_commande); $datem=$db->jdate($objp->tms); + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid; $urls = DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid; $tooltip = $langs->trans('SupplierOrder') . ': ' . $objp->ref; - $this->info_box_contents[$i][0] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left" width="16"', 'logo' => $this->boximg, 'tooltip' => $tooltip, 'url' => $urlo, ); - $this->info_box_contents[$i][1] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="left"', 'text' => $objp->ref, 'tooltip' => $tooltip, 'url' => $urlo, ); - $tooltip = $langs->trans('Supplier') . ': ' . $objp->name; - $this->info_box_contents[$i][2] = array( - 'td' => 'align="left" width="16"', - 'logo' => 'company', - 'tooltip' => $tooltip, - 'url' => $urls, + $this->info_box_contents[$line][] = array( + 'td' => 'align="left"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, ); - $this->info_box_contents[$i][3] = array( - 'td' => 'align="left"', - 'text' => $objp->name, - 'tooltip' => $tooltip, - 'url' => $urls, + $this->info_box_contents[$line][] = array( + 'td' => 'align="right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); - $this->info_box_contents[$i][4] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right"', 'text' => dol_print_date($date,'day'), ); - $this->info_box_contents[$i][5] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', 'text' => $supplierorderstatic->LibStatut($objp->fk_statut,3), ); - $i++; + $line++; } if ($num == 0) - $this->info_box_contents[$i][0] = array( + $this->info_box_contents[$line][0] = array( 'td' => 'align="center"', 'text' => $langs->trans("NoSupplierOrder"), ); -- GitLab