26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
31$langs->loadLangs(array(
"products",
"other"));
33$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
34$massaction =
GETPOST(
'massaction',
'alpha');
35$show_files =
GETPOST(
'show_files',
'int');
36$confirm =
GETPOST(
'confirm',
'alpha');
37$cancel =
GETPOST(
'cancel',
'alpha');
38$toselect =
GETPOST(
'toselect',
'array');
39$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
40$backtopage =
GETPOST(
'backtopage',
'alpha');
41$optioncss =
GETPOST(
'optioncss',
'aZ');
47$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
48$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
50$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
51if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
55$offset = $limit * $page;
62$diroutputmassaction = $conf->variants->dir_output.
'/temp/massgeneration/'.$user->id;
63$hookmanager->initHooks(array(
'productattributelist'));
72 $sortfield =
"t.position";
79$search_all =
GETPOST(
'search_all',
'alphanohtml');
81foreach ($object->fields as $key => $val) {
82 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
83 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
85 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
86 $search[$key.
'_dtstart'] =
dol_mktime(0, 0, 0,
GETPOST(
'search_'.$key.
'_dtstartmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtstartday',
'int'),
GETPOST(
'search_'.$key.
'_dtstartyear',
'int'));
87 $search[$key.
'_dtend'] =
dol_mktime(23, 59, 59,
GETPOST(
'search_'.$key.
'_dtendmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtendday',
'int'),
GETPOST(
'search_'.$key.
'_dtendyear',
'int'));
90$search[
'nb_of_values'] =
GETPOST(
'search_nb_of_values',
'alpha');
91$search[
'nb_products'] =
GETPOST(
'search_nb_products',
'alpha');
94$fieldstosearchall = array();
95foreach ($object->fields as $key => $val) {
96 if (!empty($val[
'searchall'])) {
97 $fieldstosearchall[
't.'.$key] = $val[
'label'];
100$parameters = array(
'fieldstosearchall'=>$fieldstosearchall);
101$reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action);
103 $fieldstosearchall = empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall'];
104} elseif ($reshook == 0) {
105 $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall']);
109$arrayfields = array();
110foreach ($object->fields as $key => $val) {
112 if (!empty($val[
'visible'])) {
113 $visible = (int)
dol_eval($val[
'visible'], 1);
114 $arrayfields[
't.'.$key] = array(
115 'label'=>$val[
'label'],
116 'checked'=>(($visible < 0) ? 0 : 1),
117 'enabled'=>(abs($visible) != 3 &&
dol_eval($val[
'enabled'], 1)),
118 'position'=>$val[
'position'],
119 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
123$arrayfields[
'nb_of_values'] = array(
124 'label' => $langs->trans(
'NbOfDifferentValues'),
130$arrayfields[
'nb_products'] = array(
131 'label' => $langs->trans(
'NbProducts'),
143$permissiontoread = $user->hasRight(
'variants',
'read');
144$permissiontoadd = $user->hasRight(
'variants',
'write');
145$permissiontodelete = $user->hasRight(
'variants',
'delete');
148if (!isModEnabled(
'variants')) {
152if ($user->socid > 0) {
156if (!$permissiontoread) {
165if (
GETPOST(
'cancel',
'alpha')) {
169if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
173$parameters = array();
174$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
179if (empty($reshook)) {
181 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
184 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
185 foreach ($object->fields as $key => $val) {
187 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
188 $search[$key.
'_dtstart'] =
'';
189 $search[$key.
'_dtend'] =
'';
192 $search[
'nb_of_values'] =
'';
193 $search[
'nb_products'] =
'';
195 $search_array_options = array();
197 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
198 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
202 if ($action ==
'up' && $permissiontoadd) {
203 $object->attributeMoveUp($rowid);
205 header(
'Location: '.$_SERVER[
'PHP_SELF']);
207 } elseif ($action ==
'down' && $permissiontoadd) {
208 $object->attributeMoveDown($rowid);
210 header(
'Location: '.$_SERVER[
'PHP_SELF']);
215 $objectclass =
'ProductAttribute';
216 $objectlabel =
'ProductAttribute';
217 $uploaddir = $conf->variants->dir_output;
218 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
227$form =
new Form($db);
232$title = $langs->trans(
"ProductAttributes");
239$sql =
"SELECT COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products, ";
240$sql .= $object->getFieldList(
"t");
248$parameters = array();
249$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
250$sql .= $hookmanager->resPrint;
251$sql = preg_replace(
'/,\s*$/',
'', $sql);
252$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
256$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid";
257$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_value AS pav ON pav.fk_product_attribute = t.rowid";
259$parameters = array();
260$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
261$sql .= $hookmanager->resPrint;
262if ($object->ismultientitymanaged == 1) {
263 $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
265 $sql .=
" WHERE 1 = 1";
267foreach ($search as $key => $val) {
268 if (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.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
283 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
284 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
285 if (preg_match(
'/^(date|timestamp|datetime)/', $object->fields[$columnName][
'type'])) {
286 if (preg_match(
'/_dtstart$/', $key)) {
287 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
289 if (preg_match(
'/_dtend$/', $key)) {
290 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
297 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
303$parameters = array();
304$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
305$sql .= $hookmanager->resPrint;
309foreach ($object->fields as $key => $val) {
310 $sql .=
"t." . $key .
", ";
319$parameters = array();
320$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object);
321$sql .= $hookmanager->resPrint;
322$sql = preg_replace(
"/,\s*$/",
"", $sql);
324$sql .=
" HAVING 1=1";
325if ($search[
'nb_of_values'] !=
'') {
326 $sql .=
natural_search(
"nb_of_values", $search[
'nb_of_values'], 1);
328if ($search[
'nb_products'] !=
'') {
332$parameters = array();
333$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
334$sql .= empty($hookmanager->resPrint) ?
"" :
" ".$hookmanager->resPrint;
337$nbtotalofrecords =
'';
349 $sqlforcount = preg_replace(
"/^SELECT[a-z0-9\._\s\(\),]+FROM/i",
"SELECT COUNT(*) as nbtotalofrecords FROM", $sql);
350 $resql = $db->query($sqlforcount);
353 $nbtotalofrecords = $db->num_rows($resql);
355 $objforcount = $db->fetch_object($resql);
356 $nbtotalofrecords = $objforcount->nbtotalofrecords;
358 if (($page * $limit) > $nbtotalofrecords) {
367$sql .= $db->order($sortfield, $sortorder);
369 $sql .= $db->plimit($limit + 1, $offset);
372$resql = $db->query($sql);
378$num = $db->num_rows($resql);
382if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
383 $obj = $db->fetch_object($resql);
385 header(
"Location: " .
dol_buildpath(
'/variants/card.php', 2) .
'?id=' . $id);
393llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'');
395$arrayofselected = is_array($toselect) ? $toselect : array();
399 $param .=
'&mode='.urlencode($mode);
401if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
402 $param .=
'&contextpage='.urlencode($contextpage);
404if ($limit > 0 && $limit != $conf->liste_limit) {
405 $param .=
'&limit='.((int) $limit);
407foreach ($search as $key => $val) {
408 if (is_array($search[$key])) {
409 foreach ($search[$key] as $skey) {
411 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
414 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
415 $param .=
'&search_'.$key.
'month='.((int)
GETPOST(
'search_'.$key.
'month',
'int'));
416 $param .=
'&search_'.$key.
'day='.((int)
GETPOST(
'search_'.$key.
'day',
'int'));
417 $param .=
'&search_'.$key.
'year='.((int)
GETPOST(
'search_'.$key.
'year',
'int'));
418 } elseif ($search[$key] !=
'') {
419 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
422if ($optioncss !=
'') {
423 $param .=
'&optioncss='.urlencode($optioncss);
426include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
428$parameters = array(
'param' => &$param);
429$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
430$param .= $hookmanager->resPrint;
433$arrayofmassactions = array(
439if (!empty($permissiontodelete)) {
440 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
442if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
443 $arrayofmassactions = array();
445$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
447print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
448if ($optioncss !=
'') {
449 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
451print
'<input type="hidden" name="token" value="'.newToken().
'">';
452print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
453print
'<input type="hidden" name="action" value="list">';
454print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
455print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
456print
'<input type="hidden" name="page" value="'.$page.
'">';
457print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
458print
'<input type="hidden" name="page_y" value="">';
459print
'<input type="hidden" name="mode" value="'.$mode.
'">';
462$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'));
463$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'));
465$newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/variants/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
467print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
470$topicmail =
"SendProductAttributeRef";
471$modelmail =
"productattribute";
473$trackid =
'pa'.$object->id;
474include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
478 foreach ($fieldstosearchall as $key => $val) {
479 $fieldstosearchall[$key] = $langs->trans($val);
480 $setupstring .= $key.
"=".$val.
";";
482 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
483 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
491$parameters = array();
492$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
493if (empty($reshook)) {
494 $moreforfilter .= $hookmanager->resPrint;
496 $moreforfilter = $hookmanager->resPrint;
499if (!empty($moreforfilter)) {
500 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
501 print $moreforfilter;
502 $parameters = array();
503 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
504 print $hookmanager->resPrint;
508$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
509$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
510$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
512print
'<div class="div-table-responsive">';
513print
'<table id="tableattributes" class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
518print
'<tr class="liste_titre_filter">';
521 print
'<td class="liste_titre center maxwidthsearch">';
522 $searchpicto = $form->showFilterButtons(
'left');
526foreach ($object->fields as $key => $val) {
527 $searchkey = empty($search[$key]) ?
'' : $search[$key];
528 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
529 if ($key ==
'status') {
530 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
531 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
532 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
533 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
534 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
535 } 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'])) {
536 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
538 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
539 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
540 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
541 print $form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100'.($key ==
'status' ?
' search_status width100 onrightofpage' :
''), 1);
542 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
543 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
544 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
545 print
'<div class="nowrap">';
546 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
548 print
'<div class="nowrap">';
549 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
551 } elseif ($key ==
'lang') {
552 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
554 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth150 maxwidth200', 2);
556 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
562include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
564$parameters = array(
'arrayfields'=>$arrayfields);
565$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
566print $hookmanager->resPrint;
568$key =
'nb_of_values';
569if (!empty($arrayfields[$key][
'checked'])) {
570 print
'<td class="liste_titre center">';
571 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
575if (!empty($arrayfields[$key][
'checked'])) {
576 print
'<td class="liste_titre center">';
577 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
582 print
'<td class="liste_titre center maxwidthsearch">';
583 $searchpicto = $form->showFilterButtons();
588print
'<td class="liste_titre linecolmove width25"></td>';
591$totalarray = array();
592$totalarray[
'nbfield'] = 0;
596print
'<tr class="liste_titre">';
598 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
599 $totalarray[
'nbfield']++;
601foreach ($object->fields as $key => $val) {
602 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
603 if ($key ==
'status') {
604 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
605 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
606 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
607 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
608 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
609 } 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'])) {
610 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
612 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
613 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
614 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";
615 $totalarray[
'nbfield']++;
619include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
621$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
622$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
623print $hookmanager->resPrint;
625$key =
'nb_of_values';
626if (!empty($arrayfields[$key][
'checked'])) {
627 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
630if (!empty($arrayfields[$key][
'checked'])) {
631 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
635 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
636 $totalarray[
'nbfield']++;
644$needToFetchEachLine = 0;
657$savnbfield = $totalarray[
'nbfield'];
658$totalarray = array();
659$totalarray[
'nbfield'] = 0;
660$imaxinloop = ($limit ? min($num, $limit) : $num);
661while ($i < $imaxinloop) {
662 $obj = $db->fetch_object($resql);
668 $object->setVarsFromFetchObj($obj);
670 if ($mode ==
'kanban') {
672 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
673 print
'<div class="box-flex-container kanban">';
677 if ($massactionbutton || $massaction) {
679 if (in_array($object->id, $arrayofselected)) {
683 print $object->getKanbanView(
'', array(
'selected' => $selected));
684 if ($i == ($imaxinloop - 1)) {
691 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
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']++;
707 foreach ($object->fields as $key => $val) {
708 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
709 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
710 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
711 } elseif ($key ==
'status') {
712 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
715 if (in_array($val[
'type'], array(
'timestamp'))) {
716 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowrap';
717 } elseif ($key ==
'ref') {
718 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowrap';
721 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'rowid',
'status')) && empty($val[
'arrayofkeyval'])) {
722 $cssforfield .= ($cssforfield ?
' ' :
'') .
'right';
726 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
727 print
'<td'.($cssforfield ?
' class="'.$cssforfield.(preg_match(
'/tdoverflow/', $cssforfield) ?
' classfortooltip' :
'').
'"' :
'');
728 if (preg_match(
'/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
729 print
' title="'.dol_escape_htmltag($object->$key).
'"';
732 if ($key ==
'status') {
733 print $object->getLibStatut(5);
734 } elseif ($key ==
'rowid') {
735 print $object->showOutputField($val, $key, $object->id,
'');
737 print $object->showOutputField($val, $key, $object->$key,
'');
741 $totalarray[
'nbfield']++;
743 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
745 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.' . $key;
747 if (!isset($totalarray[
'val'])) {
748 $totalarray[
'val'] = array();
750 if (!isset($totalarray[
'val'][
't.' . $key])) {
751 $totalarray[
'val'][
't.' . $key] = 0;
753 $totalarray[
'val'][
't.' . $key] += $object->$key;
758 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
760 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
761 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
762 print $hookmanager->resPrint;
764 $key =
'nb_of_values';
765 if (!empty($arrayfields[$key][
'checked'])) {
766 print
'<td class="center">';
770 $totalarray[
'nbfield']++;
773 $key =
'nb_products';
774 if (!empty($arrayfields[$key][
'checked'])) {
775 print
'<td class="center">';
779 $totalarray[
'nbfield']++;
784 print
'<td class="nowrap center">';
785 if ($massactionbutton || $massaction) {
787 if (in_array($object->id, $arrayofselected)) {
790 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
794 $totalarray[
'nbfield']++;
798 print
'<td class="center linecolmove tdlineupdown">';
800 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=up&rowid=' . $obj->rowid .
'">' .
img_up(
'default', 0,
'imgupforline') .
'</a>';
803 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=down&rowid=' . $obj->rowid .
'">' .
img_down(
'default', 0,
'imgdownforline') .
'</a>';
807 print
'</tr>' .
"\n";
814include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
819 foreach ($arrayfields as $key => $val) {
820 if (!empty($val[
'checked'])) {
824 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
829$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
830$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
831print $hookmanager->resPrint;
833print
'</table>'.
"\n";
839$tagidfortablednd = (empty($tagidfortablednd) ?
'tableattributes' : $tagidfortablednd);
842 $(document).ready(
function(){
843 $(
".imgupforline, .imgdownforline").hide();
844 $(
".lineupdown").removeAttr(
'href');
846 .css(
"background-image",
'url(<?php echo DOL_URL_ROOT.'/theme/
'.$conf->theme.'/img/grip.png
'; ?>)')
847 .css(
"background-repeat",
"no-repeat")
848 .css(
"background-position",
"center center")
851 $(
this).addClass(
'showDragHandle');
853 $(
this).removeClass(
'showDragHandle');
857 $(
"#<?php echo $tagidfortablednd; ?>").tableDnD({
858 onDrop:
function(table, row) {
860 $(
'#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr(
'id',
'');
861 $(
'#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr(
'id',
'');
862 var reloadpage =
"<?php echo $forcereloadpage; ?>";
863 var roworder = cleanSerialize(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
864 $.post(
"<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
867 token:
"<?php echo currentToken(); ?>"
870 if (reloadpage == 1) {
871 location.href =
'<?php echo dol_escape_htmltag($_SERVER['PHP_SELF
']).'?
'.dol_escape_htmltag($_SERVER['QUERY_STRING
']); ?>';
875 onDragClass:
"dragClass",
876 dragHandle:
"td.tdlineupdown"
882if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
883 $hidegeneratedfilelistifempty = 1;
884 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
885 $hidegeneratedfilelistifempty = 0;
888 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
892 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
893 $urlsource .= str_replace(
'&',
'&', $param);
895 $filedir = $diroutputmassaction;
896 $genallowed = $permissiontoread;
897 $delallowed = $permissiontoadd;
899 print $formfile->showdocuments(
'massfilesarea_productattribute',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.