31require
'../../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
47$langs->loadLangs(array(
'companies',
'bills',
'products',
'supplier_proposal',
'productbatch'));
51$batch =
GETPOST(
'batch',
'alpha');
55$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
56$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
58if (!empty($user->socid)) {
59 $socid = $user->socid;
63$hookmanager->initHooks(array(
'batchproductstatsexpedition'));
65$showmessage =
GETPOST(
'showmessage');
69$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
70$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
72if (empty($page) || $page == -1) {
75$offset = $limit * $page;
78if (empty($sortorder)) {
81if (empty($sortfield)) {
82 $sortfield =
"exp.date_creation";
88if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
93if (!$user->hasRight(
'produit',
'lire')) {
103$societestatic =
new Societe($db);
105$form =
new Form($db);
108if ($id > 0 || !empty($ref)) {
111 $tmp = explode(
'_', $ref);
115 $result =
$object->fetch($id, $objectid, $batch);
117 $parameters = array(
'id' => $id);
118 $reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
125 $title = $langs->trans(
'Batch').
" ".$shortlabel.
" - ".$langs->trans(
'Referers');
126 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
128 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-stock-stats_expedition');
132 $titre = $langs->trans(
"CardProduct".
$object->type);
137 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
138 print $hookmanager->resPrint;
143 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
146 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
150 dol_banner_tab(
$object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
152 print
'<div class="fichecenter">';
154 print
'<div class="underbanner clearboth"></div>';
155 print
'<table class="border centpercent tableforfield" width="100%">';
159 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
160 $producttmp =
new Product($db);
161 $producttmp->fetch(
$object->fk_product);
162 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
213 print
'<table class="border centpercent tableforfield" width="100%">';
220 print
'<div class="clearboth"></div>';
224 if ($showmessage && $nboflines > 1) {
225 print
'<span class="opacitymedium">'.$langs->trans(
"ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv(
"Referers")).
'</span>';
226 } elseif ($user->hasRight(
'expedition',
'lire')) {
227 $sql =
"SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
228 $sql .=
" exp.ref, exp.date_creation, exp.fk_statut as statut, exp.rowid as facid,";
229 $sql .=
" d.rowid, db.qty";
231 if (!$user->hasRight(
'societe',
'client',
'voir')) {
232 $sql .=
", sc.fk_soc, sc.fk_user ";
234 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
235 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"expedition as exp ON (exp.fk_soc = s.rowid)";
236 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"expeditiondet as d ON (d.fk_expedition = exp.rowid)";
237 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"expeditiondet_batch as db ON (db.fk_expeditiondet = d.rowid)";
238 if (!$user->hasRight(
'societe',
'client',
'voir')) {
239 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
241 $sql .=
" WHERE exp.entity IN (".getEntity(
'product').
")";
242 $sql .=
" AND db.batch = '".($db->escape(
$object->batch)).
"'";
243 if (!empty($search_month)) {
244 $sql .=
' AND MONTH(exp.date_creation) IN ('.$db->sanitize($search_month).
')';
246 if (!empty($search_year)) {
247 $sql .=
' AND YEAR(exp.date_creation) IN ('.$db->sanitize($search_year).
')';
249 if (!$user->hasRight(
'societe',
'client',
'voir')) {
250 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
253 $sql .=
" AND exp.fk_soc = ".((int) $socid);
255 $sql .= $db->order($sortfield, $sortorder);
262 $totalofrecords =
'';
264 $result = $db->query($sql);
265 $totalofrecords = $db->num_rows($result);
268 $sql .= $db->plimit($limit + 1, $offset);
270 $result = $db->query($sql);
272 $num = $db->num_rows($result);
274 $option =
'&id='.$object->id;
276 if ($limit > 0 && $limit !=
$conf->liste_limit) {
277 $option .=
'&limit='.((int) $limit);
279 if (!empty($search_month)) {
280 $option .=
'&search_month='.urlencode((
string) ($search_month));
282 if (!empty($search_year)) {
283 $option .=
'&search_year='.urlencode((
string) ($search_year));
286 print
'<form method="post" action="'.$_SERVER [
'PHP_SELF'].
'?id='.
$object->id.
'" name="search_form">'.
"\n";
287 print
'<input type="hidden" name="token" value="'.newToken().
'">';
288 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
289 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
292 print_barre_liste($langs->trans(
"Shipments"), $page, $_SERVER[
"PHP_SELF"], $option, $sortfield, $sortorder,
'', $num, $totalofrecords,
'', 0,
'',
'', $limit, 0, 0, 1);
295 $option .=
'&page='.urlencode((
string) ($page));
298 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
299 print
'<div class="divsearchfield">';
300 print $langs->trans(
'Period').
' ('.$langs->trans(
"DateCreation").
') - ';
301 print $langs->trans(
'Month').
':<input class="flat" type="text" size="4" name="search_month" value="'.$search_month.
'"> ';
302 print $langs->trans(
'Year').
':'.$formother->selectyear($search_year ? $search_year : - 1,
'search_year', 1, 20, 5);
303 print
'<div style="vertical-align: middle; display: inline-block">';
304 print
'<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans(
"Search"),
'search.png',
'', 0, 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"Search")).
'" title="'.
dol_escape_htmltag($langs->trans(
"Search")).
'">';
305 print
'<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans(
"Search"),
'searchclear.png',
'', 0, 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"RemoveFilter")).
'" title="'.
dol_escape_htmltag($langs->trans(
"RemoveFilter")).
'">';
311 print
'<div class="div-table-responsive">';
312 print
'<table class="tagtable liste listwithfilterbefore" width="100%">';
313 print
'<tr class="liste_titre">';
316 print_liste_field_titre(
"CustomerCode", $_SERVER[
"PHP_SELF"],
"s.code_client",
"", $option,
'', $sortfield, $sortorder);
317 print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"exp.date_creation",
"", $option,
'align="center"', $sortfield, $sortorder);
318 print_liste_field_titre(
"Qty", $_SERVER[
"PHP_SELF"],
"d.qty",
"", $option,
'align="center"', $sortfield, $sortorder);
320 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"exp.fk_statut",
"", $option,
'align="right"', $sortfield, $sortorder);
324 while ($i < min($num, $limit)) {
325 $objp = $db->fetch_object($result);
327 $total_ht += $objp->total_ht;
328 $total_qty += $objp->qty;
330 $expeditionstatic->id = $objp->facid;
331 $expeditionstatic->ref = $objp->ref;
332 $societestatic->fetch($objp->socid);
335 print
'<tr class="oddeven">';
337 print $expeditionstatic->getNomUrl(1);
339 print
'<td>'.$societestatic->getNomUrl(1).
'</td>';
340 print
"<td>".$objp->code_client.
"</td>\n";
341 print
'<td class="center">';
342 print
dol_print_date($db->jdate($objp->date_creation),
'dayhour').
"</td>";
343 print
'<td class="center">'.$objp->qty.
"</td>\n";
345 print
'<td align="right">'.$expeditionstatic->LibStatut($objp->statut, 5).
'</td>';
350 print
'<tr class="liste_total">';
352 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
354 print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
356 print
'<td colspan="2"></td>';
358 print
'<td class="center">'.$total_qty.
'</td>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage products or services.
Class with list of lots and properties.
Class to manage third parties objects (customers, suppliers, prospects...)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
show_stats_for_batch($batch, $socid)
Show stats for product batch.
productlot_prepare_head($object)
Prepare array with list of tabs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.