29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
42$langs->loadLangs(array(
"products",
"other"));
44$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
45$massaction =
GETPOST(
'massaction',
'alpha');
47$confirm =
GETPOST(
'confirm',
'alpha');
48$cancel =
GETPOST(
'cancel',
'alpha');
49$toselect =
GETPOST(
'toselect',
'array:int');
50$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
51$backtopage =
GETPOST(
'backtopage',
'alpha');
52$optioncss =
GETPOST(
'optioncss',
'aZ');
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
62if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
66$offset = $limit * $page;
73$diroutputmassaction =
$conf->variants->dir_output.
'/temp/massgeneration/'.$user->id;
74$hookmanager->initHooks(array(
'productattributelist'));
77$extrafields->fetch_name_optionals_label(
$object->table_element);
79$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
83 $sortfield =
"t.position";
90$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
92foreach (
$object->fields as $key => $val) {
93 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
94 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
96 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
101$search[
'nb_of_values'] =
GETPOST(
'search_nb_of_values',
'alpha');
102$search[
'nb_products'] =
GETPOST(
'search_nb_products',
'alpha');
104$fieldstosearchall = array();
106foreach (
$object->fields as $key => $val) {
107 if (!empty($val[
'searchall'])) {
108 $fieldstosearchall[
't.'.$key] = $val[
'label'];
111$parameters = array(
'fieldstosearchall' => $fieldstosearchall);
112$reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action);
114 $fieldstosearchall = empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall'];
115} elseif ($reshook == 0) {
116 $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall']);
120$arrayfields = array();
121foreach (
$object->fields as $key => $val) {
123 if (!empty($val[
'visible'])) {
124 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
125 $arrayfields[
't.'.$key] = array(
126 'label' => $val[
'label'],
127 'checked' => (($visible < 0) ? 0 : 1),
128 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
129 'position' => $val[
'position'],
130 'help' => isset($val[
'help']) ? $val[
'help'] :
''
134$arrayfields[
'nb_of_values'] = array(
135 'label' => $langs->trans(
'NbOfDifferentValues'),
141$arrayfields[
'nb_products'] = array(
142 'label' => $langs->trans(
'NbProducts'),
149include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
153'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
155$permissiontoread = $user->hasRight(
'variants',
'read');
156$permissiontoadd = $user->hasRight(
'variants',
'write');
157$permissiontodelete = $user->hasRight(
'variants',
'delete');
160if (!isModEnabled(
'variants')) {
164if ($user->socid > 0) {
168if (!$permissiontoread) {
177if (
GETPOST(
'cancel',
'alpha')) {
181if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
185$parameters = array(
'arrayfields' => &$arrayfields);
186$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
191if (empty($reshook)) {
193 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
196 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
197 foreach (
$object->fields as $key => $val) {
199 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
200 $search[$key.
'_dtstart'] =
'';
201 $search[$key.
'_dtend'] =
'';
204 $search[
'nb_of_values'] =
'';
205 $search[
'nb_products'] =
'';
207 $search_array_options = array();
209 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
210 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
214 if ($action ==
'up' && $permissiontoadd) {
215 $object->attributeMoveUp($rowid);
217 header(
'Location: '.$_SERVER[
'PHP_SELF']);
219 } elseif ($action ==
'down' && $permissiontoadd) {
220 $object->attributeMoveDown($rowid);
222 header(
'Location: '.$_SERVER[
'PHP_SELF']);
227 $objectclass =
'ProductAttribute';
228 $objectlabel =
'ProductAttribute';
229 $uploaddir =
$conf->variants->dir_output;
230 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
239$form =
new Form($db);
243$title = $langs->trans(
"ProductAttributes");
251$sql =
"SELECT COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products, ";
252$sql .=
$object->getFieldList(
"t");
254if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
255 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
256 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
"");
260$parameters = array();
261$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
262$sql .= $hookmanager->resPrint;
263$sql = preg_replace(
'/,\s*$/',
'', $sql);
267$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
268if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
269 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
271$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid";
272$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_value AS pav ON pav.fk_product_attribute = t.rowid";
274$parameters = array();
275$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
276$sql .= $hookmanager->resPrint;
277if (
$object->ismultientitymanaged == 1) {
278 $sql .=
" WHERE t.entity IN (".getEntity(
$object->element, (
GETPOSTINT(
'search_current_entity') ? 0 : 1)).
")";
280 $sql .=
" WHERE 1 = 1";
282foreach ($search as $key => $val) {
283 if (array_key_exists($key,
$object->fields)) {
284 if ($key ==
'status' && $search[$key] == -1) {
288 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
289 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
294 if ($search[$key] !=
'') {
295 $sql .=
natural_search(
"t.".$db->sanitize($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
298 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
299 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
300 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
301 if (preg_match(
'/_dtstart$/', $key)) {
302 $sql .=
" AND t.".$db->sanitize($columnName).
" >= '".$db->idate($search[$key]).
"'";
304 if (preg_match(
'/_dtend$/', $key)) {
305 $sql .=
" AND t.".$db->sanitize($columnName).
" <= '".$db->idate($search[$key]).
"'";
312 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
316include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
318$parameters = array();
319$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
320$sql .= $hookmanager->resPrint;
324foreach (
$object->fields as $key => $val) {
325 $sql .=
"t.".$db->sanitize($key).
", ";
328if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
329 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
330 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
', ' :
'');
334$parameters = array();
335$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object, $action);
336$sql .= $hookmanager->resPrint;
337$sql = preg_replace(
"/,\s*$/",
"", $sql);
339$sql .=
" HAVING 1=1";
340if ($search[
'nb_of_values'] !=
'') {
341 $sql .=
natural_search(
"nb_of_values", $search[
'nb_of_values'], 1);
343if ($search[
'nb_products'] !=
'') {
347$parameters = array();
348$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
349$sql .= empty($hookmanager->resPrint) ?
"" :
" ".$hookmanager->resPrint;
352$nbtotalofrecords =
'';
364 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
365 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
367 $resql = $db->query($sqlforcount);
370 $nbtotalofrecords = $db->num_rows($resql);
372 $objforcount = $db->fetch_object($resql);
373 $nbtotalofrecords = $objforcount->nbtotalofrecords;
375 if (($page * $limit) > $nbtotalofrecords) {
384$sql .= $db->order($sortfield, $sortorder);
386 $sql .= $db->plimit($limit + 1, $offset);
389$resql = $db->query($sql);
395$num = $db->num_rows($resql);
399if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
400 $obj = $db->fetch_object($resql);
402 header(
"Location: " .
dol_buildpath(
'/variants/card.php', 2) .
'?id='.((
int)
$id));
410llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist');
412$arrayofselected = is_array($toselect) ? $toselect : array();
416 $param .=
'&mode='.urlencode($mode);
418if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
419 $param .=
'&contextpage='.urlencode($contextpage);
421if ($limit > 0 && $limit !=
$conf->liste_limit) {
422 $param .=
'&limit='.((int) $limit);
424if ($optioncss !=
'') {
425 $param .=
'&optioncss='.urlencode($optioncss);
432foreach ($search as $key => $val) {
433 if (is_array($search[$key])) {
434 foreach ($search[$key] as $skey) {
436 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
439 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
440 $param .=
'&search_'.$key.
'month='.(
GETPOSTINT(
'search_'.$key.
'month'));
441 $param .=
'&search_'.$key.
'day='.(
GETPOSTINT(
'search_'.$key.
'day'));
442 $param .=
'&search_'.$key.
'year='.(
GETPOSTINT(
'search_'.$key.
'year'));
443 } elseif ($search[$key] !=
'') {
444 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
448include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
450$parameters = array(
'param' => &$param);
451$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
452$param .= $hookmanager->resPrint;
455$arrayofmassactions = array(
461if (!empty($permissiontodelete)) {
462 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
464if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
465 $arrayofmassactions = array();
467$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
469print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
470if ($optioncss !=
'') {
471 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
473print
'<input type="hidden" name="token" value="'.newToken().
'">';
474print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
475print
'<input type="hidden" name="action" value="list">';
476print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
477print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
478print
'<input type="hidden" name="page" value="'.$page.
'">';
479print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
480print
'<input type="hidden" name="page_y" value="">';
481print
'<input type="hidden" name="mode" value="'.$mode.
'">';
484$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'));
485$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'));
487$newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/variants/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
489print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
492$topicmail =
"SendProductAttributeRef";
493$modelmail =
"productattribute";
495$trackid =
'pa'.$object->id;
496include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
500 foreach ($fieldstosearchall as $key => $val) {
501 $fieldstosearchall[$key] = $langs->trans($val);
502 $setupstring .= $key.
"=".$val.
";";
504 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
505 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
513$parameters = array();
514$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
515if (empty($reshook)) {
516 $moreforfilter .= $hookmanager->resPrint;
518 $moreforfilter = $hookmanager->resPrint;
521if (!empty($moreforfilter)) {
522 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
523 print $moreforfilter;
527$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
528$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
529$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
530$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
532print
'<div class="div-table-responsive">';
533print
'<table id="tableattributes" class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
538print
'<tr class="liste_titre_filter nodrag nodrop">';
541 print
'<td class="liste_titre center maxwidthsearch">';
542 $searchpicto = $form->showFilterButtons(
'left');
546foreach (
$object->fields as $key => $val) {
548 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
549 if ($key ==
'status') {
550 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
551 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
552 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
553 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
554 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
555 } 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'])) {
556 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
558 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
559 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
560 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
561 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);
562 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
563 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
564 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
565 print
'<div class="nowrap">';
566 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
568 print
'<div class="nowrap">';
569 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
571 } elseif ($key ==
'lang') {
572 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
574 print $formadmin->select_language((isset($search[$key]) ? $search[$key] :
''),
'search_lang', 0, array(), 1, 0, 0,
'minwidth100imp maxwidth125', 2);
576 print
'<input type="text" class="flat maxwidth'.($val[
'type'] ==
'integer' ?
'50' :
'75').
'" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
582include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
584$parameters = array(
'arrayfields' => $arrayfields);
585$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
586print $hookmanager->resPrint;
588$key =
'nb_of_values';
589if (!empty($arrayfields[$key][
'checked'])) {
590 print
'<td class="liste_titre center">';
591 print
'<input type="text" class="flat maxwidth'.($val[
'type'] ==
'integer' ?
'50' :
'75').
'" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
595if (!empty($arrayfields[$key][
'checked'])) {
596 print
'<td class="liste_titre center">';
597 print
'<input type="text" class="flat maxwidth'.($val[
'type'] ==
'integer' ?
'50' :
'75').
'" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
602 print
'<td class="liste_titre center maxwidthsearch">';
603 $searchpicto = $form->showFilterButtons();
608print
'<td class="liste_titre linecolmove width25"></td>';
611$totalarray = array();
612$totalarray[
'nbfield'] = 0;
616print
'<tr class="liste_titre nodrag nodrop">';
619 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
620 $totalarray[
'nbfield']++;
622foreach (
$object->fields as $key => $val) {
623 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
624 if ($key ==
'status') {
625 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
626 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
627 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
628 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
629 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
630 } 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'])) {
631 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
633 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
634 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
635 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param,
'', $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
''), 0, (empty($val[
'helplist']) ?
'' : $val[
'helplist'])).
"\n";
636 $totalarray[
'nbfield']++;
640include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
642$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
643$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
644print $hookmanager->resPrint;
646$key =
'nb_of_values';
647if (!empty($arrayfields[$key][
'checked'])) {
649 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
650 $totalarray[
'nbfield']++;
653if (!empty($arrayfields[$key][
'checked'])) {
654 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
655 $totalarray[
'nbfield']++;
659 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
660 $totalarray[
'nbfield']++;
664$totalarray[
'nbfield']++;
669$needToFetchEachLine = 0;
682$savnbfield = $totalarray[
'nbfield'];
683$totalarray = array();
684$totalarray[
'nbfield'] = 0;
685$imaxinloop = ($limit ? min($num, $limit) : $num);
686while ($i < $imaxinloop) {
687 $obj = $db->fetch_object($resql);
693 $object->setVarsFromFetchObj($obj);
696 if ($mode ==
'kanban') {
698 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
699 print
'<div class="box-flex-container kanban">';
703 if ($massactionbutton || $massaction) {
705 if (in_array(
$object->id, $arrayofselected)) {
709 print
$object->getKanbanView(
'', array(
'selected' => $selected));
710 if ($i == ($imaxinloop - 1)) {
717 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
720 print
'<td class="nowrap center">';
721 if ($massactionbutton || $massaction) {
723 if (in_array(
$object->id, $arrayofselected)) {
726 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
730 $totalarray[
'nbfield']++;
734 foreach (
$object->fields as $key => $val) {
735 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
736 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
737 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
738 } elseif ($key ==
'status') {
739 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
742 if (in_array($val[
'type'], array(
'timestamp'))) {
743 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowraponall';
744 } elseif ($key ==
'ref') {
745 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowraponall';
748 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'])) {
749 $cssforfield .= ($cssforfield ?
' ' :
'') .
'right';
753 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
754 print
'<td'.($cssforfield ?
' class="'.$cssforfield.((preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) ?
' classfortooltip' :
'').
'"' :
'');
755 if (preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) {
756 print
' title="'.dol_escape_htmltag(
$object->$key).
'"';
759 if ($key ==
'status') {
760 print
$object->getLibStatut(5);
761 } elseif ($key ==
'rowid') {
768 $totalarray[
'nbfield']++;
770 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
772 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.' . $key;
774 if (!isset($totalarray[
'val'])) {
775 $totalarray[
'val'] = array();
777 if (!isset($totalarray[
'val'][
't.' . $key])) {
778 $totalarray[
'val'][
't.' . $key] = 0;
780 $totalarray[
'val'][
't.' . $key] +=
$object->$key;
785 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
787 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
788 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
789 print $hookmanager->resPrint;
791 $key =
'nb_of_values';
792 if (!empty($arrayfields[$key][
'checked'])) {
793 print
'<td class="center">';
797 $totalarray[
'nbfield']++;
800 $key =
'nb_products';
801 if (!empty($arrayfields[$key][
'checked'])) {
802 print
'<td class="center">';
806 $totalarray[
'nbfield']++;
811 print
'<td class="nowrap center">';
812 if ($massactionbutton || $massaction) {
814 if (in_array(
$object->id, $arrayofselected)) {
817 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
821 $totalarray[
'nbfield']++;
825 print
'<td class="center linecolmove tdlineupdown">';
827 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=up&rowid=' . $obj->rowid .
'">' .
img_up(
'default', 0,
'imgupforline') .
'</a>';
830 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=down&rowid=' . $obj->rowid .
'">' .
img_down(
'default', 0,
'imgdownforline') .
'</a>';
834 $totalarray[
'nbfield']++;
837 print
'</tr>' .
"\n";
844include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
849 foreach ($arrayfields as $key => $val) {
850 if (!empty($val[
'checked'])) {
855 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
860$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
861$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
862print $hookmanager->resPrint;
864print
'</table>'.
"\n";
870$tagidfortablednd = (empty($tagidfortablednd) ?
'tableattributes' : $tagidfortablednd);
873 $(document).ready(
function(){
874 $(
".imgupforline, .imgdownforline").hide();
875 $(
".lineupdown").removeAttr(
'href');
877 .css(
"background-image",
'url(<?php echo DOL_URL_ROOT.'/theme/
'.$conf->theme.'/img/grip.png
'; ?>)')
878 .css(
"background-repeat",
"no-repeat")
879 .css(
"background-position",
"center center")
882 $(
this).addClass(
'showDragHandle');
884 $(
this).removeClass(
'showDragHandle');
888 $(
"#<?php echo $tagidfortablednd; ?>").tableDnD({
889 onDrop:
function(
table, row) {
891 $(
'#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr(
'id',
'');
892 $(
'#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr(
'id',
'');
893 var reloadpage =
"<?php echo $forcereloadpage; ?>";
894 var roworder = cleanSerialize(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
895 $.post(
"<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
898 token:
"<?php echo currentToken(); ?>"
901 if (reloadpage == 1) {
902 location.href =
'<?php echo dol_escape_htmltag($_SERVER['PHP_SELF
']).'?
'.dol_escape_htmltag($_SERVER['QUERY_STRING
']); ?>';
906 onDragClass:
"dragClass",
907 dragHandle:
"td.tdlineupdown"
913if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
914 $hidegeneratedfilelistifempty = 1;
915 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
916 $hidegeneratedfilelistifempty = 0;
919 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
923 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
924 $urlsource .= str_replace(
'&',
'&', $param);
926 $filedir = $diroutputmassaction;
927 $genallowed = $permissiontoread;
928 $delallowed = $permissiontoadd;
930 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.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.