28require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36require_once __DIR__.
'/class/mo.class.php';
47$langs->loadLangs(array(
"mrp",
"other"));
50$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
51$massaction =
GETPOST(
'massaction',
'alpha');
53$confirm =
GETPOST(
'confirm',
'alpha');
54$cancel =
GETPOST(
'cancel',
'alpha');
55$toselect =
GETPOST(
'toselect',
'array');
56$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
57$backtopage =
GETPOST(
'backtopage',
'alpha');
58$optioncss =
GETPOST(
'optioncss',
'aZ');
59$mode =
GETPOST(
'mode',
'alpha');
60$groupby =
GETPOST(
'groupby',
'aZ09');
66$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
67$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
69$also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
70$changeDate =
GETPOST(
'change_date',
'alpha');
73$year =
GETPOST(
'change_dateyear',
'int');
74$month =
GETPOST(
'change_datemonth',
'int');
75$day =
GETPOST(
'change_dateday',
'int');
76$hour =
GETPOST(
'change_datehour',
'int');
77$min =
GETPOST(
'change_datemin',
'int');
79if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
83$offset = $limit * $page;
92$diroutputmassaction =
$conf->mrp->dir_output.
'/temp/massgeneration/'.$user->id;
93$hookmanager->initHooks(array($contextpage));
96$extrafields->fetch_name_optionals_label(
$object->table_element);
98$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
100$search_option =
GETPOST(
'search_option',
'alphanohtml');
104 $sortfield =
"t.ref";
111$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
113foreach (
$object->fields as $key => $val) {
114 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
115 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
117 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
123$fieldstosearchall = array();
124foreach (
$object->fields as $key => $val) {
125 if (!empty($val[
'searchall'])) {
126 $fieldstosearchall[
't.'.$key] = $val[
'label'];
132$arrayfields = array();
133foreach (
$object->fields as $key => $val) {
135 if (!empty($val[
'visible'])) {
136 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
137 $arrayfields[$tableprefix.
'.'.$key] = array(
138 'label' => $val[
'label'],
139 'checked' => (($visible < 0) ?
'0' :
'1'),
140 'enabled' => (string) (int) (abs($visible) != 3 && (bool)
dol_eval((string) $val[
'enabled'], 1)),
141 'position' => $val[
'position'],
142 'help' => isset($val[
'help']) ? $val[
'help'] :
''
146 if ($key ==
'fk_parent_line') {
147 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
148 $arrayfields[$tableprefix.
'.'.$key] = array(
149 'label' => $val[
'label'],
150 'checked' => (($visible <= 0) ? 0 : 1),
151 'enabled' => (abs($visible) != 3 && (bool)
dol_eval((string) $val[
'enabled'], 1)),
152 'position' => $val[
'position'],
153 'help' => isset($val[
'help']) ? $val[
'help'] :
''
158include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
163$permissiontoread = $user->hasRight(
'mrp',
'read');
164$permissiontoadd = $user->hasRight(
'mrp',
'write');
165$permissiontodelete = $user->hasRight(
'mrp',
'delete');
168if ($user->socid > 0) {
178if (
GETPOST(
'cancel',
'alpha')) {
182if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
186$parameters = array(
'arrayfields' => &$arrayfields);
187$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
192if (empty($reshook)) {
194 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
197 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
198 foreach (
$object->fields as $key => $val) {
200 if ($key ==
'status') {
203 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
204 $search[$key.
'_dtstart'] =
'';
205 $search[$key.
'_dtend'] =
'';
210 $search_array_options = array();
212 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
213 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
220 $uploaddir =
$conf->mrp->dir_output;
221 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
222 $objMo =
new Mo($db);
224 if ($action ==
'confirm_cancel' && $confirm ==
'yes' && $permissiontoadd) {
225 if (!empty($toselect)) {
226 foreach ($toselect as $key => $idMo) {
227 if ($objMo->fetch($idMo)) {
228 if ($objMo->status == Mo::STATUS_VALIDATED || $objMo->status == Mo::STATUS_INPROGRESS) {
229 if ($also_cancel_consumed_and_produced_lines) {
230 if ($objMo->cancelConsumedAndProducedLines($user, 0,
true, 1)) {
231 $objMo->status = Mo::STATUS_CANCELED;
234 $objMo->status = Mo::STATUS_CANCELED;
236 if ($objMo->update($user)) {
237 setEventMessages($langs->trans(
'CancelMoValidated', $objMo->ref),
null,
'mesgs');
239 setEventMessages($langs->trans(
'ErrorCancelMo', $objMo->ref),
null,
'errors');
242 setEventMessages($langs->trans(
'ErrorObjectMustHaveStatusValidatedToBeCanceled', $objMo->ref),
null,
'errors');
249 if (($action ==
'changedatestart_confirm' || $action ==
'changedateend_confirm') && $permissiontoadd) {
250 if ($confirm ==
'yes') {
251 $newDate =
dol_mktime((
int) $hour, (
int) $min, (
int) 0, (
int) $month, (
int) $day, (
int) $year);
253 if (!empty($toselect)) {
254 foreach ($toselect as $key => $idMo) {
255 if ($objMo->fetch($idMo)) {
256 if (in_array($action, array(
'changedatestart_confirm',
'changedateend_confirm'),
true) && $objMo->status == Mo::STATUS_PRODUCED) {
257 $errorKey = $action ==
'changedatestart_confirm'
258 ?
'ErrorObjectMustNotBeFinishedToModifyDateStart'
259 :
'ErrorObjectMustNotBeFinishedToModifyDateEnd';
263 if (!empty($changeDate)) {
264 if ($action ==
'changedatestart_confirm') {
265 if (empty($objMo->date_end_planned) || $newDate < $objMo->date_end_planned) {
266 $objMo->date_start_planned = $newDate;
268 setEventMessages($langs->trans(
'ErrorModifyMoDateStart', $objMo->ref),
null,
'errors');
271 } elseif ($action ==
'changedateend_confirm') {
272 if ($newDate > $objMo->date_start_planned) {
273 $objMo->date_end_planned = $newDate;
275 setEventMessages($langs->trans(
'ErrorModifyMoDateEnd', $objMo->ref),
null,
'errors');
279 if ($objMo->update($user)) {
280 setEventMessages($langs->trans(
'ModifyMoDate', $objMo->ref),
null,
'mesgs');
282 setEventMessages($langs->trans(
'ErrorModifyMoDate', $objMo->ref),
null,
'errors');
301$form =
new Form($db);
305$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
306$title = $langs->trans(
'ListOfManufacturingOrders');
314$sql .=
" ".$object->getFieldList(
't');
316if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
317 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
318 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
"");
322$parameters = array();
323$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
324$sql .= $hookmanager->resPrint;
325$sql = preg_replace(
'/,\s*$/',
'', $sql);
329$sql .=
" FROM ".$db->prefix().$object->table_element.
" as t";
330if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
331 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
333$sql .=
" LEFT JOIN ".$db->prefix().
"mrp_production as lineparent ON t.fk_parent_line = lineparent.rowid";
334$sql .=
" LEFT JOIN ".$db->prefix().
"mrp_mo as moparent ON lineparent.fk_mo = moparent.rowid";
335$sql .=
" LEFT JOIN ".$db->prefix().
"product as p ON t.fk_product = p.rowid";
337$parameters = array();
338$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
339$sql .= $hookmanager->resPrint;
340if (
$object->ismultientitymanaged == 1) {
341 $sql .=
" WHERE t.entity IN (".getEntity(
$object->element, (
GETPOSTINT(
'search_current_entity') ? 0 : 1)).
")";
343 $sql .=
" WHERE 1 = 1";
346foreach ($search as $key => $val) {
347 if (array_key_exists($key,
$object->fields)) {
348 if ($key ==
'status' && $search[$key] == -1) {
351 if ($key ==
'status' && $search[$key] == -2) {
352 $sql .=
" AND (t.status IN (".$db->sanitize($object::STATUS_VALIDATED.
",".$object::STATUS_INPROGRESS).
"))";
353 if ($search_option ==
'late') {
354 $sql .=
" AND (t.date_end_planned < '".$db->idate(
dol_now() -
$conf->mrp->progress->warning_delay).
"')";
358 if ($key ==
'fk_parent_line' && $search[$key] !=
'') {
362 if ($key ==
'status') {
368 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
369 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
374 if ($search[$key] !=
'') {
375 $sql .=
natural_search(
"t.".$db->sanitize($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
378 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
379 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
380 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
381 if (preg_match(
'/_dtstart$/', $key)) {
382 $sql .=
" AND t.".$db->sanitize($columnName).
" >= '".$db->idate($search[$key]).
"'";
384 if (preg_match(
'/_dtend$/', $key)) {
385 $sql .=
" AND t.".$db->sanitize($columnName).
" <= '".$db->idate($search[$key]).
"'";
394 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
401include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
403$parameters = array();
404$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
405$sql .= $hookmanager->resPrint;
425$nbtotalofrecords =
'';
428 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
429 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
430 $resql = $db->query($sqlforcount);
432 $objforcount = $db->fetch_object($resql);
433 $nbtotalofrecords = $objforcount->nbtotalofrecords;
438 if (($page * $limit) > $nbtotalofrecords) {
446$sql .= $db->order($sortfield, $sortorder);
448 $sql .= $db->plimit($limit + 1, $offset);
450$resql = $db->query($sql);
456$num = $db->num_rows($resql);
459if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
460 $obj = $db->fetch_object($resql);
462 header(
"Location: ".
dol_buildpath(
'/mrp/mo_card.php', 1).
'?id='.((
int) $id));
470llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist mod-mrp page-list');
473$arrayofselected = is_array($toselect) ? $toselect : array();
477 $param .=
'&mode='.urlencode($mode);
479if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
480 $param .=
'&contextpage='.urlencode($contextpage);
482if ($limit > 0 && $limit !=
$conf->liste_limit) {
483 $param .=
'&limit='.((int) $limit);
485if ($optioncss !=
'') {
486 $param .=
'&optioncss='.urlencode($optioncss);
489 $param .=
'&groupby='.urlencode($groupby);
491foreach ($search as $key => $val) {
492 if (is_array($search[$key])) {
493 foreach ($search[$key] as $skey) {
495 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
498 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
499 $param .=
'&search_'.$key.
'month='.
GETPOSTINT(
'search_'.$key.
'month');
500 $param .=
'&search_'.$key.
'day='.
GETPOSTINT(
'search_'.$key.
'day');
501 $param .=
'&search_'.$key.
'year='.
GETPOSTINT(
'search_'.$key.
'year');
502 } elseif ($search[$key] !=
'') {
503 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
507include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
509$parameters = array(
'param' => &$param);
510$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
511$param .= $hookmanager->resPrint;
514$arrayofmassactions = array(
515 'validate'=>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
516 'precancel'=>
img_picto(
'',
'close_title',
'class="pictofixedwidth"').$langs->trans(
"Cancel"),
517 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
518 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
519 'predatestart'=>
img_picto(
'',
'object_calendar',
'class="pictofixedwidth"').$langs->trans(
"MoChangeDateStart"),
520 'predateend'=>
img_picto(
'',
'object_calendar',
'class="pictofixedwidth"').$langs->trans(
"MoChangeDateEnd"),
523if (!empty($permissiontodelete)) {
524 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
526if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
527 $arrayofmassactions = array();
529$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
531print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
532if ($optioncss !=
'') {
533 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
535print
'<input type="hidden" name="token" value="'.newToken().
'">';
536print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
537print
'<input type="hidden" name="action" value="list">';
538print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
539print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
540print
'<input type="hidden" name="page" value="'.$page.
'">';
541print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
542print
'<input type="hidden" name="page_y" value="">';
543print
'<input type="hidden" name="mode" value="'.$mode.
'">';
546$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss' =>
'reposition'));
547$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
549$newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/mrp/mo_card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
551print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
554$topicmail =
"SendMoRef";
556$objecttmp =
new Mo($db);
557$trackid =
'mo'.$object->id;
558include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
560if ($massaction ==
'precancel') {
561 $formquestion = array(
563 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
564 'name' =>
'alsoCancelConsumedAndProducedLines',
565 'type' =>
'checkbox',
570 print $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'],
571 $langs->trans(
'CancelMo'),
572 $langs->trans(
'ConfirmCancelMo'),
573 'confirm_cancel', $formquestion,
577if ($massaction ==
'predatestart') {
578 $formquestion = array(
580 'type' =>
'datetime',
581 'tdclass' =>
'fieldrequired',
582 'name' =>
'change_date',
583 'label' => $langs->trans(
'ModifyDateStart'),
586 print $form->formconfirm($_SERVER[
'PHP_SELF'],
587 $langs->trans(
'ConfirmMassChangeDateStart'),
588 $langs->trans(
'ConfirmMassChangeDateStartQuestion',
589 count($toselect)),
'changedatestart_confirm', $formquestion,
593if ($massaction ==
'predateend') {
594 $formquestion = array(
596 'type' =>
'datetime',
597 'tdclass' =>
'fieldrequired',
598 'name' =>
'change_date',
599 'label' => $langs->trans(
'ModifyDateEnd'),
602 print $form->formconfirm($_SERVER[
'PHP_SELF'],
603 $langs->trans(
'ConfirmMassChangeDateEnd'),
604 $langs->trans(
'ConfirmMassChangeDateEndQuestion',
605 count($toselect)),
'changedateend_confirm', $formquestion,
610 foreach ($fieldstosearchall as $key => $val) {
611 $fieldstosearchall[$key] = $langs->trans($val);
613 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
621$parameters = array();
622$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
623if (empty($reshook)) {
624 $moreforfilter .= $hookmanager->resPrint;
626 $moreforfilter = $hookmanager->resPrint;
629if (!empty($moreforfilter)) {
630 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
631 print $moreforfilter;
635$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
636$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
637$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
638$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
640print
'<div class="div-table-responsive">';
641print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
646print
'<tr class="liste_titre_filter">';
649 print
'<td class="liste_titre center maxwidthsearch">';
650 $searchpicto = $form->showFilterButtons(
'left');
654foreach (
$object->fields as $key => $val) {
655 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
656 if ($key ==
'status') {
657 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
658 } elseif ($key ==
'fk_parent_line') {
659 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
660 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
661 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
662 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
663 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
664 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
665 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
667 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
668 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').
'">';
669 if ($key ==
'fk_parent_line') {
670 print
'<input type="text" class="flat maxwidth75" name="search_fk_parent_line">';
674 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
675 if ($key ==
'status') {
676 $val[
'arrayofkeyval'][-2] = $langs->trans(
"StatusMrpValidated").
'+'.$langs->trans(
"StatusMrpProgress");
678 print $form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100', 1);
679 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
680 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth125', 1);
681 } elseif (!preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
682 print
'<input type="text" class="flat maxwidth'.($val[
'type'] ==
'integer' ?
'50' :
'75').
'" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
683 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
684 print
'<div class="nowrap">';
685 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
687 print
'<div class="nowrap">';
688 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
695include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
698$parameters = array(
'arrayfields' => $arrayfields);
699$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
700print $hookmanager->resPrint;
703 print
'<td class="liste_titre center maxwidthsearch">';
704 $searchpicto = $form->showFilterButtons();
716print
'<tr class="liste_titre">';
719 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
722foreach (
$object->fields as $key => $val) {
723 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
724 if ($key ==
'status') {
725 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
726 } elseif ($key ==
'fk_parent_line') {
727 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
728 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
729 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
730 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
731 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
732 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'id',
'rowid',
'ref',
'status')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
733 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
735 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
736 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
737 if ($key ==
"fk_product") {
738 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
740 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
746include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
748$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
749$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
750print $hookmanager->resPrint;
753 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
760$needToFetchEachLine = 0;
761if (isset($extrafields->attributes[
$object->table_element][
'computed']) && is_array($extrafields->attributes[
$object->table_element][
'computed']) && count($extrafields->attributes[
$object->table_element][
'computed']) > 0) {
762 foreach ($extrafields->attributes[
$object->table_element][
'computed'] as $key => $val) {
763 if (!is_null($val) && preg_match(
'/\$object/', $val)) {
764 $needToFetchEachLine++;
779$imaxinloop = ($limit ? min($num, $limit) : $num);
780while ($i < $imaxinloop) {
781 $obj = $db->fetch_object($resql);
787 $object->setVarsFromFetchObj($obj);
790 if ($mode ==
'kanban' || $mode ==
'kanbangroupby') {
792 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
793 print
'<div class="box-flex-container kanban">';
798 if ($obj->fk_bom > 0) {
799 $bom->fetch($obj->fk_bom);
801 if ($obj->fk_product > 0) {
802 $product->fetch($obj->fk_product);
807 if ($massactionbutton || $massaction) {
809 if (in_array(
$object->id, $arrayofselected)) {
813 print
$object->getKanbanView(
'', array(
'bom' => ($obj->fk_bom > 0 ? $bom : null),
'product' => ($obj->fk_product > 0 ? $product : null),
'selected' => $selected));
814 if ($i == ($imaxinloop - 1)) {
821 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
825 print
'<td class="nowrap center">';
826 if ($massactionbutton || $massaction) {
828 if (in_array(
$object->id, $arrayofselected)) {
831 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
839 foreach (
$object->fields as $key => $val) {
840 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
841 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
842 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
843 } elseif ($key ==
'status') {
844 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
845 } elseif ($key ==
'fk_parent_line') {
846 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
849 if (in_array($val[
'type'], array(
'timestamp'))) {
850 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
851 } elseif ($key ==
'ref') {
852 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
855 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'id',
'rowid',
'ref',
'status')) && empty($val[
'arrayofkeyval'])) {
856 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
859 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
860 print
'<td'.($cssforfield ?
' class="'.$cssforfield.((preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) ?
' classfortooltip' :
'').
'"' :
'');
861 if (preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) {
862 print
' title="'.dolPrintHTMLForAttribute((
string)
$object->$key).
'"';
865 if ($key ==
'status') {
866 print
$object->getLibStatut(5);
867 } elseif ($key ==
'fk_parent_line') {
868 $moparent =
$object->getMoParent();
869 if (is_object($moparent)) {
870 print $moparent->getNomUrl(1);
872 } elseif ($key ==
'rowid') {
873 print
$object->showOutputField($val, $key, (
string)
$object->id,
'');
875 if ($val[
'type'] ==
'html') {
876 print
'<div class="small lineheightsmall twolinesmax-normallineheight">';
878 print
$object->showOutputField($val, $key, (
string)
$object->$key,
'');
879 if ($val[
'type'] ==
'html') {
883 if ($key ==
'date_end_planned' &&
$object->hasDelay()) {
884 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
891 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
895 if (!isset($totalarray[
'val'])) {
898 if (!isset($totalarray[
'val'][
't.'.$key])) {
906 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
908 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
909 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
910 print $hookmanager->resPrint;
914 print
'<td class="nowrap center">';
915 if ($massactionbutton || $massaction) {
917 if (in_array(
$object->id, $arrayofselected)) {
920 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
934include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
940 foreach ($arrayfields as $key => $val) {
941 if (!empty($val[
'checked'])) {
945 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
951$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
952$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
953print $hookmanager->resPrint;
955print
'</table>'.
"\n";
960if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
961 $hidegeneratedfilelistifempty = 1;
962 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
963 $hidegeneratedfilelistifempty = 0;
966 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
970 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
971 $urlsource .= str_replace(
'&',
'&', $param);
973 $filedir = $diroutputmassaction;
974 $genallowed = $permissiontoread;
975 $delallowed = $permissiontoadd;
977 print $formfile->showdocuments(
'massfilesarea_mrp',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.