From 19540b14b59bfc64d5db481a22e97dbdcb57864b Mon Sep 17 00:00:00 2001 From: frederic34 Date: Wed, 25 Mar 2015 16:38:18 +0100 Subject: [PATCH] Add last shipments to company card --- htdocs/comm/card.php | 70 ++++++++++++++++++++++++++++++++ htdocs/langs/en_US/sendings.lang | 1 + 2 files changed, 71 insertions(+) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 3ea63caf256..14bf6e42fe8 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Alexandre Spangaro + * Copyright (C) 2015 Frederic France * * 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 @@ -37,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (! empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; @@ -44,6 +46,7 @@ if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichin $langs->load("companies"); if (! empty($conf->contrat->enabled)) $langs->load("contracts"); if (! empty($conf->commande->enabled)) $langs->load("orders"); +if (! empty($conf->expedition->enabled)) $langs->load("sendings"); if (! empty($conf->facture->enabled)) $langs->load("bills"); if (! empty($conf->projet->enabled)) $langs->load("projects"); if (! empty($conf->ficheinter->enabled)) $langs->load("interventions"); @@ -661,6 +664,73 @@ if ($id > 0) } } + /* + * Last sendings + */ + if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) { + $sendingstatic = new Expedition($db); + + $sql = 'SELECT e.rowid as id'; + $sql.= ', e.ref'; + $sql.= ', e.date_creation'; + $sql.= ', e.fk_statut as statut'; + $sql.= ', s.nom'; + $sql.= ', s.rowid as socid'; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e"; + $sql.= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id; + $sql.= " AND e.entity = ".$conf->entity; + $sql.= ' GROUP BY e.rowid'; + $sql.= ', e.ref'; + $sql.= ', e.date_creation'; + $sql.= ', e.fk_statut'; + $sql.= ', s.nom'; + $sql.= ', s.rowid'; + $sql.= " ORDER BY e.date_creation DESC"; + + $resql = $db->query($sql); + if ($resql) { + $var = true; + $num = $db->num_rows($resql); + $i = 0; + if ($num > 0) { + print ''; + + $tableaushown=1; + print ''; + print ''; + print ''; + } + + while ($i < $num && $i < $MAXLIST) { + $objp = $db->fetch_object($resql); + $var = ! $var; + print ""; + print ''; + if ($objp->date_creation > 0) { + print ''; + } else { + print ''; + } + + print ''; + print "\n"; + $i++; + } + $db->free($resql); + + if ($num > 0) + print "
'; + print ''; + print '
'.$langs->trans("LastSendings",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSendings").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; + $sendingstatic->id = $objp->id; + $sendingstatic->ref = $objp->ref; + print $sendingstatic->getNomUrl(1); + print ''.dol_print_date($db->jdate($objp->date_creation),'day').'!!!' . $sendingstatic->LibStatut($objp->statut, 5) . '
"; + } else { + dol_print_error($db); + } + } + /* * Last linked contracts */ diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index b1ff55f71c1..84088c3e023 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -2,6 +2,7 @@ RefSending=Ref. shipment Sending=Shipment Sendings=Shipments +AllSendings=All Shipments Shipment=Shipment Shipments=Shipments ShowSending=Show Sending