25require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
45 public function getFilterBox($type, array $preSelected, $morecss =
"minwidth300imp widthcentpercentminusx", $searchCategoryProductOperator = -1, $multiselect = 1, $nocateg = 1, $showempty =
'')
49 if (empty($preSelected) || !is_array($preSelected)) {
50 $preSelected = array();
53 if ($showempty && !is_numeric($showempty)) {
54 $tmptitle = $showempty;
56 $tmptitle = $langs->transnoentitiesnoconv(
"Category");
60 $filter .=
'<div class="divsearchfield">';
61 $filter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
65 $categoryArray[-2] =
"- ".$langs->trans(
'NotCategorized').
" -";
67 $htmlName =
"search_category_".$type.
"_list";
68 $htmlName2 =
"search_category_".$type.
"_operator";
70 $filter .=
Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, $morecss, 0, 0,
'',
'', $tmptitle);
72 $htmlName =
"search_".$type.
"_category";
74 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
77 $filter .= $formother->select_categories($type, $preSelected[0], $htmlName, $nocateg, $tmptitle, $morecss);
79 if ($multiselect && $searchCategoryProductOperator >= 0) {
80 $filter .=
' <input type="checkbox" class="valignmiddle '.$htmlName2.
'" id="'.$htmlName2.
'" name="'.$htmlName2.
'" value="1"'.($searchCategoryProductOperator == 1 ?
' checked="checked"' :
'').
' title="'.
dol_escape_htmltag($langs->trans(
'UseOrOperatorForCategories')).
'" />';
81 $filter .=
'<label class="none valignmiddle '.$htmlName2.
'" for="'.$htmlName2.
'" title="'.
dol_escape_htmltag($langs->trans(
'UseOrOperatorForCategories')).
'">';
82 $filter .= $langs->trans(
'UseOrOperatorShort');
83 $filter .=
'</label>';
85 $filter .=
'<script>'.
"\n";
86 $filter .=
"var nbSelected = jQuery('#".$htmlName.
"').val().length;";
87 $filter .=
"console.log('Nb of element now = '+nbSelected);\n";
88 $filter .=
"if (nbSelected > 1) { jQuery('.".$htmlName2.
"').show(); } else { jQuery('.".$htmlName2.
"').hide(); }\n";
89 $filter .=
"jQuery('#".$htmlName.
"').change(function() {\n";
90 $filter .=
"console.log('Content of select box has been modified.');";
91 $filter .=
'var nbSelected = $(this).val().length;';
92 $filter .=
"console.log('Nb of element now = '+nbSelected);\n";
93 $filter .=
"if (nbSelected > 1) { jQuery('.".$htmlName2.
"').show(); } else { jQuery('.".$htmlName2.
"').hide(); }\n";
94 $filter .=
'});'.
"\n";
95 $filter .=
'</script>'.
"\n";
111 $sql =
"SELECT cp.fk_categorie as cat_index, cat.label";
112 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_product as cp";
113 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"categorie as cat ON cat.rowid = cp.fk_categorie";
114 $sql .=
" GROUP BY cp.fk_categorie, cat.label";
116 dol_syslog(get_class($this).
"::selectProductCategory", LOG_DEBUG);
117 $resql = $this->db->query($sql);
119 print
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
121 print
'<option value="0"> </option>';
125 $num_rows = $this->db->num_rows($resql);
126 while ($i < $num_rows) {
127 $category = $this->db->fetch_object($resql);
128 if ($selected && $selected == $category->cat_index) {
129 print
'<option value="'.$category->cat_index.
'" selected>'.$category->label.
'</option>';
131 print
'<option value="'.$category->cat_index.
'">'.$category->label.
'</option>';
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...