29require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
39require_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');
60$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
61$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
63if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
67$offset = $limit * $page;
74$diroutputmassaction =
$conf->variants->dir_output.
'/temp/massgeneration/'.$user->id;
75$hookmanager->initHooks(array(
'productattributelist'));
78$extrafields->fetch_name_optionals_label(
$object->table_element);
80$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
84 $sortfield =
"t.position";
91$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
93foreach (
$object->fields as $key => $val) {
94 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
95 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
97 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
102$search[
'nb_of_values'] =
GETPOST(
'search_nb_of_values',
'alpha');
103$search[
'nb_products'] =
GETPOST(
'search_nb_products',
'alpha');
105$fieldstosearchall = array();
107foreach (
$object->fields as $key => $val) {
108 if (!empty($val[
'searchall'])) {
109 $fieldstosearchall[
't.'.$key] = $val[
'label'];
112$parameters = array(
'fieldstosearchall' => $fieldstosearchall);
113$reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action);
115 $fieldstosearchall = empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall'];
116} elseif ($reshook == 0) {
117 $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall']);
121$arrayfields = array();
122foreach (
$object->fields as $key => $val) {
124 if (!empty($val[
'visible'])) {
125 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
126 $arrayfields[
't.'.$key] = array(
127 'label' => $val[
'label'],
128 'checked' => (($visible < 0) ?
'0' :
'1'),
129 'enabled' => (
string) (int) (abs($visible) != 3 && (bool)
dol_eval((
string) $val[
'enabled'], 1)),
130 'position' => $val[
'position'],
131 'help' => isset($val[
'help']) ? $val[
'help'] :
''
135$arrayfields[
'nb_of_values'] = array(
136 'label' => $langs->trans(
'NbOfDifferentValues'),
142$arrayfields[
'nb_products'] = array(
143 'label' => $langs->trans(
'NbProducts'),
150include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
152$parameters = array(
'arrayfields' => &$arrayfields);
153$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
158$permissiontoread = $user->hasRight(
'variants',
'read');
159$permissiontoadd = $user->hasRight(
'variants',
'write');
160$permissiontodelete = $user->hasRight(
'variants',
'delete');
167if ($user->socid > 0) {
171if (!$permissiontoread) {
180if (
GETPOST(
'cancel',
'alpha')) {
184if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
188$parameters = array(
'arrayfields' => &$arrayfields);
189$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
194if (empty($reshook)) {
196 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
199 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
200 foreach (
$object->fields as $key => $val) {
202 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
203 $search[$key.
'_dtstart'] =
'';
204 $search[$key.
'_dtend'] =
'';
207 $search[
'nb_of_values'] =
'';
208 $search[
'nb_products'] =
'';
210 $search_array_options = array();
212 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
213 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
217 if ($action ==
'up' && $permissiontoadd) {
218 $object->attributeMoveUp($rowid);
220 header(
'Location: '.$_SERVER[
'PHP_SELF']);
222 } elseif ($action ==
'down' && $permissiontoadd) {
223 $object->attributeMoveDown($rowid);
225 header(
'Location: '.$_SERVER[
'PHP_SELF']);
230 $objectclass =
'ProductAttribute';
231 $objectlabel =
'ProductAttribute';
232 $uploaddir =
$conf->variants->dir_output;
233 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
246$title = $langs->trans(
"ProductAttributes");
254$sql =
"SELECT COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products, ";
255$sql .=
$object->getFieldList(
"t");
257if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
258 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
259 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
"");
263$parameters = array();
264$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
265$sql .= $hookmanager->resPrint;
266$sql = preg_replace(
'/,\s*$/',
'', $sql);
270$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
271if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
272 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
274$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid";
275$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_value AS pav ON pav.fk_product_attribute = t.rowid";
277$parameters = array();
278$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
279$sql .= $hookmanager->resPrint;
280if (
$object->ismultientitymanaged == 1) {
281 $sql .=
" WHERE t.entity IN (".getEntity(
$object->element, (
GETPOSTINT(
'search_current_entity') ? 0 : 1)).
")";
283 $sql .=
" WHERE 1 = 1";
285foreach ($search as $key => $val) {
286 if (array_key_exists($key,
$object->fields)) {
287 if ($key ==
'status' && $search[$key] == -1) {
291 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
292 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
297 if ($search[$key] !=
'') {
298 $sql .=
natural_search(
"t.".
$db->sanitize($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
301 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
302 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
303 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
304 if (preg_match(
'/_dtstart$/', $key)) {
305 $sql .=
" AND t.".$db->sanitize($columnName).
" >= '".
$db->idate($search[$key]).
"'";
307 if (preg_match(
'/_dtend$/', $key)) {
308 $sql .=
" AND t.".$db->sanitize($columnName).
" <= '".
$db->idate($search[$key]).
"'";
315 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
319include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
321$parameters = array();
322$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
323$sql .= $hookmanager->resPrint;
327foreach (
$object->fields as $key => $val) {
328 $sql .=
"t.".$db->sanitize($key).
", ";
331if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
332 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
333 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
', ' :
'');
337$parameters = array();
338$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object, $action);
339$sql .= $hookmanager->resPrint;
340$sql = preg_replace(
"/,\s*$/",
"", $sql);
342$sql .=
" HAVING 1=1";
343if ($search[
'nb_of_values'] !=
'') {
344 $sql .=
natural_search(
"nb_of_values", $search[
'nb_of_values'], 1);
346if ($search[
'nb_products'] !=
'') {
350$parameters = array();
351$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
352if (empty($reshook)) {
353 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
355 $sql = $hookmanager->resPrint;
359$nbtotalofrecords =
'';
371 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
372 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
374 $resql =
$db->query($sqlforcount);
377 $nbtotalofrecords =
$db->num_rows($resql);
379 $objforcount =
$db->fetch_object($resql);
380 $nbtotalofrecords = $objforcount->nbtotalofrecords;
382 if (($page * $limit) > (
int) $nbtotalofrecords) {
391$sql .=
$db->order($sortfield, $sortorder);
393 $sql .=
$db->plimit($limit + 1, $offset);
396$resql =
$db->query($sql);
402$num =
$db->num_rows($resql);
406if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
407 $obj =
$db->fetch_object($resql);
409 header(
"Location: " .
dol_buildpath(
'/variants/card.php', 2) .
'?id='.((
int)
$id));
417llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist');
419$arrayofselected = is_array($toselect) ? $toselect : array();
423 $param .=
'&mode='.urlencode($mode);
425if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
426 $param .=
'&contextpage='.urlencode($contextpage);
428if ($limit > 0 && $limit !=
$conf->liste_limit) {
429 $param .=
'&limit='.((int) $limit);
431if ($optioncss !=
'') {
432 $param .=
'&optioncss='.urlencode($optioncss);
439foreach ($search as $key => $val) {
440 if (is_array($search[$key])) {
441 foreach ($search[$key] as $skey) {
443 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
446 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
447 $param .=
'&search_'.$key.
'month='.(
GETPOSTINT(
'search_'.$key.
'month'));
448 $param .=
'&search_'.$key.
'day='.(
GETPOSTINT(
'search_'.$key.
'day'));
449 $param .=
'&search_'.$key.
'year='.(
GETPOSTINT(
'search_'.$key.
'year'));
450 } elseif ($search[$key] !=
'') {
451 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
455include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
457$parameters = array(
'param' => &$param);
458$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
459$param .= $hookmanager->resPrint;
462$arrayofmassactions = array(
468if (!empty($permissiontodelete)) {
469 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
471if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
472 $arrayofmassactions = array();
474$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
476print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
477if ($optioncss !=
'') {
478 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
480print
'<input type="hidden" name="token" value="'.newToken().
'">';
481print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
482print
'<input type="hidden" name="action" value="list">';
483print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
484print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
485print
'<input type="hidden" name="page" value="'.$page.
'">';
486print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
487print
'<input type="hidden" name="page_y" value="">';
488print
'<input type="hidden" name="mode" value="'.$mode.
'">';
491$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'));
492$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'));
494$newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/variants/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
496print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
499$topicmail =
"SendProductAttributeRef";
500$modelmail =
"productattribute";
502$trackid =
'pa'.$object->id;
503include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
507 foreach ($fieldstosearchall as $key => $val) {
508 $fieldstosearchall[$key] = $langs->trans($val);
509 $setupstring .= $key.
"=".$val.
";";
511 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
512 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
520$parameters = array();
521$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
522if (empty($reshook)) {
523 $moreforfilter .= $hookmanager->resPrint;
525 $moreforfilter = $hookmanager->resPrint;
528if (!empty($moreforfilter)) {
529 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
530 print $moreforfilter;
534$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
535$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
536$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
537$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
539print
'<div class="div-table-responsive">';
540print
'<table id="tableattributes" class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
545print
'<tr class="liste_titre_filter nodrag nodrop">';
547if (
$conf->main_checkbox_left_column) {
548 print
'<td class="liste_titre center maxwidthsearch">';
549 $searchpicto = $form->showFilterButtons(
'left');
553foreach (
$object->fields as $key => $val) {
555 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
556 if ($key ==
'status') {
557 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
558 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
559 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
560 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
561 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
562 } 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'])) {
563 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
565 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
566 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
567 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
568 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);
569 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
570 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
571 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
572 print
'<div class="nowrap">';
573 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
575 print
'<div class="nowrap">';
576 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
578 } elseif ($key ==
'lang') {
579 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
581 print $formadmin->select_language((isset($search[$key]) ? $search[$key] :
''),
'search_lang', 0, array(), 1, 0, 0,
'minwidth100imp maxwidth125', 2);
583 print
'<input type="text" class="flat maxwidth'.($val[
'type'] ==
'integer' ?
'50' :
'75').
'" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
589include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
591$parameters = array(
'arrayfields' => $arrayfields);
592$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
593print $hookmanager->resPrint;
595$key =
'nb_of_values';
596if (!empty($arrayfields[$key][
'checked'])) {
597 print
'<td class="liste_titre center">';
598 print
'<input type="text" class="flat maxwidth50" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
602if (!empty($arrayfields[$key][
'checked'])) {
603 print
'<td class="liste_titre center">';
604 print
'<input type="text" class="flat maxwidth50" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
608if (!
$conf->main_checkbox_left_column) {
609 print
'<td class="liste_titre center maxwidthsearch">';
610 $searchpicto = $form->showFilterButtons();
615print
'<td class="liste_titre linecolmove width25"></td>';
623print
'<tr class="liste_titre nodrag nodrop">';
625if (
$conf->main_checkbox_left_column) {
626 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
629foreach (
$object->fields as $key => $val) {
630 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
631 if ($key ==
'status') {
632 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
633 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
634 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
635 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
636 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
637 } 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'])) {
638 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
640 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
641 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
642 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param,
'', $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
''), 0, (empty($val[
'helplist']) ?
'' : $val[
'helplist'])).
"\n";
647include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
649$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &
$totalarray);
650$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
651print $hookmanager->resPrint;
653$key =
'nb_of_values';
654if (!empty($arrayfields[$key][
'checked'])) {
656 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
660if (!empty($arrayfields[$key][
'checked'])) {
661 print
getTitleFieldOfList($arrayfields[$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'class="center"', $sortfield, $sortorder,
'center ').
"\n";
665if (!
$conf->main_checkbox_left_column) {
666 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
676$needToFetchEachLine = 0;
692$imaxinloop = ($limit ? min($num, $limit) : $num);
693while ($i < $imaxinloop) {
694 $obj =
$db->fetch_object($resql);
700 $object->setVarsFromFetchObj($obj);
703 if ($mode ==
'kanban') {
705 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
706 print
'<div class="box-flex-container kanban">';
710 if ($massactionbutton || $massaction) {
712 if (in_array(
$object->id, $arrayofselected)) {
716 print
$object->getKanbanView(
'', array(
'selected' => $selected));
717 if ($i == ($imaxinloop - 1)) {
724 print
'<tr data-rowid="'.$object->id.
'" class="oddeven row-with-select">';
726 if (
$conf->main_checkbox_left_column) {
727 print
'<td class="nowrap center">';
728 if ($massactionbutton || $massaction) {
730 if (in_array(
$object->id, $arrayofselected)) {
733 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
741 foreach (
$object->fields as $key => $val) {
742 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
743 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
744 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
745 } elseif ($key ==
'status') {
746 $cssforfield .= ($cssforfield ?
' ' :
'') .
'center';
749 if (in_array($val[
'type'], array(
'timestamp'))) {
750 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowraponall';
751 } elseif ($key ==
'ref') {
752 $cssforfield .= ($cssforfield ?
' ' :
'') .
'nowraponall';
755 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'])) {
756 $cssforfield .= ($cssforfield ?
' ' :
'') .
'right';
760 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
761 print
'<td'.($cssforfield ?
' class="'.$cssforfield.((preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) ?
' classfortooltip' :
'').
'"' :
'');
762 if (preg_match(
'/tdoverflow/', $cssforfield) && !in_array($val[
'type'], array(
'ip',
'url')) && !is_numeric(
$object->$key)) {
763 print
' title="'.dol_escape_htmltag((
string)
$object->$key).
'"';
766 if ($key ==
'status') {
767 print
$object->getLibStatut(5);
768 } elseif ($key ==
'rowid') {
769 print
$object->showOutputField($val, $key, (
string)
$object->id,
'');
777 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
792 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
794 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &
$totalarray);
795 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
796 print $hookmanager->resPrint;
798 $key =
'nb_of_values';
799 if (!empty($arrayfields[$key][
'checked'])) {
800 print
'<td class="center">';
807 $key =
'nb_products';
808 if (!empty($arrayfields[$key][
'checked'])) {
809 print
'<td class="center">';
817 if (!
$conf->main_checkbox_left_column) {
818 print
'<td class="nowrap center">';
819 if ($massactionbutton || $massaction) {
821 if (in_array(
$object->id, $arrayofselected)) {
824 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
832 print
'<td class="center linecolmove tdlineupdown">';
834 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=up&token='.newToken().
'&rowid=' . $obj->rowid .
'">' .
img_up(
'default', 0,
'imgupforline') .
'</a>';
837 print
'<a class="lineupdown" href="' . $_SERVER[
'PHP_SELF'] .
'?action=down&token='.newToken().
'&rowid=' . $obj->rowid .
'">' .
img_down(
'default', 0,
'imgdownforline') .
'</a>';
844 print
'</tr>' .
"\n";
851include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
856 foreach ($arrayfields as $key => $val) {
857 if (!empty($val[
'checked'])) {
862 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
867$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
868$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
869print $hookmanager->resPrint;
871print
'</table>'.
"\n";
877$tagidfortablednd = (empty($tagidfortablednd) ?
'tableattributes' : $tagidfortablednd);
880 $(document).ready(
function(){
881 $(
".imgupforline, .imgdownforline").hide();
882 $(
".lineupdown").removeAttr(
'href');
884 .css(
"background-image",
'url(<?php echo DOL_URL_ROOT.'/theme/
'.$conf->theme.'/img/grip.png
'; ?>)')
885 .css(
"background-repeat",
"no-repeat")
886 .css(
"background-position",
"center center")
889 $(
this).addClass(
'showDragHandle');
891 $(
this).removeClass(
'showDragHandle');
895 $(
"#<?php echo $tagidfortablednd; ?>").tableDnD({
896 onDrop:
function(
table, row) {
897 console.log(
'onDrop variant .tableDnD');
898 $(
'#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr(
'id',
'');
899 $(
'#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr(
'id',
'');
900 var reloadpage =
"<?php echo $forcereloadpage; ?>";
901 var roworder = cleanSerialize(decodeURI($(
"#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
902 $.post(
"<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
905 token:
"<?php echo currentToken(); ?>"
908 if (reloadpage == 1) {
909 location.href =
'<?php echo dol_escape_htmltag($_SERVER['PHP_SELF
']).'?
'.dol_escape_htmltag($_SERVER['QUERY_STRING
']); ?>';
913 onDragClass:
"dragClass",
914 dragHandle:
"td.tdlineupdown"
920if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
921 $hidegeneratedfilelistifempty = 1;
922 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
923 $hidegeneratedfilelistifempty = 0;
926 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
930 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
931 $urlsource .= str_replace(
'&',
'&', $param);
933 $filedir = $diroutputmassaction;
934 $genallowed = $permissiontoread;
935 $delallowed = $permissiontoadd;
937 print $formfile->showdocuments(
'massfilesarea_productattribute',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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_now($mode='gmt')
Return date for now.
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...
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
isModEnabled($module)
Is Dolibarr module enabled.
treeview li table
No Email.
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, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.