diff --git a/htdocs/comm/prospect/prospects.php b/htdocs/comm/prospect/prospects.php
index 68ab4472a58..8aeb72ac833 100644
--- a/htdocs/comm/prospect/prospects.php
+++ b/htdocs/comm/prospect/prospects.php
@@ -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 '
';
- print "|
*\n| ";
+ print "|
*\n| ";
for ($ij = 65 ; $ij < 91; $ij++) {
print "
";
- if ($_GET["begin"] == chr($ij) )
+ if ($user->page_param["begin"] == chr($ij) )
{
print ">" . chr($ij) . "<" ;
}
diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php
index 39befd0a08c..1cf967cc5d5 100644
--- a/htdocs/lib/functions.inc.php
+++ b/htdocs/lib/functions.inc.php
@@ -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 . "
";
+
+ 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)
{
diff --git a/htdocs/user.class.php b/htdocs/user.class.php
index 24e9a912bfe..2f2bfb73406 100644
--- a/htdocs/user.class.php
+++ b/htdocs/user.class.php
@@ -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();
- }
}
/*
*
diff --git a/mysql/migration/1.1.0-1.2.0-RC1.sql b/mysql/migration/1.1.0-1.2.0-RC1.sql
index 5bdff110355..f2012a388a0 100644
--- a/mysql/migration/1.1.0-1.2.0-RC1.sql
+++ b/mysql/migration/1.1.0-1.2.0-RC1.sql
@@ -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;
+