29require
'../../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
45$langs->loadLangs(array(
'mrp',
'products',
'companies',
'productbatch'));
51$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
52$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
55 $socid = $user->socid;
59$hookmanager->initHooks(array(
'batchproductstatsmo'));
63$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
64$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
66if (empty($page) || $page == -1) {
69$offset = $limit * $page;
72if (empty($sortorder)) {
75if (empty($sortfield)) {
76 $sortfield =
"c.date_valid";
82if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
87if (!$user->hasRight(
'produit',
'lire')) {
96$staticmo =
new Mo($db);
97$staticmoligne =
new MoLine($db);
102if ($id > 0 || !empty($ref)) {
107 $tmp = explode(
'_', $ref);
111 $result =
$object->fetch($id, $objectid, $batch);
113 $parameters = array(
'id' => $id);
114 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $product, $action);
121 $title = $langs->trans(
'Batch').
" ".$shortlabel.
" - ".$langs->trans(
'Referers');
122 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
124 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-stock-stats_mo');
128 $titre = $langs->trans(
"CardProduct".
$object->type);
133 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $product, $action);
134 print $hookmanager->resPrint;
139 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
142 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
146 dol_banner_tab(
$object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
148 print
'<div class="fichecenter">';
150 print
'<div class="underbanner clearboth"></div>';
151 print
'<table class="border tableforfield" width="100%">';
154 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
155 $producttmp =
new Product($db);
156 $producttmp->fetch(
$object->fk_product);
157 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
163 print
'<table class="border centpercent tableforfield" width="100%">';
170 print
'<div class="clearboth"></div>';
179 $sql .=
" sum(".$db->ifsql(
"cd.role='consumed'",
"cd.qty", 0).
') as nb_consumed,';
181 $sql .=
" sum(".$db->ifsql(
"cd.role='produced'",
"cd.qty", 0).
') as nb_produced,';
182 $sql .=
" c.rowid as rowid, c.ref, c.date_valid, c.status";
184 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mrp_mo as c";
185 $sql .=
", ".MAIN_DB_PREFIX.
"mrp_production as cd";
186 $sql .=
" WHERE c.rowid = cd.fk_mo";
187 $sql .=
" AND c.entity IN (".getEntity(
'mo').
")";
188 $sql .=
" AND cd.batch = '".($db->escape(
$object->batch)).
"'";
189 if (!empty($search_month)) {
190 $sql .=
' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).
')';
192 if (!empty($search_year)) {
193 $sql .=
' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).
')';
196 $sql .=
" AND s.rowid = ".((int) $socid);
198 $sql .=
" GROUP BY c.rowid, c.ref, c.date_valid, c.status";
200 $sql .= $db->order($sortfield, $sortorder);
207 $totalofrecords =
'';
209 $result = $db->query($sql);
210 $totalofrecords = $db->num_rows($result);
213 $sql .= $db->plimit($limit + 1, $offset);
215 $result = $db->query($sql);
217 $num = $db->num_rows($result);
219 $option =
'&id='.$object->id;
221 if ($limit > 0 && $limit !=
$conf->liste_limit) {
222 $option .=
'&limit='.((int) $limit);
224 if (!empty($search_month)) {
225 $option .=
'&search_month='.urlencode((
string) ($search_month));
227 if (!empty($search_year)) {
228 $option .=
'&search_year='.urlencode((
string) ($search_year));
231 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" name="search_form">'.
"\n";
232 print
'<input type="hidden" name="token" value="'.newToken().
'">';
233 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
234 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
237 print_barre_liste($langs->trans(
"MOs"), $page, $_SERVER[
"PHP_SELF"], $option, $sortfield, $sortorder,
'', $num, $totalofrecords,
'', 0,
'',
'', $limit, 0, 0, 1);
240 $option .=
'&page='.urlencode((
string) ($page));
243 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
244 print
'<div class="divsearchfield">';
245 print $langs->trans(
'Period').
' ('.$langs->trans(
"DateCreation").
') - ';
246 print $langs->trans(
'Month').
':<input class="flat" type="text" size="4" name="search_month" value="'.$search_month.
'"> ';
247 print $langs->trans(
'Year').
':'.$formother->selectyear($search_year ? $search_year : - 1,
'search_year', 1, 20, 5);
248 print
'<div style="vertical-align: middle; display: inline-block">';
249 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")).
'">';
250 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")).
'">';
256 print
'<div class="div-table-responsive">';
257 print
'<table class="tagtable liste listwithfilterbefore" width="100%">';
259 print
'<tr class="liste_titre">';
263 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"c.date_valid",
"", $option.
"&id=".
$object->id,
'align="center"', $sortfield, $sortorder);
266 print_liste_field_titre(
"QtyAlreadyConsumed", $_SERVER[
"PHP_SELF"],
"",
"", $option.
"&id=".
$object->id,
'', $sortfield, $sortorder,
'center ');
268 print_liste_field_titre(
"QtyAlreadyProduced", $_SERVER[
"PHP_SELF"],
"",
"", $option.
"&id=".
$object->id,
'', $sortfield, $sortorder,
'center ');
272 $motmp =
new Mo($db);
274 $total_consumed = $total_produced = 0;
277 while ($i < min($num, $limit)) {
278 $objp = $db->fetch_object($result);
280 $motmp->id = $objp->rowid;
281 $motmp->ref = $objp->ref;
282 $motmp->status = $objp->status;
284 $total_consumed += $objp->nb_consumed;
285 $total_produced += $objp->nb_produced;
287 print
'<tr class="oddeven">';
289 print $motmp->getNomUrl(1,
'production');
291 print
"<td align=\"center\">";
292 print
dol_print_date($db->jdate($objp->date_valid),
'dayhour').
"</td>";
296 print
'<td class="center">'.($objp->nb_consumed > 0 ? $objp->nb_consumed :
'').
'</td>';
298 print
'<td class="center">'.($objp->nb_produced > 0 ? $objp->nb_produced :
'').
'</td>';
300 print
'<td class="right">'.$motmp->getLibStatut(2).
'</td>';
305 print
'<tr class="liste_total">';
307 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
309 print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
312 print
'<td class="center">'.$total_consumed.
'</td>';
313 print
'<td class="center">'.$total_produced.
'</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.
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.
dol_now($mode='auto')
Return date for now.
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.