forked from Wavyzz/dolibarr
Work on the feature to select which field to show
This commit is contained in:
48
htdocs/core/actions_changeselectedfields.inc.php
Normal file
48
htdocs/core/actions_changeselectedfields.inc.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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'])
|
||||
{
|
||||
$lis.='<li><input type="checkbox" value="'.$key.'"'.($val['checked']?' checked="checked"':'').'/>'.dol_escape_htmltag($val['label']).'</li>';
|
||||
$liststring.=$key.',';
|
||||
$lis.='<li><input type="checkbox" value="'.$key.'"'.(empty($val['checked'])?'':' checked="checked"').'/>'.dol_escape_htmltag($val['label']).'</li>';
|
||||
$listcheckedstring.=(empty($val['checked'])?'':$key.',');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$out ='<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' -->
|
||||
|
||||
<dl class="dropdown">
|
||||
|
||||
<dt>
|
||||
<a href="#">
|
||||
'.img_picto('','list').'
|
||||
<input type="hidden" class="'.$htmlname.'" name="'.$htmlname.'" value="'.$liststring.'">
|
||||
<input type="hidden" class="'.$htmlname.'" name="'.$htmlname.'" value="'.$listcheckedstring.'">
|
||||
</a>
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
<div class="multiselectcheckbox'.$htmlname.'">
|
||||
<ul>
|
||||
@@ -4730,9 +4744,9 @@ class Form
|
||||
});
|
||||
|
||||
$(\'.multiselectcheckbox'.$htmlname.' input[type="checkbox"]\').on(\'click\', function () {
|
||||
|
||||
console.log("A new field was added/removed")
|
||||
$("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\')
|
||||
var title = $(this).val() + ",";
|
||||
|
||||
if ($(this).is(\':checked\')) {
|
||||
$(\'.'.$htmlname.'\').val(title + $(\'.'.$htmlname.'\').val());
|
||||
}
|
||||
|
||||
@@ -55,3 +55,5 @@ ALTER TABLE llx_adherent ADD COLUMN pass_crypted varchar(128) after pass;
|
||||
ALTER TABLE llx_paiement ADD COLUMN ref varchar(30) NOT NULL AFTER rowid;
|
||||
|
||||
ALTER TABLE llx_socpeople ADD COLUMN photo varchar(255) AFTER skype;
|
||||
|
||||
ALTER TABLE llx_user_param MODIFY COLUMN value text NOT NULL;
|
||||
|
||||
@@ -23,7 +23,7 @@ create table llx_user_param
|
||||
fk_user integer NOT NULL,
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
param varchar(64) NOT NULL,
|
||||
value varchar(255) NOT NULL
|
||||
value text NOT NULL
|
||||
)ENGINE=innodb;
|
||||
|
||||
--
|
||||
|
||||
@@ -89,7 +89,7 @@ else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas);
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
$sref="";
|
||||
$sbarcode="";
|
||||
|
||||
@@ -75,7 +75,8 @@ $pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('thirdpartylist'));
|
||||
$contextpage='thirdpartylist';
|
||||
$hookmanager->initHooks(array($contextpage));
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
|
||||
@@ -83,6 +84,8 @@ $extrafields = new ExtraFields($db);
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// special search
|
||||
if ($mode == 'search')
|
||||
{
|
||||
@@ -168,7 +171,7 @@ llxHeader('',$langs->trans("ThirdParty"),$help_url);
|
||||
|
||||
|
||||
// Do we click on purge search criteria ?
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
$search_categ='';
|
||||
$search_sale='';
|
||||
@@ -197,12 +200,14 @@ if ($socname)
|
||||
/*
|
||||
* Mode List
|
||||
*/
|
||||
|
||||
/*
|
||||
REM: Regle sur droits "Voir tous les clients"
|
||||
Utilisateur interne socid=0 + Droits voir tous clients => Voit toute societe
|
||||
Utilisateur interne socid=0 + Pas de droits voir tous clients => Ne voit que les societes liees comme commercial
|
||||
Utilisateur externe socid=x + Droits voir tous clients => Ne voit que lui meme
|
||||
Utilisateur externe socid=x + Pas de droits voir tous clients => Ne voit que lui meme
|
||||
REM: Rules on permissions to see thirdparties
|
||||
Internal or External user + No permission to see customers => See nothing
|
||||
Internal user socid=0 + Permission to see ALL customers => See all thirdparties
|
||||
Internal user socid=0 + No permission to see ALL customers => See only thirdparties linked to user that are sale representative
|
||||
External user socid=x + Permission to see ALL customers => Can see only himself
|
||||
External user socid=x + No permission to see ALL customers => Can see only himself
|
||||
*/
|
||||
$title=$langs->trans("ListOfThirdParties");
|
||||
|
||||
@@ -315,6 +320,7 @@ if ($resql)
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
|
||||
// Filter on categories
|
||||
/* Not possible in this page because list is for ALL third parties type
|
||||
@@ -362,7 +368,8 @@ if ($resql)
|
||||
);
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
$selectotherfields=$form->multiSelectArrayWithCheckbox('selectotherfields', $arrayfields);
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);
|
||||
}
|
||||
|
||||
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
|
||||
@@ -382,7 +389,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($selectotherfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
// Fields title search
|
||||
|
||||
Reference in New Issue
Block a user