fix: nettoyage des requetes sql
This commit is contained in:
parent
b2cad2c540
commit
5ba650728d
@ -2015,13 +2015,18 @@ class Commande extends CommonObject
|
|||||||
global $conf, $user;
|
global $conf, $user;
|
||||||
|
|
||||||
$this->nbtodo=$this->nbtodolate=0;
|
$this->nbtodo=$this->nbtodolate=0;
|
||||||
|
$clause = "WHERE";
|
||||||
|
|
||||||
$sql = 'SELECT c.rowid,'.$this->db->pdate('c.date_creation').' as datec';
|
$sql = 'SELECT c.rowid,'.$this->db->pdate('c.date_creation').' as datec';
|
||||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
|
||||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->commercial->client->voir && !$user->societe_id)
|
||||||
$sql.= ' WHERE c.fk_statut BETWEEN 1 AND 2';
|
{
|
||||||
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc";
|
||||||
|
$sql.= " WHERE sc.fk_user = " .$user->id;
|
||||||
|
$clause = "AND";
|
||||||
|
}
|
||||||
|
$sql.= ' '.$clause.' c.fk_statut BETWEEN 1 AND 2';
|
||||||
if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
|
if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
|
||||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2570,13 +2570,18 @@ class Facture extends CommonObject
|
|||||||
global $conf, $user;
|
global $conf, $user;
|
||||||
|
|
||||||
$this->nbtodo=$this->nbtodolate=0;
|
$this->nbtodo=$this->nbtodolate=0;
|
||||||
|
$clause = "WHERE";
|
||||||
|
|
||||||
$sql = 'SELECT f.rowid,'.$this->db->pdate('f.date_lim_reglement').' as datefin';
|
$sql = 'SELECT f.rowid,'.$this->db->pdate('f.date_lim_reglement').' as datefin';
|
||||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
|
||||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->commercial->client->voir && !$user->societe_id)
|
||||||
$sql.= ' WHERE f.paye=0 AND f.fk_statut = 1';
|
{
|
||||||
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc";
|
||||||
|
$sql.= " WHERE sc.fk_user = " .$user->id;
|
||||||
|
$clause = "AND";
|
||||||
|
}
|
||||||
|
$sql.= ' '.$clause.' f.paye=0 AND f.fk_statut = 1';
|
||||||
if ($user->societe_id) $sql.=' AND f.fk_soc = '.$user->societe_id;
|
if ($user->societe_id) $sql.=' AND f.fk_soc = '.$user->societe_id;
|
||||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1846,14 +1846,19 @@ class Propal extends CommonObject
|
|||||||
global $conf, $user;
|
global $conf, $user;
|
||||||
|
|
||||||
$this->nbtodo=$this->nbtodolate=0;
|
$this->nbtodo=$this->nbtodolate=0;
|
||||||
|
$clause = "WHERE";
|
||||||
|
|
||||||
$sql ="SELECT p.rowid, p.ref, ".$this->db->pdate("p.datec")." as datec,".$this->db->pdate("p.fin_validite")." as datefin";
|
$sql ="SELECT p.rowid, p.ref, ".$this->db->pdate("p.datec")." as datec,".$this->db->pdate("p.fin_validite")." as datefin";
|
||||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
|
|
||||||
$sql.=" FROM ".MAIN_DB_PREFIX."propal as p";
|
$sql.=" FROM ".MAIN_DB_PREFIX."propal as p";
|
||||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->commercial->client->voir && !$user->societe_id)
|
||||||
if ($mode == 'opened') $sql.=" WHERE p.fk_statut = 1";
|
{
|
||||||
if ($mode == 'signed') $sql.=" WHERE p.fk_statut = 2";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
|
||||||
|
$sql.= " WHERE sc.fk_user = " .$user->id;
|
||||||
|
$clause = "AND";
|
||||||
|
}
|
||||||
|
if ($mode == 'opened') $sql.=" ".$clause." p.fk_statut = 1";
|
||||||
|
if ($mode == 'signed') $sql.=" ".$clause." p.fk_statut = 2";
|
||||||
if ($user->societe_id) $sql.=" AND p.fk_soc = ".$user->societe_id;
|
if ($user->societe_id) $sql.=" AND p.fk_soc = ".$user->societe_id;
|
||||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -1864,8 +1869,8 @@ class Propal extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($mode == 'opened') $this->nbtodolate++;
|
if ($mode == 'opened') $this->nbtodolate++;
|
||||||
if ($mode == 'signed') $this->nbtodolate++;
|
if ($mode == 'signed') $this->nbtodolate++;
|
||||||
// \todo Definir règle des propales à facturer en retard
|
// \todo Definir règle des propales à facturer en retard
|
||||||
// if ($mode == 'signed' && ! sizeof($this->FactureListeArray($obj->rowid))) $this->nbtodolate++;
|
// if ($mode == 'signed' && ! sizeof($this->FactureListeArray($obj->rowid))) $this->nbtodolate++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user