27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
33 $langs->loadLangs(array(
'mrp',
'products',
'companies'));
39 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
40 $fieldtype = (!empty($ref) ?
'ref' :
'rowid');
42 $socid = $user->socid;
46 $hookmanager->initHooks(array(
'productstatsmo'));
49 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
50 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53 if (empty($page) || $page == -1) {
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
63 $sortfield =
"c.date_valid";
66 $result =
restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
73 $staticmo =
new Mo($db);
74 $staticmoligne =
new MoLine($db);
78 if ($id > 0 || !empty($ref)) {
80 $result = $product->fetch($id, $ref);
84 $parameters = array(
'id'=>$id);
85 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $product, $action);
90 llxHeader(
"",
"", $langs->trans(
"CardProduct".$product->type));
94 $titre = $langs->trans(
"CardProduct".$product->type);
98 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $product, $action);
99 print $hookmanager->resPrint;
104 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
107 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
113 print
'<div class="fichecenter">';
115 print
'<div class="underbanner clearboth"></div>';
116 print
'<table class="border tableforfield" width="100%">';
123 print
'<div style="clear:both"></div>';
131 $sql .=
" sum(".$db->ifsql(
"cd.role='toconsume'",
"cd.qty", 0).
') as nb_toconsume,';
132 $sql .=
" sum(".$db->ifsql(
"cd.role='consumed'",
"cd.qty", 0).
') as nb_consumed,';
133 $sql .=
" sum(".$db->ifsql(
"cd.role='toproduce'",
"cd.qty", 0).
') as nb_toproduce,';
134 $sql .=
" sum(".$db->ifsql(
"cd.role='produced'",
"cd.qty", 0).
') as nb_produced,';
135 $sql .=
" c.rowid as rowid, c.ref, c.date_valid, c.status";
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mrp_mo as c";
138 $sql .=
", ".MAIN_DB_PREFIX.
"mrp_production as cd";
139 $sql .=
" WHERE c.rowid = cd.fk_mo";
140 $sql .=
" AND c.entity IN (".getEntity(
'mo').
")";
141 $sql .=
" AND cd.fk_product = ".((int) $product->id);
143 $sql .=
" AND s.rowid = ".((int) $socid);
145 $sql .=
" GROUP BY c.rowid, c.ref, c.date_valid, c.status";
147 $sql .= $db->order($sortfield, $sortorder);
154 $totalofrecords =
'';
155 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
156 $result = $db->query($sql);
157 $totalofrecords = $db->num_rows($result);
160 $sql .= $db->plimit($limit + 1, $offset);
162 $result = $db->query($sql);
164 $num = $db->num_rows($result);
166 $option =
'&id='.$product->id;
168 if ($limit > 0 && $limit != $conf->liste_limit) {
169 $option .=
'&limit='.urlencode($limit);
171 if (!empty($search_month)) {
172 $option .=
'&search_month='.urlencode($search_month);
174 if (!empty($search_year)) {
175 $option .=
'&search_year='.urlencode($search_year);
178 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$product->id.
'" name="search_form">'.
"\n";
179 print
'<input type="hidden" name="token" value="'.newToken().
'">';
180 if (!empty($sortfield)) {
181 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
183 if (!empty($sortorder)) {
184 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
187 print_barre_liste($langs->trans(
"MOs"), $page, $_SERVER[
"PHP_SELF"], $option, $sortfield, $sortorder,
'', $num, $totalofrecords,
'', 0,
'',
'', $limit, 0, 0, 1);
190 $option .=
'&page='.urlencode($page);
194 print
'<div class="div-table-responsive">';
195 print
'<table class="tagtable liste listwithfilterbefore" width="100%">';
197 print
'<tr class="liste_titre">';
198 print_liste_field_titre(
"Ref", $_SERVER[
"PHP_SELF"],
"c.rowid",
"",
"&id=".$product->id,
'', $sortfield, $sortorder);
200 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"c.date_valid",
"",
"&id=".$product->id,
'align="center"', $sortfield, $sortorder);
202 print_liste_field_titre(
"ToConsume", $_SERVER[
"PHP_SELF"],
"",
"",
"&id=".$product->id,
'', $sortfield, $sortorder,
'center ');
203 print_liste_field_titre(
"QtyAlreadyConsumed", $_SERVER[
"PHP_SELF"],
"",
"",
"&id=".$product->id,
'', $sortfield, $sortorder,
'center ');
204 print_liste_field_titre(
"QtyToProduce", $_SERVER[
"PHP_SELF"],
"",
"",
"&id=".$product->id,
'', $sortfield, $sortorder,
'center ');
205 print_liste_field_titre(
"QtyAlreadyProduced", $_SERVER[
"PHP_SELF"],
"",
"",
"&id=".$product->id,
'', $sortfield, $sortorder,
'center ');
206 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"b.status",
"",
"&id=".$product->id,
'', $sortfield, $sortorder,
'right ');
209 $motmp =
new Mo($db);
212 while ($i < min($num, $limit)) {
213 $objp = $db->fetch_object($result);
215 $motmp->id = $objp->rowid;
216 $motmp->ref = $objp->ref;
217 $motmp->status = $objp->status;
219 print
'<tr class="oddeven">';
221 print $motmp->getNomUrl(1,
'production');
223 print
"<td align=\"center\">";
224 print
dol_print_date($db->jdate($objp->date_valid),
'dayhour').
"</td>";
227 print
'<td class="center">'.($objp->nb_toconsume > 0 ? $objp->nb_toconsume :
'').
'</td>';
228 print
'<td class="center">'.($objp->nb_consumed > 0 ? $objp->nb_consumed :
'').
'</td>';
229 print
'<td class="center">'.($objp->nb_toproduce > 0 ? $objp->nb_toproduce :
'').
'</td>';
230 print
'<td class="center">'.($objp->nb_produced > 0 ? $objp->nb_produced :
'').
'</td>';
232 print
'<td class="right">'.$motmp->getLibStatut(2).
'</td>';
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.
const TYPE_SERVICE
Service.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
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.
print_barre_liste($titre, $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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
product_prepare_head($object)
Prepare array with list of tabs.
show_stats_for_company($product, $socid)
Show stats for company.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.