50 if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
51 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
54 $tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
55 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
58 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
59 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
61 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
62 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
65 if (!$res && file_exists(
"../main.inc.php")) {
66 $res = @include
"../main.inc.php";
68 if (!$res && file_exists(
"../../main.inc.php")) {
69 $res = @include
"../../main.inc.php";
71 if (!$res && file_exists(
"../../../main.inc.php")) {
72 $res = @include
"../../../main.inc.php";
75 die(
"Include of main fails");
78 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
79 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
80 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
83 require_once __DIR__.
'/class/myobject.class.php';
89 $langs->loadLangs(array(
"mymodule@mymodule",
"other"));
94 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
95 $massaction =
GETPOST(
'massaction',
'alpha');
96 $show_files =
GETPOST(
'show_files',
'int');
97 $confirm =
GETPOST(
'confirm',
'alpha');
98 $cancel =
GETPOST(
'cancel',
'alpha');
99 $toselect =
GETPOST(
'toselect',
'array');
100 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
101 $backtopage =
GETPOST(
'backtopage',
'alpha');
102 $optioncss =
GETPOST(
'optioncss',
'aZ');
106 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
107 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
108 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
110 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
114 $offset = $limit * $page;
115 $pageprev = $page - 1;
116 $pagenext = $page + 1;
121 $diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
122 $hookmanager->initHooks(array(
'myobjectlist'));
125 $extrafields->fetch_name_optionals_label($object->table_element);
128 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
132 reset($object->fields);
133 $sortfield =
"t.".key($object->fields);
140 $search_all =
GETPOST(
'search_all',
'alphanohtml');
142 foreach ($object->fields as $key => $val) {
143 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
144 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
146 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
147 $search[$key.
'_dtstart'] =
dol_mktime(0, 0, 0,
GETPOST(
'search_'.$key.
'_dtstartmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtstartday',
'int'),
GETPOST(
'search_'.$key.
'_dtstartyear',
'int'));
148 $search[$key.
'_dtend'] =
dol_mktime(23, 59, 59,
GETPOST(
'search_'.$key.
'_dtendmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtendday',
'int'),
GETPOST(
'search_'.$key.
'_dtendyear',
'int'));
153 $fieldstosearchall = array();
154 foreach ($object->fields as $key => $val) {
155 if (!empty($val[
'searchall'])) {
156 $fieldstosearchall[
't.'.$key] = $val[
'label'];
161 $arrayfields = array();
162 foreach ($object->fields as $key => $val) {
164 if (!empty($val[
'visible'])) {
165 $visible = (int)
dol_eval($val[
'visible'], 1);
166 $arrayfields[
't.'.$key] = array(
167 'label'=>$val[
'label'],
168 'checked'=>(($visible < 0) ? 0 : 1),
169 'enabled'=>(abs($visible) != 3 &&
dol_eval($val[
'enabled'], 1)),
170 'position'=>$val[
'position'],
171 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
176 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
184 $enablepermissioncheck = 0;
185 if ($enablepermissioncheck) {
186 $permissiontoread = $user->rights->mymodule->myobject->read;
187 $permissiontoadd = $user->rights->mymodule->myobject->write;
188 $permissiontodelete = $user->rights->mymodule->myobject->delete;
190 $permissiontoread = 1;
191 $permissiontoadd = 1;
192 $permissiontodelete = 1;
201 if (empty($conf->mymodule->enabled))
accessforbidden(
'Module not enabled');
209 if (
GETPOST(
'cancel',
'alpha')) {
213 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
217 $parameters = array();
218 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
223 if (empty($reshook)) {
225 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
228 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
229 foreach ($object->fields as $key => $val) {
231 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
232 $search[$key.
'_dtstart'] =
'';
233 $search[$key.
'_dtend'] =
'';
237 $search_array_options = array();
239 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
240 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
245 $objectclass =
'MyObject';
246 $objectlabel =
'MyObject';
247 $uploaddir = $conf->mymodule->dir_output;
248 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
263 $title = $langs->trans(
"MyObjects");
271 $sql .= $object->getFieldList(
't');
273 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
274 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
275 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
279 $parameters = array();
280 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
281 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
282 $sql = preg_replace(
'/,\s*$/',
'', $sql);
286 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
288 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
289 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
292 $parameters = array();
293 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
294 $sql .= $hookmanager->resPrint;
295 if ($object->ismultientitymanaged == 1) {
296 $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
298 $sql .=
" WHERE 1 = 1";
300 foreach ($search as $key => $val) {
301 if (array_key_exists($key, $object->fields)) {
302 if ($key ==
'status' && $search[$key] == -1) {
305 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
306 if ((strpos($object->fields[$key][
'type'],
'integer:') === 0) || (strpos($object->fields[$key][
'type'],
'sellist:') === 0) || !empty($object->fields[$key][
'arrayofkeyval'])) {
307 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty($object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0', $object->fields[$key][
'arrayofkeyval'])))) {
312 if ($search[$key] !=
'') {
313 $sql .=
natural_search(
"t.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
316 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
317 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
318 if (preg_match(
'/^(date|timestamp|datetime)/', $object->fields[$columnName][
'type'])) {
319 if (preg_match(
'/_dtstart$/', $key)) {
320 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
322 if (preg_match(
'/_dtend$/', $key)) {
323 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
330 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
334 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
336 $parameters = array();
337 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
338 $sql .= $hookmanager->resPrint;
366 $nbtotalofrecords =
'';
367 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
382 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
383 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
385 $resql = $db->query($sqlforcount);
389 $objforcount = $db->fetch_object(
$resql);
390 $nbtotalofrecords = $objforcount->nbtotalofrecords;
391 if (($page * $limit) > $nbtotalofrecords) {
400 $sql .= $db->order($sortfield, $sortorder);
402 $sql .= $db->plimit($limit + 1, $offset);
405 $resql = $db->query($sql);
411 $num = $db->num_rows(
$resql);
415 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
416 $obj = $db->fetch_object(
$resql);
418 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$id);
443 $arrayofselected = is_array($toselect) ? $toselect : array();
447 $param .=
'&mode='.urlencode($mode);
449 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
450 $param .=
'&contextpage='.urlencode($contextpage);
452 if ($limit > 0 && $limit != $conf->liste_limit) {
453 $param .=
'&limit='.urlencode($limit);
455 foreach ($search as $key => $val) {
456 if (is_array($search[$key])) {
457 foreach ($search[$key] as $skey) {
459 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
462 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
463 $param .=
'&search_'.$key.
'month='.((int)
GETPOST(
'search_'.$key.
'month',
'int'));
464 $param .=
'&search_'.$key.
'day='.((int)
GETPOST(
'search_'.$key.
'day',
'int'));
465 $param .=
'&search_'.$key.
'year='.((int)
GETPOST(
'search_'.$key.
'year',
'int'));
466 } elseif ($search[$key] !=
'') {
467 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
470 if ($optioncss !=
'') {
471 $param .=
'&optioncss='.urlencode($optioncss);
474 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
476 $parameters = array();
477 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
478 $param .= $hookmanager->resPrint;
481 $arrayofmassactions = array(
487 if (!empty($permissiontodelete)) {
488 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
490 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
491 $arrayofmassactions = array();
493 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
495 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
496 if ($optioncss !=
'') {
497 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
499 print
'<input type="hidden" name="token" value="'.newToken().
'">';
500 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
501 print
'<input type="hidden" name="action" value="list">';
502 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
503 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
504 print
'<input type="hidden" name="page" value="'.$page.
'">';
505 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
506 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
510 $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'));
511 $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'));
513 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle',
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
515 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
518 $topicmail =
"SendMyObjectRef";
519 $modelmail =
"myobject";
521 $trackid =
'xxxx'.$object->id;
522 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
526 foreach ($fieldstosearchall as $key => $val) {
527 $fieldstosearchall[$key] = $langs->trans($val);
528 $setupstring .= $key.
"=".$val.
";";
530 print
'<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
531 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
539 $parameters = array();
540 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
541 if (empty($reshook)) {
542 $moreforfilter .= $hookmanager->resPrint;
544 $moreforfilter = $hookmanager->resPrint;
547 if (!empty($moreforfilter)) {
548 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
549 print $moreforfilter;
553 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
554 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
555 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
557 print
'<div class="div-table-responsive">';
558 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
563 print
'<tr class="liste_titre">';
565 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
566 print
'<td class="liste_titre maxwidthsearch">';
567 $searchpicto =
$form->showFilterButtons(
'left');
571 foreach ($object->fields as $key => $val) {
572 $searchkey = empty($search[$key]) ?
'' : $search[$key];
573 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
574 if ($key ==
'status') {
575 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
576 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
577 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
578 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
579 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
580 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $key !=
'rowid' && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
581 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
583 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
584 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').
'">';
585 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
586 print
$form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100', 1);
587 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
588 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
589 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
590 print
'<div class="nowrap">';
591 print
$form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
593 print
'<div class="nowrap">';
594 print
$form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
596 } elseif ($key ==
'lang') {
597 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
599 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth150 maxwidth200', 2);
601 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
607 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
610 $parameters = array(
'arrayfields'=>$arrayfields);
611 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
612 print $hookmanager->resPrint;
617 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
618 print
'<td class="liste_titre maxwidthsearch">';
619 $searchpicto =
$form->showFilterButtons();
625 $totalarray = array();
626 $totalarray[
'nbfield'] = 0;
630 print
'<tr class="liste_titre">';
631 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
632 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
634 foreach ($object->fields as $key => $val) {
635 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
636 if ($key ==
'status') {
637 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
638 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
639 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
640 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
641 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
642 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $key !=
'rowid' && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
643 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
645 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
646 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
647 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
648 $totalarray[
'nbfield']++;
652 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
654 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
655 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
656 print $hookmanager->resPrint;
662 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
663 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
665 $totalarray[
'nbfield']++;
670 $needToFetchEachLine = 0;
671 if (isset($extrafields->attributes[$object->table_element][
'computed']) && is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0) {
672 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val) {
673 if (preg_match(
'/\$object/', $val)) {
674 $needToFetchEachLine++;
683 $savnbfield = $totalarray[
'nbfield'];
684 $totalarray = array();
685 $totalarray[
'nbfield'] = 0;
686 $imaxinloop = ($limit ? min($num, $limit) : $num);
687 while ($i < $imaxinloop) {
688 $obj = $db->fetch_object(
$resql);
694 $object->setVarsFromFetchObj($obj);
696 if ($mode ==
'kanban') {
698 print
'<tr><td colspan="'.$savnbfield.
'">';
699 print
'<div class="box-flex-container">';
702 print $object->getKanbanView(
'');
703 if ($i == ($imaxinloop - 1)) {
710 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
712 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
713 print
'<td class="nowrap center">';
714 if ($massactionbutton || $massaction) {
716 if (in_array($object->id, $arrayofselected)) {
719 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
723 foreach ($object->fields as $key => $val) {
724 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
725 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
726 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
727 } elseif ($key ==
'status') {
728 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
731 if (in_array($val[
'type'], array(
'timestamp'))) {
732 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
733 } elseif ($key ==
'ref') {
734 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
737 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'rowid',
'status')) && empty($val[
'arrayofkeyval'])) {
738 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
742 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
743 print
'<td'.($cssforfield ?
' class="'.$cssforfield.
'"' :
'');
744 if (preg_match(
'/tdoverflow/', $cssforfield)) {
745 print
' title="'.dol_escape_htmltag($object->$key).
'"';
748 if ($key ==
'status') {
749 print $object->getLibStatut(5);
750 } elseif ($key ==
'rowid') {
751 print $object->showOutputField($val, $key, $object->id,
'');
753 print $object->showOutputField($val, $key, $object->$key,
'');
757 $totalarray[
'nbfield']++;
759 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
761 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
763 if (!isset($totalarray[
'val'])) {
764 $totalarray[
'val'] = array();
766 if (!isset($totalarray[
'val'][
't.'.$key])) {
767 $totalarray[
'val'][
't.'.$key] = 0;
769 $totalarray[
'val'][
't.'.$key] += $object->$key;
774 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
776 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
777 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
778 print $hookmanager->resPrint;
783 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
784 print
'<td class="nowrap center">';
785 if ($massactionbutton || $massaction) {
787 if (in_array($object->id, $arrayofselected)) {
790 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
795 $totalarray[
'nbfield']++;
805 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
810 foreach ($arrayfields as $key => $val) {
811 if (!empty($val[
'checked'])) {
815 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
821 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
822 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
823 print $hookmanager->resPrint;
825 print
'</table>'.
"\n";
828 print
'</form>'.
"\n";
830 if (in_array(
'builddoc', $arrayofmassactions) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
831 $hidegeneratedfilelistifempty = 1;
832 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
833 $hidegeneratedfilelistifempty = 0;
836 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
840 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
841 $urlsource .= str_replace(
'&',
'&', $param);
843 $filedir = $diroutputmassaction;
844 $genallowed = $permissiontoread;
845 $delallowed = $permissiontoadd;
847 print $formfile->showdocuments(
'massfilesarea_mymodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);