From e8f0f9a509978a699fe7d7b620bc65ce9a504b7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Mar 2007 19:14:06 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20liste=20des=205=20derniers=20clients=20?= =?UTF-8?q?et=205=20derniers=20fournisseurs=20enregistr=E9s=20sur=20page?= =?UTF-8?q?=20compta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/index.php | 179 +++++++++++++++++++++++++++++++++------- 1 file changed, 150 insertions(+), 29 deletions(-) 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 ''; $i = 0; @@ -156,15 +159,20 @@ if ($conf->facture->enabled && $user->rights->facture->lire) $facturestatic->type=$obj->type; print $facturestatic->getNomUrl(1,''); print ''; - print ''; + print ''; print ''; print ''; $tot_ttc+=$obj->total_ttc; $i++; } - print ''; - print ''; + print ''; + print ''; print ''; print "
'.$langs->trans("DraftBills").' ('.$num.')
'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,16).''; + $companystatic->id=$obj->idp; + $companystatic->nom=$obj->nom; + $companystatic->client=1; + print $companystatic->getNomUrl(1,'',16); + print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($tot_ttc).'
'.$langs->trans("Total").''.price($tot_ttc).'

"; @@ -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 ''; + print ''; + 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 ''; + print ''; + print ''; + + $i++; + } + + print '
'.$langs->trans("BoxTitleLastCustomers",min($max,$num)).''.$langs->trans("Date").'
'.$customerstatic->getNomUrl(1).''.dolibarr_print_date($objp->dc,'day').'

'; + } + } +} + + +// 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 ''; + print ''; + 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 ''; + print ''; + print ''; + + $i++; + } + + print '
'.$langs->trans("BoxTitleLastSuppliers",min($max,$num)).''.$langs->trans("Date").'
'.$customerstatic->getNomUrl(1).''.dolibarr_print_date($objp->dc,'day').'

'; + } + } +} + /* * 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;