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) {
163if (
GETPOST(
'cancel',
'alpha')) {
167if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
171$parameters = array();
172$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
177if (empty($reshook)) {
179 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
182 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
183 foreach ($object->fields as $key => $val) {
185 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
186 $search[$key.
'_dtstart'] =
'';
187 $search[$key.
'_dtend'] =
'';
190 $search[
'nb_of_values'] =
'';
191 $search[
'nb_products'] =
'';
193 $search_array_options = array();
195 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
196 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
200 if ($action ==
'up' && $permissiontoadd) {
201 $object->attributeMoveUp($rowid);
203 header(
'Location: '.$_SERVER[
'PHP_SELF']);
205 } elseif ($action ==
'down' && $permissiontoadd) {
206 $object->attributeMoveDown($rowid);
208 header(
'Location: '.$_SERVER[
'PHP_SELF']);
213 $objectclass =
'ProductAttribute';
214 $objectlabel =
'ProductAttribute';
215 $uploaddir = $conf->variants->dir_output;
216 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
225$form =
new Form($db);
230$title = $langs->trans(
"ProductAttributes");
237$sql =
"SELECT COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products, ";
238$sql .= $object->getFieldList(
"t");
246$parameters = array();
247$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
248$sql .= $hookmanager->resPrint;
249$sql = preg_replace(
'/,\s*$/',
'', $sql);
250$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
254$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid";
255$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_value AS pav ON pav.fk_product_attribute = t.rowid";
257$parameters = array();
258$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
259$sql .= $hookmanager->resPrint;
260if ($object->ismultientitymanaged == 1) {
261 $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
263 $sql .=
" WHERE 1 = 1";
265foreach ($search as $key => $val) {
266 if (array_key_exists($key, $object->fields)) {
267 if ($key ==
'status' && $search[$key] == -1) {
270 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
271 if ((strpos($object->fields[$key][
'type'],
'integer:') === 0) || (strpos($object->fields[$key][
'type'],
'sellist:') === 0) || !empty($object->fields[$key][
'arrayofkeyval'])) {
272 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty($object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0', $object->fields[$key][
'arrayofkeyval'])))) {
277 if ($search[$key] !=
'') {
278 $sql .=
natural_search(
"t.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
281 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
282 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
283 if (preg_match(
'/^(date|timestamp|datetime)/', $object->fields[$columnName][
'type'])) {
284 if (preg_match(
'/_dtstart$/', $key)) {
285 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
287 if (preg_match(
'/_dtend$/', $key)) {
288 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
295 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
301$parameters = array();
302$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
303$sql .= $hookmanager->resPrint;
307foreach ($object->fields as $key => $val) {
308 $sql .=
"t." . $key .
", ";
317$parameters = array();
318$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object);
319$sql .= $hookmanager->resPrint;
320$sql = preg_replace(
"/,\s*$/",
"", $sql);
322$sql .=
" HAVING 1=1";
323if ($search[
'nb_of_values'] !=
'') {
324 $sql .=
natural_search(
"nb_of_values", $search[
'nb_of_values'], 1);
326if ($search[
'nb_products'] !=
'') {
330$parameters = array();
331$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
332$sql .= empty($hookmanager->resPrint) ?
"" :
" ".$hookmanager->resPrint;
335$nbtotalofrecords =
'';
347 $sqlforcount = preg_replace(
"/^SELECT[a-z0-9\._\s\(\),]+FROM/i",
"SELECT COUNT(*) as nbtotalofrecords FROM", $sql);
348 $resql = $db->query($sqlforcount);
351 $nbtotalofrecords = $db->num_rows($resql);
353 $objforcount = $db->fetch_object($resql);
354 $nbtotalofrecords = $objforcount->nbtotalofrecords;
356 if (($page * $limit) > $nbtotalofrecords) {
365$sql .= $db->order($sortfield, $sortorder);
367 $sql .= $db->plimit($limit + 1, $offset);
370$resql = $db->query($sql);
376$num = $db->num_rows($resql);
380if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
381 $obj = $db->fetch_object($resql);
383 header(
"Location: " .
dol_buildpath(
'/variants/card.php', 2) .
'?id=' . $id);
391llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'');
393$arrayofselected = is_array($toselect) ? $toselect : array();
397 $param .=
'&mode='.urlencode($mode);
399if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
400 $param .=
'&contextpage='.urlencode($contextpage);
402if ($limit > 0 && $limit != $conf->liste_limit) {
403 $param .=
'&limit='.((int) $limit);
405foreach ($search as $key => $val) {
406 if (is_array($search[$key])) {
407 foreach ($search[$key] as $skey) {
409 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
412 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
413 $param .=
'&search_'.$key.
'month='.((int)
GETPOST(
'search_'.$key.
'month',
'int'));
414 $param .=
'&search_'.$key.
'day='.((int)
GETPOST(
'search_'.$key.
'day',
'int'));
415 $param .=
'&search_'.$key.
'year='.((int)
GETPOST(
'search_'.$key.
'year',
'int'));
416 } elseif ($search[$key] !=
'') {
417 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
420if ($optioncss !=
'') {
421 $param .=
'&optioncss='.urlencode($optioncss);
424include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
426$parameters = array();
427$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
428$param .= $hookmanager->resPrint;
431$arrayofmassactions = array(
437if (!empty($permissiontodelete)) {
438 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
440if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
441 $arrayofmassactions = array();
443$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
445print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
446if ($optioncss !=
'') {
447 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
449print
'<input type="hidden" name="token" value="'.newToken().
'">';
450print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
451print
'<input type="hidden" name="action" value="list">';
452print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
453print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
454print
'<input type="hidden" name="page" value="'.$page.
'">';
455print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
456print
'<input type="hidden" name="page_y" value="">';
457print
'<input type="hidden" name="mode" value="'.$mode.
'">';
460$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'));
461$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'));
463$newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/variants/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
465print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
468$topicmail =
"SendProductAttributeRef";
469$modelmail =
"productattribute";
471$trackid =
'pa'.$object->id;
472include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
476 foreach ($fieldstosearchall as $key => $val) {
477 $fieldstosearchall[$key] = $langs->trans($val);
478 $setupstring .= $key.
"=".$val.
";";
480 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
481 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
489$parameters = array();
490$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
491if (empty($reshook)) {
492 $moreforfilter .= $hookmanager->resPrint;
494 $moreforfilter = $hookmanager->resPrint;
497if (!empty($moreforfilter)) {
498 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
499 print $moreforfilter;
500 $parameters = array();
501 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
502 print $hookmanager->resPrint;
506$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
507$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
508$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
510print
'<div class="div-table-responsive">';
511print
'<table id="tableattributes" class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
516print
'<tr class="liste_titre_filter">';
519 print
'<td class="liste_titre center maxwidthsearch">';
520 $searchpicto = $form->showFilterButtons(
'left');
524foreach ($object->fields as $key => $val) {
525 $searchkey = empty($search[$key]) ?
'' : $search[$key];
526 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
527 if ($key ==
'status') {
528 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
529 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
530 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
531 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
532 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
533 } 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'])) {
534 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
536 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
537 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
538 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
539 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);
540 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
541 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
542 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
543 print
'<div class="nowrap">';
544 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
546 print
'<div class="nowrap">';
547 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
549 } elseif ($key ==
'lang') {
550 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
552 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth150 maxwidth200', 2);
554 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
560include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
562$parameters = array(
'arrayfields'=>$arrayfields);
563$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
564print $hookmanager->resPrint;
566$key =
'nb_of_values';
567if (!empty($arrayfields[$key][
'checked'])) {
568 print
'<td class="liste_titre center">';
569 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
573if (!empty($arrayfields[$key][
'checked'])) {
574 print
'<td class="liste_titre center">';
575 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
580 print
'<td class="liste_titre center maxwidthsearch">';
581 $searchpicto = $form->showFilterButtons();
586print
'<td class="liste_titre linecolmove width25"></td>';
589$totalarray = array();
590$totalarray[
'nbfield'] = 0;
594print
'<tr class="liste_titre">';
596 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
597 $totalarray[
'nbfield']++;
599foreach ($object->fields as $key => $val) {
600 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
601 if ($key ==
'status') {
602 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
603 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
604 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
605 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
606 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
607 } 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'])) {
608 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
610 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
611 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
612 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";
613 $totalarray[
'nbfield']++;
617include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
619$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
620$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
621print $hookmanager->resPrint;
623$key =
'nb_of_values';
624if (!empty($arrayfields[$key][
'checked'])) {
625 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
628if (!empty($arrayfields[$key][
'checked'])) {
629 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
633 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
634 $totalarray[
'nbfield']++;
642$needToFetchEachLine = 0;
655$savnbfield = $totalarray[
'nbfield'];
656$totalarray = array();
657$totalarray[
'nbfield'] = 0;
658$imaxinloop = ($limit ? min($num, $limit) : $num);
659while ($i < $imaxinloop) {
660 $obj = $db->fetch_object($resql);
666 $object->setVarsFromFetchObj($obj);
668 if ($mode ==
'kanban') {
670 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
671 print
'<div class="box-flex-container kanban">';
674 if ($massactionbutton || $massaction) {
676 if (in_array($object->id, $arrayofselected)) {
680 print $object->getKanbanView(
'', array(
'selected' => in_array($object->id, $arrayofselected)));
681 if ($i == ($imaxinloop - 1)) {
688 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
691 print
'<td class="nowrap center">';
692 if ($massactionbutton || $massaction) {
694 if (in_array($object->id, $arrayofselected)) {
697 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
701 $totalarray[
'nbfield']++;
704 foreach ($object->fields as $key => $val) {
705 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
706 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
707 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
708 } elseif ($key ==
'status') {
709 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
712 if (in_array($val[
'type'], array(
'timestamp'))) {
713 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowrap';
714 } elseif ($key ==
'ref') {
715 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowrap';
718 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'rowid',
'status')) && empty($val[
'arrayofkeyval'])) {
719 $cssforfield .= ($cssforfield ?
' ' :
'') .
'right';
723 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
724 print
'<td'.($cssforfield ?
' class="'.$cssforfield.(preg_match(
'/tdoverflow/', $cssforfield) ?
' classfortooltip' :
'').
'"' :
'');
725 if (preg_match(
'/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
726 print
' title="'.dol_escape_htmltag($object->$key).
'"';
729 if ($key ==
'status') {
730 print $object->getLibStatut(5);
731 } elseif ($key ==
'rowid') {
732 print $object->showOutputField($val, $key, $object->id,
'');
734 print $object->showOutputField($val, $key, $object->$key,
'');
738 $totalarray[
'nbfield']++;
740 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
742 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.' . $key;
744 if (!isset($totalarray[
'val'])) {
745 $totalarray[
'val'] = array();
747 if (!isset($totalarray[
'val'][
't.' . $key])) {
748 $totalarray[
'val'][
't.' . $key] = 0;
750 $totalarray[
'val'][
't.' . $key] += $object->$key;
755 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
757 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
758 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
759 print $hookmanager->resPrint;
761 $key =
'nb_of_values';
762 if (!empty($arrayfields[$key][
'checked'])) {
763 print
'<td class="center">';
767 $totalarray[
'nbfield']++;
770 $key =
'nb_products';
771 if (!empty($arrayfields[$key][
'checked'])) {
772 print
'<td class="center">';
776 $totalarray[
'nbfield']++;
781 print
'<td class="nowrap center">';
782 if ($massactionbutton || $massaction) {
784 if (in_array($object->id, $arrayofselected)) {
787 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
791 $totalarray[
'nbfield']++;
795 print
'<td class="center linecolmove tdlineupdown">';
797 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=up&rowid=' . $obj->rowid .
'">' .
img_up(
'default', 0,
'imgupforline') .
'</a>';
800 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=down&rowid=' . $obj->rowid .
'">' .
img_down(
'default', 0,
'imgdownforline') .
'</a>';
804 print
'</tr>' .
"\n";
811include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
816 foreach ($arrayfields as $key => $val) {
817 if (!empty($val[
'checked'])) {
821 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
826$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
827$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
828print $hookmanager->resPrint;
830print
'</table>'.
"\n";
835$forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
836$tagidfortablednd = (empty($tagidfortablednd) ?
'tableattributes' : $tagidfortablednd);
839 $(document).ready(
function(){
840 $(
".imgupforline, .imgdownforline").hide();
841 $(
".lineupdown").removeAttr(
'href');
843 .css(
"background-image",
'url(<?php echo DOL_URL_ROOT.'/theme/
'.$conf->theme.'/img/grip.png
'; ?>)')
844 .css(
"background-repeat",
"no-repeat")
845 .css(
"background-position",
"center center")
848 $(
this).addClass(
'showDragHandle');
850 $(
this).removeClass(
'showDragHandle');
854 $(
"#<?php echo $tagidfortablednd; ?>").tableDnD({
855 onDrop:
function(table, row) {
857 $(
'#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr(
'id',
'');
858 $(
'#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr(
'id',
'');
859 var reloadpage =
"<?php echo $forcereloadpage; ?>";
860 var roworder = cleanSerialize(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
861 $.post(
"<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
864 token:
"<?php echo currentToken(); ?>"
867 if (reloadpage == 1) {
868 location.href =
'<?php echo dol_escape_htmltag($_SERVER['PHP_SELF
']).'?
'.dol_escape_htmltag($_SERVER['QUERY_STRING
']); ?>';
872 onDragClass:
"dragClass",
873 dragHandle:
"td.tdlineupdown"
879if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
880 $hidegeneratedfilelistifempty = 1;
881 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
882 $hidegeneratedfilelistifempty = 0;
885 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
889 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
890 $urlsource .= str_replace(
'&',
'&', $param);
892 $filedir = $diroutputmassaction;
893 $genallowed = $permissiontoread;
894 $delallowed = $permissiontoadd;
896 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 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.