28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
33$langs->loadLangs(array(
"products",
"other"));
35$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
36$massaction =
GETPOST(
'massaction',
'alpha');
38$confirm =
GETPOST(
'confirm',
'alpha');
39$cancel =
GETPOST(
'cancel',
'alpha');
40$toselect =
GETPOST(
'toselect',
'array:int');
41$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
42$backtopage =
GETPOST(
'backtopage',
'alpha');
43$optioncss =
GETPOST(
'optioncss',
'aZ');
50$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
57$offset = $limit * $page;
64$diroutputmassaction = $conf->variants->dir_output.
'/temp/massgeneration/'.$user->id;
65$hookmanager->initHooks(array(
'productattributelist'));
74 $sortfield =
"t.position";
81$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
83foreach (
$object->fields as $key => $val) {
84 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
85 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
87 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
92$search[
'nb_of_values'] =
GETPOST(
'search_nb_of_values',
'alpha');
93$search[
'nb_products'] =
GETPOST(
'search_nb_products',
'alpha');
95$fieldstosearchall = array();
97foreach (
$object->fields as $key => $val) {
98 if (!empty($val[
'searchall'])) {
99 $fieldstosearchall[
't.'.$key] = $val[
'label'];
102$parameters = array(
'fieldstosearchall' => $fieldstosearchall);
103$reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action);
105 $fieldstosearchall = empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall'];
106} elseif ($reshook == 0) {
107 $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall']);
111$arrayfields = array();
112foreach (
$object->fields as $key => $val) {
114 if (!empty($val[
'visible'])) {
115 $visible = (int)
dol_eval($val[
'visible'], 1);
116 $arrayfields[
't.'.$key] = array(
117 'label' => $val[
'label'],
118 'checked' => (($visible < 0) ? 0 : 1),
119 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
120 'position' => $val[
'position'],
121 'help' => isset($val[
'help']) ? $val[
'help'] :
''
125$arrayfields[
'nb_of_values'] = array(
126 'label' => $langs->trans(
'NbOfDifferentValues'),
132$arrayfields[
'nb_products'] = array(
133 'label' => $langs->trans(
'NbProducts'),
144'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
146$permissiontoread = $user->hasRight(
'variants',
'read');
147$permissiontoadd = $user->hasRight(
'variants',
'write');
148$permissiontodelete = $user->hasRight(
'variants',
'delete');
151if (!isModEnabled(
'variants')) {
155if ($user->socid > 0) {
159if (!$permissiontoread) {
168if (
GETPOST(
'cancel',
'alpha')) {
172if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
176$parameters = array(
'arrayfields' => &$arrayfields);
177$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
182if (empty($reshook)) {
184 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
187 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
188 foreach (
$object->fields as $key => $val) {
190 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
191 $search[$key.
'_dtstart'] =
'';
192 $search[$key.
'_dtend'] =
'';
195 $search[
'nb_of_values'] =
'';
196 $search[
'nb_products'] =
'';
198 $search_array_options = array();
200 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
201 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
205 if ($action ==
'up' && $permissiontoadd) {
206 $object->attributeMoveUp($rowid);
208 header(
'Location: '.$_SERVER[
'PHP_SELF']);
210 } elseif ($action ==
'down' && $permissiontoadd) {
211 $object->attributeMoveDown($rowid);
213 header(
'Location: '.$_SERVER[
'PHP_SELF']);
218 $objectclass =
'ProductAttribute';
219 $objectlabel =
'ProductAttribute';
220 $uploaddir = $conf->variants->dir_output;
221 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
230$form =
new Form($db);
234$title = $langs->trans(
"ProductAttributes");
242$sql =
"SELECT COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products, ";
243$sql .=
$object->getFieldList(
"t");
251$parameters = array();
252$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
253$sql .= $hookmanager->resPrint;
254$sql = preg_replace(
'/,\s*$/',
'', $sql);
258$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
262$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid";
263$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_value AS pav ON pav.fk_product_attribute = t.rowid";
265$parameters = array();
266$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
267$sql .= $hookmanager->resPrint;
268if (
$object->ismultientitymanaged == 1) {
269 $sql .=
" WHERE t.entity IN (".getEntity(
$object->element, (
GETPOST(
'search_current_entity',
'int') ? 0 : 1)).
")";
271 $sql .=
" WHERE 1 = 1";
273foreach ($search as $key => $val) {
274 if (array_key_exists($key,
$object->fields)) {
275 if ($key ==
'status' && $search[$key] == -1) {
279 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
280 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
285 if ($search[$key] !=
'') {
286 $sql .=
natural_search(
"t.".$db->sanitize($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
289 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
290 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
291 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
292 if (preg_match(
'/_dtstart$/', $key)) {
293 $sql .=
" AND t.".$db->sanitize($columnName).
" >= '".$db->idate($search[$key]).
"'";
295 if (preg_match(
'/_dtend$/', $key)) {
296 $sql .=
" AND t.".$db->sanitize($columnName).
" <= '".$db->idate($search[$key]).
"'";
303 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
309$parameters = array();
310$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
311$sql .= $hookmanager->resPrint;
315foreach (
$object->fields as $key => $val) {
316 $sql .=
"t.".$db->sanitize($key).
", ";
325$parameters = array();
326$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object, $action);
327$sql .= $hookmanager->resPrint;
328$sql = preg_replace(
"/,\s*$/",
"", $sql);
330$sql .=
" HAVING 1=1";
331if ($search[
'nb_of_values'] !=
'') {
332 $sql .=
natural_search(
"nb_of_values", $search[
'nb_of_values'], 1);
334if ($search[
'nb_products'] !=
'') {
338$parameters = array();
339$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
340$sql .= empty($hookmanager->resPrint) ?
"" :
" ".$hookmanager->resPrint;
343$nbtotalofrecords =
'';
355 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
356 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
358 $resql = $db->query($sqlforcount);
361 $nbtotalofrecords = $db->num_rows($resql);
363 $objforcount = $db->fetch_object($resql);
364 $nbtotalofrecords = $objforcount->nbtotalofrecords;
366 if (($page * $limit) > $nbtotalofrecords) {
375$sql .= $db->order($sortfield, $sortorder);
377 $sql .= $db->plimit($limit + 1, $offset);
380$resql = $db->query($sql);
386$num = $db->num_rows($resql);
390if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
391 $obj = $db->fetch_object($resql);
393 header(
"Location: " .
dol_buildpath(
'/variants/card.php', 2) .
'?id='.((
int) $id));
401llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist');
403$arrayofselected = is_array($toselect) ? $toselect : array();
407 $param .=
'&mode='.urlencode($mode);
409if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
410 $param .=
'&contextpage='.urlencode($contextpage);
412if ($limit > 0 && $limit != $conf->liste_limit) {
413 $param .=
'&limit='.((int) $limit);
415if ($optioncss !=
'') {
416 $param .=
'&optioncss='.urlencode($optioncss);
419 $param .=
'&groupby='.urlencode($groupby);
421foreach ($search as $key => $val) {
422 if (is_array($search[$key])) {
423 foreach ($search[$key] as $skey) {
425 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
428 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
429 $param .=
'&search_'.$key.
'month='.(
GETPOSTINT(
'search_'.$key.
'month'));
430 $param .=
'&search_'.$key.
'day='.(
GETPOSTINT(
'search_'.$key.
'day'));
431 $param .=
'&search_'.$key.
'year='.(
GETPOSTINT(
'search_'.$key.
'year'));
432 } elseif ($search[$key] !=
'') {
433 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
437include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
439$parameters = array(
'param' => &$param);
440$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
441$param .= $hookmanager->resPrint;
444$arrayofmassactions = array(
450if (!empty($permissiontodelete)) {
451 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
453if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
454 $arrayofmassactions = array();
456$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
458print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
459if ($optioncss !=
'') {
460 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
462print
'<input type="hidden" name="token" value="'.newToken().
'">';
463print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
464print
'<input type="hidden" name="action" value="list">';
465print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
466print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
467print
'<input type="hidden" name="page" value="'.$page.
'">';
468print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
469print
'<input type="hidden" name="page_y" value="">';
470print
'<input type="hidden" name="mode" value="'.$mode.
'">';
473$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'));
474$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'));
476$newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/variants/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
478print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
481$topicmail =
"SendProductAttributeRef";
482$modelmail =
"productattribute";
484$trackid =
'pa'.$object->id;
485include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
489 foreach ($fieldstosearchall as $key => $val) {
490 $fieldstosearchall[$key] = $langs->trans($val);
491 $setupstring .= $key.
"=".$val.
";";
493 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
494 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
502$parameters = array();
503$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
504if (empty($reshook)) {
505 $moreforfilter .= $hookmanager->resPrint;
507 $moreforfilter = $hookmanager->resPrint;
510if (!empty($moreforfilter)) {
511 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
512 print $moreforfilter;
516$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
517$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
518$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
519$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
521print
'<div class="div-table-responsive">';
522print
'<table id="tableattributes" class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
527print
'<tr class="liste_titre_filter">';
530 print
'<td class="liste_titre center maxwidthsearch">';
531 $searchpicto = $form->showFilterButtons(
'left');
535foreach (
$object->fields as $key => $val) {
537 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
538 if ($key ==
'status') {
539 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
540 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
541 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
542 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
543 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
544 } 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'])) {
545 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
547 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
548 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
549 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
550 print $form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), 1, 0, 0,
'', 1, 0, 0,
'',
'maxwidth100'.($key ==
'status' ?
' search_status width100 onrightofpage' :
''), 1);
551 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
552 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
553 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
554 print
'<div class="nowrap">';
555 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
557 print
'<div class="nowrap">';
558 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
560 } elseif ($key ==
'lang') {
561 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
563 print $formadmin->select_language((isset($search[$key]) ? $search[$key] :
''),
'search_lang', 0, null, 1, 0, 0,
'minwidth100imp maxwidth125', 2);
565 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
571include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
573$parameters = array(
'arrayfields' => $arrayfields);
574$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
575print $hookmanager->resPrint;
577$key =
'nb_of_values';
578if (!empty($arrayfields[$key][
'checked'])) {
579 print
'<td class="liste_titre center">';
580 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
584if (!empty($arrayfields[$key][
'checked'])) {
585 print
'<td class="liste_titre center">';
586 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
591 print
'<td class="liste_titre center maxwidthsearch">';
592 $searchpicto = $form->showFilterButtons();
597print
'<td class="liste_titre linecolmove width25"></td>';
600$totalarray = array();
601$totalarray[
'nbfield'] = 0;
605print
'<tr class="liste_titre">';
608 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
609 $totalarray[
'nbfield']++;
611foreach (
$object->fields as $key => $val) {
612 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
613 if ($key ==
'status') {
614 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
615 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
616 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
617 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
618 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
619 } 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'])) {
620 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
622 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
623 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
624 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";
625 $totalarray[
'nbfield']++;
629include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
631$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
632$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
633print $hookmanager->resPrint;
635$key =
'nb_of_values';
636if (!empty($arrayfields[$key][
'checked'])) {
637 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
638 $totalarray[
'nbfield']++;
641if (!empty($arrayfields[$key][
'checked'])) {
642 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
643 $totalarray[
'nbfield']++;
647 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
648 $totalarray[
'nbfield']++;
652$totalarray[
'nbfield']++;
657$needToFetchEachLine = 0;
670$savnbfield = $totalarray[
'nbfield'];
671$totalarray = array();
672$totalarray[
'nbfield'] = 0;
673$imaxinloop = ($limit ? min($num, $limit) : $num);
674while ($i < $imaxinloop) {
675 $obj = $db->fetch_object($resql);
681 $object->setVarsFromFetchObj($obj);
683 if ($mode ==
'kanban') {
685 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
686 print
'<div class="box-flex-container kanban">';
690 if ($massactionbutton || $massaction) {
692 if (in_array(
$object->id, $arrayofselected)) {
696 print
$object->getKanbanView(
'', array(
'selected' => $selected));
697 if ($i == ($imaxinloop - 1)) {
704 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
707 print
'<td class="nowrap center">';
708 if ($massactionbutton || $massaction) {
710 if (in_array(
$object->id, $arrayofselected)) {
713 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
717 $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 ?
' ' :
'') .
'nowraponall';
731 } elseif ($key ==
'ref') {
732 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowraponall';
735 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'])) {
736 $cssforfield .= ($cssforfield ?
' ' :
'') .
'right';
740 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
741 print
'<td'.($cssforfield ?
' class="'.$cssforfield.((preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) ?
' classfortooltip' :
'').
'"' :
'');
742 if (preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) {
743 print
' title="'.dol_escape_htmltag(
$object->$key).
'"';
746 if ($key ==
'status') {
747 print
$object->getLibStatut(5);
748 } elseif ($key ==
'rowid') {
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;
778 $key =
'nb_of_values';
779 if (!empty($arrayfields[$key][
'checked'])) {
780 print
'<td class="center">';
784 $totalarray[
'nbfield']++;
787 $key =
'nb_products';
788 if (!empty($arrayfields[$key][
'checked'])) {
789 print
'<td class="center">';
793 $totalarray[
'nbfield']++;
798 print
'<td class="nowrap center">';
799 if ($massactionbutton || $massaction) {
801 if (in_array(
$object->id, $arrayofselected)) {
804 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
808 $totalarray[
'nbfield']++;
812 print
'<td class="center linecolmove tdlineupdown">';
814 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=up&rowid=' . $obj->rowid .
'">' .
img_up(
'default', 0,
'imgupforline') .
'</a>';
817 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=down&rowid=' . $obj->rowid .
'">' .
img_down(
'default', 0,
'imgdownforline') .
'</a>';
821 $totalarray[
'nbfield']++;
824 print
'</tr>' .
"\n";
831include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
836 foreach ($arrayfields as $key => $val) {
837 if (!empty($val[
'checked'])) {
842 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
847$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
848$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
849print $hookmanager->resPrint;
851print
'</table>'.
"\n";
857$tagidfortablednd = (empty($tagidfortablednd) ?
'tableattributes' : $tagidfortablednd);
860 $(document).ready(
function(){
861 $(
".imgupforline, .imgdownforline").hide();
862 $(
".lineupdown").removeAttr(
'href');
864 .css(
"background-image",
'url(<?php echo DOL_URL_ROOT.'/theme/
'.$conf->theme.'/img/grip.png
'; ?>)')
865 .css(
"background-repeat",
"no-repeat")
866 .css(
"background-position",
"center center")
869 $(
this).addClass(
'showDragHandle');
871 $(
this).removeClass(
'showDragHandle');
875 $(
"#<?php echo $tagidfortablednd; ?>").tableDnD({
876 onDrop:
function(
table, row) {
878 $(
'#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr(
'id',
'');
879 $(
'#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr(
'id',
'');
880 var reloadpage =
"<?php echo $forcereloadpage; ?>";
881 var roworder = cleanSerialize(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
882 $.post(
"<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
885 token:
"<?php echo currentToken(); ?>"
888 if (reloadpage == 1) {
889 location.href =
'<?php echo dol_escape_htmltag($_SERVER['PHP_SELF
']).'?
'.dol_escape_htmltag($_SERVER['QUERY_STRING
']); ?>';
893 onDragClass:
"dragClass",
894 dragHandle:
"td.tdlineupdown"
900if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
901 $hidegeneratedfilelistifempty = 1;
902 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
903 $hidegeneratedfilelistifempty = 0;
906 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
910 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
911 $urlsource .= str_replace(
'&',
'&', $param);
913 $filedir = $diroutputmassaction;
914 $genallowed = $permissiontoread;
915 $delallowed = $permissiontoadd;
917 print $formfile->showdocuments(
'massfilesarea_productattribute',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class ProductAttribute Used to represent a Product attribute Examples:
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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...
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
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.
print_barre_liste($title, $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.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
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...
treeview li table
No Email.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.