diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 2e51b09fd7d..951e979e833 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -121,12 +121,13 @@ if ($conf->facture->enabled)
*/
if ($conf->facture->enabled && $user->rights->facture->lire)
{
- $sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type, s.nom, s.idp";
- 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";
- if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0";
- if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
+ $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 ";
+ $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";
+ $sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0";
+ if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
@@ -140,7 +141,9 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
$num = $db->num_rows($resql);
if ($num)
{
- print '
';
+ $companystatic=new Societe($db);
+
+ print '';
print '';
print '| '.$langs->trans("DraftBills").' ('.$num.') |
';
$i = 0;
@@ -156,15 +159,20 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
$facturestatic->type=$obj->type;
print $facturestatic->getNomUrl(1,'');
print '';
- print ''.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,16).' | ';
+ print '';
+ $companystatic->id=$obj->idp;
+ $companystatic->nom=$obj->nom;
+ $companystatic->client=1;
+ print $companystatic->getNomUrl(1,'',16);
+ print ' | ';
print ''.price($obj->total_ttc).' | ';
print '';
$tot_ttc+=$obj->total_ttc;
$i++;
}
- print '| '.$langs->trans("Total").' | ';
- print ''.price($tot_ttc).' | ';
+ print '
| '.$langs->trans("Total").' | ';
+ print ''.price($tot_ttc).' | ';
print '
';
print "
";
@@ -276,6 +284,121 @@ else
print '';
+// 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 '';
+ print '| '.$langs->trans("BoxTitleLastCustomers",min($max,$num)).' | ';
+ print ''.$langs->trans("Date").' | ';
+ print ' ';
+ $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 '';
+ print '| '.$customerstatic->getNomUrl(1).' | ';
+ print ''.dolibarr_print_date($objp->dc,'day').' | ';
+ print ' ';
+
+ $i++;
+ }
+
+ print ' ';
+ }
+ }
+}
+
+
+// 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 '';
+ print '| '.$langs->trans("BoxTitleLastSuppliers",min($max,$num)).' | ';
+ print ''.$langs->trans("Date").' | ';
+ print ' ';
+ $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 '';
+ print '| '.$customerstatic->getNomUrl(1).' | ';
+ print ''.dolibarr_print_date($objp->dc,'day').' | ';
+ print ' ';
+
+ $i++;
+ }
+
+ print ' ';
+ }
+ }
+}
+
/*
* Commandes à facturer
*/
@@ -396,28 +519,26 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
print '';
$var = True;
$total_ttc = $totalam = $total = 0;
- while ($i < $num)
+ while ($i < $num && $i < $conf->liste_limit)
{
$obj = $db->fetch_object($resql);
- if ($i < $conf->liste_limit)
- {
- $var=!$var;
- print ' | ';
- print '| ';
- $facturestatic->ref=$obj->facnumber;
- $facturestatic->id=$obj->rowid;
- $facturestatic->type=$obj->type;
- print $facturestatic->getNomUrl(1,'');
- if ($obj->datelimite < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
- print ' | ';
- print ''.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,44).' | ';
- if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.price($obj->total).' | ';
- print ''.price($obj->total_ttc).' | ';
- print ''.price($obj->am).' | ';
- print ''.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3,$obj->am).' | ';
- print '
';
- }
+ $var=!$var;
+ print '';
+ print '| ';
+ $facturestatic->ref=$obj->facnumber;
+ $facturestatic->id=$obj->rowid;
+ $facturestatic->type=$obj->type;
+ print $facturestatic->getNomUrl(1,'');
+ if ($obj->datelimite < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
+ print ' | ';
+ print ''.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,44).' | ';
+ if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.price($obj->total).' | ';
+ print ''.price($obj->total_ttc).' | ';
+ print ''.price($obj->am).' | ';
+ print ''.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3,$obj->am).' | ';
+ print '
';
+
$total_ttc += $obj->total_ttc;
$total += $obj->total;
$totalam += $obj->am;