* Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2024 Frédéric 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 * 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. */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $hookmanager = new HookManager($db); $socid = GETPOSTINT('socid'); // Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('sendingindex')); // Load translation files required by the page $langs->loadLangs(array('orders', '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, '', 0, 0, '', '', '', 'mod-expedition page-index'); print load_fiche_titre($langs->trans("SendingsArea"), '', 'dolly'); print '
'; /* * Shipments to validate */ $clause = " WHERE "; $sql = "SELECT e.rowid, e.ref, e.ref_customer,"; $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->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; $sql .= $clause." sc.fk_user = ".((int) $user->id); $clause = " AND "; } $sql .= $clause." e.fk_statut = ".Expedition::STATUS_DRAFT; $sql .= " AND e.entity IN (".getEntity('expedition').")"; if ($socid) { $sql .= " AND c.fk_soc = ".((int) $socid); } $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); print '
'; print ''; print ''; print ''; print ''; if ($num) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); $shipment->id = $obj->rowid; $shipment->ref = $obj->ref; $shipment->ref_customer = $obj->ref_customer; print '"; print ''; print ''; $i++; } } else { print ''; } print "
'; print $langs->trans("SendingsToValidate").' '; print ''; print ''.$num.''; print ''; print '
'; print $shipment->getNomUrl(1); print "'; print ''.$obj->name.''; print ''; if ($obj->commande_id) { print ''.$obj->commande_ref.''; } print '
'.$langs->trans("None").'

"; } //print ''; print '
'; $max = 5; /* * Latest shipments */ $sql = "SELECT e.rowid, e.ref, e.ref_customer,"; $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->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; } $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND sc.fk_user = ".((int) $user->id); } $sql .= " AND e.fk_statut = ".Expedition::STATUS_VALIDATED; if ($socid) { $sql .= " AND c.fk_soc = ".((int) $socid); } $sql .= " ORDER BY e.date_delivery DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); print '
'; print ''; print ''; print ''; print ''; if ($num) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); $shipment->id = $obj->rowid; $shipment->ref = $obj->ref; $shipment->ref_customer = $obj->ref_customer; print ''; print ''; print ''; print ''; print ''; $i++; } } else { print ''; } print "
'; print $langs->trans("LastSendings").' '; print ''; print ''.$num.''; print ''; print '
'; print $shipment->getNomUrl(1); print ''.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.''; if ($obj->commande_id > 0) { $orderstatic->id = $obj->commande_id; $orderstatic->ref = $obj->commande_ref; print $orderstatic->getNomUrl(1); } print ''; print '
'.$langs->trans("None").'

"; $db->free($resql); } else { dol_print_error($db); } /* * Open orders */ $sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, 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->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity IN (".getEntity('order').")"; $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")"; if ($socid > 0) { $sql .= " AND c.fk_soc = ".((int) $socid); } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " ORDER BY c.rowid ASC"; $resql = $db->query($sql); if ($resql) { $langs->load("orders"); $num = $db->num_rows($resql); print '
'; print ''; print ''; print ''; print ''; if ($num) { $i = 0; while ($i < $num && $i < 10) { $obj = $db->fetch_object($resql); $orderstatic->id = $obj->rowid; $orderstatic->ref = $obj->ref; $orderstatic->ref_customer = $obj->ref_customer; $orderstatic->statut = $obj->status; $orderstatic->billed = $obj->billed; $companystatic->name = $obj->name; $companystatic->id = $obj->socid; print ''; print ''; print ''; print ''; $i++; } if ($i < $num) { print ''; print ''; print ''; print ''; print ''; } } else { print ''; } print "
'.$langs->trans("OrdersToProcess").' '; print ''; print ''.$num.''; print ''; print '
'; print $orderstatic->getNomUrl(1); print ''; print $companystatic->getNomUrl(1, 'customer', 32); print ''; print $orderstatic->getLibStatut(3); print '
'.$langs->trans("More").'...
'.$langs->trans("None").'

"; } else { dol_print_error($db); } print '
'; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardWarehouseSendings', $parameters, $object); // Note that $action and $object may have been modified by hook // End of page llxFooter(); $db->close();