FIX Total in summary was not same than into detail on the referrer page.
Conflicts: htdocs/product/stats/facture.php
This commit is contained in:
parent
5c1daa6135
commit
0211ad64ee
@ -128,9 +128,9 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
if ($user->rights->commande->lire)
|
if ($user->rights->commande->lire)
|
||||||
{
|
{
|
||||||
$sql = "SELECT distinct s.nom as name, s.rowid as socid, s.code_client, c.rowid, d.total_ht as total_ht, c.ref,";
|
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, c.rowid, d.total_ht as total_ht, c.ref,";
|
||||||
$sql .= " c.ref_client,";
|
$sql .= " c.ref_client,";
|
||||||
$sql.= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.qty";
|
$sql.= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
|
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
|
||||||
|
|||||||
@ -135,9 +135,9 @@ if ($id > 0 || ! empty($ref)) {
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
if ($user->rights->fournisseur->commande->lire) {
|
if ($user->rights->fournisseur->commande->lire) {
|
||||||
$sql = "SELECT distinct s.nom as name, s.rowid as socid, s.code_client,";
|
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
|
||||||
$sql .= " c.rowid, d.total_ht as total_ht, c.ref,";
|
$sql .= " c.rowid, d.total_ht as total_ht, c.ref,";
|
||||||
$sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.qty";
|
$sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.rowid, d.qty";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid)
|
if (! $user->rights->societe->client->voir && ! $socid)
|
||||||
$sql .= ", sc.fk_soc, sc.fk_user ";
|
$sql .= ", sc.fk_soc, sc.fk_user ";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
|
||||||
|
|||||||
@ -128,10 +128,11 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
if ($user->rights->facture->lire) {
|
if ($user->rights->facture->lire)
|
||||||
$sql = "SELECT distinct s.nom as name, s.rowid as socid, s.code_client,";
|
{
|
||||||
$sql.= " f.facnumber, d.total_ht as total_ht,";
|
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
|
||||||
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty";
|
$sql.= " f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,";
|
||||||
|
$sql.= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
||||||
@ -147,17 +148,20 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$sql.= ' AND YEAR(f.datef) IN (' . $search_year . ')';
|
$sql.= ' AND YEAR(f.datef) IN (' . $search_year . ')';
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||||
$sql.= " ORDER BY $sortfield $sortorder ";
|
$sql.= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
//Calcul total qty and amount for global if full scan list
|
//Calcul total qty and amount for global if full scan list
|
||||||
$total_ht=0;
|
$total_ht=0;
|
||||||
$total_qty=0;
|
$total_qty=0;
|
||||||
$totalrecords=0;
|
$totalrecords=0;
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||||
|
{
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result) {
|
if ($result)
|
||||||
|
{
|
||||||
$totalrecords = $db->num_rows($result);
|
$totalrecords = $db->num_rows($result);
|
||||||
while ($objp = $db->fetch_object($result)) {
|
while ($objp = $db->fetch_object($result))
|
||||||
|
{
|
||||||
$total_ht+=$objp->total_ht;
|
$total_ht+=$objp->total_ht;
|
||||||
$total_qty+=$objp->qty;
|
$total_qty+=$objp->qty;
|
||||||
}
|
}
|
||||||
@ -214,7 +218,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
$var=True;
|
$var=True;
|
||||||
while ($i < $num && $i < $conf->liste_limit)
|
while ($i < min($num,$conf->liste_limit))
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|||||||
@ -130,7 +130,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
if ($user->rights->fournisseur->facture->lire)
|
if ($user->rights->fournisseur->facture->lire)
|
||||||
{
|
{
|
||||||
$sql = "SELECT distinct s.nom as name, s.rowid as socid, s.code_client, f.ref, d.total_ht as total_ht,";
|
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, f.ref, d.rowid, d.total_ht as total_ht,";
|
||||||
$sql .= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty";
|
$sql .= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid)
|
if (! $user->rights->societe->client->voir && ! $socid)
|
||||||
$sql .= ", sc.fk_soc, sc.fk_user ";
|
$sql .= ", sc.fk_soc, sc.fk_user ";
|
||||||
|
|||||||
@ -129,7 +129,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
if ($user->rights->propale->lire) {
|
if ($user->rights->propale->lire) {
|
||||||
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,";
|
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,";
|
||||||
$sql .= " p.ref_client,";
|
$sql .= " p.ref_client,";
|
||||||
$sql .= "p.datep, p.fk_statut as statut, d.qty";
|
$sql .= "p.datep, p.fk_statut as statut, d.rowid, d.qty";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid)
|
if (! $user->rights->societe->client->voir && ! $socid)
|
||||||
$sql .= ", sc.fk_soc, sc.fk_user ";
|
$sql .= ", sc.fk_soc, sc.fk_user ";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user