Ajout d'un onglet dans les comptes banquaire qui affiche le budget de trsorerie - merci David Roche
This commit is contained in:
parent
73299477a1
commit
d1ffaca601
@ -182,7 +182,7 @@ print "</tr>\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)
|
||||
|
||||
192
htdocs/compta/bank/treso.php
Normal file
192
htdocs/compta/bank/treso.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/* Copytight (C) 2005-2007 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
*
|
||||
* 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 '<div class="error">'.$mesg.'</div>';
|
||||
|
||||
|
||||
/*
|
||||
* 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 '<table class="notopnoleftnoright" width="100% border="1">';
|
||||
|
||||
// Ligne de titre tableau des ecritures
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Invoices").'</td>';
|
||||
print '<td>'.$langs->trans("ThirdParty").'</td>';
|
||||
print '<td>'.$langs->trans("DateEcheance").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Debit").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Credit").'</td>';
|
||||
print '<td align="right" width="80">'.$langs->trans("BankBalance").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Solde initial
|
||||
print '<tr class="liste_total"><td align="left" colspan="5">'.$langs->trans("CurrentBalance").'</td>';
|
||||
print '<td align="right" nowrap>'.price($solde).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
||||
// 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 "<tr $bc[$var]>";
|
||||
print "<td>".$facture."</td>";
|
||||
print "<td>".$societestatic->getNomUrl(0,'',16)."</td>";
|
||||
print "<td>".dolibarr_print_date($obj->dlr,"day")."</td>";
|
||||
if ($obj->total_ttc < 0) { print "<td align=\"right\">".price($obj->total_ttc)."</td><td> </td>"; };
|
||||
if ($obj->total_ttc >= 0) { print "<td> </td><td align=\"right\">".price($obj->total_ttc)."</td>"; };
|
||||
print "<td align=\"right\">".price($solde)."</td>";
|
||||
print "</tr>";
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorBankAccountNotFound");
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
@ -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
|
||||
BankMovements=Movements
|
||||
CashBudget=Cash budget
|
||||
@ -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
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user