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);
284 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
286 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
287 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
290 $parameters = array();
291 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
292 $sql .= $hookmanager->resPrint;
293 if ($object->ismultientitymanaged == 1) {
294 $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
296 $sql .=
" WHERE 1 = 1";
298 foreach ($search as $key => $val) {
299 if (array_key_exists($key, $object->fields)) {
300 if ($key ==
'status' && $search[$key] == -1) {
303 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
304 if ((strpos($object->fields[$key][
'type'],
'integer:') === 0) || (strpos($object->fields[$key][
'type'],
'sellist:') === 0) || !empty($object->fields[$key][
'arrayofkeyval'])) {
305 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty($object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0', $object->fields[$key][
'arrayofkeyval'])))) {
310 if ($search[$key] !=
'') {
311 $sql .=
natural_search(
"t.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
314 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
315 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
316 if (preg_match(
'/^(date|timestamp|datetime)/', $object->fields[$columnName][
'type'])) {
317 if (preg_match(
'/_dtstart$/', $key)) {
318 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
320 if (preg_match(
'/_dtend$/', $key)) {
321 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
328 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
332 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
334 $parameters = array();
335 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
336 $sql .= $hookmanager->resPrint;
364 $nbtotalofrecords =
'';
365 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
380 $sqlforcount = preg_replace(
'/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/',
'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
381 $resql = $db->query($sqlforcount);
383 $objforcount = $db->fetch_object(
$resql);
384 $nbtotalofrecords = $objforcount->nbtotalofrecords;
389 if (($page * $limit) > $nbtotalofrecords) {
397 $sql .= $db->order($sortfield, $sortorder);
399 $sql .= $db->plimit($limit + 1, $offset);
402 $resql = $db->query($sql);
408 $num = $db->num_rows(
$resql);
412 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
413 $obj = $db->fetch_object(
$resql);
415 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$id);
440 $arrayofselected = is_array($toselect) ? $toselect : array();
444 $param .=
'&mode='.urlencode($mode);
446 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
447 $param .=
'&contextpage='.urlencode($contextpage);
449 if ($limit > 0 && $limit != $conf->liste_limit) {
450 $param .=
'&limit='.urlencode($limit);
452 foreach ($search as $key => $val) {
453 if (is_array($search[$key])) {
454 foreach ($search[$key] as $skey) {
456 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
459 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
460 $param .=
'&search_'.$key.
'month='.((int)
GETPOST(
'search_'.$key.
'month',
'int'));
461 $param .=
'&search_'.$key.
'day='.((int)
GETPOST(
'search_'.$key.
'day',
'int'));
462 $param .=
'&search_'.$key.
'year='.((int)
GETPOST(
'search_'.$key.
'year',
'int'));
463 } elseif ($search[$key] !=
'') {
464 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
467 if ($optioncss !=
'') {
468 $param .=
'&optioncss='.urlencode($optioncss);
471 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
473 $parameters = array();
474 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
475 $param .= $hookmanager->resPrint;
478 $arrayofmassactions = array(
484 if (!empty($permissiontodelete)) {
485 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
487 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
488 $arrayofmassactions = array();
490 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
492 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
493 if ($optioncss !=
'') {
494 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
496 print
'<input type="hidden" name="token" value="'.newToken().
'">';
497 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
498 print
'<input type="hidden" name="action" value="list">';
499 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
500 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
501 print
'<input type="hidden" name="page" value="'.$page.
'">';
502 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
503 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
507 $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'));
508 $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'));
510 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle',
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
512 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
515 $topicmail =
"SendMyObjectRef";
516 $modelmail =
"myobject";
518 $trackid =
'xxxx'.$object->id;
519 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
523 foreach ($fieldstosearchall as $key => $val) {
524 $fieldstosearchall[$key] = $langs->trans($val);
525 $setupstring .= $key.
"=".$val.
";";
527 print
'<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
528 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
536 $parameters = array();
537 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
538 if (empty($reshook)) {
539 $moreforfilter .= $hookmanager->resPrint;
541 $moreforfilter = $hookmanager->resPrint;
544 if (!empty($moreforfilter)) {
545 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
546 print $moreforfilter;
550 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
551 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
552 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
554 print
'<div class="div-table-responsive">';
555 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
560 print
'<tr class="liste_titre">';
562 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
563 print
'<td class="liste_titre maxwidthsearch">';
564 $searchpicto =
$form->showFilterButtons(
'left');
568 foreach ($object->fields as $key => $val) {
569 $searchkey = empty($search[$key]) ?
'' : $search[$key];
570 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
571 if ($key ==
'status') {
572 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
573 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
574 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
575 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
576 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
577 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $key !=
'rowid' && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
578 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
580 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
581 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').
'">';
582 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
583 print
$form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100', 1);
584 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
585 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
586 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
587 print
'<div class="nowrap">';
588 print
$form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
590 print
'<div class="nowrap">';
591 print
$form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
593 } elseif ($key ==
'lang') {
594 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
596 print $formadmin->select_language($search[$key],
'search_lang', 0, null, 1, 0, 0,
'minwidth150 maxwidth200', 2);
598 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
604 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
607 $parameters = array(
'arrayfields'=>$arrayfields);
608 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
609 print $hookmanager->resPrint;
614 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
615 print
'<td class="liste_titre maxwidthsearch">';
616 $searchpicto =
$form->showFilterButtons();
622 $totalarray = array();
623 $totalarray[
'nbfield'] = 0;
627 print
'<tr class="liste_titre">';
628 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
629 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
631 foreach ($object->fields as $key => $val) {
632 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
633 if ($key ==
'status') {
634 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
635 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
636 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
637 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
638 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
639 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $key !=
'rowid' && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
640 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
642 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
643 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
644 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
645 $totalarray[
'nbfield']++;
649 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
651 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
652 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
653 print $hookmanager->resPrint;
659 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
660 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
662 $totalarray[
'nbfield']++;
667 $needToFetchEachLine = 0;
668 if (isset($extrafields->attributes[$object->table_element][
'computed']) && is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0) {
669 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val) {
670 if (preg_match(
'/\$object/', $val)) {
671 $needToFetchEachLine++;
680 $savnbfield = $totalarray[
'nbfield'];
681 $totalarray = array();
682 $totalarray[
'nbfield'] = 0;
683 $imaxinloop = ($limit ? min($num, $limit) : $num);
684 while ($i < $imaxinloop) {
685 $obj = $db->fetch_object(
$resql);
691 $object->setVarsFromFetchObj($obj);
693 if ($mode ==
'kanban') {
695 print
'<tr><td colspan="'.$savnbfield.
'">';
696 print
'<div class="box-flex-container">';
699 print $object->getKanbanView(
'');
700 if ($i == ($imaxinloop - 1)) {
707 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
709 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
710 print
'<td class="nowrap center">';
711 if ($massactionbutton || $massaction) {
713 if (in_array($object->id, $arrayofselected)) {
716 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
720 foreach ($object->fields as $key => $val) {
721 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
722 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
723 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
724 } elseif ($key ==
'status') {
725 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
728 if (in_array($val[
'type'], array(
'timestamp'))) {
729 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
730 } elseif ($key ==
'ref') {
731 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
734 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'rowid',
'status')) && empty($val[
'arrayofkeyval'])) {
735 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
739 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
740 print
'<td'.($cssforfield ?
' class="'.$cssforfield.
'"' :
'');
741 if (preg_match(
'/tdoverflow/', $cssforfield)) {
742 print
' title="'.dol_escape_htmltag($object->$key).
'"';
745 if ($key ==
'status') {
746 print $object->getLibStatut(5);
747 } elseif ($key ==
'rowid') {
748 print $object->showOutputField($val, $key, $object->id,
'');
750 print $object->showOutputField($val, $key, $object->$key,
'');
754 $totalarray[
'nbfield']++;
756 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
758 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
760 if (!isset($totalarray[
'val'])) {
761 $totalarray[
'val'] = array();
763 if (!isset($totalarray[
'val'][
't.'.$key])) {
764 $totalarray[
'val'][
't.'.$key] = 0;
766 $totalarray[
'val'][
't.'.$key] += $object->$key;
771 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
773 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
774 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
775 print $hookmanager->resPrint;
780 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
781 print
'<td class="nowrap center">';
782 if ($massactionbutton || $massaction) {
784 if (in_array($object->id, $arrayofselected)) {
787 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
792 $totalarray[
'nbfield']++;
802 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
807 foreach ($arrayfields as $key => $val) {
808 if (!empty($val[
'checked'])) {
812 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
818 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
819 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
820 print $hookmanager->resPrint;
822 print
'</table>'.
"\n";
825 print
'</form>'.
"\n";
827 if (in_array(
'builddoc', $arrayofmassactions) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
828 $hidegeneratedfilelistifempty = 1;
829 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
830 $hidegeneratedfilelistifempty = 0;
833 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
837 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
838 $urlsource .= str_replace(
'&',
'&', $param);
840 $filedir = $diroutputmassaction;
841 $genallowed = $permissiontoread;
842 $delallowed = $permissiontoadd;
844 print $formfile->showdocuments(
'massfilesarea_mymodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'', null, $hidegeneratedfilelistifempty);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
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.
dol_now($mode= 'auto')
Return date for now.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
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_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring= '1')
Replace eval function to add more security.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.