32require
'../../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
44require_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(
'batchproductstatsreception'));
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 =
"recep.date_creation";
85$search_month =
GETPOST(
'search_month');
86$search_year =
GETPOST(
'search_year');
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);
120 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
123 $title = $langs->trans(
'ProductServiceCard');
126 $title = $langs->trans(
'Batch').
" ".$shortlabel.
" - ".$langs->trans(
'Referers');
128 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-stock-stats_reception');
136 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
137 print $hookmanager->resPrint;
139 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
142 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
145 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
149 dol_banner_tab(
$object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
151 print
'<div class="fichecenter">';
153 print
'<div class="underbanner clearboth"></div>';
154 print
'<table class="border centpercent tableforfield" width="100%">';
158 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
159 $producttmp =
new Product($db);
160 $producttmp->fetch(
$object->fk_product);
161 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
215 print
'<table class="noborder centpercent tableforfield">';
224 print
'<div class="clearboth"></div>';
228 if ($showmessage && $nboflines > 1) {
229 print
'<span class="opacitymedium">'.$langs->trans(
"ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv(
"Referers")).
'</span>';
230 } elseif ($user->hasRight(
'reception',
'lire')) {
231 $sql =
"SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,";
232 $sql .=
" recep.ref, recep.date_creation, recep.fk_statut as statut, recep.rowid as facid,";
235 if (!$user->hasRight(
'societe',
'client',
'voir')) {
236 $sql .=
", sc.fk_soc, sc.fk_user ";
238 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
239 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"reception as recep ON (recep.fk_soc = s.rowid)";
240 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"receptiondet_batch as d ON (d.fk_reception = recep.rowid)";
241 if (!$user->hasRight(
'societe',
'client',
'voir')) {
242 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
244 $sql .=
" WHERE recep.entity IN (".getEntity(
'product').
")";
245 $sql .=
" AND d.batch = '".($db->escape(
$object->batch)).
"'";
246 if (!empty($search_month)) {
247 $sql .=
' AND MONTH(recep.date_creation) IN ('.$db->sanitize((
string) $search_month).
')';
249 if (!empty($search_year)) {
250 $sql .=
' AND YEAR(recep.date_creation) IN ('.$db->sanitize((
string) $search_year).
')';
252 if (!$user->hasRight(
'societe',
'client',
'voir')) {
253 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
256 $sql .=
" AND recep.fk_soc = ".((int) $socid);
258 $sql .= $db->order($sortfield, $sortorder);
265 $totalofrecords =
'';
267 $result = $db->query($sql);
268 $totalofrecords = $db->num_rows($result);
271 $sql .= $db->plimit($limit + 1, $offset);
273 $result = $db->query($sql);
275 $num = $db->num_rows($result);
277 $option =
'&id='.$object->id;
279 if ($limit > 0 && $limit !=
$conf->liste_limit) {
280 $option .=
'&limit='.((int) $limit);
282 if (!empty($search_month)) {
283 $option .=
'&search_month='.urlencode((
string) ($search_month));
285 if (!empty($search_year)) {
286 $option .=
'&search_year='.urlencode((
string) ($search_year));
289 print
'<form method="post" action="'.$_SERVER [
'PHP_SELF'].
'?id='.
$object->id.
'" name="search_form">'.
"\n";
290 print
'<input type="hidden" name="token" value="'.newToken().
'">';
291 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
292 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
295 print_barre_liste($langs->trans(
"Receptions"), $page, $_SERVER[
"PHP_SELF"], $option, $sortfield, $sortorder,
'', $num, $totalofrecords,
'', 0,
'',
'', $limit, 0, 0, 1);
298 $option .=
'&page='.urlencode((
string) ($page));
301 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
302 print
'<div class="divsearchfield">';
303 print $langs->trans(
'Period').
' ('.$langs->trans(
"DateCreation").
') - ';
304 print $langs->trans(
'Month').
':<input class="flat" type="text" size="4" name="search_month" value="'.$search_month.
'"> ';
305 print $langs->trans(
'Year').
':'.$formother->selectyear($search_year ? (
string) $search_year :
'-1',
'search_year', 1, 20, 5);
306 print
'<div style="vertical-align: middle; display: inline-block">';
307 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")).
'">';
308 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")).
'">';
314 print
'<div class="div-table-responsive">';
315 print
'<table class="tagtable liste listwithfilterbefore" width="100%">';
316 print
'<tr class="liste_titre">';
319 print_liste_field_titre(
"SupplierCode", $_SERVER[
"PHP_SELF"],
"s.code_fournisseur",
"", $option,
'', $sortfield, $sortorder);
320 print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"recep.date_creation",
"", $option,
'align="center"', $sortfield, $sortorder);
321 print_liste_field_titre(
"Qty", $_SERVER[
"PHP_SELF"],
"d.qty",
"", $option,
'align="center"', $sortfield, $sortorder);
323 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"recep.fk_statut",
"", $option,
'align="right"', $sortfield, $sortorder);
327 while ($i < min($num, $limit)) {
328 $objp = $db->fetch_object($result);
330 $total_ht += $objp->total_ht;
331 $total_qty += $objp->qty;
333 $receptionstatic->id = $objp->facid;
334 $receptionstatic->ref = $objp->ref;
335 $societestatic->fetch($objp->socid);
338 print
'<tr class="oddeven">';
340 print $receptionstatic->getNomUrl(1);
342 print
'<td>'.$societestatic->getNomUrl(1).
'</td>';
343 print
"<td>".$objp->code_fournisseur.
"</td>\n";
344 print
'<td class="center">';
345 print
dol_print_date($db->jdate($objp->date_creation),
'dayhour').
"</td>";
346 print
'<td class="center">'.$objp->qty.
"</td>\n";
348 print
'<td align="right">'.$receptionstatic->LibStatut($objp->statut, 5).
'</td>';
353 print
'<tr class="liste_total">';
355 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
357 print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
359 print
'<td colspan="2"></td>';
361 print
'<td class="center">'.$total_qty.
'</td>';
367 dol_print_error($db);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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 receptions.
Class to manage third parties objects (customers, suppliers, prospects...)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
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.