';
+
+
+if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
+{
+ print '
\n";
+}
+
+/*
+ * 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->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').")";
+if ($socid) $sql.= " AND c.fk_soc = ".$socid;
+
+$resql=$db->query($sql);
+if ($resql)
+{
+ $num = $db->num_rows($resql);
+ if ($num)
+ {
+ print '
';
+ print '';
+ print '| '.$langs->trans("SendingsToValidate").' |
';
+ $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 $shipment->getNomUrl(1);
+ print " | ";
+ print '';
+ print ''.$obj->name.'';
+ print ' | ';
+ print '';
+ if ($obj->commande_id) print ''.$obj->commande_ref.'';
+ print ' |
';
+ $i++;
+ }
+ print "
";
+ }
+}
+
+
+/*
+ * Commandes a traiter
+ */
+$sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, 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 '| '.$langs->trans("OrdersToProcess").' |
';
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ $orderstatic->id=$obj->rowid;
+ $orderstatic->ref=$obj->ref;
+ $orderstatic->ref_customer=$obj->ref_customer;
+ $orderstatic->statut=$obj->fk_statut;
+ $orderstatic->facturee=0;
+
+ $companystatic->name=$obj->name;
+ $companystatic->id=$obj->socid;
+
+ print '';
+ print '| ';
+ print $orderstatic->getNomUrl(1);
+ print ' | ';
+ print '';
+ print $companystatic->getNomUrl(1,'customer',32);
+ print ' | ';
+ print '';
+ print $orderstatic->getLibStatut(3);
+ print ' | ';
+ print '
';
+ $i++;
+ }
+ print "
";
+ }
+}
+
+
+//print '
';
+print '';
+
+
+/*
+ * Commandes en traitement
+ */
+$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->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 '| '.$langs->trans("OrdersInProcess").' | ';
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ $orderstatic->id=$obj->rowid;
+ $orderstatic->ref=$obj->ref;
+ $orderstatic->ref_customer=$obj->ref_customer;
+ $orderstatic->statut=$obj->status;
+ $orderstatic->facturee=$obj->billed;
+
+ $companystatic->name=$obj->name;
+ $companystatic->id=$obj->socid;
+
+ print '| ';
+ print $orderstatic->getNomUrl(1);
+ print ' | ';
+ print '';
+ print $companystatic->getNomUrl(1,'customer');
+ print ' | ';
+ print '';
+ print $orderstatic->getLibStatut(3);
+ print ' | ';
+ print ' ';
+ $i++;
+ }
+ print " ";
+ }
+}
+else dol_print_error($db);
+
+
+/*
+ * Last 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->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').")";
+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 '| '.$langs->trans("LastSendings", $num).' | ';
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ $shipment->id=$obj->rowid;
+ $shipment->ref=$obj->ref;
+ $shipment->ref_customer=$obj->ref_customer;
+
+ print '| ';
+ print $shipment->getNomUrl(1);
+ print ' | ';
+ print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.' | ';
+ print '';
+ if ($obj->commande_id > 0)
+ {
+ $orderstatic->id=$obj->commande_id;
+ $orderstatic->ref=$obj->commande_ref;
+ print $orderstatic->getNomUrl(1);
+ }
+ else print ' ';
+ print ' | ';
+ $i++;
+ }
+ print " ";
+ }
+ $db->free($resql);
+}
+else dol_print_error($db);
+
+
+print ' ';
+
+
+llxFooter();
+$db->close();
diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php
new file mode 100644
index 00000000000..ab5fa27b13f
--- /dev/null
+++ b/htdocs/reception/list.php
@@ -0,0 +1,669 @@
+
+ * Copyright (C) 2004-2015 Laurent Destailleur
+ * Copyright (C) 2005-2010 Regis Houssin
+ * Copyright (C) 2016 Ferran Marcet
+ *
+ * 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/list.php
+ * \ingroup expedition
+ * \brief Page to list all shipments
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+
+$langs->load("sendings");
+$langs->load("deliveries");
+$langs->load('companies');
+
+$socid=GETPOST('socid','int');
+// Security check
+$expeditionid = GETPOST('id','int');
+if ($user->societe_id) $socid=$user->societe_id;
+$result = restrictedArea($user, 'expedition',$expeditionid,'');
+
+$diroutputmassaction=$conf->expedition->dir_output . '/temp/massgeneration/'.$user->id;
+
+$search_ref_exp = GETPOST("search_ref_exp");
+$search_ref_liv = GETPOST('search_ref_liv');
+$search_company = GETPOST("search_company");
+$search_town=GETPOST('search_town','alpha');
+$search_zip=GETPOST('search_zip','alpha');
+$search_state=trim(GETPOST("search_state"));
+$search_country=GETPOST("search_country",'int');
+$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
+$search_billed=GETPOST("search_billed",'int');
+$sall = GETPOST('sall', 'alphanohtml');
+$optioncss = GETPOST('optioncss','alpha');
+
+$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
+$sortfield = GETPOST('sortfield','alpha');
+$sortorder = GETPOST('sortorder','alpha');
+$page = GETPOST('page','int');
+if (! $sortfield) $sortfield="e.ref";
+if (! $sortorder) $sortorder="DESC";
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$contextpage='shipmentlist';
+
+$viewstatut=GETPOST('viewstatut');
+
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('shipmentlist'));
+$extrafields = new ExtraFields($db);
+
+// fetch optionals attributes and labels
+$extralabels = $extrafields->fetch_name_optionals_label('expedition');
+$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
+
+// List of fields to search into when doing a "search in all"
+$fieldstosearchall = array(
+ 'e.ref'=>"Ref",
+ 's.nom'=>"ThirdParty",
+ 'e.note_public'=>'NotePublic',
+);
+if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate";
+
+$checkedtypetiers=0;
+$arrayfields=array(
+ 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
+ 'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
+ 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
+ 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
+ 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
+ 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
+ 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
+ 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
+ 'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1),
+ 'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
+ 'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
+ 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
+ 'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>$conf->livraison_bon->enabled),
+ 'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>$conf->livraison_bon->enabled),
+ 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
+);
+
+// Extra fields
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
+{
+ foreach($extrafields->attribute_label as $key => $val)
+ {
+ $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
+ }
+}
+
+
+/*
+ * Actions
+ */
+
+if (GETPOST('cancel')) { $action='list'; $massaction=''; }
+if (! GETPOST('confirmmassaction')) { $massaction=''; }
+
+$parameters=array('socid'=>$socid);
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+
+// Purge search criteria
+if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
+{
+ $search_ref_exp='';
+ $search_ref_liv='';
+ $search_company='';
+ $search_town='';
+ $search_zip="";
+ $search_state="";
+ $search_type='';
+ $search_country='';
+ $search_type_thirdparty='';
+ $search_billed='';
+ $viewstatut='';
+ $search_array_options=array();
+}
+
+if (empty($reshook))
+{
+ // Mass actions. Controls on number of lines checked
+ $maxformassaction=1000;
+ if (! empty($massaction) && count($toselect) < 1)
+ {
+ $error++;
+ setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
+ }
+ if (! $error && count($toselect) > $maxformassaction)
+ {
+ setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
+ $error++;
+ }
+
+}
+
+
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+$companystatic=new Societe($db);
+$shipment=new Expedition($db);
+$formcompany=new FormCompany($db);
+
+$helpurl='EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones';
+llxHeader('',$langs->trans('ListOfSendings'),$helpurl);
+
+$sql = "SELECT e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,";
+$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
+$sql.= " typent.code as typent_code,";
+$sql.= " state.code_departement as state_code, state.nom as state_name,";
+$sql.= ' e.date_creation as date_creation, e.tms as date_update';
+// Add fields from extrafields
+foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
+// Add fields from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
+$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields as ef on (e.rowid = ef.fk_object)";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target";
+if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all
+{
+ $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+}
+$sql.= " WHERE e.entity IN (".getEntity('expedition').")";
+if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all
+{
+ $sql.= " AND e.fk_soc = sc.fk_soc";
+ $sql.= " AND sc.fk_user = " .$user->id;
+}
+if ($socid)
+{
+ $sql.= " AND e.fk_soc = ".$socid;
+}
+if ($viewstatut <> '' && $viewstatut >= 0) {
+ $sql.= " AND e.fk_statut = ".$viewstatut;
+}
+if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed;
+if ($search_town) $sql.= natural_search('s.town', $search_town);
+if ($search_zip) $sql.= natural_search("s.zip",$search_zip);
+if ($search_state) $sql.= natural_search("state.nom",$search_state);
+if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
+if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
+if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
+if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
+if ($search_company) $sql .= natural_search('s.nom', $search_company);
+if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
+
+// Add where from extra fields
+foreach ($search_array_options as $key => $val)
+{
+ $crit=$val;
+ $tmpkey=preg_replace('/search_options_/','',$key);
+ $typ=$extrafields->attribute_type[$tmpkey];
+ $mode=0;
+ if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric
+ if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int
+ if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0'))
+ {
+ $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
+ }
+}
+// Add where from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
+
+$nbtotalofrecords = '';
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+{
+ $result = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($result);
+}
+
+$sql.= $db->order($sortfield,$sortorder);
+$sql.= $db->plimit($limit + 1,$offset);
+
+//print $sql;
+$resql=$db->query($sql);
+if ($resql)
+{
+ $num = $db->num_rows($resql);
+
+ $expedition = new Expedition($db);
+
+ $param='';
+ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
+ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
+ if ($sall) $param.= "&sall=".$sall;
+ if ($search_ref_exp) $param.= "&search_ref_exp=".$search_ref_exp;
+ if ($search_ref_liv) $param.= "&search_ref_liv=".$search_ref_liv;
+ if ($search_company) $param.= "&search_company=".$search_company;
+ if ($optioncss != '') $param.='&optioncss='.$optioncss;
+ // Add $param from extra fields
+ foreach ($search_array_options as $key => $val)
+ {
+ $crit=$val;
+ $tmpkey=preg_replace('/search_options_/','',$key);
+ if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
+ }
+
+ //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
+
+ $i = 0;
+ print '';
+ $db->free($resql);
+}
+else
+{
+ dol_print_error($db);
+}
+
+llxFooter();
+$db->close();
diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php
new file mode 100644
index 00000000000..c32ec5c5124
--- /dev/null
+++ b/htdocs/reception/note.php
@@ -0,0 +1,164 @@
+
+ * Copyright (C) 2004-2008 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2013 Florian Henry
+ *
+ * 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/note.php
+ * \ingroup expedition
+ * \brief Note card expedition
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
+if (! empty($conf->projet->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+}
+
+$langs->load("sendings");
+$langs->load("companies");
+$langs->load("bills");
+$langs->load('deliveries');
+$langs->load('orders');
+$langs->load('stocks');
+$langs->load('other');
+$langs->load('propal');
+
+$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
+$ref=GETPOST('ref','alpha');
+$action=GETPOST('action','alpha');
+
+// Security check
+$socid='';
+if ($user->societe_id) $socid=$user->societe_id;
+$result=restrictedArea($user, $origin, $origin_id);
+
+$object = new Expedition($db);
+if ($id > 0 || ! empty($ref))
+{
+ $object->fetch($id, $ref);
+ $object->fetch_thirdparty();
+
+ if (!empty($object->origin))
+ {
+ $typeobject = $object->origin;
+ $origin = $object->origin;
+ $object->fetch_origin();
+ }
+
+ // Linked documents
+ if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
+ {
+ $objectsrc=new Commande($db);
+ $objectsrc->fetch($object->$typeobject->id);
+ }
+ if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
+ {
+ $objectsrc=new Propal($db);
+ $objectsrc->fetch($object->$typeobject->id);
+ }
+}
+
+$permissionnote=$user->rights->expedition->creer; // Used by the include of actions_setnotes.inc.php
+
+
+/*
+ * Actions
+ */
+
+include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
+
+
+/*
+ * View
+ */
+
+llxHeader();
+
+$form = new Form($db);
+
+if ($id > 0 || ! empty($ref))
+{
+
+ $head=shipping_prepare_head($object);
+ dol_fiche_head($head, 'note', $langs->trans("Shipment"), -1, 'sending');
+
+
+ // Shipment card
+ $linkback = ''.$langs->trans("BackToList").'';
+
+ $morehtmlref='';
+ // Ref customer shipment
+ $morehtmlref.=$form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref.=' '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+ // Project
+ if (! empty($conf->projet->enabled)) {
+ $langs->load("projects");
+ $morehtmlref .= ' ' . $langs->trans('Project') . ' ';
+ if (0) { // Do not change on shipment
+ if ($action != 'classify') {
+ $morehtmlref .= ' ' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ }
+ if ($action == 'classify') {
+ // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= ' ';
+ } else {
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ // We don't have project on shipment, so we will use the project or source object instead
+ // TODO Add project on shipment
+ $morehtmlref .= ' : ';
+ if (! empty($objectsrc->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($objectsrc->fk_project);
+ $morehtmlref .= ' ';
+ $morehtmlref .= $proj->ref;
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= '';
+ }
+ }
+ }
+ $morehtmlref.=' ';
+
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+
+ print '';
+
+ $cssclass='titlefield';
+ include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
+
+ dol_fiche_end();
+}
+
+
+llxFooter();
+
+$db->close();
diff --git a/htdocs/reception/shipment.php b/htdocs/reception/shipment.php
new file mode 100644
index 00000000000..849053c610c
--- /dev/null
+++ b/htdocs/reception/shipment.php
@@ -0,0 +1,939 @@
+
+ * Copyright (C) 2005-2012 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2012-2015 Juanjo Menent
+ *
+ * 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/shipment.php
+ * \ingroup expedition
+ * \brief Tab shipments/delivery receipts on the order
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+if (! empty($conf->projet->enabled)) {
+ require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
+}
+if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
+if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
+if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+
+$langs->load('orders');
+$langs->load("companies");
+$langs->load("bills");
+$langs->load('propal');
+$langs->load('deliveries');
+$langs->load('stocks');
+$langs->load("productbatch");
+
+$id=GETPOST('id','int'); // id of order
+$ref= GETPOST('ref','alpha');
+$action=GETPOST('action','alpha');
+
+// Security check
+$socid=0;
+if (! empty($user->societe_id)) $socid=$user->societe_id;
+$result=restrictedArea($user,'commande',$id);
+
+$object = new Commande($db);
+$extrafields = new ExtraFields($db);
+
+// fetch optionals attributes and labels
+$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
+
+
+
+
+/*
+ * Actions
+ */
+
+$parameters = array('socid' => $socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
+{
+ // Categorisation dans projet
+ if ($action == 'classin')
+ {
+ $object = new Commande($db);
+ $object->fetch($id);
+ $object->setProject(GETPOST('projectid','int'));
+ }
+
+ if ($action == 'confirm_cloture' && GETPOST('confirm','alpha') == 'yes')
+ {
+ $object = new Commande($db);
+ $object->fetch($id);
+ $result = $object->cloture($user);
+ }
+
+ // Positionne ref commande client
+ else if ($action == 'setref_client' && $user->rights->commande->creer) {
+ $result = $object->set_ref_client($user, GETPOST('ref_client'));
+ if ($result < 0)
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+
+ if ($action == 'setdatedelivery' && $user->rights->commande->creer)
+ {
+ //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
+ $datelivraison=dol_mktime(0, 0, 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int'));
+
+ $object = new Commande($db);
+ $object->fetch($id);
+ $result=$object->set_date_livraison($user,$datelivraison);
+ if ($result < 0)
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ /*
+ if ($action == 'setdeliveryaddress' && $user->rights->commande->creer)
+ {
+ $object = new Commande($db);
+ $object->fetch($id);
+ $object->setDeliveryAddress(GETPOST('delivery_address_id','int'));
+ if ($result < 0)
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ */
+ if ($action == 'setmode' && $user->rights->commande->creer)
+ {
+ $object = new Commande($db);
+ $object->fetch($id);
+ $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
+ if ($result < 0)
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+
+ if ($action == 'setavailability' && $user->rights->commande->creer) {
+ $object = new Commande($db);
+ $object->fetch($id);
+ $result=$object->availability(GETPOST('availability_id'));
+ if ($result < 0)
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+
+ if ($action == 'setdemandreason' && $user->rights->commande->creer) {
+ $object = new Commande($db);
+ $object->fetch($id);
+ $result=$object->demand_reason(GETPOST('demand_reason_id'));
+ if ($result < 0)
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+
+ if ($action == 'setconditions' && $user->rights->commande->creer)
+ {
+ $object = new Commande($db);
+ $object->fetch($id);
+ $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
+ if ($result < 0)
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+
+ // shipping method
+ if ($action == 'setshippingmethod' && $user->rights->commande->creer) {
+ $object = new Commande($db);
+ $object->fetch($id);
+ $result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
+ if ($result < 0)
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+
+ // warehouse
+ if ($action == 'setwarehouse' && $user->rights->commande->creer) {
+ $object = new Commande($db);
+ $object->fetch($id);
+ $result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
+ if ($result < 0)
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+
+ if ($action == 'update_extras')
+ {
+ // Fill array 'array_options' with data from update form
+ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
+ $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
+ if ($ret < 0) $error++;
+
+ if (! $error)
+ {
+ // Actions on extra fields (by external module or standard code)
+ $hookmanager->initHooks(array('orderdao'));
+ $parameters = array('id' => $object->id);
+ $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
+ // some hooks
+ if (empty($reshook)) {
+ $result = $object->insertExtraFields();
+ if ($result < 0) {
+ $error++;
+ }
+ } else if ($reshook < 0)
+ $error++;
+ }
+
+ if ($error)
+ $action = 'edit_extras';
+ }
+
+ if ($action == 'set_thirdparty' && $user->rights->commande->creer)
+ {
+ $object->fetch($id);
+ $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY');
+
+ header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
+ exit();
+ }
+
+ include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
+
+}
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formfile = new FormFile($db);
+$formproduct = new FormProduct($db);
+if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
+
+llxHeader('',$langs->trans('OrderCard'),'');
+
+
+if ($id > 0 || ! empty($ref))
+{
+ $object = new Commande($db);
+ if ( $object->fetch($id,$ref) > 0)
+ {
+ $object->loadExpeditions(1);
+
+ $product_static=new Product($db);
+
+ $soc = new Societe($db);
+ $soc->fetch($object->socid);
+
+ $author = new User($db);
+ $author->fetch($object->user_author_id);
+
+ $res = $object->fetch_optionals($object->id, $extralabels);
+
+ $head = commande_prepare_head($object);
+ dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), -1, 'order');
+
+
+ $formconfirm = '';
+
+ // Confirm validation
+ if ($action == 'cloture')
+ {
+ $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id,$langs->trans("CloseShipment"),$langs->trans("ConfirmCloseShipment"),"confirm_cloture");
+
+ }
+
+ if (! $formconfirm) {
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
+ elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
+ }
+
+ // Print form confirm
+ print $formconfirm;
+
+
+ // Order card
+
+ $linkback = '' . $langs->trans("BackToList") . '';
+
+
+ $morehtmlref='';
+ // Ref customer
+ $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref.=' '.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $langs->load("projects");
+ $morehtmlref.=' '.$langs->trans('Project') . ' ';
+ if ($user->rights->commande->creer)
+ {
+ if ($action != 'classify')
+ $morehtmlref.=' ' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref.=' ';
+ $morehtmlref.=$proj->ref;
+ $morehtmlref.='';
+ } else {
+ $morehtmlref.='';
+ }
+ }
+ }
+ $morehtmlref.=' ';
+
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+
+ print '';
+ print ' ';
+ print ' ';
+
+ print ' ';
+
+ // Discounts for third party
+ print '| '.$langs->trans('Discounts').' | ';
+ if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent);
+ else print $langs->trans("CompanyHasNoRelativeDiscount");
+ print '. ';
+ $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
+ $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
+ $absolute_discount=price2num($absolute_discount,'MT');
+ $absolute_creditnote=price2num($absolute_creditnote,'MT');
+ if ($absolute_discount)
+ {
+ if ($object->statut > Commande::STATUS_DRAFT)
+ {
+ print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
+ }
+ else
+ {
+ // Remise dispo de type non avoir
+ $filter='fk_facture_source IS NULL';
+ print ' ';
+ $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter, 0, '', 1);
+ }
+ }
+ if ($absolute_creditnote)
+ {
+ print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'. ';
+ }
+ if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
+ print ' | ';
+
+ // Date
+ print '| '.$langs->trans('Date').' | ';
+ print '';
+ print dol_print_date($object->date,'daytext');
+ if ($object->hasDelay() && empty($object->date_livraison)) {
+ print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning");
+ }
+ print ' | ';
+ print ' ';
+
+ // Delivery date planned
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editdate_livraison')
+ {
+ print '';
+ }
+ else
+ {
+ print dol_print_date($object->date_livraison,'daytext');
+ if ($object->hasDelay() && ! empty($object->date_livraison)) {
+ print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning");
+ }
+ }
+ print ' | ';
+ // Note on several rows
+ //print ''.$langs->trans('NotePublic').' : ';
+ //print nl2br($object->note_public);
+ //print ' | ';
+ print ' ';
+
+ // Shipping Method
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editshippingmethod') {
+ $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
+ } else {
+ $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
+ }
+ print ' | ';
+ print ' ';
+
+ // Warehouse
+ if (! empty($conf->stock->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
+ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
+ $formproduct=new FormProduct($db);
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editwarehouse') {
+ $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1);
+ } else {
+ $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none');
+ }
+ print ' | ';
+ print ' ';
+ }
+
+ // Terms of payment
+ /*
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editconditions')
+ {
+ $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
+ }
+ else
+ {
+ $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none');
+ }
+ print ' | ';
+
+ // Mode of payment
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editmode')
+ {
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
+ }
+ else
+ {
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none');
+ }
+ print ' | ';*/
+
+ // Availability
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editavailability') {
+ $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1);
+ } else {
+ $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1);
+ }
+ print ' | ';
+
+ // Source
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editdemandreason') {
+ $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1);
+ } else {
+ $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none');
+ }
+
+ $tmparray=$object->getTotalWeightVolume();
+ $totalWeight=$tmparray['weight'];
+ $totalVolume=$tmparray['volume'];
+ if ($totalWeight || $totalVolume)
+ {
+ print ' | | '.$langs->trans("CalculatedWeight").' | ';
+ print '';
+ print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no');
+ print ' | ';
+ print '| '.$langs->trans("CalculatedVolume").' | ';
+ print '';
+ print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
+ print ' | ';
+ }
+
+ // TODO How record was recorded OrderMode (llx_c_input_method)
+
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print '| ';
+ print $langs->trans('IncotermLabel');
+ print ' | | ';
+ if ($user->rights->commande->creer) print ''.img_edit().'';
+ else print ' ';
+ print ' | ';
+ print ' | ';
+ print '';
+ if ($action != 'editincoterm')
+ {
+ print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
+ }
+ else
+ {
+ print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
+ }
+ print ' | ';
+ }
+
+ // Other attributes
+ $cols = 2;
+ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
+
+ print ' ';
+
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+
+ print ' ';
+
+ if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
+ {
+ // Multicurrency Amount HT
+ print '| ' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ' | ';
+ print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' | ';
+ print ' ';
+
+ // Multicurrency Amount VAT
+ print '| ' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ' | ';
+ print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' | ';
+ print ' ';
+
+ // Multicurrency Amount TTC
+ print '| ' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ' | ';
+ print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' | ';
+ print ' ';
+ }
+
+ // Total HT
+ print '| '.$langs->trans('AmountHT').' | ';
+ print ''.price($object->total_ht, 0, '', 1, -1, -1, $conf->currency).' | ';
+ print ' ';
+
+ // Total VAT
+ print '| '.$langs->trans('AmountVAT').' | '.price($object->total_tva, 0, '', 1, -1, -1, $conf->currency).' | ';
+ print ' ';
+
+ // Amount Local Taxes
+ if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1
+ {
+ print '| ' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ' | ';
+ print '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . ' | ';
+ }
+ if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF
+ {
+ print '| ' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ' | ';
+ print '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . ' | ';
+ }
+
+ // Total TTC
+ print '| '.$langs->trans('AmountTTC').' | '.price($object->total_ttc, 0, '', 1, -1, -1, $conf->currency).' | ';
+ print ' ';
+
+ print ' ';
+
+ print ' ';
+ print ' ';
+ print ' ';
+
+ print ' ';
+
+
+
+ /**
+ * Lines or orders with quantity shipped and remain to ship
+ * Note: Qty shipped are already available into $object->expeditions[fk_product]
+ */
+ print '';
+
+ $sql = "SELECT cd.rowid, cd.fk_product, cd.product_type as type, cd.label, cd.description,";
+ $sql.= " cd.price, cd.tva_tx, cd.subprice,";
+ $sql.= " cd.qty,";
+ $sql.= ' cd.date_start,';
+ $sql.= ' cd.date_end,';
+ $sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc';
+ $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
+ $sql.= " WHERE cd.fk_commande = ".$object->id;
+ $sql.= " ORDER BY cd.rang, cd.rowid";
+
+ //print $sql;
+ dol_syslog("shipment.php", LOG_DEBUG);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ print '';
+ print '| '.$langs->trans("Description").' | ';
+ print ''.$langs->trans("QtyOrdered").' | ';
+ print ''.$langs->trans("QtyShipped").' | ';
+ print ''.$langs->trans("KeepToShip").' | ';
+ if (! empty($conf->stock->enabled))
+ {
+ print ''.$langs->trans("RealStock").' | ';
+ }
+ else
+ {
+ print ' | ';
+ }
+ print " \n";
+
+ $var=true;
+ $toBeShipped=array();
+ $toBeShippedTotal=0;
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($resql);
+
+
+ // Show product and description
+ $type=isset($objp->type)?$objp->type:$objp->product_type;
+
+ // Try to enhance type detection using date_start and date_end for free lines where type
+ // was not saved.
+ if (! empty($objp->date_start)) $type=1;
+ if (! empty($objp->date_end)) $type=1;
+
+ print '';
+
+ // Product label
+ if ($objp->fk_product > 0)
+ {
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ {
+ $object->fetch_thirdparty();
+
+ $prod = new Product($db);
+ $prod->id = $objp->fk_product;
+ $prod->entity = $objp->entity;
+ $prod->getMultiLangs();
+
+ $outputlangs = $langs;
+ $newlang='';
+ if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
+ }
+ else
+ $label = (! empty($objp->label)?$objp->label:$objp->product_label);
+
+ print '';
+ print ''; // ancre pour retourner sur la ligne
+
+ // Show product and description
+ $product_static->type=$type;
+ $product_static->id=$objp->fk_product;
+ $product_static->ref=$objp->ref;
+ $product_static->entity = $objp->entity;
+ $text=$product_static->getNomUrl(1);
+ $text.= ' - '.$label;
+ $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).' ';
+ $description.= $product_static->show_photos($conf->product->multidir_output[$product_static->entity],1,1,0,0,0,80);
+ print $form->textwithtooltip($text,$description,3,'','',$i);
+
+ // Show range
+ print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
+
+ // Add description in form
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ print ($objp->description && $objp->description!=$objp->product_label)?' '.dol_htmlentitiesbr($objp->description):'';
+ }
+
+ print ' | ';
+ }
+ else
+ {
+ print "";
+ if ($type==1) $text = img_object($langs->trans('Service'),'service');
+ else $text = img_object($langs->trans('Product'),'product');
+
+ if (! empty($objp->label)) {
+ $text.= ' '.$objp->label.'';
+ print $form->textwithtooltip($text,$objp->description,3,'','',$i);
+ } else {
+ print $text.' '.nl2br($objp->description);
+ }
+
+ // Show range
+ print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
+ print " | \n";
+ }
+
+ // Qty ordered
+ print '' . $objp->qty . ' | ';
+
+ // Qty already shipped
+ $qtyProdCom=$objp->qty;
+ print '';
+ // Nb of sending products for this line of order
+ $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
+ print $qtyAlreadyShipped;
+ print ' | ';
+
+ // Qty remains to ship
+ print '';
+ if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
+ {
+ $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
+ $toBeShippedTotal += $toBeShipped[$objp->fk_product];
+ print $toBeShipped[$objp->fk_product];
+ }
+ else
+ {
+ print '0 ('.$langs->trans("Service").')';
+ }
+ print ' | ';
+
+ if ($objp->fk_product > 0)
+ {
+ $product = new Product($db);
+ $product->fetch($objp->fk_product);
+ $product->load_stock('warehouseopen');
+ }
+
+ if ($objp->fk_product > 0 && $type == 0 && ! empty($conf->stock->enabled))
+ {
+ print '';
+ print $product->stock_reel;
+ if ($product->stock_reel < $toBeShipped[$objp->fk_product])
+ {
+ print ' '.img_warning($langs->trans("StockTooLow"));
+ }
+ print ' | ';
+ }
+ else
+ {
+ print ' | ';
+ }
+ print " \n";
+
+ // Show subproducts lines
+ if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
+ {
+ // Set tree of subproducts in product->sousprods
+ $product->get_sousproduits_arbo();
+ //var_dump($product->sousprods);exit;
+
+ // Define a new tree with quantiies recalculated
+ $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
+ //var_dump($prods_arbo);
+ if (count($prods_arbo) > 0)
+ {
+ foreach($prods_arbo as $key => $value)
+ {
+ $img='';
+ if ($value['stock'] < $value['stock_alert'])
+ {
+ $img=img_warning($langs->trans("StockTooLow"));
+ }
+ print '| -> '.$value['fullpath'].' ('.$value['nb'].') | ';
+ print ' '.$value['nb_total'].' | ';
+ print '  | ';
+ print '  | ';
+ print ''.$value['stock'].' '.$img.' | '."\n";
+ }
+ }
+ }
+
+ $i++;
+ }
+ $db->free($resql);
+
+ if (! $num)
+ {
+ print ''.$langs->trans("NoArticleOfTypeProduct").' ';
+ }
+
+ print " | ";
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+
+ print '';
+
+
+ /*
+ * Boutons Actions
+ */
+
+ if (empty($user->societe_id))
+ {
+ print '';
+
+ // Bouton expedier sans gestion des stocks
+ if (empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED))
+ {
+ if ($user->rights->expedition->creer)
+ {
+ print ' '.$langs->trans("CreateShipment").'';
+ if ($toBeShippedTotal <= 0)
+ {
+ print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
+ }
+ }
+ else
+ {
+ print ' '.$langs->trans("CreateShipment").'';
+ }
+ }
+ print " ";
+ }
+
+
+ // Bouton expedier avec gestion des stocks
+
+ if (! empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT)
+ {
+ print $langs->trans("ValidateOrderFirstBeforeShipment");
+ }
+
+ if (! empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED))
+ {
+ if ($user->rights->expedition->creer)
+ {
+ //print load_fiche_titre($langs->trans("CreateShipment"));
+ print '';
+
+ print ' \n";
+
+ print ' ';
+
+ $somethingshown=1;
+
+ }
+ else
+ {
+ print '';
+ }
+ }
+
+ show_list_sending_receive('commande',$object->id);
+ }
+ else
+ {
+ /* Commande non trouvee */
+ print "Commande inexistante";
+ }
+}
+
+
+llxFooter();
+
+$db->close();
diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php
new file mode 100644
index 00000000000..53837c76fd1
--- /dev/null
+++ b/htdocs/reception/stats/index.php
@@ -0,0 +1,364 @@
+
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2009 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/stats/index.php
+ * \ingroup expedition
+ * \brief Page with shipment statistics
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionstats.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
+
+$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
+$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
+
+$userid=GETPOST('userid','int');
+$socid=GETPOST('socid','int');
+// Security check
+if ($user->societe_id > 0)
+{
+ $action = '';
+ $socid = $user->societe_id;
+}
+
+$nowyear=strftime("%Y", dol_now());
+$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
+//$startyear=$year-2;
+$startyear=$year-1;
+$endyear=$year;
+
+$langs->load("sendings");
+$langs->load("other");
+$langs->load("companies");
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+
+llxHeader();
+
+print load_fiche_titre($langs->trans("StatisticsOfSendings"), $mesg);
+
+
+dol_mkdir($dir);
+
+$stats = new ExpeditionStats($db, $socid, $mode, ($userid>0?$userid:0));
+
+// Build graphic number of object
+$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
+//var_dump($data);exit;
+// $data = array(array('Lib',val1,val2,val3),...)
+
+
+if (!$user->rights->societe->client->voir || $user->societe_id)
+{
+ $filenamenb = $dir.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
+ if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
+ if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
+}
+else
+{
+ $filenamenb = $dir.'/shipmentsnbinyear-'.$year.'.png';
+ if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$year.'.png';
+ if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$year.'.png';
+}
+
+$px1 = new DolGraph();
+$mesg = $px1->isGraphKo();
+if (! $mesg)
+{
+ $px1->SetData($data);
+ $px1->SetPrecisionY(0);
+ $i=$startyear;$legend=array();
+ while ($i <= $endyear)
+ {
+ $legend[]=$i;
+ $i++;
+ }
+ $px1->SetLegend($legend);
+ $px1->SetMaxValue($px1->GetCeilMaxValue());
+ $px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
+ $px1->SetWidth($WIDTH);
+ $px1->SetHeight($HEIGHT);
+ $px1->SetYLabel($langs->trans("NbOfSendings"));
+ $px1->SetShading(3);
+ $px1->SetHorizTickIncrement(1);
+ $px1->SetPrecisionY(0);
+ $px1->mode='depth';
+ $px1->SetTitle($langs->trans("NumberOfShipmentsByMonth"));
+
+ $px1->draw($filenamenb,$fileurlnb);
+}
+
+// Build graphic amount of object
+/*
+$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
+//var_dump($data);
+// $data = array(array('Lib',val1,val2,val3),...)
+
+if (!$user->rights->societe->client->voir || $user->societe_id)
+{
+ $filenameamount = $dir.'/shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
+ if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
+ if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
+}
+else
+{
+ $filenameamount = $dir.'/shipmentsamountinyear-'.$year.'.png';
+ if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsamountinyear-'.$year.'.png';
+ if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsamountinyear-'.$year.'.png';
+}
+
+$px2 = new DolGraph();
+$mesg = $px2->isGraphKo();
+if (! $mesg)
+{
+ $px2->SetData($data);
+ $i=$startyear;$legend=array();
+ while ($i <= $endyear)
+ {
+ $legend[]=$i;
+ $i++;
+ }
+ $px2->SetLegend($legend);
+ $px2->SetMaxValue($px2->GetCeilMaxValue());
+ $px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
+ $px2->SetWidth($WIDTH);
+ $px2->SetHeight($HEIGHT);
+ $px2->SetYLabel($langs->trans("AmountOfShipments"));
+ $px2->SetShading(3);
+ $px2->SetHorizTickIncrement(1);
+ $px2->SetPrecisionY(0);
+ $px2->mode='depth';
+ $px2->SetTitle($langs->trans("AmountOfShipmentsByMonthHT"));
+
+ $px2->draw($filenameamount,$fileurlamount);
+}
+*/
+
+/*
+$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
+
+if (!$user->rights->societe->client->voir || $user->societe_id)
+{
+ $filename_avg = $dir.'/shipmentsaverage-'.$user->id.'-'.$year.'.png';
+ if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsaverage-'.$user->id.'-'.$year.'.png';
+ if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsaverage-'.$user->id.'-'.$year.'.png';
+}
+else
+{
+ $filename_avg = $dir.'/shipmentsaverage-'.$year.'.png';
+ if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsaverage-'.$year.'.png';
+ if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsaverage-'.$year.'.png';
+}
+
+$px3 = new DolGraph();
+$mesg = $px3->isGraphKo();
+if (! $mesg)
+{
+ $px3->SetData($data);
+ $i=$startyear;$legend=array();
+ while ($i <= $endyear)
+ {
+ $legend[]=$i;
+ $i++;
+ }
+ $px3->SetLegend($legend);
+ $px3->SetYLabel($langs->trans("AmountAverage"));
+ $px3->SetMaxValue($px3->GetCeilMaxValue());
+ $px3->SetMinValue($px3->GetFloorMinValue());
+ $px3->SetWidth($WIDTH);
+ $px3->SetHeight($HEIGHT);
+ $px3->SetShading(3);
+ $px3->SetHorizTickIncrement(1);
+ $px3->SetPrecisionY(0);
+ $px3->mode='depth';
+ $px3->SetTitle($langs->trans("AmountAverage"));
+
+ $px3->draw($filename_avg,$fileurl_avg);
+}
+*/
+
+
+// Show array
+$data = $stats->getAllByYear();
+$arrayyears=array();
+foreach($data as $val) {
+ if (! empty($val['year'])) {
+ $arrayyears[$val['year']]=$val['year'];
+ }
+}
+if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
+
+$h=0;
+$head = array();
+$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php?mode='.$mode;
+$head[$h][1] = $langs->trans("ByMonthYear");
+$head[$h][2] = 'byyear';
+$h++;
+
+$type='shipment_stats';
+
+complete_head_from_modules($conf,$langs,null,$head,$h,$type);
+
+dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);
+
+
+print '';
+
+
+//if (empty($socid))
+//{
+ // Show filter box
+ print ' ';
+ print ' ';
+//}
+
+print ' ';
+print '';
+print '| '.$langs->trans("Year").' | ';
+print ''.$langs->trans("NbOfSendings").' | ';
+/*print ''.$langs->trans("AmountTotal").' | ';
+print ''.$langs->trans("AmountAverage").' | ';*/
+print ' ';
+
+$oldyear=0;
+foreach ($data as $val)
+{
+ $year = $val['year'];
+ while (! empty($year) && $oldyear > $year+1)
+ { // If we have empty year
+ $oldyear--;
+
+
+ print '';
+ print '| '.$oldyear.' | ';
+
+ print '0 | ';
+ /*print '0 | ';
+ print '0 | ';*/
+ print ' ';
+ }
+
+ print '';
+ print '| ';
+ if ($year) print ''.$year.'';
+ else print $langs->trans("ValidationDateNotDefinedEvenIfShipmentValidated");
+ print ' | ';
+ print ''.$val['nb'].' | ';
+ /*print ''.price(price2num($val['total'],'MT'),1).' | ';
+ print ''.price(price2num($val['avg'],'MT'),1).' | ';*/
+ print ' ';
+ $oldyear=$year;
+}
+
+print ' ';
+
+
+print ' ';
+
+
+// Show graphs
+print ' ';
+if ($mesg) { print $mesg; }
+else {
+ print $px1->show();
+ print " \n";
+ /*print $px2->show();
+ print " \n";
+ print $px3->show();*/
+}
+print ' |
';
+
+
+print ' ';
+print '';
+
+dol_fiche_end();
+
+
+
+// TODO USe code similar to commande/stats/index.php instead of this one.
+/*
+print '';
+print '| '.$langs->trans("Year").' | ';
+print ''.$langs->trans("NbOfSendings").' | ';
+
+$sql = "SELECT count(*) as nb, date_format(date_expedition,'%Y') as dm";
+$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
+$sql.= " WHERE fk_statut > 0";
+$sql.= " AND entity = ".$conf->entity;
+$sql.= " GROUP BY dm DESC";
+
+$resql=$db->query($sql);
+if ($resql)
+{
+ $num = $db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $row = $db->fetch_row($resql);
+ $nbproduct = $row[0];
+ $year = $row[1];
+ print "";
+ print '| '.$year.' | '.$nbproduct.' | ';
+ $i++;
+ }
+}
+$db->free($resql);
+
+print ' ';
+*/
+
+print ' ';
+print ''.$langs->trans("StatsOnShipmentsOnlyValidated").'';
+
+llxFooter();
+
+$db->close();
diff --git a/htdocs/reception/stats/month.php b/htdocs/reception/stats/month.php
new file mode 100644
index 00000000000..b7d217217c2
--- /dev/null
+++ b/htdocs/reception/stats/month.php
@@ -0,0 +1,76 @@
+
+ * Copyright (C) 2004-2009 Laurent Destailleur
+ *
+ * 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/stats/month.php
+ * \ingroup commande
+ * \brief Page des stats expeditions par mois
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionstats.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
+
+
+/*
+ * View
+ */
+
+llxHeader();
+
+$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
+$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
+
+$mesg = '';
+
+print load_fiche_titre($langs->trans("StatisticsOfSendings").' '.$_GET["year"], $mesg);
+
+$stats = new ExpeditionStats($db);
+$data = $stats->getNbExpeditionByMonth($_GET["year"]);
+
+dol_mkdir($conf->expedition->dir_temp);
+
+$filename = $conf->expedition->dir_temp."/expedition".$year.".png";
+$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=expeditionstats&file=expedition'.$year.'.png';
+
+$px = new DolGraph();
+$mesg = $px->isGraphKo();
+if (! $mesg)
+{
+ $px->SetData($data);
+ $px->SetMaxValue($px->GetCeilMaxValue());
+ $px->SetWidth($WIDTH);
+ $px->SetHeight($HEIGHT);
+ $px->SetYLabel($langs->trans("NbOfOrders"));
+ $px->SetShading(3);
+ $px->SetHorizTickIncrement(1);
+ $px->SetPrecisionY(0);
+ $px->draw($filename,$fileurl);
+}
+
+print '';
+print '| Nombre d expedition par mois | ';
+print '';
+print $px->show();
+print ' | ';
+print ' ';
+
+llxFooter();
+
+$db->close();
diff --git a/htdocs/reception/tpl/index.html b/htdocs/reception/tpl/index.html
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php
new file mode 100644
index 00000000000..b55654f4786
--- /dev/null
+++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php
@@ -0,0 +1,80 @@
+
+ * Copyright (C) 2014 Marcos García
+ *
+ * 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 .
+ *
+ */
+?>
+
+
+
+load("sendings");
+
+$total=0; $ilink=0;
+$var=true;
+foreach($linkedObjectBlock as $key => $objectlink)
+{
+ $ilink++;
+
+ $trclass=($var?'pair':'impair');
+ if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total';
+?>
+
+ | trans("Shipment"); ?> |
+ getNomUrl(1); ?> |
+ |
+ date_delivery,'day'); ?> |
+ rights->expedition->lire) {
+ $total = $total + $objectlink->total_ht;
+ echo price($objectlink->total_ht);
+ } ?> |
+ getLibStatut(3); ?> |
+
+ element != 'commande') {
+ ?>
+ id.'&action=dellink&dellinkid='.$key; ?>">transnoentitiesnoconv("RemoveLink")); ?> |
+
+
+ 1)
+{
+ ?>
+
+ | trans("Total"); ?> |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
|