diff --git a/htdocs/core/actions_changeselectedfields.inc.php b/htdocs/core/actions_changeselectedfields.inc.php new file mode 100644 index 00000000000..11884f81224 --- /dev/null +++ b/htdocs/core/actions_changeselectedfields.inc.php @@ -0,0 +1,48 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/actions_changeselectedfields.inc.php + * \brief Code for actions when we change list of fields on a list page + */ + + +// $action must be defined +// $db must be defined +// $conf must be defined +// $object must be defined (object is loaded in this file with fetch) + +// Save selection +if (GETPOST('formfilteraction') == 'listafterchangingselectedfields') +{ + $tabparam=array(); + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + + if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields"); + else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=''; + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + + $result=dol_set_user_param($db, $conf, $user, $tabparam); + + //$action='list'; + //var_dump($tabparam);exit; +} + + diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 17771a56782..b7ea040fc17 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4671,37 +4671,51 @@ class Form * Show a multiselect form from an array. * * @param string $htmlname Name of select - * @param array $array Array with array to show + * @param array $array Array with array of fields we could show + * @param string $varpage Id of context for page. Can be set with $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; * @return string HTML multiselect string * @see selectarray */ - static function multiSelectArrayWithCheckbox($htmlname, $array) + static function multiSelectArrayWithCheckbox($htmlname, $array, $varpage) { + global $user; + + $tmpvar="MAIN_SELECTEDFIELDS_".$varpage; + if (! empty($user->conf->$tmpvar)) + { + $tmparray=explode(',', $user->conf->$tmpvar); + foreach($array as $key => $val) + { + //var_dump($key); + //var_dump($tmparray); + if (in_array($key, $tmparray)) $array[$key]['checked']=1; + else $array[$key]['checked']=0; + } + } + //var_dump($array); + $lis=''; - $liststring=''; + $listcheckedstring=''; foreach($array as $key => $val) { if (isset($val['cond']) && ! $val['cond']) continue; - if ($val['label']) + if ($val['label']) { - $lis.='
  • '.dol_escape_htmltag($val['label']).'
  • '; - $liststring.=$key.','; + $lis.='
  • '.dol_escape_htmltag($val['label']).'
  • '; + $listcheckedstring.=(empty($val['checked'])?'':$key.','); } } - $out ='