diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 61afec22569e3af23a3ad2a35c04e21f50951db4..52b4290e83da5e66fd616807c3a4282d06d4e022 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4591,34 +4591,36 @@ class Form { global $conf, $langs; + $out = ''; + // Add code for jquery to use multiselect if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT; - print '<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' --> + $out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' --> <script type="text/javascript"> function formatResult(record) {'."\n"; if ($elemtype == 'category') { - print ' //return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> <a href="'.DOL_URL_ROOT.'/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\'; + $out.=' //return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> <a href="'.DOL_URL_ROOT.'/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\'; return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> \'+record.text+\'</span>\';'; } else { - print 'return record.text;'; + $out.='return record.text;'; } - print ' }; + $out.= ' }; function formatSelection(record) {'."\n"; if ($elemtype == 'category') { - print ' //return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> <a href="'.DOL_URL_ROOT.'/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\'; + $out.=' //return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> <a href="'.DOL_URL_ROOT.'/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\'; return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> \'+record.text+\'</span>\';'; } else { - print 'return record.text;'; + $out.='return record.text;'; } - print ' }; + $out.= ' }; $(document).ready(function () { $(\'#'.$htmlname.'\').'.$tmpplugin.'({ dir: \'ltr\', @@ -4636,7 +4638,7 @@ class Form // Try also magic suggest // Add data-role="none" to disable jmobile decoration - $out = '<select data-role="none" id="'.$htmlname.'" class="multiselect'.($morecss?' '.$morecss:'').'" multiple name="'.$htmlname.'[]"'.($moreattrib?' '.$moreattrib:'').($width?' style="width: '.(preg_match('/%/',$width)?$width:$width.'px').'"':'').'>'."\n"; + $out .= '<select data-role="none" id="'.$htmlname.'" class="multiselect'.($morecss?' '.$morecss:'').'" multiple name="'.$htmlname.'[]"'.($moreattrib?' '.$moreattrib:'').($width?' style="width: '.(preg_match('/%/',$width)?$width:$width.'px').'"':'').'>'."\n"; if (is_array($array) && ! empty($array)) { if ($value_as_key) $array=array_combine($array, $array); @@ -4665,6 +4667,84 @@ class Form } + /** + * Show a multiselect form from an array. + * + * @param string $htmlname Name of select + * @param array $array Array with array to show + * @return string HTML multiselect string + * @see selectarray + */ + static function multiSelectArrayWithCheckbox($htmlname, $array) + { + $lis=''; + $liststring=''; + + foreach($array as $key => $val) + { + if (isset($val['cond']) && ! $val['cond']) continue; + if ($val['label']) + { + $lis.='<li><input type="checkbox" value="'.$key.'"'.($val['checked']?' checked="checked"':'').'/>'.dol_escape_htmltag($val['label']).'</li>'; + $liststring.=$key.','; + } + } + + + $out ='<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' --> + + <dl class="dropdown"> + + <dt> + <a href="#"> + '.img_picto('','list').' + <input type="hidden" class="'.$htmlname.'" name="'.$htmlname.'" value="'.$liststring.'"> + </a> + </dt> + + <dd> + <div class="multiselectcheckbox'.$htmlname.'"> + <ul> + '.$lis.' + </ul> + </div> + </dd> + </dl> + + <script type="text/javascript"> + $(".dropdown dt a").on(\'click\', function () { + $(".dropdown dd ul").slideToggle(\'fast\'); + }); + + $(".dropdown dd ul li a").on(\'click\', function () { + $(".dropdown dd ul").hide(); + }); + + function getSelectedValue(id) { + return $("#" + id).find("dt a span.value").html(); + } + + $(document).bind(\'click\', function (e) { + var $clicked = $(e.target); + if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide(); + }); + + $(\'.multiselectcheckbox'.$htmlname.' input[type="checkbox"]\').on(\'click\', function () { + + var title = $(this).val() + ","; + + if ($(this).is(\':checked\')) { + $(\'.'.$htmlname.'\').val(title + $(\'.'.$htmlname.'\').val()); + } + else { + $(\'.'.$htmlname.'\').val( $(\'.'.$htmlname.'\').val().replace(title, \'\') ) + } + }); + </script> + + '; + return $out; + } /** * Render list of categories linked to object with id $id and type $type diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 80e4c553dc1ad956082038ab89c0446820249bf3..501e54cce11cabc02f7a437b59bf4c8b458cf3b0 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -208,9 +208,9 @@ $title=$langs->trans("ListOfThirdParties"); $sql = "SELECT s.rowid, s.nom as name, s.barcode, s.town, s.datec, s.code_client, s.code_fournisseur, "; $sql.= " st.libelle as stcomm, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; -$sql.= " s.siren as idprof1, s.siret as idprof2, ape as idprof3, idprof4 as idprof4"; -$sql.= ",s.fk_pays"; -$sql.= ",typent.code as typent_code"; +$sql.= " s.siren as idprof1, s.siret as idprof2, ape as idprof3, idprof4 as idprof4,"; +$sql.= " s.fk_pays, s.tms as date_update, s.datec as date_creation,"; +$sql.= " typent.code as typent_code"; // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We'll need these fields in order to filter by categ @@ -345,10 +345,29 @@ if ($resql) print '</div>'; } + // Define list of fields to show into list + $arrayfields=array( + 's.nom'=>array('label'=>$langs->trans("Company"), 'checked'=>1), + 's.barcode'=>array('label'=>$langs->trans("BarCode"), 'checked'=>1, 'cond'=>(! empty($conf->barcode->enabled))), + 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), + 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>1), + 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>1), + 's.siren'=>array('label'=>$langs->trans("ProfId1Short"), 'checked'=>1), + 's.siret'=>array('label'=>$langs->trans("ProfId2Short"), 'checked'=>1), + 's.ape'=>array('label'=>$langs->trans("ProfId3Short"), 'checked'=>1), + 's.idprof4'=>array('label'=>$langs->trans("ProfId4Short"), 'checked'=>1), + 's.status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>200), + 's.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 's.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + ); + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $selectotherfields=$form->multiSelectArrayWithCheckbox('selectotherfields', $arrayfields); + } + print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">'; - - // Lines of titles - print '<tr class="liste_titre">'; + + print '<tr class="liste_titre">'; print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); if (! empty($conf->barcode->enabled)) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); @@ -363,7 +382,7 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($selectotherfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "</tr>\n"; // Fields title search @@ -372,18 +391,19 @@ if ($resql) print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only; - print '<input class="flat" type="text" name="search_nom" size="8" value="'.htmlspecialchars($search_nom).'">'; + + print '<input class="flat" type="text" name="search_nom" size="8" value="'.dol_escape_htmltag($search_nom).'">'; print '</td>'; // Barcode if (! empty($conf->barcode->enabled)) { print '<td class="liste_titre">'; - print '<input class="flat" type="text" name="sbarcode" size="6" value="'.htmlspecialchars($sbarcode).'">'; + print '<input class="flat" type="text" name="sbarcode" size="6" value="'.dol_escape_htmltag($sbarcode).'">'; print '</td>'; } // Town print '<td class="liste_titre">'; - print '<input class="flat" size="8" type="text" name="search_town" value="'.htmlspecialchars($search_town).'">'; + print '<input class="flat" size="8" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">'; print '</td>'; //Country print '<td class="liste_titre" align="center">'; @@ -395,19 +415,19 @@ if ($resql) print '</td>'; // IdProf1 print '<td class="liste_titre">'; - print '<input class="flat" size="4" type="text" name="search_idprof1" value="'.htmlspecialchars($search_idprof1).'">'; + print '<input class="flat" size="4" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">'; print '</td>'; // IdProf2 print '<td class="liste_titre">'; - print '<input class="flat" size="4" type="text" name="search_idprof2" value="'.htmlspecialchars($search_idprof2).'">'; + print '<input class="flat" size="4" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">'; print '</td>'; // IdProf3 print '<td class="liste_titre">'; - print '<input class="flat" size="4" type="text" name="search_idprof3" value="'.htmlspecialchars($search_idprof3).'">'; + print '<input class="flat" size="4" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">'; print '</td>'; // IdProf4 print '<td class="liste_titre">'; - print '<input class="flat" size="4" type="text" name="search_idprof4" value="'.htmlspecialchars($search_idprof4).'">'; + print '<input class="flat" size="4" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">'; print '</td>'; // Type (customer/prospect/supplier) print '<td class="liste_titre" align="middle">'; diff --git a/htdocs/theme/eldy/img/list.png b/htdocs/theme/eldy/img/list.png new file mode 100644 index 0000000000000000000000000000000000000000..f5df34a3bc9f8393c23f35e25fb7b18b4b51654b Binary files /dev/null and b/htdocs/theme/eldy/img/list.png differ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 9f5376947da406670c45efed26dff85cbc812b23..2eddc0eba237a39771143c5a5089f1659c0ef0d9 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3487,6 +3487,61 @@ a span.select2-chosen } +/* ============================================================================== */ +/* Multiselect with checkbox */ +/* ============================================================================== */ + +dl.dropdown { + margin:0px; + padding:0px; +} +.dropdown dd, .dropdown dt { + margin:0px; + padding:0px; +} +.dropdown ul { + margin: -1px 0 0 0; + text-align: left; +} +.dropdown dd { + position:relative; +} +.dropdown dt a { + display:block; + overflow: hidden; + border:0; +} +.dropdown dt a span, .multiSel span { + cursor:pointer; + display:inline-block; + padding: 0 3px 2px 0; +} +.dropdown dd ul { + background-color: #FFF; + border: 1px solid #888; + display:none; + right:0px; /* pop is align on right */ + padding: 2px 15px 2px 5px; + position:absolute; + top:2px; + list-style:none; + max-height: 200px; + overflow: auto; +} +.dropdown span.value { + display:none; +} +.dropdown dd ul li { + white-space: nowrap; +} +.dropdown dd ul li a { + padding:5px; + display:block; +} +.dropdown dd ul li a:hover { + background-color:#fff; +} + /* ============================================================================== */ /* JMobile */ diff --git a/htdocs/theme/md/img/list.png b/htdocs/theme/md/img/list.png new file mode 100644 index 0000000000000000000000000000000000000000..f5df34a3bc9f8393c23f35e25fb7b18b4b51654b Binary files /dev/null and b/htdocs/theme/md/img/list.png differ