Integration persistence des parametres de liste

This commit is contained in:
Rodolphe Quiedeville 2004-02-27 14:24:42 +00:00
parent 9b84730e45
commit d8cdb5db3c
4 changed files with 136 additions and 42 deletions

View File

@ -34,6 +34,7 @@ if ($_GET["action"] == 'cstc')
$db->query($sql); $db->query($sql);
} }
dolibarr_user_page_param($db, $user, $_GET);
/* /*
* Sécurité accés client * Sécurité accés client
@ -44,6 +45,7 @@ if ($user->societe_id > 0)
$socidp = $user->societe_id; $socidp = $user->societe_id;
} }
$page = $user->page_param["page"];
if ($page == -1) { $page = 0 ; } if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ; $offset = $conf->liste_limit * $page ;
@ -62,9 +64,9 @@ if (strlen($stcomm))
$sql .= " AND s.fk_stcomm=$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) if ($user->societe_id)
@ -79,15 +81,23 @@ if ($socname)
$sortorder = "ASC"; $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"; $sortfield="s.nom";
} }
else
{
$sortfield=$user->page_param["sortfield"];
}
$sql .= " ORDER BY $sortfield $sortorder, s.nom ASC " . $db->plimit($conf->liste_limit +1, $offset); $sql .= " ORDER BY $sortfield $sortorder, s.nom ASC " . $db->plimit($conf->liste_limit +1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
@ -105,17 +115,17 @@ if ($result)
llxHeader(); 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 '<div align="center">';
print "| <A href=\"$PHP_SELF?page=$pageprev&amp;stcomm=$stcomm&amp;sortfield=$sortfield&amp;sortorder=$sortorder\">*</A>\n| "; print "| <A href=\"$PHP_SELF?page=$pageprev&amp;stcomm=$stcomm&amp;begin=%25\">*</A>\n| ";
for ($ij = 65 ; $ij < 91; $ij++) { for ($ij = 65 ; $ij < 91; $ij++) {
print "<A href=\"$PHP_SELF?begin=" . chr($ij) . "&stcomm=$stcomm\" class=\"T3\">"; 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>&gt;" . chr($ij) . "&lt;</b>" ; print "<b>&gt;" . chr($ij) . "&lt;</b>" ;
} }

View File

@ -271,7 +271,59 @@ function doliMoveFileUpload($src_file, $dest_file)
return move_uploaded_file($src_file, $file_name); 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) function transcoS2L($zonein,$devise)
{ {

View File

@ -373,7 +373,7 @@ class User
*/ */
Function fetch($login='') 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 = "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 .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql = "SELECT * 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'"; $sql .= " WHERE u.login = '$login'";
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
if ($this->db->num_rows()) if ($this->db->num_rows())
{ {
$obj = $this->db->fetch_object($result , 0); $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; $sql = "SELECT param, value FROM ".MAIN_DB_PREFIX."user_param";
$this->nom = stripslashes($obj->name); $sql .= " WHERE fk_user = ".$this->id;
$this->prenom = stripslashes($obj->firstname); $sql .= " AND page = '".$GLOBALS["SCRIPT_URL"]."'";
$this->note = stripslashes($obj->note);
$this->fullname = $this->prenom . ' ' . $this->nom; if ( $this->db->query($sql) );
$this->admin = $obj->admin; {
$this->webcal_login = $obj->webcal_login; $num = $this->db->num_rows();
$this->code = $obj->code; $i = 0;
$this->email = $obj->email; $page_param_url = '';
$this->page_param = array();
$this->contact_id = $obj->fk_socpeople; while ($i < $num)
{
$obj = $this->db->fetch_object($i);
$this->page_param[$obj->param] = $obj->value;
$page_param_url .= $obj->param . "=".$obj->value."&amp;";
$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();
}
} }
/* /*
* *

View File

@ -463,3 +463,13 @@ create table llx_c_ape
active tinyint default 1 active tinyint default 1
)type=innodb; )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;