* Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * 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 3 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/expedition/index.php * \ingroup expedition * \brief Home page of shipping area. */ require '../main.inc.php'; require DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $langs->load("orders"); $langs->load("sendings"); /* * View */ $orderstatic=new Commande($db); $companystatic=new Societe($db); $shipment=new Expedition($db); $helpurl='EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones'; llxHeader('',$langs->trans("Shipment"),$helpurl); print_fiche_titre($langs->trans("SendingsArea")); print '
'; $var=false; print '
'; print ''; print ''; print ''; print ''; print "
'.$langs->trans("SearchASending").'
'; print $langs->trans("Ref").':

\n"; /* * Shipments to validate */ $clause = " WHERE "; $sql = "SELECT e.rowid, e.ref"; $sql.= ", s.nom as name, s.rowid as socid"; $sql.= ", c.ref as commande_ref, c.rowid as commande_id"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; if (!$user->rights->societe->client->voir && !$socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; $sql.= $clause." sc.fk_user = " .$user->id; $clause = " AND "; } $sql.= $clause." e.fk_statut = 0"; $sql.= " AND e.entity IN (".getEntity('expedition', 1).")"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { print ''; print ''; print ''; $i = 0; $var = True; while ($i < $num) { $var=!$var; $obj = $db->fetch_object($resql); print ""; print ''; print ''; $i++; } print "
'.$langs->trans("SendingsToValidate").'
'; $shipment->id=$obj->rowid; $shipment->ref=$obj->ref; print $shipment->getNomUrl(1); print "'; print ''.$obj->name.''; print ''; if ($obj->commande_id) print ''.$obj->commande_ref.''; print '

"; } } /* * Commandes a traiter */ $sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as name, s.rowid as socid"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.fk_statut = 1"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " ORDER BY c.rowid ASC"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { $langs->load("orders"); $i = 0; print ''; print ''; print ''; $var = True; while ($i < $num) { $var=!$var; $obj = $db->fetch_object($resql); print ""; print ''; print ''; print ''; print ''; $i++; } print "
'.$langs->trans("OrdersToProcess").'
'; $orderstatic->id=$obj->rowid; $orderstatic->ref=$obj->ref; $orderstatic->statut=$obj->fk_statut; $orderstatic->facturee=0; print $orderstatic->getNomUrl(1); print ''; $companystatic->name=$obj->name; $companystatic->id=$obj->socid; print $companystatic->getNomUrl(1,'customer',32); print ''; print $orderstatic->getLibStatut(3); print '

"; } } //print ''; print '
'; /* * Commandes en traitement */ $sql = "SELECT c.rowid, c.ref, c.fk_statut as status, c.facture as billed, s.nom as name, s.rowid as socid"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.fk_statut = 2"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $resql = $db->query($sql); if ( $resql ) { $langs->load("orders"); $num = $db->num_rows($resql); if ($num) { $i = 0; print ''; print ''; print ''; $var = True; while ($i < $num) { $var=!$var; $obj = $db->fetch_object($resql); print "'; print ''; print ''; print ''; $i++; } print "
'.$langs->trans("OrdersInProcess").'
"; $orderstatic->id=$obj->rowid; $orderstatic->ref=$obj->ref; print $orderstatic->getNomUrl(1); print ''; $companystatic->name=$obj->name; $companystatic->id=$obj->socid; print $companystatic->getNomUrl(1,'customer'); print ''; $orderstatic->statut=$obj->status; $orderstatic->facturee=$obj->billed; print $orderstatic->getLibStatut(3); print '

"; } } else dol_print_error($db); /* * Last shipments */ $sql = "SELECT e.rowid, e.ref"; $sql.= ", s.nom as name, s.rowid as socid"; $sql.= ", c.ref as commande_ref, c.rowid as commande_id"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; $sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id; $sql.= " AND e.fk_statut = 1"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; $sql.= " ORDER BY e.date_delivery DESC"; $sql.= $db->plimit(5, 0); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { $i = 0; print ''; print ''; print ''; $var = True; while ($i < $num) { $var=!$var; $obj = $db->fetch_object($resql); print ''; print ''; print ''; $i++; } print "
'.$langs->trans("LastSendings",$num).'
'.img_object($langs->trans("ShowSending"),"sending").' '; print $obj->ref.''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''; if ($obj->commande_id) { $orderstatic->id=$obj->commande_id; $orderstatic->ref=$obj->commande_ref; print $orderstatic->getNomUrl(1); } else print ' '; print '

"; } $db->free($resql); } else dol_print_error($db); print '
'; llxFooter(); $db->close();