28require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
43require_once __DIR__.
'/class/mo.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcategory.class.php';
50$langs->loadLangs(array(
"mrp",
"other"));
53$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
54$massaction =
GETPOST(
'massaction',
'alpha');
56$confirm =
GETPOST(
'confirm',
'alpha');
57$cancel =
GETPOST(
'cancel',
'alpha');
58$toselect =
GETPOST(
'toselect',
'array:int');
59$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
60$backtopage =
GETPOST(
'backtopage',
'alpha');
61$optioncss =
GETPOST(
'optioncss',
'aZ');
62$mode =
GETPOST(
'mode',
'alpha');
63$groupby =
GETPOST(
'groupby',
'aZ09');
69$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
70$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
72$also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
73$changeDate =
GETPOST(
'change_date',
'alpha');
76$year =
GETPOST(
'change_dateyear',
'int');
77$month =
GETPOST(
'change_datemonth',
'int');
78$day =
GETPOST(
'change_dateday',
'int');
79$hour =
GETPOST(
'change_datehour',
'int');
80$min =
GETPOST(
'change_datemin',
'int');
82if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
86$offset = $limit * $page;
94$diroutputmassaction =
$conf->mrp->dir_output.
'/temp/massgeneration/'.$user->id;
95$hookmanager->initHooks(array($contextpage));
98$extrafields->fetch_name_optionals_label(
$object->table_element);
100$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
102$search_option =
GETPOST(
'search_option',
'alphanohtml');
106 $sortfield =
"t.ref";
113$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
114$searchCategoryMoOperator = 0;
115if (GETPOSTISSET(
'formfilteraction')) {
116 $searchCategoryMoOperator =
GETPOSTINT(
'search_category_mo_operator');
120$searchCategoryMoList =
GETPOST(
'search_category_mo_list',
'array:int');
122foreach (
$object->fields as $key => $val) {
123 if ($key ==
'status' && GETPOSTISSET(
'search_status')) {
124 $search_status =
GETPOST(
'search_status',
'array:int');
125 if (empty($search_status) &&
GETPOST(
'search_status',
'alpha') !==
'') {
126 $search_status =
GETPOST(
'search_status',
'int');
127 if ($search_status !== -1) {
128 $search_status = array($search_status);
133 $search[$key] = $search_status;
134 } elseif (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
135 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
137 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
143$fieldstosearchall = array();
144foreach (
$object->fields as $key => $val) {
145 if (!empty($val[
'searchall'])) {
146 $fieldstosearchall[
't.'.$key] = $val[
'label'];
152$arrayfields = array();
153foreach (
$object->fields as $key => $val) {
155 if (!empty($val[
'visible'])) {
156 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
157 $arrayfields[$tableprefix.
'.'.$key] = array(
158 'label' => $val[
'label'],
159 'checked' => (($visible < 0) ?
'0' :
'1'),
160 'enabled' => (
string) (int) (abs($visible) != 3 && (bool)
dol_eval((
string) $val[
'enabled'], 1)),
161 'position' => $val[
'position'],
162 'help' => isset($val[
'help']) ? $val[
'help'] :
''
166 if ($key ==
'fk_parent_line') {
167 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
168 $arrayfields[$tableprefix.
'.'.$key] = array(
169 'label' => $val[
'label'],
170 'checked' => (($visible <= 0) ? 0 : 1),
171 'enabled' => (abs($visible) != 3 && (bool)
dol_eval((
string) $val[
'enabled'], 1)),
172 'position' => $val[
'position'],
173 'help' => isset($val[
'help']) ? $val[
'help'] :
''
178include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
183$permissiontoread = $user->hasRight(
'mrp',
'read');
184$permissiontoadd = $user->hasRight(
'mrp',
'write');
185$permissiontodelete = $user->hasRight(
'mrp',
'delete');
188if ($user->socid > 0) {
198if (
GETPOST(
'cancel',
'alpha')) {
202if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
206$parameters = array(
'arrayfields' => &$arrayfields);
207$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
212if (empty($reshook)) {
214 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
217 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
218 foreach (
$object->fields as $key => $val) {
220 if ($key ==
'status') {
223 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
224 $search[$key.
'_dtstart'] =
'';
225 $search[$key.
'_dtend'] =
'';
229 $searchCategoryMoOperator = 0;
230 $searchCategoryMoList = array();
232 $search_array_options = array();
234 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
235 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
242 $uploaddir =
$conf->mrp->dir_output;
243 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
244 $objMo =
new Mo(
$db);
246 if ($action ==
'confirm_cancel' && $confirm ==
'yes' && $permissiontoadd) {
247 if (!empty($toselect)) {
248 foreach ($toselect as $key => $idMo) {
249 if ($objMo->fetch($idMo)) {
250 if ($objMo->status == Mo::STATUS_VALIDATED || $objMo->status == Mo::STATUS_INPROGRESS) {
251 if ($also_cancel_consumed_and_produced_lines) {
252 if ($objMo->cancelConsumedAndProducedLines($user, 0,
true, 1)) {
253 $objMo->status = Mo::STATUS_CANCELED;
256 $objMo->status = Mo::STATUS_CANCELED;
258 if ($objMo->update($user)) {
259 setEventMessages($langs->trans(
'CancelMoValidated', $objMo->ref),
null,
'mesgs');
261 setEventMessages($langs->trans(
'ErrorCancelMo', $objMo->ref),
null,
'errors');
264 setEventMessages($langs->trans(
'ErrorObjectMustHaveStatusValidatedToBeCanceled', $objMo->ref),
null,
'errors');
271 if (($action ==
'changedatestart_confirm' || $action ==
'changedateend_confirm') && $permissiontoadd) {
272 if ($confirm ==
'yes') {
273 $newDate =
dol_mktime((
int) $hour, (
int) $min, (
int) 0, (
int) $month, (
int) $day, (
int) $year);
275 if (!empty($toselect)) {
276 foreach ($toselect as $key => $idMo) {
277 if ($objMo->fetch($idMo)) {
278 if (in_array($action, array(
'changedatestart_confirm',
'changedateend_confirm'),
true) && $objMo->status == Mo::STATUS_PRODUCED) {
279 $errorKey = $action ==
'changedatestart_confirm'
280 ?
'ErrorObjectMustNotBeFinishedToModifyDateStart'
281 :
'ErrorObjectMustNotBeFinishedToModifyDateEnd';
285 if (!empty($changeDate)) {
286 if ($action ==
'changedatestart_confirm') {
287 if (empty($objMo->date_end_planned) || $newDate < $objMo->date_end_planned) {
288 $objMo->date_start_planned = $newDate;
290 setEventMessages($langs->trans(
'ErrorModifyMoDateStart', $objMo->ref),
null,
'errors');
293 } elseif ($action ==
'changedateend_confirm') {
294 if ($newDate > $objMo->date_start_planned) {
295 $objMo->date_end_planned = $newDate;
297 setEventMessages($langs->trans(
'ErrorModifyMoDateEnd', $objMo->ref),
null,
'errors');
301 if ($objMo->update($user)) {
302 setEventMessages($langs->trans(
'ModifyMoDate', $objMo->ref),
null,
'mesgs');
304 setEventMessages($langs->trans(
'ErrorModifyMoDate', $objMo->ref),
null,
'errors');
327$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
328$title = $langs->trans(
'ListOfManufacturingOrders');
336$sql .=
" ".$object->getFieldList(
't');
338if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
339 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
340 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
"");
344$parameters = array();
345$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
346$sql .= $hookmanager->resPrint;
347$sql = preg_replace(
'/,\s*$/',
'', $sql);
351$sql .=
" FROM ".$db->prefix().$object->table_element.
" as t";
352if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
353 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
355$sql .=
" LEFT JOIN ".$db->prefix().
"mrp_production as lineparent ON t.fk_parent_line = lineparent.rowid";
356$sql .=
" LEFT JOIN ".$db->prefix().
"mrp_mo as moparent ON lineparent.fk_mo = moparent.rowid";
357$sql .=
" LEFT JOIN ".$db->prefix().
"product as p ON t.fk_product = p.rowid";
359$parameters = array();
360$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
361$sql .= $hookmanager->resPrint;
362if (
$object->ismultientitymanaged == 1) {
363 $sql .=
" WHERE t.entity IN (".getEntity(
$object->element, (
GETPOSTINT(
'search_current_entity') ? 0 : 1)).
")";
365 $sql .=
" WHERE 1 = 1";
368foreach ($search as $key => $val) {
369 if (array_key_exists($key,
$object->fields)) {
370 if ($key ==
'status') {
371 if ($search[$key] === -1 || (is_array($search[$key]) && (count($search[$key]) == 0 || (count($search[$key]) == 1 && reset($search[$key]) == -1)))) {
375 $status_to_search = array();
376 if (is_array($search[$key])) {
377 foreach ($search[$key] as $status_val) {
378 if ($status_val == -2) {
379 $status_to_search[] = $object::STATUS_VALIDATED;
380 $status_to_search[] = $object::STATUS_INPROGRESS;
381 } elseif ($status_val !==
'' && $status_val >= 0) {
382 $status_to_search[] = $status_val;
385 } elseif ($search[$key] == -2) {
386 $status_to_search[] = $object::STATUS_VALIDATED;
387 $status_to_search[] = $object::STATUS_INPROGRESS;
388 } elseif ($search[$key] !==
'' && $search[$key] >= 0) {
389 $status_to_search[] = $search[$key];
392 if (!empty($status_to_search)) {
393 $sql .=
" AND t.status IN (".$db->sanitize(implode(
',', array_unique($status_to_search))).
")";
396 if ($search_option ==
'late' && (in_array(-2, (array) $search[$key]) || in_array($object::STATUS_VALIDATED, (array) $search[$key]) || in_array($object::STATUS_INPROGRESS, (array) $search[$key]))) {
402 if ($key ==
'fk_parent_line' && $search[$key] !=
'') {
408 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
409 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
414 if ($search[$key] !=
'') {
415 $sql .=
natural_search(
"t.".
$db->sanitize($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
418 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
419 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
420 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
421 if (preg_match(
'/_dtstart$/', $key)) {
422 $sql .=
" AND t.".$db->sanitize($columnName).
" >= '".
$db->idate($search[$key]).
"'";
424 if (preg_match(
'/_dtend$/', $key)) {
425 $sql .=
" AND t.".$db->sanitize($columnName).
" <= '".
$db->idate($search[$key]).
"'";
434 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
438if (!empty($searchCategoryMoList)) {
439 $searchCategoryMoSqlList = array();
440 $listofcategoryid =
'';
441 foreach ($searchCategoryMoList as $searchCategoryMo) {
442 if (intval($searchCategoryMo) == -2) {
443 $searchCategoryMoSqlList[] =
"NOT EXISTS (SELECT ck.fk_mo FROM ".MAIN_DB_PREFIX.
"categorie_mo as ck WHERE t.rowid = ck.fk_mo)";
444 } elseif (intval($searchCategoryMo) > 0) {
445 if ($searchCategoryMoOperator == 0) {
446 $searchCategoryMoSqlList[] =
" EXISTS (SELECT ck.fk_mo FROM ".MAIN_DB_PREFIX.
"categorie_mo as ck WHERE t.rowid = ck.fk_mo AND ck.fk_categorie = ".((int) $searchCategoryMo).
")";
448 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') . ((
int) $searchCategoryMo);
452 if ($listofcategoryid) {
453 $searchCategoryMoSqlList[] =
" EXISTS (SELECT ck.fk_mo FROM ".MAIN_DB_PREFIX.
"categorie_mo as ck WHERE t.rowid = ck.fk_mo AND ck.fk_categorie IN (".
$db->sanitize($listofcategoryid).
"))";
455 if ($searchCategoryMoOperator == 1) {
456 if (!empty($searchCategoryMoSqlList)) {
457 $sql .=
" AND (".implode(
' OR ', $searchCategoryMoSqlList).
")";
460 if (!empty($searchCategoryMoSqlList)) {
461 $sql .=
" AND (".implode(
' AND ', $searchCategoryMoSqlList).
")";
470include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
472$parameters = array();
473$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
474$sql .= $hookmanager->resPrint;
494$nbtotalofrecords =
'';
497 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
498 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
499 $resql =
$db->query($sqlforcount);
501 $objforcount =
$db->fetch_object($resql);
502 $nbtotalofrecords = $objforcount->nbtotalofrecords;
507 if (($page * $limit) > (
int) $nbtotalofrecords) {
515$sql .=
$db->order($sortfield, $sortorder);
517 $sql .=
$db->plimit($limit + 1, $offset);
519$resql =
$db->query($sql);
525$num =
$db->num_rows($resql);
528if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
529 $obj =
$db->fetch_object($resql);
531 header(
"Location: ".
dol_buildpath(
'/mrp/mo_card.php', 1).
'?id='.((
int) $id));
539llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist mod-mrp page-list');
542$arrayofselected = is_array($toselect) ? $toselect : array();
546 $param .=
'&mode='.urlencode($mode);
548if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
549 $param .=
'&contextpage='.urlencode($contextpage);
551if ($limit > 0 && $limit !=
$conf->liste_limit) {
552 $param .=
'&limit='.((int) $limit);
554if ($optioncss !=
'') {
555 $param .=
'&optioncss='.urlencode($optioncss);
558 $param .=
'&groupby='.urlencode($groupby);
560foreach ($search as $key => $val) {
561 if (is_array($search[$key])) {
562 foreach ($search[$key] as $skey) {
564 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
567 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
568 $param .=
'&search_'.$key.
'month='.
GETPOSTINT(
'search_'.$key.
'month');
569 $param .=
'&search_'.$key.
'day='.
GETPOSTINT(
'search_'.$key.
'day');
570 $param .=
'&search_'.$key.
'year='.
GETPOSTINT(
'search_'.$key.
'year');
571 } elseif ($search[$key] !=
'') {
572 $param .=
'&search_'.$key.
'='.urlencode((
string) $search[$key]);
575if ($searchCategoryMoOperator == 1) {
576 $param .=
'&search_category_mo_operator='.urlencode((
string) ($searchCategoryMoOperator));
578foreach ($searchCategoryMoList as $searchCategoryMo) {
579 $param .=
'&search_category_mo_list[]='.urlencode($searchCategoryMo);
582include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
584$parameters = array(
'param' => &$param);
585$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
586$param .= $hookmanager->resPrint;
589$arrayofmassactions = array(
590 'validate'=>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
591 'precancel'=>
img_picto(
'',
'close_title',
'class="pictofixedwidth"').$langs->trans(
"Cancel"),
592 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
593 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
594 'predatestart'=>
img_picto(
'',
'object_calendar',
'class="pictofixedwidth"').$langs->trans(
"MoChangeDateStart"),
595 'predateend'=>
img_picto(
'',
'object_calendar',
'class="pictofixedwidth"').$langs->trans(
"MoChangeDateEnd"),
599 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
601if (!empty($permissiontodelete)) {
602 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
604if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
605 $arrayofmassactions = array();
607$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
609print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
610if ($optioncss !=
'') {
611 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
613print
'<input type="hidden" name="token" value="'.newToken().
'">';
614print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
615print
'<input type="hidden" name="action" value="list">';
616print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
617print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
618print
'<input type="hidden" name="page" value="'.$page.
'">';
619print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
620print
'<input type="hidden" name="page_y" value="">';
621print
'<input type="hidden" name="mode" value="'.$mode.
'">';
624$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'));
625$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'));
626$newcardbutton .= dolGetButtonTitleSeparator();
627$newcardbutton .= dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/mrp/mo_card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
629print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
632$topicmail =
"SendMoRef";
634$objecttmp =
new Mo(
$db);
635$trackid =
'mo'.$object->id;
636include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
638if ($massaction ==
'precancel') {
639 $formquestion = array(
641 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
642 'name' =>
'alsoCancelConsumedAndProducedLines',
643 'type' =>
'checkbox',
648 print $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'],
649 $langs->trans(
'CancelMo'),
650 $langs->trans(
'ConfirmCancelMo'),
651 'confirm_cancel', $formquestion,
655if ($massaction ==
'predatestart') {
656 $formquestion = array(
658 'type' =>
'datetime',
659 'tdclass' =>
'fieldrequired',
660 'name' =>
'change_date',
661 'label' => $langs->trans(
'ModifyDateStart'),
664 print $form->formconfirm($_SERVER[
'PHP_SELF'],
665 $langs->trans(
'ConfirmMassChangeDateStart'),
666 $langs->trans(
'ConfirmMassChangeDateStartQuestion',
667 count($toselect)),
'changedatestart_confirm', $formquestion,
671if ($massaction ==
'predateend') {
672 $formquestion = array(
674 'type' =>
'datetime',
675 'tdclass' =>
'fieldrequired',
676 'name' =>
'change_date',
677 'label' => $langs->trans(
'ModifyDateEnd'),
680 print $form->formconfirm($_SERVER[
'PHP_SELF'],
681 $langs->trans(
'ConfirmMassChangeDateEnd'),
682 $langs->trans(
'ConfirmMassChangeDateEndQuestion',
683 count($toselect)),
'changedateend_confirm', $formquestion,
688 foreach ($fieldstosearchall as $key => $val) {
689 $fieldstosearchall[$key] = $langs->trans($val);
691 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
698if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'read')) {
700 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_MO, $searchCategoryMoList,
'minwidth300', $searchCategoryMoOperator ? $searchCategoryMoOperator : 0);
703$parameters = array();
704$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
705if (empty($reshook)) {
706 $moreforfilter .= $hookmanager->resPrint;
708 $moreforfilter = $hookmanager->resPrint;
711if (!empty($moreforfilter)) {
712 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
713 print $moreforfilter;
717$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
718$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
719$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
720$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
722print
'<div class="div-table-responsive">';
723print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
728print
'<tr class="liste_titre_filter">';
730if (
$conf->main_checkbox_left_column) {
731 print
'<td class="liste_titre center maxwidthsearch">';
732 $searchpicto = $form->showFilterButtons(
'left');
736foreach (
$object->fields as $key => $val) {
737 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
738 if ($key ==
'status') {
739 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
740 } elseif ($key ==
'fk_parent_line') {
741 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
742 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
743 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
744 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
745 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
746 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
747 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
749 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
750 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').
'">';
751 if ($key ==
'fk_parent_line') {
752 print
'<input type="text" class="flat maxwidth75" name="search_fk_parent_line">';
756 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
757 if ($key ==
'status') {
758 $val[
'arrayofkeyval'][-2] = $langs->trans(
"StatusMrpValidated").
'+'.$langs->trans(
"StatusMrpProgress");
759 print $form->multiselectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) && $search[$key] !==
'' && $search[$key] != -1 ? (array) $search[$key] : array()), 0, 0,
'maxwidth100', 0, 0,
'',
'',
'');
761 print $form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100', 1);
763 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
764 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth125', 1);
765 } elseif (!preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
766 print
'<input type="text" class="flat maxwidth'.($val[
'type'] ==
'integer' ?
'50' :
'75').
'" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
767 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
768 print
'<div class="nowrap">';
769 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
771 print
'<div class="nowrap">';
772 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
779include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
782$parameters = array(
'arrayfields' => $arrayfields);
783$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
784print $hookmanager->resPrint;
786if (!
$conf->main_checkbox_left_column) {
787 print
'<td class="liste_titre center maxwidthsearch">';
788 $searchpicto = $form->showFilterButtons();
800print
'<tr class="liste_titre">';
802if (
$conf->main_checkbox_left_column) {
803 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
806foreach (
$object->fields as $key => $val) {
807 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
808 if ($key ==
'status') {
809 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
810 } elseif ($key ==
'fk_parent_line') {
811 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
812 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
813 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
814 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
815 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
816 } 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'])) {
817 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
819 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
820 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
821 if ($key ==
"fk_product") {
822 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
824 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
830include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
832$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
833$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
834print $hookmanager->resPrint;
836if (!
$conf->main_checkbox_left_column) {
837 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
844$needToFetchEachLine = 0;
845if (isset($extrafields->attributes[
$object->table_element][
'computed']) && is_array($extrafields->attributes[
$object->table_element][
'computed']) && count($extrafields->attributes[
$object->table_element][
'computed']) > 0) {
846 foreach ($extrafields->attributes[
$object->table_element][
'computed'] as $key => $val) {
847 if (!is_null($val) && preg_match(
'/\$object/', $val)) {
848 $needToFetchEachLine++;
863$imaxinloop = ($limit ? min($num, $limit) : $num);
864while ($i < $imaxinloop) {
865 $obj =
$db->fetch_object($resql);
871 $object->setVarsFromFetchObj($obj);
874 if ($mode ==
'kanban' || $mode ==
'kanbangroupby') {
876 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
877 print
'<div class="box-flex-container kanban">';
882 if ($obj->fk_bom > 0) {
883 $bom->fetch($obj->fk_bom);
885 if ($obj->fk_product > 0) {
886 $product->fetch($obj->fk_product);
891 if ($massactionbutton || $massaction) {
893 if (in_array(
$object->id, $arrayofselected)) {
897 print
$object->getKanbanView(
'', array(
'bom' => ($obj->fk_bom > 0 ? $bom : null),
'product' => ($obj->fk_product > 0 ? $product : null),
'selected' => $selected));
898 if ($i == ($imaxinloop - 1)) {
905 print
'<tr data-rowid="'.$object->id.
'" class="oddeven row-with-select">';
908 if (
$conf->main_checkbox_left_column) {
909 print
'<td class="nowrap center">';
910 if ($massactionbutton || $massaction) {
912 if (in_array(
$object->id, $arrayofselected)) {
915 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
923 foreach (
$object->fields as $key => $val) {
924 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
925 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
926 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
927 } elseif ($key ==
'status') {
928 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
929 } elseif ($key ==
'fk_parent_line') {
930 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
933 if (in_array($val[
'type'], array(
'timestamp'))) {
934 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
935 } elseif ($key ==
'ref') {
936 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
939 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'])) {
940 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
943 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
944 print
'<td'.($cssforfield ?
' class="'.$cssforfield.((preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) ?
' classfortooltip' :
'').
'"' :
'');
945 if (preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) {
946 print
' title="'.dolPrintHTMLForAttribute((
string)
$object->$key).
'"';
949 if ($key ==
'status') {
950 print
$object->getLibStatut(5);
951 } elseif ($key ==
'fk_parent_line') {
952 $moparent =
$object->getMoParent();
953 if (is_object($moparent)) {
954 print $moparent->getNomUrl(1);
956 } elseif ($key ==
'rowid') {
957 print
$object->showOutputField($val, $key, (
string)
$object->id,
'');
959 if ($val[
'type'] ==
'html') {
960 print
'<div class="small lineheightsmall twolinesmax-normallineheight">';
962 print
$object->showOutputField($val, $key, (
string)
$object->$key,
'');
963 if ($val[
'type'] ==
'html') {
967 if ($key ==
'date_end_planned' &&
$object->hasDelay()) {
968 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
975 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
979 if (!isset($totalarray[
'val'])) {
982 if (!isset($totalarray[
'val'][
't.'.$key])) {
990 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
992 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
993 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
994 print $hookmanager->resPrint;
997 if (!
$conf->main_checkbox_left_column) {
998 print
'<td class="nowrap center">';
999 if ($massactionbutton || $massaction) {
1001 if (in_array(
$object->id, $arrayofselected)) {
1004 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1018include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1024 foreach ($arrayfields as $key => $val) {
1025 if (!empty($val[
'checked'])) {
1029 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1035$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1036$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1037print $hookmanager->resPrint;
1039print
'</table>'.
"\n";
1042print
'</form>'.
"\n";
1044if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
1045 $hidegeneratedfilelistifempty = 1;
1046 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1047 $hidegeneratedfilelistifempty = 0;
1050 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
1054 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1055 $urlsource .= str_replace(
'&',
'&', $param);
1057 $filedir = $diroutputmassaction;
1058 $genallowed = $permissiontoread;
1059 $delallowed = $permissiontoadd;
1061 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(! $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.
dol_now($mode='gmt')
Return date for now.
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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.
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.
isModEnabled($module)
Is Dolibarr module enabled.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.