From 0c0402110ebf2b6adcbd44814e1685a5a7d14dd2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Mar 2009 19:48:29 +0000 Subject: [PATCH] New: Show remain to pay on social contributions on accountancy page --- htdocs/compta/index.php | 165 ++++++++++++++++++++++------------------ 1 file changed, 91 insertions(+), 74 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 3bbf46c1e93..633a1b2702c 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2008 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -19,10 +19,10 @@ */ /** - \file htdocs/compta/index.php - \ingroup compta - \brief Page accueil zone comptabilité - \version $Id$ + * \file htdocs/compta/index.php + * \ingroup compta + * \brief Main page of accountancy area + * \version $Id$ */ require("./pre.inc.php"); @@ -102,7 +102,7 @@ print ''; print ''; print ''; print "
'; /* - * Zone recherche facture + * Find invoices */ if ($conf->facture->enabled) { @@ -115,7 +115,10 @@ if ($conf->facture->enabled) print "
".$langs->trans("Other").':

"; +} +if ($conf->fournisseur->enabled) +{ print '
'; print ''; print ''; @@ -129,7 +132,7 @@ if ($conf->facture->enabled) /** - * Factures clients brouillons + * Draft customers invoices */ if ($conf->facture->enabled && $user->rights->facture->lire) { @@ -202,7 +205,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire) } /** - * Factures fournisseurs brouillons + * Draft suppliers invoices */ if ($conf->facture->enabled && $user->rights->facture->lire) { @@ -274,74 +277,15 @@ if ($conf->facture->enabled && $user->rights->facture->lire) } } -/** - * Charges a payer - */ -if ($conf->tax->enabled) -{ - if ($user->societe_id == 0) - { - $chargestatic=new ChargeSociales($db); - - $sql = "SELECT c.rowid, c.amount, ".$db->pdate("c.date_ech")." as date_ech,"; - $sql.= " cc.libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc"; - $sql.= " WHERE c.fk_type = cc.id AND c.paye=0"; - - $resql = $db->query($sql); - if ( $resql ) - { - $var = false; - $num = $db->num_rows($resql); - - print '
'.$langs->trans("SearchASupplierInvoice").'
'; - print ''; - print ''; - if ($num) - { - $i = 0; - $tot_ttc=0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - print ""; - $chargestatic->id=$obj->rowid; - $chargestatic->lib=$obj->libelle; - print ''; - print ''; - print ''; - $tot_ttc+=$obj->amount; - $var = !$var; - $i++; - } - - print ''; - print ''; - print ''; - } - else - { - print ''; - } - print "
'.$langs->trans("ContributionsToPay").($num?' ('.$num.')':'').'
'.$chargestatic->getNomUrl(1).''.price($obj->amount).'
'.$langs->trans("Total").''.price($tot_ttc).'
'.$langs->trans("None").'

"; - $db->free($resql); - } - else - { - dol_print_error($db); - } - } -} - print ''; -// Derniers clients -if ($user->societe->enabled && $user->rights->societe->lire) +// Last customers +if ($conf->societe->enabled && $user->rights->societe->lire) { $langs->load("boxes"); - $max=5; + $max=3; $sql = "SELECT s.nom, s.rowid, ".$db->pdate("s.datec")." as dc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; @@ -400,11 +344,11 @@ if ($user->societe->enabled && $user->rights->societe->lire) } -// Derniers fournisseurs -if ($user->fournisseur->enabled && $user->rights->societe->lire) +// Last suppliers +if ($conf->fournisseur->enabled && $user->rights->societe->lire) { $langs->load("boxes"); - $max=5; + $max=3; $sql = "SELECT s.nom, s.rowid, ".$db->pdate("s.datec")." as dc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; @@ -420,7 +364,6 @@ if ($user->fournisseur->enabled && $user->rights->societe->lire) $sql .= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) { $var=false; @@ -459,6 +402,80 @@ if ($user->fournisseur->enabled && $user->rights->societe->lire) } } + +/** + * Social contributions to pay + */ +if ($conf->tax->enabled) +{ + if ($user->societe_id == 0) + { + $chargestatic=new ChargeSociales($db); + + $sql = "SELECT c.rowid, c.amount, c.date_ech, c.paye,"; + $sql.= " cc.libelle,"; + $sql.= " sum(pc.amount) as sumpayed"; + $sql.= " FROM (".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON c.rowid = pc.fk_charge"; + $sql.= " WHERE c.fk_type = cc.id AND c.paye=0"; + $sql.= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle"; + + $resql = $db->query($sql); + if ( $resql ) + { + $var = false; + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + $i = 0; + $tot_ttc=0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + print ""; + $chargestatic->id=$obj->rowid; + $chargestatic->lib=$obj->libelle; + $chargestatic->paye=$obj->paye; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $tot_ttc+=$obj->amount; + $var = !$var; + $i++; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + } + print "
'.$langs->trans("ContributionsToPay").($num?' ('.$num.')':'').''.$langs->trans("DateDue").''.$langs->trans("AmountTTC").''.$langs->trans("Payed").' 
'.$chargestatic->getNomUrl(1).''.dol_print_date($obj->date_ech,'day').''.price($obj->amount).''.price($obj->sumpayed).''.$chargestatic->getLibStatut(3).'
'.$langs->trans("Total").''.price($tot_ttc).' 
'.$langs->trans("None").'

"; + $db->free($resql); + } + else + { + dol_print_error($db); + } + } +} + /* * Commandes clients ŕ facturer */