25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/product/inventory/class/inventory.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
35 $langs->loadLangs(array(
"stocks",
"other"));
37 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
38 $massaction =
GETPOST(
'massaction',
'alpha');
39 $show_files =
GETPOST(
'show_files',
'int');
40 $confirm =
GETPOST(
'confirm',
'alpha');
41 $cancel =
GETPOST(
'cancel',
'alpha');
42 $toselect =
GETPOST(
'toselect',
'array');
43 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
44 $backtopage =
GETPOST(
'backtopage',
'alpha');
45 $optioncss =
GETPOST(
'optioncss',
'aZ');
51 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
52 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
55 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
59 $offset = $limit * $page;
60 $pageprev = $page - 1;
61 $pagenext = $page + 1;
68 $diroutputmassaction =
null;
69 $hookmanager->initHooks(array(
'inventorylist'));
71 $extrafields->fetch_name_optionals_label($object->table_element);
72 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
76 reset($object->fields);
77 $sortfield =
"t.".key($object->fields);
84 $search_all =
GETPOST(
'search_all',
'alphanohtml');
86 foreach ($object->fields as $key => $val) {
87 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
88 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
90 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
91 $search[$key.
'_dtstart'] =
dol_mktime(0, 0, 0,
GETPOST(
'search_'.$key.
'_dtstartmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtstartday',
'int'),
GETPOST(
'search_'.$key.
'_dtstartyear',
'int'));
92 $search[$key.
'_dtend'] =
dol_mktime(23, 59, 59,
GETPOST(
'search_'.$key.
'_dtendmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtendday',
'int'),
GETPOST(
'search_'.$key.
'_dtendyear',
'int'));
95 $searchCategoryProductOperator = 0;
97 $searchCategoryProductOperator =
GETPOST(
'search_category_product_operator',
'int');
98 } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
99 $searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
101 $searchCategoryProductList =
GETPOST(
'search_category_product_list',
'array');
104 $fieldstosearchall = array();
105 foreach ($object->fields as $key => $val) {
106 if (!empty($val[
'searchall'])) {
107 $fieldstosearchall[
't.'.$key] = $val[
'label'];
112 $arrayfields = array();
113 foreach ($object->fields as $key => $val) {
115 if (!empty($val[
'visible'])) {
116 $visible = (int)
dol_eval($val[
'visible'], 1);
117 $arrayfields[
't.'.$key] = array(
118 'label'=>$val[
'label'],
119 'checked'=>(($visible < 0) ? 0 : 1),
120 'enabled'=>(abs($visible) != 3 &&
dol_eval($val[
'enabled'], 1)),
121 'position'=>$val[
'position'],
122 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
127 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
132 $permissiontoread = $user->rights->stock->lire;
133 $permissiontoadd = $user->rights->stock->creer;
134 $permissiontodelete = $user->rights->stock->supprimer;
138 if ($user->socid > 0) {
142 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
145 $result =
restrictedArea($user,
'stock', 0,
'',
'inventory_advance');
153 if (
GETPOST(
'cancel',
'alpha')) {
157 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
161 $parameters = array();
162 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
167 if (empty($reshook)) {
169 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
172 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
173 foreach ($object->fields as $key => $val) {
175 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
176 $search[$key.
'_dtstart'] =
'';
177 $search[$key.
'_dtend'] =
'';
180 $searchCategoryProductList = array();
182 $search_array_options = array();
184 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
185 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
190 $objectclass =
'Inventory';
191 $objectlabel =
'Inventory';
192 $uploaddir = $conf->stock->dir_output;
193 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
206 $title = $langs->trans(
'Inventories');
216 $sql .= $object->getFieldList(
't');
218 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
219 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
220 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
224 $parameters = array();
225 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
226 $sql .= $hookmanager->resPrint;
227 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
231 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
232 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
233 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
236 $parameters = array();
237 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
238 $sql .= $hookmanager->resPrint;
239 if ($object->ismultientitymanaged == 1) {
240 $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
242 $sql .=
" WHERE 1 = 1";
244 foreach ($search as $key => $val) {
245 if (array_key_exists($key, $object->fields)) {
246 if ($key ==
'status' && $search[$key] == -1) {
249 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
250 if ((strpos($object->fields[$key][
'type'],
'integer:') === 0) || (strpos($object->fields[$key][
'type'],
'sellist:') === 0) || !empty($object->fields[$key][
'arrayofkeyval'])) {
251 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty($object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0', $object->fields[$key][
'arrayofkeyval'])))) {
256 if ($search[$key] !=
'') {
257 $sql .=
natural_search(
"t.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
260 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
261 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
262 if (preg_match(
'/^(date|timestamp|datetime)/', $object->fields[$columnName][
'type'])) {
263 if (preg_match(
'/_dtstart$/', $key)) {
264 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
266 if (preg_match(
'/_dtend$/', $key)) {
267 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
278 if (!empty($searchCategoryProductList)) {
279 $searchCategoryProductSqlList = array();
280 $listofcategoryid =
'';
281 foreach ($searchCategoryProductList as $searchCategoryProduct) {
282 if (intval($searchCategoryProduct) == -2) {
283 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck WHERE p.rowid = ck.fk_product)";
284 } elseif (intval($searchCategoryProduct) > 0) {
285 if ($searchCategoryProductOperator == 0) {
286 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
288 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
292 if ($listofcategoryid) {
293 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
295 if ($searchCategoryProductOperator == 1) {
296 if (!empty($searchCategoryProductSqlList)) {
297 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
300 if (!empty($searchCategoryProductSqlList)) {
301 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
306 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
308 $parameters = array();
309 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
310 $sql .= $hookmanager->resPrint;
331 $nbtotalofrecords =
'';
334 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
335 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
336 $resql = $db->query($sqlforcount);
338 $objforcount = $db->fetch_object($resql);
339 $nbtotalofrecords = $objforcount->nbtotalofrecords;
344 if (($page * $limit) > $nbtotalofrecords) {
352 $sql .= $db->order($sortfield, $sortorder);
354 $sql .= $db->plimit($limit + 1, $offset);
357 $resql = $db->query(
$sql);
363 $num = $db->num_rows($resql);
366 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
367 $obj = $db->fetch_object($resql);
369 header(
"Location: ".DOL_URL_ROOT.
'/inventory/card.php?id='.$id);
379 $arrayofselected = is_array($toselect) ? $toselect : array();
383 $param .=
'&mode='.urlencode($mode);
385 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
386 $param .=
'&contextpage='.urlencode($contextpage);
388 if ($limit > 0 && $limit != $conf->liste_limit) {
389 $param .=
'&limit='.((int) $limit);
391 foreach ($search as $key => $val) {
392 if (is_array($search[$key])) {
393 foreach ($search[$key] as $skey) {
395 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
398 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
399 $param .=
'&search_'.$key.
'month='.((int)
GETPOST(
'search_'.$key.
'month',
'int'));
400 $param .=
'&search_'.$key.
'day='.((int)
GETPOST(
'search_'.$key.
'day',
'int'));
401 $param .=
'&search_'.$key.
'year='.((int)
GETPOST(
'search_'.$key.
'year',
'int'));
402 } elseif ($search[$key] !=
'') {
403 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
406 if ($optioncss !=
'') {
407 $param .=
'&optioncss='.urlencode($optioncss);
409 foreach ($searchCategoryProductList as $searchCategoryProduct) {
410 $param .=
"&search_category_product_list[]=".urlencode($searchCategoryProduct);
413 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
415 $parameters = array();
416 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
417 $param .= $hookmanager->resPrint;
420 $arrayofmassactions = array(
426 if (!empty($permissiontodelete)) {
427 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
429 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
430 $arrayofmassactions = array();
432 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
434 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
435 if ($optioncss !=
'') {
436 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
438 print
'<input type="hidden" name="token" value="'.newToken().
'">';
439 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
440 print
'<input type="hidden" name="action" value="list">';
441 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
442 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
443 print
'<input type="hidden" name="page" value="'.$page.
'">';
444 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
445 print
'<input type="hidden" name="page_y" value="">';
446 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
449 $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'));
450 $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'));
452 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/inventory/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
454 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
457 $topicmail =
"Information";
458 $modelmail =
"inventory";
460 $trackid =
'stockinv'.$object->id;
461 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
465 foreach ($fieldstosearchall as $key => $val) {
466 $fieldstosearchall[$key] = $langs->trans($val);
467 $setupstring .= $key.
"=".$val.
";";
469 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
470 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
479 if (!empty($conf->global->MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS) &&
isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
480 $moreforfilter .=
'<div class="divsearchfield">';
481 $tmptitle = $langs->transnoentities(
'ProductsCategoriesShort');
482 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
483 $categoriesProductArr =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'', 64, 0, 1);
484 $categoriesProductArr[-2] =
'- '.$langs->trans(
'NotCategorized').
' -';
485 $moreforfilter .=
Form::multiselectarray(
'search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0,
'minwidth300', 0, 0,
'',
'category', $tmptitle);
486 $moreforfilter .=
' <input type="checkbox" class="valignmiddle" id="search_category_product_operator" name="search_category_product_operator" value="1"'.($searchCategoryProductOperator == 1 ?
' checked="checked"' :
'').
'/>';
487 $moreforfilter .=
$form->textwithpicto(
'', $langs->trans(
'UseOrOperatorForCategories') .
' : ' . $tmptitle, 1,
'help',
'', 0, 2,
'tooltip_cat_pro');
488 $moreforfilter .=
'</div>';
491 $parameters = array();
492 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
493 if (empty($reshook)) {
494 $moreforfilter .= $hookmanager->resPrint;
496 $moreforfilter = $hookmanager->resPrint;
499 if (!empty($moreforfilter)) {
500 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
501 print $moreforfilter;
502 $parameters = array();
503 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
504 print $hookmanager->resPrint;
508 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
509 $selectedfields = ($mode !=
'kanban' ?
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
510 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
512 print
'<div class="div-table-responsive">';
513 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
518 print
'<tr class="liste_titre_filter">';
521 print
'<td class="liste_titre center maxwidthsearch">';
522 $searchpicto =
$form->showFilterButtons(
'left');
526 foreach ($object->fields as $key => $val) {
527 $searchkey = empty($search[$key]) ?
'' : $search[$key];
528 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
529 if ($key ==
'status') {
530 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
531 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
532 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
533 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
534 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
535 } 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'])) {
536 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
538 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
539 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
540 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
541 print
$form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100'.($key ==
'status' ?
' search_status width100 onrightofpage' :
''), 1);
542 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
543 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
544 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
545 print
'<div class="nowrap">';
546 print
$form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
548 print
'<div class="nowrap">';
549 print
$form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
551 } elseif ($key ==
'lang') {
552 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
554 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth150 maxwidth200', 2);
556 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
562 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
565 $parameters = array(
'arrayfields'=>$arrayfields);
566 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
567 print $hookmanager->resPrint;
570 print
'<td class="liste_titre center maxwidthsearch">';
571 $searchpicto =
$form->showFilterButtons();
577 $totalarray = array();
578 $totalarray[
'nbfield'] = 0;
582 print
'<tr class="liste_titre">';
585 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
586 $totalarray[
'nbfield']++;
588 foreach ($object->fields as $key => $val) {
589 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
590 if ($key ==
'status') {
591 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
592 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
593 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
594 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
595 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
596 } 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'])) {
597 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
599 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
600 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
601 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
''), 0, (empty($val[
'helplist']) ?
'' : $val[
'helplist'])).
"\n";
602 $totalarray[
'nbfield']++;
606 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
608 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
609 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
610 print $hookmanager->resPrint;
613 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
614 $totalarray[
'nbfield']++;
620 $needToFetchEachLine = 0;
621 if (isset($extrafields->attributes[$object->table_element][
'computed']) && is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0) {
622 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val) {
623 if (!is_null($val) && preg_match(
'/\$object/', $val)) {
624 $needToFetchEachLine++;
632 $savnbfield = $totalarray[
'nbfield'];
633 $totalarray = array();
634 $totalarray[
'nbfield'] = 0;
635 $imaxinloop = ($limit ? min($num, $limit) : $num);
636 while ($i < $imaxinloop) {
637 $obj = $db->fetch_object($resql);
643 $object->setVarsFromFetchObj($obj);
645 if ($mode ==
'kanban') {
647 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
648 print
'<div class="box-flex-container kanban">';
651 if ($massactionbutton || $massaction) {
653 if (in_array($object->id, $arrayofselected)) {
657 print $object->getKanbanView(
'', array(
'selected' => in_array($object->id, $arrayofselected)));
658 if ($i == ($imaxinloop - 1)) {
665 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
668 print
'<td class="nowrap center">';
669 if ($massactionbutton || $massaction) {
671 if (in_array($object->id, $arrayofselected)) {
674 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
678 $totalarray[
'nbfield']++;
681 foreach ($object->fields as $key => $val) {
682 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
683 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
684 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
685 } elseif ($key ==
'status') {
686 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
689 if (in_array($val[
'type'], array(
'timestamp'))) {
690 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
691 } elseif ($key ==
'ref') {
692 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
695 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'rowid',
'status')) && empty($val[
'arrayofkeyval'])) {
696 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
699 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
700 print
'<td'.($cssforfield ?
' class="'.$cssforfield.(preg_match(
'/tdoverflow/', $cssforfield) ?
' classfortooltip' :
'').
'"' :
'');
701 if (preg_match(
'/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
702 print
' title="'.dol_escape_htmltag($object->$key).
'"';
705 if ($key ==
'status') {
706 print $object->getLibStatut(5);
707 } elseif ($key ==
'rowid') {
708 print $object->showOutputField($val, $key, $object->id,
'');
710 print $object->showOutputField($val, $key, $object->$key,
'');
714 $totalarray[
'nbfield']++;
716 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
718 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
720 if (!isset($totalarray[
'val'])) {
721 $totalarray[
'val'] = array();
723 if (!isset($totalarray[
'val'][
't.'.$key])) {
724 $totalarray[
'val'][
't.'.$key] = 0;
726 $totalarray[
'val'][
't.'.$key] += $object->$key;
731 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
733 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
734 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
735 print $hookmanager->resPrint;
738 print
'<td class="nowrap center">';
739 if ($massactionbutton || $massaction) {
741 if (in_array($object->id, $arrayofselected)) {
744 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
748 $totalarray[
'nbfield']++;
759 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
765 foreach ($arrayfields as $key => $val) {
766 if (!empty($val[
'checked'])) {
770 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
776 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
777 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
778 print $hookmanager->resPrint;
780 print
'</table>'.
"\n";
783 print
'</form>'.
"\n";