30require
'../../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38$langs->loadLangs(array(
'companies',
'bills',
'products',
'supplier_proposal',
'productbatch'));
42$batch =
GETPOST(
'batch',
'alpha');
46$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
47$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
49if (!empty($user->socid)) {
50 $socid = $user->socid;
54$hookmanager->initHooks(array(
'batchproductstatsreception'));
56$showmessage =
GETPOST(
'showmessage');
60$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
61$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
63if (empty($page) || $page == -1) {
66$offset = $limit * $page;
73 $sortfield =
"recep.date_creation";
79if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
84if (!$user->hasRight(
'produit',
'lire')) {
94$societestatic =
new Societe($db);
99if ($id > 0 || !empty($ref)) {
102 $tmp = explode(
'_', $ref);
106 $result =
$object->fetch($id, $objectid, $batch);
108 $parameters = array(
'id' => $id);
109 $reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
114 $title = $langs->trans(
'ProductServiceCard');
117 $title = $langs->trans(
'Batch').
" ".$shortlabel.
" - ".$langs->trans(
'Referers');
119 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-stock-stats_reception');
123 $titre = $langs->trans(
"CardProduct".
$object->type);
127 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
128 print $hookmanager->resPrint;
133 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
136 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
140 dol_banner_tab(
$object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
142 print
'<div class="fichecenter">';
144 print
'<div class="underbanner clearboth"></div>';
145 print
'<table class="border centpercent tableforfield" width="100%">';
149 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
150 $producttmp =
new Product($db);
151 $producttmp->fetch(
$object->fk_product);
152 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
203 print
'<table class="border centpercent tableforfield" width="100%">';
210 print
'<div class="clearboth"></div>';
214 if ($showmessage && $nboflines > 1) {
215 print
'<span class="opacitymedium">'.$langs->trans(
"ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv(
"Referers")).
'</span>';
216 } elseif ($user->hasRight(
'reception',
'lire')) {
217 $sql =
"SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,";
218 $sql .=
" recep.ref, recep.date_creation, recep.fk_statut as statut, recep.rowid as facid,";
221 if (!$user->hasRight(
'societe',
'client',
'voir')) {
222 $sql .=
", sc.fk_soc, sc.fk_user ";
224 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
225 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"reception as recep ON (recep.fk_soc = s.rowid)";
226 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"receptiondet_batch as d ON (d.fk_reception = recep.rowid)";
227 if (!$user->hasRight(
'societe',
'client',
'voir')) {
228 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
230 $sql .=
" WHERE recep.entity IN (".getEntity(
'product').
")";
231 $sql .=
" AND d.batch = '".($db->escape(
$object->batch)).
"'";
232 if (!empty($search_month)) {
233 $sql .=
' AND MONTH(recep.date_creation) IN ('.$db->sanitize($search_month).
')';
235 if (!empty($search_year)) {
236 $sql .=
' AND YEAR(recep.date_creation) IN ('.$db->sanitize($search_year).
')';
238 if (!$user->hasRight(
'societe',
'client',
'voir')) {
239 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
242 $sql .=
" AND recep.fk_soc = ".((int) $socid);
244 $sql .= $db->order($sortfield, $sortorder);
251 $totalofrecords =
'';
253 $result = $db->query($sql);
254 $totalofrecords = $db->num_rows($result);
257 $sql .= $db->plimit($limit + 1, $offset);
259 $result = $db->query($sql);
261 $num = $db->num_rows($result);
263 $option .=
'&id='.$object->id;
265 if ($limit > 0 && $limit != $conf->liste_limit) {
266 $option .=
'&limit='.((int) $limit);
268 if (!empty($search_month)) {
269 $option .=
'&search_month='.urlencode((
string) ($search_month));
271 if (!empty($search_year)) {
272 $option .=
'&search_year='.urlencode((
string) ($search_year));
275 print
'<form method="post" action="'.$_SERVER [
'PHP_SELF'].
'?id='.
$object->id.
'" name="search_form">'.
"\n";
276 print
'<input type="hidden" name="token" value="'.newToken().
'">';
277 if (!empty($sortfield)) {
278 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
280 if (!empty($sortorder)) {
281 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
285 print_barre_liste($langs->trans(
"Receptions"), $page, $_SERVER[
"PHP_SELF"], $option, $sortfield, $sortorder,
'', $num, $totalofrecords,
'', 0,
'',
'', $limit, 0, 0, 1);
288 $option .=
'&page='.urlencode((
string) ($page));
291 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
292 print
'<div class="divsearchfield">';
293 print $langs->trans(
'Period').
' ('.$langs->trans(
"DateCreation").
') - ';
294 print $langs->trans(
'Month').
':<input class="flat" type="text" size="4" name="search_month" value="'.$search_month.
'"> ';
295 print $langs->trans(
'Year').
':'.$formother->selectyear($search_year ? $search_year : - 1,
'search_year', 1, 20, 5);
296 print
'<div style="vertical-align: middle; display: inline-block">';
297 print
'<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans(
"Search"),
'search.png',
'',
'', 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"Search")).
'" title="'.
dol_escape_htmltag($langs->trans(
"Search")).
'">';
298 print
'<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans(
"Search"),
'searchclear.png',
'',
'', 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"RemoveFilter")).
'" title="'.
dol_escape_htmltag($langs->trans(
"RemoveFilter")).
'">';
304 print
'<div class="div-table-responsive">';
305 print
'<table class="tagtable liste listwithfilterbefore" width="100%">';
306 print
'<tr class="liste_titre">';
309 print_liste_field_titre(
"SupplierCode", $_SERVER[
"PHP_SELF"],
"s.code_fournisseur",
"", $option,
'', $sortfield, $sortorder);
310 print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"recep.date_creation",
"", $option,
'align="center"', $sortfield, $sortorder);
311 print_liste_field_titre(
"Qty", $_SERVER[
"PHP_SELF"],
"d.qty",
"", $option,
'align="center"', $sortfield, $sortorder);
313 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"recep.fk_statut",
"", $option,
'align="right"', $sortfield, $sortorder);
317 while ($i < min($num, $limit)) {
318 $objp = $db->fetch_object($result);
320 $total_ht += $objp->total_ht;
321 $total_qty += $objp->qty;
323 $receptionstatic->id = $objp->facid;
324 $receptionstatic->ref = $objp->ref;
325 $societestatic->fetch($objp->socid);
328 print
'<tr class="oddeven">';
330 print $receptionstatic->getNomUrl(1);
332 print
'<td>'.$societestatic->getNomUrl(1).
'</td>';
333 print
"<td>".$objp->code_fournisseur.
"</td>\n";
334 print
'<td class="center">';
335 print
dol_print_date($db->jdate($objp->date_creation),
'dayhour').
"</td>";
336 print
'<td class="center">'.$objp->qty.
"</td>\n";
338 print
'<td align="right">'.$receptionstatic->LibStatut($objp->statut, 5).
'</td>';
343 print
'<tr class="liste_total">';
345 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
347 print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
349 print
'<td colspan="2"></td>';
351 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()
Empty header.
Class to manage products or services.
Class with list of lots and properties.
Class to manage receptions.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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...
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.