25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
30 $langs->loadLangs(array(
"products",
"other"));
32 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
33 $massaction =
GETPOST(
'massaction',
'alpha');
34 $show_files =
GETPOST(
'show_files',
'int');
35 $confirm =
GETPOST(
'confirm',
'alpha');
36 $cancel =
GETPOST(
'cancel',
'alpha');
37 $toselect =
GETPOST(
'toselect',
'array');
38 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'productattributelist';
39 $backtopage =
GETPOST(
'backtopage',
'alpha');
40 $optioncss =
GETPOST(
'optioncss',
'aZ');
45 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
46 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
47 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
49 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
53 $offset = $limit * $page;
54 $pageprev = $page - 1;
55 $pagenext = $page + 1;
60 $diroutputmassaction = $conf->variants->dir_output.
'/temp/massgeneration/'.$user->id;
61 $hookmanager->initHooks(array(
'productattributelist'));
70 $sortfield =
"t.position";
77 $search_all =
GETPOST(
'search_all',
'alphanohtml') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml');
79 foreach ($object->fields as $key => $val) {
80 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
81 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
83 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
84 $search[$key.
'_dtstart'] =
dol_mktime(0, 0, 0,
GETPOST(
'search_'.$key.
'_dtstartmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtstartday',
'int'),
GETPOST(
'search_'.$key.
'_dtstartyear',
'int'));
85 $search[$key.
'_dtend'] =
dol_mktime(23, 59, 59,
GETPOST(
'search_'.$key.
'_dtendmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtendday',
'int'),
GETPOST(
'search_'.$key.
'_dtendyear',
'int'));
88 $search[
'nb_of_values'] =
GETPOST(
'search_nb_of_values',
'alpha');
89 $search[
'nb_products'] =
GETPOST(
'search_nb_products',
'alpha');
92 $fieldstosearchall = array();
93 foreach ($object->fields as $key => $val) {
94 if (!empty($val[
'searchall'])) {
95 $fieldstosearchall[
't.'.$key] = $val[
'label'];
100 $arrayfields = array();
101 foreach ($object->fields as $key => $val) {
103 if (!empty($val[
'visible'])) {
104 $visible = (int)
dol_eval($val[
'visible'], 1);
105 $arrayfields[
't.'.$key] = array(
106 'label'=>$val[
'label'],
107 'checked'=>(($visible < 0) ? 0 : 1),
108 'enabled'=>($visible != 3 &&
dol_eval($val[
'enabled'], 1)),
109 'position'=>$val[
'position'],
110 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
114 $arrayfields[
'nb_of_values'] = array(
115 'label' => $langs->trans(
'NbOfDifferentValues'),
121 $arrayfields[
'nb_products'] = array(
122 'label' => $langs->trans(
'NbProducts'),
134 $permissiontoread = $user->rights->variants->read;
135 $permissiontoadd = $user->rights->variants->write;
136 $permissiontodelete = $user->rights->variants->delete;
139 if (empty($conf->variants->enabled)) {
143 if ($user->socid > 0) {
154 if (
GETPOST(
'cancel',
'alpha')) {
158 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
162 $parameters = array();
163 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
168 if (empty($reshook)) {
170 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
173 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
174 foreach ($object->fields as $key => $val) {
176 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
177 $search[$key.
'_dtstart'] =
'';
178 $search[$key.
'_dtend'] =
'';
181 $search[
'nb_of_values'] =
'';
182 $search[
'nb_products'] =
'';
184 $search_array_options = array();
186 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
187 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
191 if ($action ==
'up' && $permissiontoadd) {
192 $object->attributeMoveUp($rowid);
194 header(
'Location: '.$_SERVER[
'PHP_SELF']);
196 } elseif ($action ==
'down' && $permissiontoadd) {
197 $object->attributeMoveDown($rowid);
199 header(
'Location: '.$_SERVER[
'PHP_SELF']);
204 $objectclass =
'ProductAttribute';
205 $objectlabel =
'ProductAttribute';
206 $uploaddir = $conf->variants->dir_output;
207 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
221 $title = $langs->trans(
'ListOf', $langs->transnoentitiesnoconv(
"ProductAttributes"));
229 $sql .=
" COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products,";
230 $sql .= $object->getFieldList(
"t");
238 $parameters = array();
239 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
240 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
241 $sql = preg_replace(
'/,\s*$/',
'', $sql);
242 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
246 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid";
247 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_value AS pav ON pav.fk_product_attribute = t.rowid";
249 $parameters = array();
250 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
251 $sql .= $hookmanager->resPrint;
252 if ($object->ismultientitymanaged == 1) {
253 $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
255 $sql .=
" WHERE 1 = 1";
257 foreach ($search as $key => $val) {
258 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
259 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
260 if (preg_match(
'/^(date|timestamp|datetime)/', $object->fields[$columnName][
'type'])) {
261 if (preg_match(
'/_dtstart$/', $key)) {
262 $sql .=
" AND t.".$columnName.
" >= '".$db->idate($search[$key]).
"'";
264 if (preg_match(
'/_dtend$/', $key)) {
265 $sql .=
" AND t." . $columnName .
" <= '" . $db->idate($search[$key]) .
"'";
268 } elseif (array_key_exists($key, $object->fields)) {
269 if ($key ==
'status' && $search[$key] == -1) {
272 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
273 if ((strpos($object->fields[$key][
'type'],
'integer:') === 0) || (strpos($object->fields[$key][
'type'],
'sellist:') === 0) || !empty($object->fields[$key][
'arrayofkeyval'])) {
274 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty($object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0', $object->fields[$key][
'arrayofkeyval'])))) {
279 if ($search[$key] !=
'') {
280 $sql .=
natural_search(
"t.".$key, $search[$key], (($key ==
'status') ? 2 : $mode_search));
285 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
291 $parameters = array();
292 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
293 $sql .= $hookmanager->resPrint;
296 $sql .=
" GROUP BY ";
297 foreach ($object->fields as $key => $val) {
298 $sql .=
"t." . $key .
", ";
307 $parameters = array();
308 $reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object);
309 $sql .= $hookmanager->resPrint;
310 $sql = preg_replace(
"/,\s*$/",
"", $sql);
312 $sql .=
" HAVING 1=1";
313 if ($search[
'nb_of_values'] !=
'') {
314 $sql .=
natural_search(
"nb_of_values", $search[
'nb_of_values'], 1);
316 if ($search[
'nb_products'] !=
'') {
320 $parameters = array();
321 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
322 $sql .= empty($hookmanager->resPrint) ?
"" :
" ".$hookmanager->resPrint;
325 $nbtotalofrecords =
'';
326 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
337 $sqlforcount = preg_replace(
"/^SELECT[a-z0-9\._\s\(\),]+FROM/i",
"SELECT COUNT(*) as nbtotalofrecords FROM", $sql);
338 $resql = $db->query($sqlforcount);
341 $nbtotalofrecords = $db->num_rows(
$resql);
343 $objforcount = $db->fetch_object(
$resql);
344 $nbtotalofrecords = $objforcount->nbtotalofrecords;
346 if (($page * $limit) > $nbtotalofrecords) {
355 $sql .= $db->order($sortfield, $sortorder);
357 $sql .= $db->plimit($limit + 1, $offset);
360 $resql = $db->query($sql);
366 $num = $db->num_rows(
$resql);
370 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
371 $obj = $db->fetch_object(
$resql);
373 header(
"Location: " .
dol_buildpath(
'/variants/card.php', 2) .
'?id=' . $id);
383 $arrayofselected = is_array($toselect) ? $toselect : array();
386 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
387 $param .=
'&contextpage='.urlencode($contextpage);
389 if ($limit > 0 && $limit != $conf->liste_limit) {
390 $param .=
'&limit='.urlencode($limit);
392 foreach ($search as $key => $val) {
393 if (is_array($search[$key]) && count($search[$key])) {
394 foreach ($search[$key] as $skey) {
396 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
399 } elseif ($search[$key] !=
'') {
400 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
403 if ($optioncss !=
'') {
404 $param .=
'&optioncss='.urlencode($optioncss);
409 $parameters = array();
410 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
411 $param .= $hookmanager->resPrint;
414 $arrayofmassactions = array(
420 if ($permissiontodelete) {
421 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
423 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
424 $arrayofmassactions = array();
426 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
428 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
429 if ($optioncss !=
'') {
430 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
432 print
'<input type="hidden" name="token" value="'.newToken().
'">';
433 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
434 print
'<input type="hidden" name="action" value="list">';
435 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
436 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
437 print
'<input type="hidden" name="page" value="'.$page.
'">';
438 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
440 $newcardbutton =
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/variants/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
442 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
445 $topicmail =
"SendProductAttributeRef";
446 $modelmail =
"productattribute";
448 $trackid =
'pa'.$object->id;
449 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
452 foreach ($fieldstosearchall as $key => $val) {
453 $fieldstosearchall[$key] = $langs->trans($val);
455 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
463 $parameters = array();
464 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
465 if (empty($reshook)) {
466 $moreforfilter .= $hookmanager->resPrint;
468 $moreforfilter = $hookmanager->resPrint;
471 if (!empty($moreforfilter)) {
472 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
473 print $moreforfilter;
477 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
478 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
479 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
481 print
'<div class="div-table-responsive">';
482 print
'<table id="tableattributes" class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
487 print
'<tr class="liste_titre">';
488 foreach ($object->fields as $key => $val) {
489 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
490 if ($key ==
'status') {
491 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
492 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
493 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
494 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
495 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
496 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
497 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
499 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
500 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').
'">';
501 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
502 print
$form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100', 1);
503 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
504 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_',
'maxwidth125', 1);
505 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
506 print
'<div class="nowrap">';
507 print
$form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
509 print
'<div class="nowrap">';
510 print
$form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
512 } elseif ($key ==
'lang') {
513 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
515 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth150 maxwidth200', 2);
517 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
524 $key =
'nb_of_values';
525 if (!empty($arrayfields[$key][
'checked'])) {
526 print
'<td class="liste_titre center">';
527 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
530 $key =
'nb_products';
531 if (!empty($arrayfields[$key][
'checked'])) {
532 print
'<td class="liste_titre center">';
533 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
537 $parameters = array(
'arrayfields'=>$arrayfields);
538 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
539 print $hookmanager->resPrint;
541 print
'<td class="liste_titre linecoledit width25"></td>';
542 print
'<td class="liste_titre maxwidthsearch">';
543 $searchpicto =
$form->showFilterButtons();
546 print
'<td class="liste_titre linecolmove width25"></td>';
552 print
'<tr class="liste_titre">';
553 foreach ($object->fields as $key => $val) {
554 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
555 if ($key ==
'status') {
556 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
557 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
558 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
559 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
560 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
561 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
562 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
564 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
565 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
570 $key =
'nb_of_values';
571 if (!empty($arrayfields[$key][
'checked'])) {
572 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
574 $key =
'nb_products';
575 if (!empty($arrayfields[$key][
'checked'])) {
576 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
579 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
580 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
581 print $hookmanager->resPrint;
584 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
590 $needToFetchEachLine = 0;
603 $totalarray = array();
604 $totalarray[
'nbfield'] = 0;
605 while ($i < ($limit ? min($num, $limit) : $num)) {
606 $obj = $db->fetch_object(
$resql);
611 $object->setVarsFromFetchObj($obj);
614 print
'<tr id="row-' . $obj->rowid .
'" class="oddeven drag drop">';
615 foreach ($object->fields as $key => $val) {
616 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
617 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
618 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
619 } elseif ($key ==
'status') {
620 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
623 if (in_array($val[
'type'], array(
'timestamp'))) {
624 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowrap';
625 } elseif ($key ==
'ref') {
626 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowrap';
629 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'rowid',
'status')) && empty($val[
'arrayofkeyval'])) {
630 $cssforfield .= ($cssforfield ?
' ' :
'') .
'right';
634 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
635 print
'<td' . ($cssforfield ?
' class="' . $cssforfield .
'"' :
'') .
'>';
636 if ($key ==
'status') {
637 print $object->getLibStatut(5);
638 } elseif ($key ==
'rowid') {
639 print $object->showOutputField($val, $key, $object->id,
'');
641 print $object->showOutputField($val, $key, $object->$key,
'');
645 $totalarray[
'nbfield']++;
647 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
649 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.' . $key;
651 if (!isset($totalarray[
'val'])) {
652 $totalarray[
'val'] = array();
654 if (!isset($totalarray[
'val'][
't.' . $key])) {
655 $totalarray[
'val'][
't.' . $key] = 0;
657 $totalarray[
'val'][
't.' . $key] += $object->$key;
663 $key =
'nb_of_values';
664 if (!empty($arrayfields[$key][
'checked'])) {
665 print
'<td class="center">';
669 $totalarray[
'nbfield']++;
672 $key =
'nb_products';
673 if (!empty($arrayfields[$key][
'checked'])) {
674 print
'<td class="center">';
678 $totalarray[
'nbfield']++;
682 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
683 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
684 print $hookmanager->resPrint;
686 print
'<td class="linecoledit center width25">';
687 if ($permissiontoadd) {
688 print
'<a class="editfielda reposition" href="' . DOL_URL_ROOT .
'/variants/card.php?id=' . $obj->rowid .
'&action=edit&save_lastsearch_values=1&backtopage=' . urlencode($_SERVER[
'PHP_SELF']) .
'">' .
img_edit() .
'</a>';
692 $totalarray[
'nbfield']++;
694 print
'<td class="nowrap center">';
695 if ($massactionbutton || $massaction) {
697 if (in_array($object->id, $arrayofselected)) {
700 print
'<input id="cb' . $object->id .
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object->id .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
704 $totalarray[
'nbfield']++;
706 print
'<td class="center linecolmove tdlineupdown">';
708 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=up&rowid=' . $obj->rowid .
'">' .
img_up(
'default', 0,
'imgupforline') .
'</a>';
711 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=down&rowid=' . $obj->rowid .
'">' .
img_down(
'default', 0,
'imgdownforline') .
'</a>';
715 $totalarray[
'nbfield']++;
718 print
'</tr>' .
"\n";
724 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
729 foreach ($arrayfields as $key => $val) {
730 if (!empty($val[
'checked'])) {
734 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
739 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
740 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
741 print $hookmanager->resPrint;
743 print
'</table>'.
"\n";
746 print
'</form>'.
"\n";
748 $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
749 $tagidfortablednd = (empty($tagidfortablednd) ?
'tableattributes' : $tagidfortablednd);
752 $(document).ready(
function(){
753 $(
".imgupforline, .imgdownforline").hide();
754 $(
".lineupdown").removeAttr(
'href');
756 .css(
"background-image",
'url(<?php echo DOL_URL_ROOT.'/theme/
'.$conf->theme.'/img/grip.png
'; ?>)')
757 .css(
"background-repeat",
"no-repeat")
758 .css(
"background-position",
"center center")
761 $(
this).addClass(
'showDragHandle');
763 $(
this).removeClass(
'showDragHandle');
767 $(
"#<?php echo $tagidfortablednd; ?>").tableDnD({
768 onDrop:
function(table, row) {
770 $(
'#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr(
'id',
'');
771 $(
'#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr(
'id',
'');
772 var reloadpage =
"<?php echo $forcereloadpage; ?>";
773 var roworder = cleanSerialize(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
774 $.post(
"<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
777 token:
"<?php echo currentToken(); ?>"
780 if (reloadpage == 1) {
781 location.href =
'<?php echo dol_escape_htmltag($_SERVER['PHP_SELF
']).'?
'.dol_escape_htmltag($_SERVER['QUERY_STRING
']); ?>';
785 onDragClass:
"dragClass",
786 dragHandle:
"td.tdlineupdown"
792 if (in_array(
'builddoc', $arrayofmassactions) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
793 $hidegeneratedfilelistifempty = 1;
794 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
795 $hidegeneratedfilelistifempty = 0;
798 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
802 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
803 $urlsource .= str_replace(
'&',
'&', $param);
805 $filedir = $diroutputmassaction;
806 $genallowed = $permissiontoread;
807 $delallowed = $permissiontoadd;
809 print $formfile->showdocuments(
'massfilesarea_productattribute',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);