diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 3993447978b..e67c08b9cc1 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -182,7 +182,7 @@ print "\n"; // Solde actuel $balance=0; $sql = "SELECT sum(f.amount) as total"; -$sql .= " FROM llx_bank as f"; +$sql.= " FROM ".MAIN_DB_PREFIX."bank as f"; if ($_GET["account"]) { $sql .= " WHERE fk_account = ".$_GET["account"]; } $resql=$db->query($sql); if ($resql) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php new file mode 100644 index 00000000000..50152163b3b --- /dev/null +++ b/htdocs/compta/bank/treso.php @@ -0,0 +1,192 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/compta/bank/treso.php + \ingroup banque + \brief Page de détail du budget de trésorerie + \version $Revision$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php"); +require_once(DOL_DOCUMENT_ROOT.'/facture.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php'); +require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); + +$langs->load("banks"); + +$user->getrights('banque'); + +if (!$user->admin && !$user->rights->banque) + accessforbidden(); + +$account=isset($_GET["account"])?$_GET["account"]:$_POST["account"]; +$vline=isset($_GET["vline"])?$_GET["vline"]:$_POST["vline"]; +$page=isset($_GET["page"])?$_GET["page"]:0; + +$mesg=''; + + + +/* +* Affichage page +*/ + +llxHeader(); +$societestatic = new Societe($db); +$facturestatic=new Facture($db); +$facturefournstatic=new FactureFournisseur($db); + +$html = new Form($db); + +if ($account > 0) +{ + if ($vline) + { + $viewline = $vline; + } + else + { + $viewline = 20; + } + $acct = new Account($db); + $result=$acct->fetch($account); + /* + * + * + */ + // Onglets + $head=bank_prepare_head($acct); + dolibarr_fiche_head($head,'cash',$langs->trans("FinancialAccount"),0); + + + if ($mesg) print '
'.$mesg.'
'; + + + /* + * Calcul du solde du compte bancaire + */ + $sql = "SELECT sum( amount ) AS solde"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank"; + $sql.= " WHERE fk_account =".$account; + + $result = $db->query($sql); + if ($result) + { + $obj = $db->fetch_object($result); + if ($obj) $solde = $obj->solde; + } + + /* + * Affiche tableau des echeances à venir + * + */ + + print ''; + + // Ligne de titre tableau des ecritures + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Solde initial + print ''; + print ''; + print ''; + + + + // Recuperation des factures clients et fournisseurs impayes + $sql = "SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.type, ".$db->pdate("f.date_lim_reglement")." as dlr,"; + $sql.= " s.rowid as socid, s.nom, s.fournisseur"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; + $sql.= " WHERE f.paye = 0 AND fk_statut > 0"; + $sql.= " UNION DISTINCT"; + $sql.= " SELECT ff.rowid as facid, ff.facnumber, (-1*ff.total_ttc), ff.type, ".$db->pdate("ff.date_lim_reglement")." as dlr,"; + $sql.= " s.rowid as socid, s.nom, s.fournisseur"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; + $sql.= " WHERE ff.paye = 0 AND fk_statut > 0"; + $sql.= " ORDER BY dlr ASC"; + + $result = $db->query($sql); + if ($result) + { + $var=False; + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($result); + + $societestatic->id = $obj->socid; + $societestatic->nom = $obj->nom; + + if ($obj->fournisseur == 1) + { + $facturefournstatic->ref=$obj->facnumber; + $facturefournstatic->id=$obj->facid; + $facturefournstatic->type=$obj->type; + $facture = $facturefournstatic->getNomUrl(1,''); + } + else + { + $facturestatic->ref=$obj->facnumber; + $facturestatic->id=$obj->facid; + $facturestatic->type=$obj->type; + $facture = $facturestatic->getNomUrl(1,''); + } + + $solde += $obj->total_ttc; + + print ""; + print ""; + print ""; + print ""; + if ($obj->total_ttc < 0) { print ""; }; + if ($obj->total_ttc >= 0) { print ""; }; + print ""; + print ""; + $i++; + } + $db->free($result); + } + + print "
'.$langs->trans("Invoices").''.$langs->trans("ThirdParty").''.$langs->trans("DateEcheance").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("BankBalance").'
'.$langs->trans("CurrentBalance").''.price($solde).'
".$facture."".$societestatic->getNomUrl(0,'',16)."".dolibarr_print_date($obj->dlr,"day")."".price($obj->total_ttc)."  ".price($obj->total_ttc)."".price($solde)."
"; + +} +else +{ + print $langs->trans("ErrorBankAccountNotFound"); +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 1e266c712aa..cc3c5a9c6d1 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -107,4 +107,5 @@ BankChecksToReceipt=Cheques waiting for deposit DeleteTransaction=Delete transaction ConfirmDeleteTransaction=Are you sure you want to delete this transaction ? ThisWillAlsoDeleteBankRecord=This will also delete generated bank transactions -BankMovements=Movements \ No newline at end of file +BankMovements=Movements +CashBudget=Cash budget \ No newline at end of file diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index 23f31f0ce47..32bd2a35790 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -108,3 +108,4 @@ DeleteTransaction=Supprimer la transaction ConfirmDeleteTransaction=Etes-vous sur de vouloir supprimer cette transaction ? ThisWillAlsoDeleteBankRecord=Ceci supprimera aussi les écritures banquaires générées BankMovements=Mouvements +CashBudget=Budget de trésorerie \ No newline at end of file diff --git a/htdocs/lib/bank.lib.php b/htdocs/lib/bank.lib.php index f4e1bf6bc6c..9aebaeee5fd 100644 --- a/htdocs/lib/bank.lib.php +++ b/htdocs/lib/bank.lib.php @@ -57,11 +57,16 @@ function bank_prepare_head($obj) $head[$h][1] = $langs->trans("IOMonthlyReporting"); $head[$h][2] = 'annual'; $h++; - + $head[$h][0] = DOL_URL_ROOT."/compta/bank/graph.php?account=".$obj->id; $head[$h][1] = $langs->trans("Graph"); $head[$h][2] = 'graph'; $h++; + + $head[$h][0] = DOL_URL_ROOT."/compta/bank/treso.php?account=".$obj->id; + $head[$h][1] = $langs->trans("CashBudget"); + $head[$h][2] = 'cash'; + $h++; if ($obj->courant != 2) {