Integration persistence des parametres de liste
This commit is contained in:
parent
9b84730e45
commit
d8cdb5db3c
@ -34,6 +34,7 @@ if ($_GET["action"] == 'cstc')
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
dolibarr_user_page_param($db, $user, $_GET);
|
||||
|
||||
/*
|
||||
* Sécurité accés client
|
||||
@ -44,6 +45,7 @@ if ($user->societe_id > 0)
|
||||
$socidp = $user->societe_id;
|
||||
}
|
||||
|
||||
$page = $user->page_param["page"];
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
|
||||
$offset = $conf->liste_limit * $page ;
|
||||
@ -62,9 +64,9 @@ if (strlen($stcomm))
|
||||
$sql .= " AND s.fk_stcomm=$stcomm";
|
||||
}
|
||||
|
||||
if (strlen($begin))
|
||||
if (strlen($user->page_param["begin"]))
|
||||
{
|
||||
$sql .= " AND upper(s.nom) like '$begin%'";
|
||||
$sql .= " AND upper(s.nom) like '".$user->page_param["begin"]."%'";
|
||||
}
|
||||
|
||||
if ($user->societe_id)
|
||||
@ -79,15 +81,23 @@ if ($socname)
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
if ($sortorder == "")
|
||||
if ($user->page_param["sortorder"] == '')
|
||||
{
|
||||
$sortorder="DESC";
|
||||
$sortorder="ASC";
|
||||
}
|
||||
if ($sortfield == "")
|
||||
else
|
||||
{
|
||||
$sortorder=$user->page_param["sortorder"];
|
||||
}
|
||||
|
||||
if ($user->page_param["sortfield"] == '')
|
||||
{
|
||||
$sortfield="s.nom";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$sortfield=$user->page_param["sortfield"];
|
||||
}
|
||||
$sql .= " ORDER BY $sortfield $sortorder, s.nom ASC " . $db->plimit($conf->liste_limit +1, $offset);
|
||||
|
||||
$result = $db->query($sql);
|
||||
@ -105,17 +115,17 @@ if ($result)
|
||||
llxHeader();
|
||||
}
|
||||
|
||||
$urladd="page=$page&stcomm=$stcomm&sortfield=$sortfield&sortorder=$sortorder&begin=$begin";
|
||||
$urladd="page=$page&stcomm=$stcomm";
|
||||
|
||||
print_barre_liste("Liste des prospects", $page, $PHP_SELF,"",$sortfield,$sortorder,'',$num);
|
||||
print_barre_liste("Liste des prospects", $page, $PHP_SELF,"","","",'',$num);
|
||||
|
||||
print '<div align="center">';
|
||||
|
||||
print "| <A href=\"$PHP_SELF?page=$pageprev&stcomm=$stcomm&sortfield=$sortfield&sortorder=$sortorder\">*</A>\n| ";
|
||||
print "| <A href=\"$PHP_SELF?page=$pageprev&stcomm=$stcomm&begin=%25\">*</A>\n| ";
|
||||
for ($ij = 65 ; $ij < 91; $ij++) {
|
||||
print "<A href=\"$PHP_SELF?begin=" . chr($ij) . "&stcomm=$stcomm\" class=\"T3\">";
|
||||
|
||||
if ($_GET["begin"] == chr($ij) )
|
||||
if ($user->page_param["begin"] == chr($ij) )
|
||||
{
|
||||
print "<b>>" . chr($ij) . "<</b>" ;
|
||||
}
|
||||
|
||||
@ -271,7 +271,59 @@ function doliMoveFileUpload($src_file, $dest_file)
|
||||
return move_uploaded_file($src_file, $file_name);
|
||||
}
|
||||
|
||||
function dolibarr_user_page_param($db, &$user)
|
||||
{
|
||||
foreach ($GLOBALS["_GET"] as $key=>$value)
|
||||
{
|
||||
if ($key == "sortfield")
|
||||
{
|
||||
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param ";
|
||||
$sql .= " SET fk_user =".$user->id;
|
||||
$sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'";
|
||||
$sql .= " ,param='sortfield'";
|
||||
$sql .= " ,value='".urlencode($value)."'";
|
||||
|
||||
$db->query($sql);
|
||||
$user->page_param["sortfield"] = $value;
|
||||
}
|
||||
|
||||
// print $key . "=".$value . "<br>";
|
||||
|
||||
if ($key == "sortorder")
|
||||
{
|
||||
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param ";
|
||||
$sql .= " SET fk_user =".$user->id;
|
||||
$sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'";
|
||||
$sql .= " ,param='sortorder'";
|
||||
$sql .= " ,value='".urlencode($value)."'";
|
||||
|
||||
$db->query($sql);
|
||||
$user->page_param["sortorder"] = $value;
|
||||
}
|
||||
if ($key == "begin")
|
||||
{
|
||||
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param ";
|
||||
$sql .= " SET fk_user =".$user->id;
|
||||
$sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'";
|
||||
$sql .= " ,param='begin'";
|
||||
$sql .= " ,value='".$value."'";
|
||||
|
||||
$db->query($sql);
|
||||
$user->page_param["begin"] = $value;
|
||||
}
|
||||
if ($key == "page")
|
||||
{
|
||||
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param ";
|
||||
$sql .= " SET fk_user =".$user->id;
|
||||
$sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'";
|
||||
$sql .= " ,param='page'";
|
||||
$sql .= " ,value='".$value."'";
|
||||
|
||||
$db->query($sql);
|
||||
$user->page_param["page"] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function transcoS2L($zonein,$devise)
|
||||
{
|
||||
|
||||
@ -373,7 +373,7 @@ class User
|
||||
*/
|
||||
Function fetch($login='')
|
||||
{
|
||||
|
||||
|
||||
//$sql = "SELECT u.rowid, u.name, u.firstname, u.email, u.code, u.admin, u.module_comm, u.module_compta, u.login, u.pass, u.webcal_login, u.note";
|
||||
//$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql = "SELECT * FROM ".MAIN_DB_PREFIX."user as u";
|
||||
@ -385,42 +385,64 @@ class User
|
||||
{
|
||||
$sql .= " WHERE u.login = '$login'";
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
$obj = $this->db->fetch_object($result , 0);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
$obj = $this->db->fetch_object($result , 0);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->nom = stripslashes($obj->name);
|
||||
$this->prenom = stripslashes($obj->firstname);
|
||||
|
||||
$this->note = stripslashes($obj->note);
|
||||
|
||||
$this->fullname = $this->prenom . ' ' . $this->nom;
|
||||
$this->admin = $obj->admin;
|
||||
$this->webcal_login = $obj->webcal_login;
|
||||
$this->code = $obj->code;
|
||||
$this->email = $obj->email;
|
||||
|
||||
$this->contact_id = $obj->fk_socpeople;
|
||||
|
||||
$this->login = $obj->login;
|
||||
$this->pass = $obj->pass;
|
||||
$this->webcal_login = $obj->webcal_login;
|
||||
|
||||
$this->societe_id = $obj->fk_societe;
|
||||
}
|
||||
$this->db->free();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->nom = stripslashes($obj->name);
|
||||
$this->prenom = stripslashes($obj->firstname);
|
||||
|
||||
$this->note = stripslashes($obj->note);
|
||||
$sql = "SELECT param, value FROM ".MAIN_DB_PREFIX."user_param";
|
||||
$sql .= " WHERE fk_user = ".$this->id;
|
||||
$sql .= " AND page = '".$GLOBALS["SCRIPT_URL"]."'";
|
||||
|
||||
$this->fullname = $this->prenom . ' ' . $this->nom;
|
||||
$this->admin = $obj->admin;
|
||||
$this->webcal_login = $obj->webcal_login;
|
||||
$this->code = $obj->code;
|
||||
$this->email = $obj->email;
|
||||
|
||||
$this->contact_id = $obj->fk_socpeople;
|
||||
if ( $this->db->query($sql) );
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
$i = 0;
|
||||
$page_param_url = '';
|
||||
$this->page_param = array();
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($i);
|
||||
$this->page_param[$obj->param] = $obj->value;
|
||||
$page_param_url .= $obj->param . "=".$obj->value."&";
|
||||
$i++;
|
||||
}
|
||||
$this->page_param_url = $page_param_url;
|
||||
}
|
||||
|
||||
$this->login = $obj->login;
|
||||
$this->pass = $obj->pass;
|
||||
$this->webcal_login = $obj->webcal_login;
|
||||
|
||||
$this->societe_id = $obj->fk_societe;
|
||||
}
|
||||
$this->db->free();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
|
||||
@ -463,3 +463,13 @@ create table llx_c_ape
|
||||
active tinyint default 1
|
||||
)type=innodb;
|
||||
|
||||
|
||||
create table llx_user_param
|
||||
(
|
||||
fk_user integer,
|
||||
page varchar(255),
|
||||
param varchar(255),
|
||||
value varchar(255),
|
||||
UNIQUE (fk_user,page,param)
|
||||
)type=innodb;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user