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') :
'inventorylist';
44 $backtopage =
GETPOST(
'backtopage',
'alpha');
45 $optioncss =
GETPOST(
'optioncss',
'aZ');
50 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
51 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
58 $offset = $limit * $page;
59 $pageprev = $page - 1;
60 $pagenext = $page + 1;
67 $diroutputmassaction =
null;
68 $hookmanager->initHooks(array(
'inventorylist'));
70 $extrafields->fetch_name_optionals_label($object->table_element);
71 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
75 reset($object->fields);
76 $sortfield =
"t.".key($object->fields);
83 $search_all =
GETPOST(
'search_all',
'alphanohtml');
85 foreach ($object->fields as $key => $val) {
86 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
87 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
89 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
90 $search[$key.
'_dtstart'] =
dol_mktime(0, 0, 0,
GETPOST(
'search_'.$key.
'_dtstartmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtstartday',
'int'),
GETPOST(
'search_'.$key.
'_dtstartyear',
'int'));
91 $search[$key.
'_dtend'] =
dol_mktime(23, 59, 59,
GETPOST(
'search_'.$key.
'_dtendmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtendday',
'int'),
GETPOST(
'search_'.$key.
'_dtendyear',
'int'));
94 $searchCategoryProductOperator = 0;
96 $searchCategoryProductOperator =
GETPOST(
'search_category_product_operator',
'int');
97 } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
98 $searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
100 $searchCategoryProductList =
GETPOST(
'search_category_product_list',
'array');
103 $fieldstosearchall = array();
104 foreach ($object->fields as $key => $val) {
105 if (!empty($val[
'searchall'])) {
106 $fieldstosearchall[
't.'.$key] = $val[
'label'];
111 $arrayfields = array();
112 foreach ($object->fields as $key => $val) {
114 if (!empty($val[
'visible'])) {
115 $visible = (int)
dol_eval($val[
'visible'], 1, 1,
'1');
116 $arrayfields[
't.'.$key] = array(
117 'label'=>$val[
'label'],
118 'checked'=>(($visible < 0) ? 0 : 1),
119 'enabled'=>($visible != 3 &&
dol_eval($val[
'enabled'], 1, 1,
'1')),
120 'position'=>$val[
'position'],
121 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
126 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
131 $permissiontoread = $user->rights->stock->lire;
132 $permissiontoadd = $user->rights->stock->creer;
133 $permissiontodelete = $user->rights->stock->supprimer;
137 if ($user->socid > 0) {
141 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
144 $result =
restrictedArea($user,
'stock', 0,
'',
'inventory_advance');
152 if (
GETPOST(
'cancel',
'alpha')) {
156 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
160 $parameters = array();
161 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
166 if (empty($reshook)) {
168 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
171 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
172 foreach ($object->fields as $key => $val) {
174 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
175 $search[$key.
'_dtstart'] =
'';
176 $search[$key.
'_dtend'] =
'';
179 $searchCategoryProductList = array();
181 $search_array_options = array();
183 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
184 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
189 $objectclass =
'Inventory';
190 $objectlabel =
'Inventory';
191 $uploaddir = $conf->stock->dir_output;
192 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
207 $title = $langs->trans(
'ListOfInventories');
215 $sql .= $object->getFieldList(
't');
217 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
218 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
219 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
223 $parameters = array();
224 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
225 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
226 $sql = preg_replace(
'/,\s*$/',
'', $sql);
230 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
231 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
232 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
235 $parameters = array();
236 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
237 $sql .= $hookmanager->resPrint;
238 if ($object->ismultientitymanaged == 1) {
239 $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
241 $sql .=
" WHERE 1 = 1";
243 foreach ($search as $key => $val) {
244 if (array_key_exists($key, $object->fields)) {
245 if ($key ==
'status' && $search[$key] == -1) {
248 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
249 if ((strpos($object->fields[$key][
'type'],
'integer:') === 0) || (strpos($object->fields[$key][
'type'],
'sellist:') === 0) || !empty($object->fields[$key][
'arrayofkeyval'])) {
250 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty($object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0', $object->fields[$key][
'arrayofkeyval'])))) {
255 if ($search[$key] !=
'') {
256 $sql .=
natural_search($key, $search[$key], (($key ==
'status') ? 2 : $mode_search));
259 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
260 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
261 if (preg_match(
'/^(date|timestamp|datetime)/', $object->fields[$columnName][
'type'])) {
262 if (preg_match(
'/_dtstart$/', $key)) {
263 $sql .=
" AND t.".$columnName.
" >= '".$db->idate($search[$key]).
"'";
265 if (preg_match(
'/_dtend$/', $key)) {
266 $sql .=
" AND t." . $columnName .
" <= '" . $db->idate($search[$key]) .
"'";
274 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
277 if (!empty($searchCategoryProductList)) {
278 $searchCategoryProductSqlList = array();
279 $listofcategoryid =
'';
280 foreach ($searchCategoryProductList as $searchCategoryProduct) {
281 if (intval($searchCategoryProduct) == -2) {
282 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck WHERE p.rowid = ck.fk_product)";
283 } elseif (intval($searchCategoryProduct) > 0) {
284 if ($searchCategoryProductOperator == 0) {
285 $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).
")";
287 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
291 if ($listofcategoryid) {
292 $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).
"))";
294 if ($searchCategoryProductOperator == 1) {
295 if (!empty($searchCategoryProductSqlList)) {
296 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
299 if (!empty($searchCategoryProductSqlList)) {
300 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
305 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
307 $parameters = array();
308 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
309 $sql .= $hookmanager->resPrint;
330 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
332 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
333 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
334 $resql = $db->query($sqlforcount);
336 $objforcount = $db->fetch_object(
$resql);
350 $sql .= $db->order($sortfield, $sortorder);
352 $sql .= $db->plimit($limit + 1, $offset);
355 $resql = $db->query($sql);
361 $num = $db->num_rows(
$resql);
364 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
365 $obj = $db->fetch_object(
$resql);
367 header(
"Location: ".DOL_URL_ROOT.
'/inventory/card.php?id='.$id);
375 llxHeader(
'', $title,
$help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
377 $arrayofselected = is_array($toselect) ? $toselect : array();
380 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
381 $param .=
'&contextpage='.urlencode($contextpage);
383 if ($limit > 0 && $limit != $conf->liste_limit) {
384 $param .=
'&limit='.urlencode($limit);
386 foreach ($search as $key => $val) {
387 if (is_array($search[$key]) && count($search[$key])) {
388 foreach ($search[$key] as $skey) {
389 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
392 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
395 if ($optioncss !=
'') {
396 $param .=
'&optioncss='.urlencode($optioncss);
398 foreach ($searchCategoryProductList as $searchCategoryProduct) {
399 $param .=
"&search_category_product_list[]=".urlencode($searchCategoryProduct);
402 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
404 $parameters = array();
405 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
406 $param .= $hookmanager->resPrint;
409 $arrayofmassactions = array(
415 if ($permissiontodelete) {
416 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
418 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
419 $arrayofmassactions = array();
421 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
423 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
424 if ($optioncss !=
'') {
425 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
427 print
'<input type="hidden" name="token" value="'.newToken().
'">';
428 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
429 print
'<input type="hidden" name="action" value="list">';
430 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
431 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
432 print
'<input type="hidden" name="page" value="'.$page.
'">';
433 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
435 $newcardbutton =
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/inventory/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
437 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords, $object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
440 $topicmail =
"Information";
441 $modelmail =
"inventory";
443 $trackid =
'stockinv'.$object->id;
444 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
447 foreach ($fieldstosearchall as $key => $val) {
448 $fieldstosearchall[$key] = $langs->trans($val);
450 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
459 if (!empty($conf->global->MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS) &&
isModEnabled(
'categorie') && $user->rights->categorie->lire) {
460 $moreforfilter .=
'<div class="divsearchfield">';
461 $tmptitle = $langs->transnoentities(
'ProductsCategoriesShort');
462 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
463 $categoriesProductArr =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'', 64, 0, 1);
464 $categoriesProductArr[-2] =
'- '.$langs->trans(
'NotCategorized').
' -';
465 $moreforfilter .=
Form::multiselectarray(
'search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0,
'minwidth300', 0, 0,
'',
'category', $tmptitle);
466 $moreforfilter .=
' <input type="checkbox" class="valignmiddle" id="search_category_product_operator" name="search_category_product_operator" value="1"'.($searchCategoryProductOperator == 1 ?
' checked="checked"' :
'').
'/>';
467 $moreforfilter .=
$form->textwithpicto(
'', $langs->trans(
'UseOrOperatorForCategories') .
' : ' . $tmptitle, 1,
'help',
'', 0, 2,
'tooltip_cat_pro');
468 $moreforfilter .=
'</div>';
471 $parameters = array();
472 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
473 if (empty($reshook)) {
474 $moreforfilter .= $hookmanager->resPrint;
476 $moreforfilter = $hookmanager->resPrint;
479 if (!empty($moreforfilter)) {
480 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
481 print $moreforfilter;
485 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
486 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
487 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
489 print
'<div class="div-table-responsive">';
490 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
495 print
'<tr class="liste_titre">';
498 print
'<td class="liste_titre maxwidthsearch">';
499 $searchpicto =
$form->showFilterButtons(
'left');
503 foreach ($object->fields as $key => $val) {
504 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
505 if ($key ==
'status') {
506 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
507 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
508 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
509 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
510 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
511 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
512 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
514 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
515 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').
'">';
516 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
517 print
$form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100', 1);
518 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
519 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_',
'maxwidth125', 1);
520 } elseif (!preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
521 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
522 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
523 print
'<div class="nowrap">';
524 print
$form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
526 print
'<div class="nowrap">';
527 print
$form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
534 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
537 $parameters = array(
'arrayfields'=>$arrayfields);
538 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
539 print $hookmanager->resPrint;
542 print
'<td class="liste_titre maxwidthsearch">';
543 $searchpicto =
$form->showFilterButtons();
552 print
'<tr class="liste_titre">';
555 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
557 foreach ($object->fields as $key => $val) {
558 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
559 if ($key ==
'status') {
560 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
561 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
562 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
563 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
564 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
565 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
566 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
568 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
569 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
573 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
575 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
576 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
577 print $hookmanager->resPrint;
580 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
586 $needToFetchEachLine = 0;
587 if (isset($extrafields->attributes[$object->table_element][
'computed']) && is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0) {
588 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val) {
589 if (preg_match(
'/\$object/', $val)) {
590 $needToFetchEachLine++;
598 $totalarray = array();
599 $totalarray[
'nbfield'] = 0;
600 while ($i < ($limit ? min($num, $limit) : $num)) {
601 $obj = $db->fetch_object(
$resql);
607 $object->setVarsFromFetchObj($obj);
610 print
'<tr class="oddeven">';
613 print
'<td class="nowrap center">';
614 if ($massactionbutton || $massaction) {
616 if (in_array($object->id, $arrayofselected)) {
619 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
623 foreach ($object->fields as $key => $val) {
624 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
625 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
626 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
627 } elseif ($key ==
'status') {
628 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
631 if (in_array($val[
'type'], array(
'timestamp'))) {
632 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
633 } elseif ($key ==
'ref') {
634 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
637 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'rowid',
'status')) && empty($val[
'arrayofkeyval'])) {
638 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
641 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
642 print
'<td'.($cssforfield ?
' class="'.$cssforfield.
'"' :
'').
'>';
643 if ($key ==
'status') {
644 print $object->getLibStatut(5);
645 } elseif ($key ==
'rowid') {
646 print $object->showOutputField($val, $key, $object->id,
'');
648 print $object->showOutputField($val, $key, $object->$key,
'');
652 $totalarray[
'nbfield']++;
654 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
656 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
658 if (!isset($totalarray[
'val'])) {
659 $totalarray[
'val'] = array();
661 if (!isset($totalarray[
'val'][
't.'.$key])) {
662 $totalarray[
'val'][
't.'.$key] = 0;
664 $totalarray[
'val'][
't.'.$key] += $object->$key;
669 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
671 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
672 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
673 print $hookmanager->resPrint;
676 print
'<td class="nowrap center">';
677 if ($massactionbutton || $massaction) {
679 if (in_array($object->id, $arrayofselected)) {
682 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
687 $totalarray[
'nbfield']++;
696 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
702 foreach ($arrayfields as $key => $val) {
703 if (!empty($val[
'checked'])) {
707 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
713 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
714 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
715 print $hookmanager->resPrint;
717 print
'</table>'.
"\n";
720 print
'</form>'.
"\n";
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
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.