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($contextpage));
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');
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'));
167 $arrayfields = array();
168 foreach ($object->fields as $key => $val) {
170 if (!empty($val[
'visible'])) {
171 $visible = (int)
dol_eval($val[
'visible'], 1);
172 $arrayfields[
't.'.$key] = array(
173 'label'=>$val[
'label'],
174 'checked'=>(($visible < 0) ? 0 : 1),
175 'enabled'=>(abs($visible) != 3 &&
dol_eval($val[
'enabled'], 1)),
176 'position'=>$val[
'position'],
177 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
182 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
190 $enablepermissioncheck = 0;
191 if ($enablepermissioncheck) {
192 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
193 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
194 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete');
196 $permissiontoread = 1;
197 $permissiontoadd = 1;
198 $permissiontodelete = 1;
217 if (
GETPOST(
'cancel',
'alpha')) {
221 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
225 $parameters = array();
226 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
231 if (empty($reshook)) {
233 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
236 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
237 foreach ($object->fields as $key => $val) {
239 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
240 $search[$key.
'_dtstart'] =
'';
241 $search[$key.
'_dtend'] =
'';
245 $search_array_options = array();
247 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
248 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
253 $objectclass =
'MyObject';
254 $objectlabel =
'MyObject';
255 $uploaddir = $conf->mymodule->dir_output;
256 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
272 $title = $langs->trans(
"MyObjects");
282 $sql .= $object->getFieldList(
't');
284 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
285 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
286 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
290 $parameters = array();
291 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
292 $sql .= $hookmanager->resPrint;
293 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
297 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
299 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
300 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
303 $parameters = array();
304 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
305 $sql .= $hookmanager->resPrint;
306 if ($object->ismultientitymanaged == 1) {
307 $sql .=
" WHERE t.entity IN (".getEntity($object->element, (
GETPOST(
'search_current_entity',
'int') ? 0 : 1)).
")";
309 $sql .=
" WHERE 1 = 1";
311 foreach ($search as $key => $val) {
312 if (array_key_exists($key, $object->fields)) {
313 if ($key ==
'status' && $search[$key] == -1) {
316 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
317 if ((strpos($object->fields[$key][
'type'],
'integer:') === 0) || (strpos($object->fields[$key][
'type'],
'sellist:') === 0) || !empty($object->fields[$key][
'arrayofkeyval'])) {
318 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty($object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0', $object->fields[$key][
'arrayofkeyval'])))) {
323 if ($search[$key] !=
'') {
324 $sql .=
natural_search(
"t.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
327 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
328 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
329 if (preg_match(
'/^(date|timestamp|datetime)/', $object->fields[$columnName][
'type'])) {
330 if (preg_match(
'/_dtstart$/', $key)) {
331 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
333 if (preg_match(
'/_dtend$/', $key)) {
334 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
345 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
347 $parameters = array();
348 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
349 $sql .= $hookmanager->resPrint;
377 $nbtotalofrecords =
'';
380 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
381 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
383 $resql = $db->query($sqlforcount);
385 $objforcount = $db->fetch_object($resql);
386 $nbtotalofrecords = $objforcount->nbtotalofrecords;
391 if (($page * $limit) > $nbtotalofrecords) {
399 $sql .= $db->order($sortfield, $sortorder);
401 $sql .= $db->plimit($limit + 1, $offset);
404 $resql = $db->query(
$sql);
410 $num = $db->num_rows($resql);
414 if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
415 $obj = $db->fetch_object($resql);
417 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((
int) $id));
442 $arrayofselected = is_array($toselect) ? $toselect : array();
446 $param .=
'&mode='.urlencode($mode);
448 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
449 $param .=
'&contextpage='.urlencode($contextpage);
451 if ($limit > 0 && $limit != $conf->liste_limit) {
452 $param .=
'&limit='.((int) $limit);
454 if ($optioncss !=
'') {
455 $param .=
'&optioncss='.urlencode($optioncss);
457 foreach ($search as $key => $val) {
458 if (is_array($search[$key])) {
459 foreach ($search[$key] as $skey) {
461 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
464 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
465 $param .=
'&search_'.$key.
'month='.((int)
GETPOST(
'search_'.$key.
'month',
'int'));
466 $param .=
'&search_'.$key.
'day='.((int)
GETPOST(
'search_'.$key.
'day',
'int'));
467 $param .=
'&search_'.$key.
'year='.((int)
GETPOST(
'search_'.$key.
'year',
'int'));
468 } elseif ($search[$key] !=
'') {
469 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
473 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
475 $parameters = array();
476 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
477 $param .= $hookmanager->resPrint;
480 $arrayofmassactions = array(
486 if (!empty($permissiontodelete)) {
487 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
489 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
490 $arrayofmassactions = array();
492 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
494 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
495 if ($optioncss !=
'') {
496 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
498 print
'<input type="hidden" name="token" value="'.newToken().
'">';
499 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
500 print
'<input type="hidden" name="action" value="list">';
501 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
502 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
503 print
'<input type="hidden" name="page" value="'.$page.
'">';
504 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
505 print
'<input type="hidden" name="page_y" value="">';
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 MYOBJECT_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, $action);
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;
550 $parameters = array();
551 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
552 print $hookmanager->resPrint;
556 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
557 $selectedfields = ($mode !=
'kanban' ?
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
558 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
560 print
'<div class="div-table-responsive">';
561 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
565 print
'<tr class="liste_titre_filter">';
568 print
'<td class="liste_titre center maxwidthsearch">';
569 $searchpicto =
$form->showFilterButtons(
'left');
573 foreach ($object->fields as $key => $val) {
574 $searchkey = empty($search[$key]) ?
'' : $search[$key];
575 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
576 if ($key ==
'status') {
577 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
578 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
579 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
580 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
581 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
582 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'id',
'rowid',
'ref',
'status')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
583 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
585 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
586 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
587 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
588 print
$form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100'.($key ==
'status' ?
' search_status width100 onrightofpage' :
''), 1);
589 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
590 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
591 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
592 print
'<div class="nowrap">';
593 print
$form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
595 print
'<div class="nowrap">';
596 print
$form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
598 } elseif ($key ==
'lang') {
599 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
601 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth150 maxwidth200', 2);
603 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
609 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
612 $parameters = array(
'arrayfields'=>$arrayfields);
613 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
614 print $hookmanager->resPrint;
620 print
'<td class="liste_titre center maxwidthsearch">';
621 $searchpicto =
$form->showFilterButtons();
627 $totalarray = array();
628 $totalarray[
'nbfield'] = 0;
632 print
'<tr class="liste_titre">';
635 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
636 $totalarray[
'nbfield']++;
638 foreach ($object->fields as $key => $val) {
639 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
640 if ($key ==
'status') {
641 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
642 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
643 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
644 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
645 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
646 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'id',
'rowid',
'ref',
'status')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
647 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
649 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
650 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
651 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
''), 0, (empty($val[
'helplist']) ?
'' : $val[
'helplist'])).
"\n";
652 $totalarray[
'nbfield']++;
656 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
658 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
659 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
660 print $hookmanager->resPrint;
667 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
668 $totalarray[
'nbfield']++;
673 $needToFetchEachLine = 0;
674 if (isset($extrafields->attributes[$object->table_element][
'computed']) && is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0) {
675 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val) {
676 if (!is_null($val) && preg_match(
'/\$object/', $val)) {
677 $needToFetchEachLine++;
686 $savnbfield = $totalarray[
'nbfield'];
687 $totalarray = array();
688 $totalarray[
'nbfield'] = 0;
689 $imaxinloop = ($limit ? min($num, $limit) : $num);
690 while ($i < $imaxinloop) {
691 $obj = $db->fetch_object($resql);
697 $object->setVarsFromFetchObj($obj);
713 if ($mode ==
'kanban') {
715 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
716 print
'<div class="box-flex-container kanban">';
720 if ($massactionbutton || $massaction) {
722 if (in_array($object->id, $arrayofselected)) {
727 print $object->getKanbanView(
'', array(
'selected' => $selected));
728 if ($i == ($imaxinloop - 1)) {
735 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
739 print
'<td class="nowrap center">';
740 if ($massactionbutton || $massaction) {
742 if (in_array($object->id, $arrayofselected)) {
745 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
749 $totalarray[
'nbfield']++;
752 foreach ($object->fields as $key => $val) {
753 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
754 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
755 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
756 } elseif ($key ==
'status') {
757 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
760 if (in_array($val[
'type'], array(
'timestamp'))) {
761 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
762 } elseif ($key ==
'ref') {
763 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
766 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'id',
'rowid',
'ref',
'status')) && empty($val[
'arrayofkeyval'])) {
767 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
771 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
772 print
'<td'.($cssforfield ?
' class="'.$cssforfield.(preg_match(
'/tdoverflow/', $cssforfield) ?
' classfortooltip' :
'').
'"' :
'');
773 if (preg_match(
'/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
774 print
' title="'.dol_escape_htmltag($object->$key).
'"';
777 if ($key ==
'status') {
778 print $object->getLibStatut(5);
779 } elseif ($key ==
'rowid') {
780 print $object->showOutputField($val, $key, $object->id,
'');
782 print $object->showOutputField($val, $key, $object->$key,
'');
786 $totalarray[
'nbfield']++;
788 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
790 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
792 if (!isset($totalarray[
'val'])) {
793 $totalarray[
'val'] = array();
795 if (!isset($totalarray[
'val'][
't.'.$key])) {
796 $totalarray[
'val'][
't.'.$key] = 0;
798 $totalarray[
'val'][
't.'.$key] += $object->$key;
803 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
805 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
806 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
807 print $hookmanager->resPrint;
815 print
'<td class="nowrap center">';
816 if ($massactionbutton || $massaction) {
818 if (in_array($object->id, $arrayofselected)) {
821 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
825 $totalarray[
'nbfield']++;
836 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
841 foreach ($arrayfields as $key => $val) {
842 if (!empty($val[
'checked'])) {
846 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
852 $parameters = array(
'arrayfields' => $arrayfields,
'sql' =>
$sql);
853 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
854 print $hookmanager->resPrint;
856 print
'</table>'.
"\n";
859 print
'</form>'.
"\n";
861 if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
862 $hidegeneratedfilelistifempty = 1;
863 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
864 $hidegeneratedfilelistifempty = 0;
867 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
871 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
872 $urlsource .= str_replace(
'&',
'&', $param);
874 $filedir = $diroutputmassaction;
875 $genallowed = $permissiontoread;
876 $delallowed = $permissiontoadd;
878 print $formfile->showdocuments(
'massfilesarea_'.$object->module,
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
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') && $user->hasRight('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') && $user->hasRight('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)) $sql
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_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...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.