dolibarr 24.0.0-beta
mo_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
4 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
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';
42// load mrp libraries
43require_once __DIR__.'/class/mo.class.php';
44if (isModEnabled('category')) {
45 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
47}
48
49// Load translation files required by the page
50$langs->loadLangs(array("mrp", "other"));
51
52// Get parameters
53$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
54$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
55$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
56$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
57$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
58$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
59$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
60$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
61$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
62$mode = GETPOST('mode', 'alpha');
63$groupby = GETPOST('groupby', 'aZ09'); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut'
64
65$id = GETPOSTINT('id');
66
67// Load variable for pagination
68$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
69$sortfield = GETPOST('sortfield', 'aZ09comma');
70$sortorder = GETPOST('sortorder', 'aZ09comma');
71$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
72$also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0);
73$changeDate = GETPOST('change_date', 'alpha');
74
75//Data request for date
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');
81
82if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
83 // If $page is not defined, or '' or -1 or if we click on clear filters
84 $page = 0;
85}
86$offset = $limit * $page;
87$pageprev = $page - 1;
88$pagenext = $page + 1;
89//if (! $sortfield) $sortfield="p.date_fin";
90//if (! $sortorder) $sortorder="DESC";
91
92// Initialize a technical objects
93$object = new Mo($db);
94$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
95$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
96
97// Fetch optionals attributes and labels
98$extrafields->fetch_name_optionals_label($object->table_element);
99
100$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
101
102$search_option = GETPOST('search_option', 'alphanohtml');
103
104// Default sort order (if not yet defined by previous GETPOST)
105if (!$sortfield) {
106 $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition.
107}
108if (!$sortorder) {
109 $sortorder = "ASC";
110}
111
112// Initialize array of search criteria
113$search_all = trim(GETPOST('search_all', 'alphanohtml'));
114$searchCategoryMoOperator = 0;
115if (GETPOSTISSET('formfilteraction')) {
116 $searchCategoryMoOperator = GETPOSTINT('search_category_mo_operator');
117} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
118 $searchCategoryMoOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
119}
120$searchCategoryMoList = GETPOST('search_category_mo_list', 'array:int');
121$search = array();
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);
129 } else {
130 $search_status = '';
131 }
132 }
133 $search[$key] = $search_status;
134 } elseif (GETPOST('search_'.$key, 'alpha') !== '') {
135 $search[$key] = GETPOST('search_'.$key, 'alpha');
136 }
137 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
138 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
139 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
140 }
141}
142// List of fields to search into when doing a "search in all"
143$fieldstosearchall = array();
144foreach ($object->fields as $key => $val) {
145 if (!empty($val['searchall'])) {
146 $fieldstosearchall['t.'.$key] = $val['label'];
147 }
148}
149
150// Definition of array of fields for columns
151$tableprefix = 't';
152$arrayfields = array();
153foreach ($object->fields as $key => $val) {
154 // If $val['visible']==0, then we never show the field
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'] : ''
163 );
164 }
165
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'] : ''
174 );
175 }
176}
177// Extra fields
178include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
179
180$object->fields = dol_sort_array($object->fields, 'position');
181$arrayfields = dol_sort_array($arrayfields, 'position');
182
183$permissiontoread = $user->hasRight('mrp', 'read');
184$permissiontoadd = $user->hasRight('mrp', 'write');
185$permissiontodelete = $user->hasRight('mrp', 'delete');
186
187// Security check
188if ($user->socid > 0) {
190}
191$result = restrictedArea($user, 'mrp');
192
193
194/*
195 * Actions
196 */
197
198if (GETPOST('cancel', 'alpha')) {
199 $action = 'list';
200 $massaction = '';
201}
202if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
203 $massaction = '';
204}
205
206$parameters = array('arrayfields' => &$arrayfields);
207$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
208if ($reshook < 0) {
209 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
210}
211
212if (empty($reshook)) {
213 // Selection of new fields
214 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
215
216 // Purge search criteria
217 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
218 foreach ($object->fields as $key => $val) {
219 $search[$key] = '';
220 if ($key == 'status') {
221 $search[$key] = -1;
222 }
223 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
224 $search[$key.'_dtstart'] = '';
225 $search[$key.'_dtend'] = '';
226 }
227 }
228 $search_all = '';
229 $searchCategoryMoOperator = 0;
230 $searchCategoryMoList = array();
231 $toselect = array();
232 $search_array_options = array();
233 }
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')) {
236 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
237 }
238
239 // Mass actions
240 $objectclass = 'Mo';
241 $objectlabel = 'Mo';
242 $uploaddir = $conf->mrp->dir_output;
243 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
244 $objMo = new Mo($db);
245
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;
254 }
255 } else {
256 $objMo->status = Mo::STATUS_CANCELED;
257 }
258 if ($objMo->update($user)) {
259 setEventMessages($langs->trans('CancelMoValidated', $objMo->ref), null, 'mesgs');
260 } else {
261 setEventMessages($langs->trans('ErrorCancelMo', $objMo->ref), null, 'errors');
262 }
263 } else {
264 setEventMessages($langs->trans('ErrorObjectMustHaveStatusValidatedToBeCanceled', $objMo->ref), null, 'errors');
265 }
266 }
267 }
268 }
269 }
270
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);
274
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';
282 setEventMessages($langs->trans($errorKey, $objMo->ref), null, 'errors');
283 continue;
284 }
285 if (!empty($changeDate)) {
286 if ($action == 'changedatestart_confirm') { // Test on permission not required
287 if (empty($objMo->date_end_planned) || $newDate < $objMo->date_end_planned) {
288 $objMo->date_start_planned = $newDate;
289 } else {
290 setEventMessages($langs->trans('ErrorModifyMoDateStart', $objMo->ref), null, 'errors');
291 break;
292 }
293 } elseif ($action == 'changedateend_confirm') { // Test on permission not required
294 if ($newDate > $objMo->date_start_planned) {
295 $objMo->date_end_planned = $newDate;
296 } else {
297 setEventMessages($langs->trans('ErrorModifyMoDateEnd', $objMo->ref), null, 'errors');
298 break;
299 }
300 }
301 if ($objMo->update($user)) {
302 setEventMessages($langs->trans('ModifyMoDate', $objMo->ref), null, 'mesgs');
303 } else {
304 setEventMessages($langs->trans('ErrorModifyMoDate', $objMo->ref), null, 'errors');
305 }
306 } else {
307 setEventMessages($langs->trans('ErrorEmptyChangeDate'), null, 'errors');
308 break;
309 }
310 }
311 }
312 }
313 }
314 }
315}
316
317
318
319/*
320 * View
321 */
322
323$form = new Form($db);
324
325$now = dol_now();
326
327$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
328$title = $langs->trans('ListOfManufacturingOrders');
329$morejs = array();
330$morecss = array();
331
332
333// Build and execute select
334// --------------------------------------------------------------------
335$sql = "SELECT ";
336$sql .= " ".$object->getFieldList('t');
337// Add fields from extrafields
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 : "");
341 }
342}
343// Add fields from hooks
344$parameters = array();
345$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
346$sql .= $hookmanager->resPrint;
347$sql = preg_replace('/,\s*$/', '', $sql);
348
349$sqlfields = $sql; // $sql fields to remove for count total
350
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)";
354}
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";
358// Add table from hooks
359$parameters = array();
360$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
361$sql .= $hookmanager->resPrint;
362if ($object->ismultientitymanaged == 1) {
363 $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
364} else {
365 $sql .= " WHERE 1 = 1";
366}
367
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)))) {
372 continue;
373 }
374
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;
383 }
384 }
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];
390 }
391
392 if (!empty($status_to_search)) {
393 $sql .= " AND t.status IN (".$db->sanitize(implode(',', array_unique($status_to_search))).")";
394 }
395
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]))) {
397 $sql .= " AND (t.date_end_planned < '".$db->idate(dol_now() - getWarningDelay('mrp', 'progress'))."')";
398 }
399 continue;
400 }
401
402 if ($key == 'fk_parent_line' && $search[$key] != '') {
403 $sql .= natural_search('moparent.ref', $search[$key], 0);
404 continue;
405 }
406
407 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
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'])))) {
410 $search[$key] = '';
411 }
412 $mode_search = 2;
413 }
414 if ($search[$key] != '') {
415 $sql .= natural_search("t.".$db->sanitize($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
416 }
417 } else {
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])."'";
423 }
424 if (preg_match('/_dtend$/', $key)) {
425 $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'";
426 }
427 }
428 }
429 }
430}
431
432
433if ($search_all) {
434 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
435}
436
437// Search for tag/category ($searchCategoryMoList is an array of ID)
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).")";
447 } else {
448 $listofcategoryid .= ($listofcategoryid ? ', ' : '') . ((int) $searchCategoryMo);
449 }
450 }
451 }
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)."))";
454 }
455 if ($searchCategoryMoOperator == 1) {
456 if (!empty($searchCategoryMoSqlList)) {
457 $sql .= " AND (".implode(' OR ', $searchCategoryMoSqlList).")";
458 }
459 } else {
460 if (!empty($searchCategoryMoSqlList)) {
461 $sql .= " AND (".implode(' AND ', $searchCategoryMoSqlList).")";
462 }
463 }
464}
465
466
467
468//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
469// Add where from extra fields
470include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
471// Add where from hooks
472$parameters = array();
473$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
474$sql .= $hookmanager->resPrint;
475/* If a group by is required
476$sql.= " GROUP BY ";
477foreach($object->fields as $key => $val) {
478 $sql .= "t.".$db->sanitize($key).", ";
479}
480// Add fields from extrafields
481if (!empty($extrafields->attributes[$object->table_element]['label'])) {
482 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
483 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
484 }
485}
486// Add groupby from hooks
487$parameters=array();
488$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
489$sql.=$hookmanager->resPrint;
490$sql=preg_replace('/,\s*$/','', $sql);
491*/
492
493// Count total nb of records
494$nbtotalofrecords = '';
495if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
496 /* The fast and low memory method to get and count full list converts the sql into a sql count */
497 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
498 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
499 $resql = $db->query($sqlforcount);
500 if ($resql) {
501 $objforcount = $db->fetch_object($resql);
502 $nbtotalofrecords = $objforcount->nbtotalofrecords;
503 } else {
505 }
506
507 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
508 $page = 0;
509 $offset = 0;
510 }
511 $db->free($resql);
512}
513
514// Complete request and execute it with limit
515$sql .= $db->order($sortfield, $sortorder);
516if ($limit) {
517 $sql .= $db->plimit($limit + 1, $offset);
518}
519$resql = $db->query($sql);
520if (!$resql) {
522 exit;
523}
524
525$num = $db->num_rows($resql);
526
527// Direct jump if only one record found
528if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
529 $obj = $db->fetch_object($resql);
530 $id = $obj->rowid;
531 header("Location: ".dol_buildpath('/mrp/mo_card.php', 1).'?id='.((int) $id));
532 exit;
533}
534
535
536// Output page
537// --------------------------------------------------------------------
538
539llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist mod-mrp page-list');
540
541
542$arrayofselected = is_array($toselect) ? $toselect : array();
543
544$param = '';
545if (!empty($mode)) {
546 $param .= '&mode='.urlencode($mode);
547}
548if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
549 $param .= '&contextpage='.urlencode($contextpage);
550}
551if ($limit > 0 && $limit != $conf->liste_limit) {
552 $param .= '&limit='.((int) $limit);
553}
554if ($optioncss != '') {
555 $param .= '&optioncss='.urlencode($optioncss);
556}
557if ($groupby != '') {
558 $param .= '&groupby='.urlencode($groupby);
559}
560foreach ($search as $key => $val) {
561 if (is_array($search[$key])) {
562 foreach ($search[$key] as $skey) {
563 if ($skey != '') {
564 $param .= '&search_'.$key.'[]='.urlencode($skey);
565 }
566 }
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]);
573 }
574}
575if ($searchCategoryMoOperator == 1) {
576 $param .= '&search_category_mo_operator='.urlencode((string) ($searchCategoryMoOperator));
577}
578foreach ($searchCategoryMoList as $searchCategoryMo) {
579 $param .= '&search_category_mo_list[]='.urlencode($searchCategoryMo);
580}
581// Add $param from extra fields
582include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
583// Add $param from hooks
584$parameters = array('param' => &$param);
585$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
586$param .= $hookmanager->resPrint;
587
588// List of mass actions available
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"),
596 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
597);
598if (isModEnabled('category') && $permissiontoadd) {
599 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
600}
601if (!empty($permissiontodelete)) {
602 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
603}
604if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
605 $arrayofmassactions = array();
606}
607$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
608
609print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
610if ($optioncss != '') {
611 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
612}
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.'">';
622
623$newcardbutton = '';
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);
628
629print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
630
631// Add code for pre mass action (confirmation or email presend form)
632$topicmail = "SendMoRef";
633$modelmail = "mo";
634$objecttmp = new Mo($db);
635$trackid = 'mo'.$object->id;
636include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
637
638if ($massaction == 'precancel') {
639 $formquestion = array(
640 array(
641 'label' => $langs->trans('MoCancelConsumedAndProducedLines'),
642 'name' => 'alsoCancelConsumedAndProducedLines',
643 'type' => 'checkbox',
644 'value' => 0
645 ),
646 );
647
648 print $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'],
649 $langs->trans('CancelMo'),
650 $langs->trans('ConfirmCancelMo'),
651 'confirm_cancel', $formquestion,
652 1, 0, 200, 500, 1);
653}
654
655if ($massaction == 'predatestart') {
656 $formquestion = array(
657 array(
658 'type' => 'datetime',
659 'tdclass' => 'fieldrequired',
660 'name' => 'change_date',
661 'label' => $langs->trans('ModifyDateStart'),
662 'value' => -1),
663 );
664 print $form->formconfirm($_SERVER['PHP_SELF'],
665 $langs->trans('ConfirmMassChangeDateStart'),
666 $langs->trans('ConfirmMassChangeDateStartQuestion',
667 count($toselect)), 'changedatestart_confirm', $formquestion,
668 '', 0, 200, 500, 1);
669}
670
671if ($massaction == 'predateend') {
672 $formquestion = array(
673 array(
674 'type' => 'datetime',
675 'tdclass' => 'fieldrequired',
676 'name' => 'change_date',
677 'label' => $langs->trans('ModifyDateEnd'),
678 'value' => -1),
679 );
680 print $form->formconfirm($_SERVER['PHP_SELF'],
681 $langs->trans('ConfirmMassChangeDateEnd'),
682 $langs->trans('ConfirmMassChangeDateEndQuestion',
683 count($toselect)), 'changedateend_confirm', $formquestion,
684 '', 0, 200, 500, 1);
685}
686
687if ($search_all) {
688 foreach ($fieldstosearchall as $key => $val) {
689 $fieldstosearchall[$key] = $langs->trans($val);
690 }
691 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
692}
693
694$moreforfilter = '';
695/*$moreforfilter.='<div class="divsearchfield">';
696$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
697$moreforfilter.= '</div>';*/
698if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
699 $formcategory = new FormCategory($db);
700 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_MO, $searchCategoryMoList, 'minwidth300', $searchCategoryMoOperator ? $searchCategoryMoOperator : 0);
701}
702
703$parameters = array();
704$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
705if (empty($reshook)) {
706 $moreforfilter .= $hookmanager->resPrint;
707} else {
708 $moreforfilter = $hookmanager->resPrint;
709}
710
711if (!empty($moreforfilter)) {
712 print '<div class="liste_titre liste_titre_bydiv centpercent">';
713 print $moreforfilter;
714 print '</div>';
715}
716
717$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
718$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
719$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
720$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
721
722print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
723print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
724
725
726// Fields title search
727// --------------------------------------------------------------------
728print '<tr class="liste_titre_filter">';
729// Action column
730if ($conf->main_checkbox_left_column) {
731 print '<td class="liste_titre center maxwidthsearch">';
732 $searchpicto = $form->showFilterButtons('left');
733 print $searchpicto;
734 print '</td>';
735}
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';
748 }
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">';
753 print '</td>';
754 continue;
755 }
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, '', '', '');
760 } else {
761 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
762 }
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'));
770 print '</div>';
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'));
773 print '</div>';
774 }
775 print '</td>';
776 }
777}
778// Extra fields
779include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
780
781// Fields from hook
782$parameters = array('arrayfields' => $arrayfields);
783$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
784print $hookmanager->resPrint;
785// Action column
786if (!$conf->main_checkbox_left_column) {
787 print '<td class="liste_titre center maxwidthsearch">';
788 $searchpicto = $form->showFilterButtons();
789 print $searchpicto;
790 print '</td>';
791}
792print '</tr>'."\n";
793
794$totalarray = array();
795$totalarray['nbfield'] = 0;
796
797
798// Fields title label
799// --------------------------------------------------------------------
800print '<tr class="liste_titre">';
801// Action column
802if ($conf->main_checkbox_left_column) {
803 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
804 $totalarray['nbfield']++;
805}
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';
818 }
819 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
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";
823 } else {
824 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
825 }
826 $totalarray['nbfield']++;
827 }
828}
829// Extra fields
830include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
831// Hook fields
832$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
833$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
834print $hookmanager->resPrint;
835// Action column
836if (!$conf->main_checkbox_left_column) {
837 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
838 $totalarray['nbfield']++;
839}
840print '</tr>'."\n";
841
842
843// Detect if we need a fetch on each output line
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++; // There is at least one compute field that use $object
849 }
850 }
851}
852
853
854$bom = new BOM($db);
855$product = new Product($db);
856
857// Loop on record
858// --------------------------------------------------------------------
859$i = 0;
860$savnbfield = $totalarray['nbfield'];
861$totalarray = array();
862$totalarray['nbfield'] = 0;
863$imaxinloop = ($limit ? min($num, $limit) : $num);
864while ($i < $imaxinloop) {
865 $obj = $db->fetch_object($resql);
866 if (empty($obj)) {
867 break; // Should not happen
868 }
869
870 // Store properties in $object
871 $object->setVarsFromFetchObj($obj);
872
873
874 if ($mode == 'kanban' || $mode == 'kanbangroupby') {
875 if ($i == 0) {
876 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
877 print '<div class="box-flex-container kanban">';
878 }
879 //$object->type_id = $obj->type_id;
880
881 // TODO Use a cache on BOM
882 if ($obj->fk_bom > 0) {
883 $bom->fetch($obj->fk_bom);
884 }
885 if ($obj->fk_product > 0) {
886 $product->fetch($obj->fk_product);
887 }
888
889 // Output Kanban
890 $selected = -1;
891 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
892 $selected = 0;
893 if (in_array($object->id, $arrayofselected)) {
894 $selected = 1;
895 }
896 }
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)) {
899 print '</div>';
900 print '</td></tr>';
901 }
902 } else {
903 // Show line of result
904 $j = 0;
905 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
906
907 // Action column
908 if ($conf->main_checkbox_left_column) {
909 print '<td class="nowrap center">';
910 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
911 $selected = 0;
912 if (in_array($object->id, $arrayofselected)) {
913 $selected = 1;
914 }
915 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
916 }
917 print '</td>';
918 if (!$i) {
919 $totalarray['nbfield']++;
920 }
921 }
922 // Fields
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';
931 }
932
933 if (in_array($val['type'], array('timestamp'))) {
934 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
935 } elseif ($key == 'ref') {
936 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
937 }
938
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';
941 }
942
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).'"';
947 }
948 print '>';
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);
955 }
956 } elseif ($key == 'rowid') {
957 print $object->showOutputField($val, $key, (string) $object->id, '');
958 } else {
959 if ($val['type'] == 'html') {
960 print '<div class="small lineheightsmall twolinesmax-normallineheight">';
961 }
962 print $object->showOutputField($val, $key, (string) $object->$key, '');
963 if ($val['type'] == 'html') {
964 print '</div>';
965 }
966
967 if ($key == 'date_end_planned' && $object->hasDelay()) {
968 print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
969 }
970 }
971 print '</td>';
972 if (!$i) {
973 $totalarray['nbfield']++;
974 }
975 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
976 if (!$i) {
977 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
978 }
979 if (!isset($totalarray['val'])) {
980 $totalarray['val'] = array();
981 }
982 if (!isset($totalarray['val']['t.'.$key])) {
983 $totalarray['val']['t.'.$key] = 0;
984 }
985 $totalarray['val']['t.'.$key] += $object->$key;
986 }
987 }
988 }
989 // Extra fields
990 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
991 // Fields from hook
992 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
993 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
994 print $hookmanager->resPrint;
995
996 // Action column
997 if (!$conf->main_checkbox_left_column) {
998 print '<td class="nowrap center">';
999 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1000 $selected = 0;
1001 if (in_array($object->id, $arrayofselected)) {
1002 $selected = 1;
1003 }
1004 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1005 }
1006 print '</td>';
1007 if (!$i) {
1008 $totalarray['nbfield']++;
1009 }
1010 }
1011
1012 print '</tr>'."\n";
1013 }
1014 $i++;
1015}
1016
1017// Show total line
1018include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1019
1020
1021// If no record found
1022if ($num == 0) {
1023 $colspan = 1;
1024 foreach ($arrayfields as $key => $val) {
1025 if (!empty($val['checked'])) {
1026 $colspan++;
1027 }
1028 }
1029 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1030}
1031
1032
1033$db->free($resql);
1034
1035$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1036$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1037print $hookmanager->resPrint;
1038
1039print '</table>'."\n";
1040print '</div>'."\n";
1041
1042print '</form>'."\n";
1043
1044if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1045 $hidegeneratedfilelistifempty = 1;
1046 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1047 $hidegeneratedfilelistifempty = 0;
1048 }
1049
1050 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1051 $formfile = new FormFile($db);
1052
1053 // Show list of available documents
1054 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1055 $urlsource .= str_replace('&amp;', '&', $param);
1056
1057 $filedir = $diroutputmassaction;
1058 $genallowed = $permissiontoread;
1059 $delallowed = $permissiontoadd;
1060
1061 print $formfile->showdocuments('massfilesarea_mrp', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1062}
1063
1064// End of page
1065llxFooter();
1066$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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.
Definition wrapper.php:73
Class for BOM.
Definition bom.class.php:42
Class to manage forms for categories.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class for Mo.
Definition mo.class.php:35
Class to manage products or services.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.