Ajout liste des 5 derniers clients et 5 derniers fournisseurs enregistrés sur page compta
This commit is contained in:
parent
4b52aff62d
commit
e8f0f9a509
@ -121,7 +121,8 @@ if ($conf->facture->enabled)
|
|||||||
*/
|
*/
|
||||||
if ($conf->facture->enabled && $user->rights->facture->lire)
|
if ($conf->facture->enabled && $user->rights->facture->lire)
|
||||||
{
|
{
|
||||||
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type, s.nom, s.idp";
|
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type,";
|
||||||
|
$sql.= " s.nom, s.idp";
|
||||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
|
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
@ -140,6 +141,8 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
|
|||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
|
$companystatic=new Societe($db);
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td colspan="3">'.$langs->trans("DraftBills").' ('.$num.')</td></tr>';
|
print '<td colspan="3">'.$langs->trans("DraftBills").' ('.$num.')</td></tr>';
|
||||||
@ -156,15 +159,20 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
|
|||||||
$facturestatic->type=$obj->type;
|
$facturestatic->type=$obj->type;
|
||||||
print $facturestatic->getNomUrl(1,'');
|
print $facturestatic->getNomUrl(1,'');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,16).'</a></td>';
|
print '<td>';
|
||||||
|
$companystatic->id=$obj->idp;
|
||||||
|
$companystatic->nom=$obj->nom;
|
||||||
|
$companystatic->client=1;
|
||||||
|
print $companystatic->getNomUrl(1,'',16);
|
||||||
|
print '</td>';
|
||||||
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$tot_ttc+=$obj->total_ttc;
|
$tot_ttc+=$obj->total_ttc;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr class="liste_total"><td colspan="2" align="left">'.$langs->trans("Total").'</td>';
|
print '<tr class="liste_total"><td align="left">'.$langs->trans("Total").'</td>';
|
||||||
print '<td align="right">'.price($tot_ttc).'</td>';
|
print '<td colspan="2" align="right">'.price($tot_ttc).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
@ -276,6 +284,121 @@ else
|
|||||||
print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
|
print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
|
||||||
|
|
||||||
|
|
||||||
|
// Derniers clients
|
||||||
|
if ($user->rights->societe->lire)
|
||||||
|
{
|
||||||
|
$langs->load("boxes");
|
||||||
|
$max=5;
|
||||||
|
|
||||||
|
$sql = "SELECT s.nom, s.idp, ".$db->pdate("s.datec")." as dc";
|
||||||
|
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
|
$sql .= " WHERE s.client = 1";
|
||||||
|
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
|
if ($user->societe_id > 0)
|
||||||
|
{
|
||||||
|
$sql .= " AND s.idp = $user->societe_id";
|
||||||
|
}
|
||||||
|
$sql .= " ORDER BY s.datec DESC ";
|
||||||
|
$sql .= $db->plimit($max, 0);
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($result);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre"><td>'.$langs->trans("BoxTitleLastCustomers",min($max,$num)).'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("Date").'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
$var = True;
|
||||||
|
$total_ttc = $totalam = $total = 0;
|
||||||
|
|
||||||
|
$customerstatic=new Client($db);
|
||||||
|
$var=true;
|
||||||
|
while ($i < $num && $i < $max)
|
||||||
|
{
|
||||||
|
$objp = $db->fetch_object($result);
|
||||||
|
$customerstatic->id=$objp->idp;
|
||||||
|
$customerstatic->nom=$objp->nom;
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.$customerstatic->getNomUrl(1).'</td>';
|
||||||
|
print '<td align="right">'.dolibarr_print_date($objp->dc,'day').'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table><br>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Derniers fournisseurs
|
||||||
|
if ($user->rights->societe->lire)
|
||||||
|
{
|
||||||
|
$langs->load("boxes");
|
||||||
|
$max=5;
|
||||||
|
|
||||||
|
$sql = "SELECT s.nom, s.idp, ".$db->pdate("s.datec")." as dc";
|
||||||
|
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
|
$sql .= " WHERE s.fournisseur = 1";
|
||||||
|
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
|
if ($user->societe_id > 0)
|
||||||
|
{
|
||||||
|
$sql .= " AND s.idp = $user->societe_id";
|
||||||
|
}
|
||||||
|
$sql .= " ORDER BY s.datec DESC ";
|
||||||
|
$sql .= $db->plimit($max, 0);
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($result);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre"><td>'.$langs->trans("BoxTitleLastSuppliers",min($max,$num)).'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("Date").'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
$var = True;
|
||||||
|
$total_ttc = $totalam = $total = 0;
|
||||||
|
|
||||||
|
$customerstatic=new Client($db);
|
||||||
|
$var=true;
|
||||||
|
while ($i < $num && $i < $max)
|
||||||
|
{
|
||||||
|
$objp = $db->fetch_object($result);
|
||||||
|
$customerstatic->id=$objp->idp;
|
||||||
|
$customerstatic->nom=$objp->nom;
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.$customerstatic->getNomUrl(1).'</td>';
|
||||||
|
print '<td align="right">'.dolibarr_print_date($objp->dc,'day').'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table><br>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Commandes à facturer
|
* Commandes à facturer
|
||||||
*/
|
*/
|
||||||
@ -396,12 +519,10 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
$var = True;
|
$var = True;
|
||||||
$total_ttc = $totalam = $total = 0;
|
$total_ttc = $totalam = $total = 0;
|
||||||
while ($i < $num)
|
while ($i < $num && $i < $conf->liste_limit)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
if ($i < $conf->liste_limit)
|
|
||||||
{
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td nowrap>';
|
print '<td nowrap>';
|
||||||
@ -417,7 +538,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
|
|||||||
print '<td align="right">'.price($obj->am).'</td>';
|
print '<td align="right">'.price($obj->am).'</td>';
|
||||||
print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3,$obj->am).'</td>';
|
print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3,$obj->am).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
|
||||||
$total_ttc += $obj->total_ttc;
|
$total_ttc += $obj->total_ttc;
|
||||||
$total += $obj->total;
|
$total += $obj->total;
|
||||||
$totalam += $obj->am;
|
$totalam += $obj->am;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user