29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
34$langs->loadLangs(array(
"products",
"other"));
36$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
37$massaction =
GETPOST(
'massaction',
'alpha');
39$confirm =
GETPOST(
'confirm',
'alpha');
40$cancel =
GETPOST(
'cancel',
'alpha');
41$toselect =
GETPOST(
'toselect',
'array:int');
42$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
43$backtopage =
GETPOST(
'backtopage',
'alpha');
44$optioncss =
GETPOST(
'optioncss',
'aZ');
51$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
58$offset = $limit * $page;
65$diroutputmassaction = $conf->variants->dir_output.
'/temp/massgeneration/'.$user->id;
66$hookmanager->initHooks(array(
'productattributelist'));
75 $sortfield =
"t.position";
82$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
84foreach (
$object->fields as $key => $val) {
85 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
86 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
88 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
93$search[
'nb_of_values'] =
GETPOST(
'search_nb_of_values',
'alpha');
94$search[
'nb_products'] =
GETPOST(
'search_nb_products',
'alpha');
96$fieldstosearchall = array();
98foreach (
$object->fields as $key => $val) {
99 if (!empty($val[
'searchall'])) {
100 $fieldstosearchall[
't.'.$key] = $val[
'label'];
103$parameters = array(
'fieldstosearchall' => $fieldstosearchall);
104$reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action);
106 $fieldstosearchall = empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall'];
107} elseif ($reshook == 0) {
108 $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall']);
112$arrayfields = array();
113foreach (
$object->fields as $key => $val) {
115 if (!empty($val[
'visible'])) {
116 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
117 $arrayfields[
't.'.$key] = array(
118 'label' => $val[
'label'],
119 'checked' => (($visible < 0) ? 0 : 1),
120 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
121 'position' => $val[
'position'],
122 'help' => isset($val[
'help']) ? $val[
'help'] :
''
126$arrayfields[
'nb_of_values'] = array(
127 'label' => $langs->trans(
'NbOfDifferentValues'),
133$arrayfields[
'nb_products'] = array(
134 'label' => $langs->trans(
'NbProducts'),
145'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
147$permissiontoread = $user->hasRight(
'variants',
'read');
148$permissiontoadd = $user->hasRight(
'variants',
'write');
149$permissiontodelete = $user->hasRight(
'variants',
'delete');
152if (!isModEnabled(
'variants')) {
156if ($user->socid > 0) {
160if (!$permissiontoread) {
169if (
GETPOST(
'cancel',
'alpha')) {
173if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
177$parameters = array(
'arrayfields' => &$arrayfields);
178$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
183if (empty($reshook)) {
185 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
188 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
189 foreach (
$object->fields as $key => $val) {
191 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
192 $search[$key.
'_dtstart'] =
'';
193 $search[$key.
'_dtend'] =
'';
196 $search[
'nb_of_values'] =
'';
197 $search[
'nb_products'] =
'';
199 $search_array_options = array();
201 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
202 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
206 if ($action ==
'up' && $permissiontoadd) {
207 $object->attributeMoveUp($rowid);
209 header(
'Location: '.$_SERVER[
'PHP_SELF']);
211 } elseif ($action ==
'down' && $permissiontoadd) {
212 $object->attributeMoveDown($rowid);
214 header(
'Location: '.$_SERVER[
'PHP_SELF']);
219 $objectclass =
'ProductAttribute';
220 $objectlabel =
'ProductAttribute';
221 $uploaddir = $conf->variants->dir_output;
222 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
231$form =
new Form($db);
235$title = $langs->trans(
"ProductAttributes");
243$sql =
"SELECT COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products, ";
244$sql .=
$object->getFieldList(
"t");
252$parameters = array();
253$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
254$sql .= $hookmanager->resPrint;
255$sql = preg_replace(
'/,\s*$/',
'', $sql);
259$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
263$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid";
264$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_value AS pav ON pav.fk_product_attribute = t.rowid";
266$parameters = array();
267$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
268$sql .= $hookmanager->resPrint;
269if (
$object->ismultientitymanaged == 1) {
270 $sql .=
" WHERE t.entity IN (".getEntity(
$object->element, (
GETPOST(
'search_current_entity',
'int') ? 0 : 1)).
")";
272 $sql .=
" WHERE 1 = 1";
274foreach ($search as $key => $val) {
275 if (array_key_exists($key,
$object->fields)) {
276 if ($key ==
'status' && $search[$key] == -1) {
280 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
281 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
286 if ($search[$key] !=
'') {
287 $sql .=
natural_search(
"t.".$db->sanitize($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
290 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
291 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
292 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
293 if (preg_match(
'/_dtstart$/', $key)) {
294 $sql .=
" AND t.".$db->sanitize($columnName).
" >= '".$db->idate($search[$key]).
"'";
296 if (preg_match(
'/_dtend$/', $key)) {
297 $sql .=
" AND t.".$db->sanitize($columnName).
" <= '".$db->idate($search[$key]).
"'";
304 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
310$parameters = array();
311$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
312$sql .= $hookmanager->resPrint;
316foreach (
$object->fields as $key => $val) {
317 $sql .=
"t.".$db->sanitize($key).
", ";
326$parameters = array();
327$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object, $action);
328$sql .= $hookmanager->resPrint;
329$sql = preg_replace(
"/,\s*$/",
"", $sql);
331$sql .=
" HAVING 1=1";
332if ($search[
'nb_of_values'] !=
'') {
333 $sql .=
natural_search(
"nb_of_values", $search[
'nb_of_values'], 1);
335if ($search[
'nb_products'] !=
'') {
339$parameters = array();
340$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
341$sql .= empty($hookmanager->resPrint) ?
"" :
" ".$hookmanager->resPrint;
344$nbtotalofrecords =
'';
356 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
357 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
359 $resql = $db->query($sqlforcount);
362 $nbtotalofrecords = $db->num_rows($resql);
364 $objforcount = $db->fetch_object($resql);
365 $nbtotalofrecords = $objforcount->nbtotalofrecords;
367 if (($page * $limit) > $nbtotalofrecords) {
376$sql .= $db->order($sortfield, $sortorder);
378 $sql .= $db->plimit($limit + 1, $offset);
381$resql = $db->query($sql);
387$num = $db->num_rows($resql);
391if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
392 $obj = $db->fetch_object($resql);
394 header(
"Location: " .
dol_buildpath(
'/variants/card.php', 2) .
'?id='.((
int)
$id));
402llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist');
404$arrayofselected = is_array($toselect) ? $toselect : array();
408 $param .=
'&mode='.urlencode($mode);
410if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
411 $param .=
'&contextpage='.urlencode($contextpage);
413if ($limit > 0 && $limit != $conf->liste_limit) {
414 $param .=
'&limit='.((int) $limit);
416if ($optioncss !=
'') {
417 $param .=
'&optioncss='.urlencode($optioncss);
424foreach ($search as $key => $val) {
425 if (is_array($search[$key])) {
426 foreach ($search[$key] as $skey) {
428 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
431 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
432 $param .=
'&search_'.$key.
'month='.(
GETPOSTINT(
'search_'.$key.
'month'));
433 $param .=
'&search_'.$key.
'day='.(
GETPOSTINT(
'search_'.$key.
'day'));
434 $param .=
'&search_'.$key.
'year='.(
GETPOSTINT(
'search_'.$key.
'year'));
435 } elseif ($search[$key] !=
'') {
436 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
440include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
442$parameters = array(
'param' => &$param);
443$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
444$param .= $hookmanager->resPrint;
447$arrayofmassactions = array(
453if (!empty($permissiontodelete)) {
454 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
456if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
457 $arrayofmassactions = array();
459$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
461print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
462if ($optioncss !=
'') {
463 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
465print
'<input type="hidden" name="token" value="'.newToken().
'">';
466print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
467print
'<input type="hidden" name="action" value="list">';
468print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
469print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
470print
'<input type="hidden" name="page" value="'.$page.
'">';
471print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
472print
'<input type="hidden" name="page_y" value="">';
473print
'<input type="hidden" name="mode" value="'.$mode.
'">';
476$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'));
477$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'));
479$newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/variants/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
481print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
484$topicmail =
"SendProductAttributeRef";
485$modelmail =
"productattribute";
487$trackid =
'pa'.$object->id;
488include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
492 foreach ($fieldstosearchall as $key => $val) {
493 $fieldstosearchall[$key] = $langs->trans($val);
494 $setupstring .= $key.
"=".$val.
";";
496 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
497 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
505$parameters = array();
506$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
507if (empty($reshook)) {
508 $moreforfilter .= $hookmanager->resPrint;
510 $moreforfilter = $hookmanager->resPrint;
513if (!empty($moreforfilter)) {
514 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
515 print $moreforfilter;
519$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
520$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
521$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
522$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
524print
'<div class="div-table-responsive">';
525print
'<table id="tableattributes" class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
530print
'<tr class="liste_titre_filter">';
533 print
'<td class="liste_titre center maxwidthsearch">';
534 $searchpicto = $form->showFilterButtons(
'left');
538foreach (
$object->fields as $key => $val) {
540 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
541 if ($key ==
'status') {
542 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
543 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
544 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
545 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
546 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
547 } 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'])) {
548 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
550 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
551 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
552 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
553 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);
554 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
555 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
556 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
557 print
'<div class="nowrap">';
558 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
560 print
'<div class="nowrap">';
561 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
563 } elseif ($key ==
'lang') {
564 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
566 print $formadmin->select_language((isset($search[$key]) ? $search[$key] :
''),
'search_lang', 0, array(), 1, 0, 0,
'minwidth100imp maxwidth125', 2);
568 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
574include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
576$parameters = array(
'arrayfields' => $arrayfields);
577$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
578print $hookmanager->resPrint;
580$key =
'nb_of_values';
581if (!empty($arrayfields[$key][
'checked'])) {
582 print
'<td class="liste_titre center">';
583 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
587if (!empty($arrayfields[$key][
'checked'])) {
588 print
'<td class="liste_titre center">';
589 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
594 print
'<td class="liste_titre center maxwidthsearch">';
595 $searchpicto = $form->showFilterButtons();
600print
'<td class="liste_titre linecolmove width25"></td>';
603$totalarray = array();
604$totalarray[
'nbfield'] = 0;
608print
'<tr class="liste_titre">';
611 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
612 $totalarray[
'nbfield']++;
614foreach (
$object->fields as $key => $val) {
615 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
616 if ($key ==
'status') {
617 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
618 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
619 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
620 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
621 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
622 } 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'])) {
623 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
625 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
626 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
627 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";
628 $totalarray[
'nbfield']++;
632include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
634$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
635$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
636print $hookmanager->resPrint;
638$key =
'nb_of_values';
639if (!empty($arrayfields[$key][
'checked'])) {
641 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
642 $totalarray[
'nbfield']++;
645if (!empty($arrayfields[$key][
'checked'])) {
646 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
647 $totalarray[
'nbfield']++;
651 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
652 $totalarray[
'nbfield']++;
656$totalarray[
'nbfield']++;
661$needToFetchEachLine = 0;
674$savnbfield = $totalarray[
'nbfield'];
675$totalarray = array();
676$totalarray[
'nbfield'] = 0;
677$imaxinloop = ($limit ? min($num, $limit) : $num);
678while ($i < $imaxinloop) {
679 $obj = $db->fetch_object($resql);
685 $object->setVarsFromFetchObj($obj);
687 if ($mode ==
'kanban') {
689 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
690 print
'<div class="box-flex-container kanban">';
694 if ($massactionbutton || $massaction) {
696 if (in_array(
$object->id, $arrayofselected)) {
700 print
$object->getKanbanView(
'', array(
'selected' => $selected));
701 if ($i == ($imaxinloop - 1)) {
708 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
711 print
'<td class="nowrap center">';
712 if ($massactionbutton || $massaction) {
714 if (in_array(
$object->id, $arrayofselected)) {
717 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
721 $totalarray[
'nbfield']++;
725 foreach (
$object->fields as $key => $val) {
726 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
727 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
728 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
729 } elseif ($key ==
'status') {
730 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
733 if (in_array($val[
'type'], array(
'timestamp'))) {
734 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowraponall';
735 } elseif ($key ==
'ref') {
736 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowraponall';
739 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'])) {
740 $cssforfield .= ($cssforfield ?
' ' :
'') .
'right';
744 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
745 print
'<td'.($cssforfield ?
' class="'.$cssforfield.((preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) ?
' classfortooltip' :
'').
'"' :
'');
746 if (preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) {
747 print
' title="'.dol_escape_htmltag(
$object->$key).
'"';
750 if ($key ==
'status') {
751 print
$object->getLibStatut(5);
752 } elseif ($key ==
'rowid') {
759 $totalarray[
'nbfield']++;
761 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
763 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.' . $key;
765 if (!isset($totalarray[
'val'])) {
766 $totalarray[
'val'] = array();
768 if (!isset($totalarray[
'val'][
't.' . $key])) {
769 $totalarray[
'val'][
't.' . $key] = 0;
771 $totalarray[
'val'][
't.' . $key] +=
$object->$key;
776 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
778 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
779 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
780 print $hookmanager->resPrint;
782 $key =
'nb_of_values';
783 if (!empty($arrayfields[$key][
'checked'])) {
784 print
'<td class="center">';
788 $totalarray[
'nbfield']++;
791 $key =
'nb_products';
792 if (!empty($arrayfields[$key][
'checked'])) {
793 print
'<td class="center">';
797 $totalarray[
'nbfield']++;
802 print
'<td class="nowrap center">';
803 if ($massactionbutton || $massaction) {
805 if (in_array(
$object->id, $arrayofselected)) {
808 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
812 $totalarray[
'nbfield']++;
816 print
'<td class="center linecolmove tdlineupdown">';
818 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=up&rowid=' . $obj->rowid .
'">' .
img_up(
'default', 0,
'imgupforline') .
'</a>';
821 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=down&rowid=' . $obj->rowid .
'">' .
img_down(
'default', 0,
'imgdownforline') .
'</a>';
825 $totalarray[
'nbfield']++;
828 print
'</tr>' .
"\n";
835include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
840 foreach ($arrayfields as $key => $val) {
841 if (!empty($val[
'checked'])) {
846 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
851$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
852$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
853print $hookmanager->resPrint;
855print
'</table>'.
"\n";
861$tagidfortablednd = (empty($tagidfortablednd) ?
'tableattributes' : $tagidfortablednd);
864 $(document).ready(
function(){
865 $(
".imgupforline, .imgdownforline").hide();
866 $(
".lineupdown").removeAttr(
'href');
868 .css(
"background-image",
'url(<?php echo DOL_URL_ROOT.'/theme/
'.$conf->theme.'/img/grip.png
'; ?>)')
869 .css(
"background-repeat",
"no-repeat")
870 .css(
"background-position",
"center center")
873 $(
this).addClass(
'showDragHandle');
875 $(
this).removeClass(
'showDragHandle');
879 $(
"#<?php echo $tagidfortablednd; ?>").tableDnD({
880 onDrop:
function(
table, row) {
882 $(
'#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr(
'id',
'');
883 $(
'#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr(
'id',
'');
884 var reloadpage =
"<?php echo $forcereloadpage; ?>";
885 var roworder = cleanSerialize(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
886 $.post(
"<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
889 token:
"<?php echo currentToken(); ?>"
892 if (reloadpage == 1) {
893 location.href =
'<?php echo dol_escape_htmltag($_SERVER['PHP_SELF
']).'?
'.dol_escape_htmltag($_SERVER['QUERY_STRING
']); ?>';
897 onDragClass:
"dragClass",
898 dragHandle:
"td.tdlineupdown"
904if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
905 $hidegeneratedfilelistifempty = 1;
906 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
907 $hidegeneratedfilelistifempty = 0;
910 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
914 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
915 $urlsource .= str_replace(
'&',
'&', $param);
917 $filedir = $diroutputmassaction;
918 $genallowed = $permissiontoread;
919 $delallowed = $permissiontoadd;
921 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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 a 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.