Ajout de restriction pour les commerciaux et les accs socits
This commit is contained in:
parent
cc14aca523
commit
187267b818
@ -59,7 +59,17 @@ if (! $mesg) {
|
||||
$px->draw($filename);
|
||||
}
|
||||
|
||||
$sql = "SELECT count(*), date_format(datep,'%Y') as dm, sum(price) FROM ".MAIN_DB_PREFIX."propal WHERE fk_statut > 0 GROUP BY dm DESC ";
|
||||
$sql = "SELECT count(*), date_format(p.datep,'%Y') as dm, sum(p.price)";
|
||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
$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";
|
||||
$sql.= " WHERE fk_statut > 0";
|
||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if($user->societe_id)
|
||||
{
|
||||
$sql .= " AND p.fk_soc = ".$user->societe_id;
|
||||
}
|
||||
$sql.= " GROUP BY dm DESC ";
|
||||
if ($db->query($sql))
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
@ -67,8 +77,16 @@ if ($db->query($sql))
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="2">';
|
||||
print '<tr><td align="center">'.$langs->trans("Year").'</td><td width="10%" align="center">'.$langs->trans("NbOfProposals").'</td><td align="center">'.$langs->trans("AmountTotal").'</td>';
|
||||
print '<td align="center" valign="top" rowspan="'.($num + 1).'">';
|
||||
if ($mesg) { print "$mesg"; }
|
||||
else { print '<img src="'.$fileurl.'" alt="Nombre de proposition par mois">'; }
|
||||
|
||||
if ($mesg)
|
||||
{
|
||||
print "$mesg";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<img src="'.$fileurl.'" alt="Nombre de proposition par mois">';
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
@ -77,7 +95,9 @@ if ($db->query($sql))
|
||||
$nbproduct = $row[0];
|
||||
$year = $row[1];
|
||||
print "<tr>";
|
||||
print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td align="center">'.$nbproduct.'</td><td align="center">'.price($row[2]).'</td></tr>';
|
||||
print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td>';
|
||||
print '<td align="center">'.$nbproduct.'</td>';
|
||||
print '<td align="center">'.price($row[2]).'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
@ -52,8 +52,18 @@ class PropaleStats extends Stats
|
||||
*/
|
||||
function getNbByMonth($year)
|
||||
{
|
||||
$sql = "SELECT date_format(datep,'%m') as dm, count(*) FROM ".MAIN_DB_PREFIX."propal";
|
||||
global $user;
|
||||
|
||||
$sql = "SELECT date_format(p.datep,'%m') as dm, count(*)";
|
||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
$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";
|
||||
$sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
|
||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if($user->societe_id)
|
||||
{
|
||||
$sql .= " AND p.fk_soc = ".$user->societe_id;
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
return $this->_getNbByMonth($year, $sql);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user