48 if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
49 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
52 $tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
53 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
57 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
58 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
60 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
61 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
64 if (!$res && file_exists(
"../main.inc.php")) {
65 $res = @include
"../main.inc.php";
67 if (!$res && file_exists(
"../../main.inc.php")) {
68 $res = @include
"../../main.inc.php";
70 if (!$res && file_exists(
"../../../main.inc.php")) {
71 $res = @include
"../../../main.inc.php";
74 die(
"Include of main fails");
77 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
78 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
79 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
82 require_once __DIR__.
'/class/myobject.class.php';
88 $langs->loadLangs(array(
"mymodule@mymodule",
"other"));
90 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
91 $massaction =
GETPOST(
'massaction',
'alpha');
92 $show_files =
GETPOST(
'show_files',
'int');
93 $confirm =
GETPOST(
'confirm',
'alpha');
94 $cancel =
GETPOST(
'cancel',
'alpha');
95 $toselect =
GETPOST(
'toselect',
'array');
96 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
97 $backtopage =
GETPOST(
'backtopage',
'alpha');
98 $optioncss =
GETPOST(
'optioncss',
'aZ');
102 $ref =
GETPOST(
'ref',
'alpha');
105 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
106 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
107 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
109 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
113 $offset = $limit * $page;
114 $pageprev = $page - 1;
115 $pagenext = $page + 1;
120 $diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
121 $hookmanager->initHooks(array(
'myobjectlist'));
124 $extrafields->fetch_name_optionals_label($object->table_element);
127 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
131 reset($object->fields);
132 $sortfield =
"t.".key($object->fields);
139 $search_all =
GETPOST(
'search_all',
'alphanohtml') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml');
141 foreach ($object->fields as $key => $val) {
142 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
143 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
145 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
146 $search[$key.
'_dtstart'] =
dol_mktime(0, 0, 0,
GETPOST(
'search_'.$key.
'_dtstartmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtstartday',
'int'),
GETPOST(
'search_'.$key.
'_dtstartyear',
'int'));
147 $search[$key.
'_dtend'] =
dol_mktime(23, 59, 59,
GETPOST(
'search_'.$key.
'_dtendmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtendday',
'int'),
GETPOST(
'search_'.$key.
'_dtendyear',
'int'));
152 $fieldstosearchall = array();
153 foreach ($object->fields as $key => $val) {
154 if (!empty($val[
'searchall'])) {
155 $fieldstosearchall[
't.'.$key] = $val[
'label'];
160 $arrayfields = array();
161 foreach ($object->fields as $key => $val) {
163 if (!empty($val[
'visible'])) {
164 $visible = (int)
dol_eval($val[
'visible'], 1);
165 $arrayfields[
't.'.$key] = array(
166 'label'=>$val[
'label'],
167 'checked'=>(($visible < 0) ? 0 : 1),
168 'enabled'=>(abs($visible) != 3 &&
dol_eval($val[
'enabled'], 1)),
169 'position'=>$val[
'position'],
170 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
175 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
183 $enablepermissioncheck = 0;
184 if ($enablepermissioncheck) {
185 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
186 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
187 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete');
189 $permissiontoread = 1;
190 $permissiontoadd = 1;
191 $permissiontodelete = 1;
210 if (
GETPOST(
'cancel',
'alpha')) {
214 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
218 $parameters = array();
219 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
224 if (empty($reshook)) {
226 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
229 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
230 foreach ($object->fields as $key => $val) {
232 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
233 $search[$key.
'_dtstart'] =
'';
234 $search[$key.
'_dtend'] =
'';
238 $search_array_options = array();
240 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
241 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
246 $objectclass =
'MyObject';
247 $objectlabel =
'MyObject';
248 $uploaddir = $conf->mymodule->dir_output;
249 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
267 $title = $langs->trans(
"MyObjects");
275 $sql .= $object->getFieldList(
't');
277 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
278 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
279 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
283 $parameters = array();
284 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
285 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
286 $sql = preg_replace(
'/,\s*$/',
'', $sql);
291 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
293 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
294 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
297 $parameters = array();
298 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
299 $sql .= $hookmanager->resPrint;
300 if ($object->ismultientitymanaged == 1) {
301 $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
303 $sql .=
" WHERE 1 = 1";
305 foreach ($search as $key => $val) {
306 if (array_key_exists($key, $object->fields)) {
307 if ($key ==
'status' && $search[$key] == -1) {
310 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
311 if ((strpos($object->fields[$key][
'type'],
'integer:') === 0) || (strpos($object->fields[$key][
'type'],
'sellist:') === 0) || !empty($object->fields[$key][
'arrayofkeyval'])) {
312 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty($object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0', $object->fields[$key][
'arrayofkeyval'])))) {
317 if ($search[$key] !=
'') {
318 $sql .=
natural_search(
"t.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
321 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
322 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
323 if (preg_match(
'/^(date|timestamp|datetime)/', $object->fields[$columnName][
'type'])) {
324 if (preg_match(
'/_dtstart$/', $key)) {
325 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
327 if (preg_match(
'/_dtend$/', $key)) {
328 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
335 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
339 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
341 $parameters = array();
342 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
343 $sql .= $hookmanager->resPrint;
374 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
375 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
376 $resql = $db->query($sqlforcount);
378 $objforcount = $db->fetch_object(
$resql);
392 $sql .= $db->order($sortfield, $sortorder);
394 $sql .= $db->plimit($limit + 1, $offset);
397 $resql = $db->query($sql);
403 $num = $db->num_rows(
$resql);
407 if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
408 $obj = $db->fetch_object(
$resql);
410 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$id);
435 $arrayofselected = is_array($toselect) ? $toselect : array();
439 $param .=
'&mode='.urlencode($mode);
441 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
442 $param .=
'&contextpage='.urlencode($contextpage);
444 if ($limit > 0 && $limit != $conf->liste_limit) {
445 $param .=
'&limit='.urlencode($limit);
447 foreach ($search as $key => $val) {
448 if (is_array($search[$key])) {
449 foreach ($search[$key] as $skey) {
451 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
454 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
455 $param .=
'&search_'.$key.
'month='.((int)
GETPOST(
'search_'.$key.
'month',
'int'));
456 $param .=
'&search_'.$key.
'day='.((int)
GETPOST(
'search_'.$key.
'day',
'int'));
457 $param .=
'&search_'.$key.
'year='.((int)
GETPOST(
'search_'.$key.
'year',
'int'));
458 } elseif ($search[$key] !=
'') {
459 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
462 if ($optioncss !=
'') {
463 $param .=
'&optioncss='.urlencode($optioncss);
466 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
468 $parameters = array();
469 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
470 $param .= $hookmanager->resPrint;
473 $arrayofmassactions = array(
479 if (!empty($permissiontodelete)) {
480 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
482 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
483 $arrayofmassactions = array();
485 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
487 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
488 if ($optioncss !=
'') {
489 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
491 print
'<input type="hidden" name="token" value="'.newToken().
'">';
492 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
493 print
'<input type="hidden" name="action" value="list">';
494 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
495 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
496 print
'<input type="hidden" name="page" value="'.$page.
'">';
497 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
498 print
'<input type="hidden" name="page_y" value="">';
499 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
503 $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'));
504 $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'));
506 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle',
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
508 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'object_'.$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
511 $topicmail =
"SendMyObjectRef";
512 $modelmail =
"myobject";
514 $trackid =
'xxxx'.$object->id;
515 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
519 foreach ($fieldstosearchall as $key => $val) {
520 $fieldstosearchall[$key] = $langs->trans($val);
521 $setupstring .= $key.
"=".$val.
";";
523 print
'<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
524 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
532 $parameters = array();
533 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
534 if (empty($reshook)) {
535 $moreforfilter .= $hookmanager->resPrint;
537 $moreforfilter = $hookmanager->resPrint;
540 if (!empty($moreforfilter)) {
541 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
542 print $moreforfilter;
546 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
547 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
548 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
550 print
'<div class="div-table-responsive">';
551 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
555 print
'<tr class="liste_titre">';
558 print
'<td class="liste_titre maxwidthsearch">';
559 $searchpicto =
$form->showFilterButtons(
'left');
563 foreach ($object->fields as $key => $val) {
564 $searchkey = empty($search[$key]) ?
'' : $search[$key];
565 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
566 if ($key ==
'status') {
567 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
568 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
569 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
570 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
571 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
572 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $key !=
'rowid' && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
573 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
575 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
576 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').
'">';
577 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
578 print
$form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100'.($key ==
'status' ?
' search_status onrightofpage' :
''), 1);
579 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
580 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
581 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
582 print
'<div class="nowrap">';
583 print
$form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
585 print
'<div class="nowrap">';
586 print
$form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
588 } elseif ($key ==
'lang') {
589 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
591 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth150 maxwidth200', 2);
593 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
599 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
602 $parameters = array(
'arrayfields'=>$arrayfields);
603 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
604 print $hookmanager->resPrint;
610 print
'<td class="liste_titre maxwidthsearch">';
611 $searchpicto =
$form->showFilterButtons();
617 $totalarray = array();
618 $totalarray[
'nbfield'] = 0;
622 print
'<tr class="liste_titre">';
624 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
625 $totalarray[
'nbfield']++;
627 foreach ($object->fields as $key => $val) {
628 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
629 if ($key ==
'status') {
630 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
631 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
632 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
633 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
634 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
635 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $key !=
'rowid' && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
636 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
638 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
639 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
640 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
641 $totalarray[
'nbfield']++;
645 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
647 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
648 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
649 print $hookmanager->resPrint;
656 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
657 $totalarray[
'nbfield']++;
661 $totalarray = array();
662 $totalarray[
'nbfield'] = 0;
665 $needToFetchEachLine = 0;
666 if (isset($extrafields->attributes[$object->table_element][
'computed']) && is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0) {
667 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val) {
668 if (preg_match(
'/\$object/', $val)) {
669 $needToFetchEachLine++;
678 $savnbfield = $totalarray[
'nbfield'];
679 $totalarray = array();
680 $totalarray[
'nbfield'] = 0;
681 $imaxinloop = ($limit ? min($num, $limit) : $num);
682 while ($i < $imaxinloop) {
683 $obj = $db->fetch_object(
$resql);
689 $object->setVarsFromFetchObj($obj);
691 if ($mode ==
'kanban') {
693 print
'<tr><td colspan="'.$savnbfield.
'">';
694 print
'<div class="box-flex-container">';
697 print $object->getKanbanView(
'');
698 if ($i == ($imaxinloop - 1)) {
705 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
708 print
'<td class="nowrap center">';
709 if ($massactionbutton || $massaction) {
711 if (in_array($object->id, $arrayofselected)) {
714 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
718 $totalarray[
'nbfield']++;
721 foreach ($object->fields as $key => $val) {
722 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
723 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
724 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
725 } elseif ($key ==
'status') {
726 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
729 if (in_array($val[
'type'], array(
'timestamp'))) {
730 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
731 } elseif ($key ==
'ref') {
732 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
735 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'rowid',
'status')) && empty($val[
'arrayofkeyval'])) {
736 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
740 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
741 print
'<td'.($cssforfield ?
' class="'.$cssforfield.(preg_match(
'/tdoverflow/', $cssforfield) ?
' classfortooltip' :
'').
'"' :
'');
742 if (preg_match(
'/tdoverflow/', $cssforfield)) {
743 print
' title="'.dol_escape_htmltag($object->$key).
'"';
746 if ($key ==
'status') {
747 print $object->getLibStatut(5);
748 } elseif ($key ==
'rowid') {
749 print $object->showOutputField($val, $key, $object->id,
'');
751 print $object->showOutputField($val, $key, $object->$key,
'');
755 $totalarray[
'nbfield']++;
757 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
759 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
761 if (!isset($totalarray[
'val'])) {
762 $totalarray[
'val'] = array();
764 if (!isset($totalarray[
'val'][
't.'.$key])) {
765 $totalarray[
'val'][
't.'.$key] = 0;
767 $totalarray[
'val'][
't.'.$key] += $object->$key;
772 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
774 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
775 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
776 print $hookmanager->resPrint;
782 print
'<td class="nowrap center">';
783 if ($massactionbutton || $massaction) {
785 if (in_array($object->id, $arrayofselected)) {
788 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
792 $totalarray[
'nbfield']++;
803 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
808 foreach ($arrayfields as $key => $val) {
809 if (!empty($val[
'checked'])) {
813 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
819 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
820 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
821 print $hookmanager->resPrint;
823 print
'</table>'.
"\n";
826 print
'</form>'.
"\n";
829 $hidegeneratedfilelistifempty = 1;
830 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
831 $hidegeneratedfilelistifempty = 0;
834 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
838 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
839 $urlsource .= str_replace(
'&',
'&', $param);
841 $filedir = $diroutputmassaction;
842 $genallowed = $permissiontoread;
843 $delallowed = $permissiontoadd;
845 print $formfile->showdocuments(
'massfilesarea_mymodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);