Erg: Les fonctions compte bancaires sont regroupes en onglets

This commit is contained in:
Laurent Destailleur 2006-08-13 00:34:16 +00:00
parent ffed30c84b
commit bf255eaf3d
21 changed files with 1054 additions and 1108 deletions

View File

@ -50,11 +50,11 @@ $stcomm=isset($_GET["stcomm"])?$_GET["stcomm"]:$_POST["stcomm"];
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
$page=isset($_GET["page"])?$_GET["page"]:$_POST["page"]; $page=isset($_GET["page"])?$_GET["page"]:$_POST["page"];
if ($page == -1) { $page = 0 ; } if ($page == -1) { $page = 0; }
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="s.nom"; if (! $sortfield) $sortfield="s.nom";
$offset = $conf->liste_limit * $page ; $offset = $conf->liste_limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;

View File

@ -185,7 +185,7 @@ class CompanyBankAccount
*/ */
function verif() function verif()
{ {
require_once DOL_DOCUMENT_ROOT . '/compta/bank/bank.lib.php'; require_once DOL_DOCUMENT_ROOT . '/lib/bank.lib.php';
if (strlen(trim($this->code_banque)) == 0) if (strlen(trim($this->code_banque)) == 0)

View File

@ -271,7 +271,7 @@ class Account
if (! $this->min_desired) $this->min_desired=0; if (! $this->min_desired) $this->min_desired=0;
// Chargement librairie pour acces fonction controle RIB // Chargement librairie pour acces fonction controle RIB
require_once DOL_DOCUMENT_ROOT . '/compta/bank/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/lib/bank.lib.php';
if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) { if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) {
$this->error="Le contrôle de la clé indique que les informations de votre compte bancaire sont incorrectes."; $this->error="Le contrôle de la clé indique que les informations de votre compte bancaire sont incorrectes.";
@ -388,7 +388,7 @@ class Account
global $langs; global $langs;
// Chargement librairie pour acces fonction controle RIB // Chargement librairie pour acces fonction controle RIB
require_once(DOL_DOCUMENT_ROOT . '/compta/bank/bank.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/bank.lib.php');
dolibarr_syslog("Account.class::update $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix"); dolibarr_syslog("Account.class::update $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix");

View File

@ -30,6 +30,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
if (!$user->rights->banque->lire) if (!$user->rights->banque->lire)
accessforbidden(); accessforbidden();
@ -67,6 +68,7 @@ if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]))
if ($insertid) if ($insertid)
{ {
Header("Location: account.php?account=" . $account); Header("Location: account.php?account=" . $account);
exit;
} }
else else
{ {
@ -85,259 +87,266 @@ llxHeader();
if ($account > 0) if ($account > 0)
{ {
if ($vline) if ($vline)
{
$viewline = $vline;
}
else
{
$viewline = 20;
}
$acct = new Account($db);
$acct->fetch($account);
// Chargement des categories dans $options
$nbcategories=0;
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ;";
$result = $db->query($sql);
if ($result)
{
$var=True;
$num = $db->num_rows($result);
$i = 0;
$options = "<option value=\"0\" selected=\"true\">&nbsp;</option>";
while ($i < $num)
{
$obj = $db->fetch_object($result);
$options .= "<option value=\"$obj->rowid\">$obj->label</option>\n";
$nbcategories++;
$i++;
}
$db->free($result);
}
/*
*
*
*/
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.fk_account=".$acct->id;
$sql_rech="";
if ($_POST["req_desc"])
{
$sql_rech .= " AND b.label like '%".strtolower($_POST["req_desc"])."%'";
$mode_search = 1;
}
else
{
$mode_search = 0;
}
if ($_POST["req_debit"]) $sql_rech.=" AND amount = -".$_POST["req_debit"];
if ($_POST["req_credit"]) $sql_rech.=" AND amount = ".$_POST["req_credit"];
$sql .= $sql_rech;
$result=$db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$nbline = $obj->nb;
$total_lines = $nbline;
if ($nbline > $viewline )
{ {
$limit = $nbline - $viewline ; $viewline = $vline;
} }
else else
{ {
$limit = $viewline; $viewline = 20;
} }
$acct = new Account($db);
$acct->fetch($account);
// Chargement des categories dans $options
$nbcategories=0;
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ;";
$result = $db->query($sql);
if ($result)
{
$var=True;
$num = $db->num_rows($result);
$i = 0;
$options = "<option value=\"0\" selected=\"true\">&nbsp;</option>";
while ($i < $num)
{
$obj = $db->fetch_object($result);
$options .= "<option value=\"$obj->rowid\">$obj->label</option>\n";
$nbcategories++;
$i++;
}
$db->free($result);
}
/*
*
*
*/
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.fk_account=".$acct->id;
$sql_rech="";
if ($_POST["req_desc"])
{
$sql_rech .= " AND b.label like '%".strtolower($_POST["req_desc"])."%'";
$mode_search = 1;
}
else
{
$mode_search = 0;
}
if ($_POST["req_debit"]) $sql_rech.=" AND amount = -".$_POST["req_debit"];
if ($_POST["req_credit"]) $sql_rech.=" AND amount = ".$_POST["req_credit"];
$sql .= $sql_rech;
$result=$db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$nbline = $obj->nb;
$total_lines = $nbline;
if ($nbline > $viewline )
{
$limit = $nbline - $viewline ;
}
else
{
$limit = $viewline;
}
$db->free($result);
}
else {
dolibarr_print_error($db);
}
if ($page > 0 && $mode_search == 0)
{
$limitsql = $nbline - ($page * $viewline);
if ($limitsql < $viewline)
{
$limitsql = $viewline;
}
$nbline = $limitsql;
}
else
{
$page = 0;
$limitsql = $nbline;
}
/**
* Formulaire de recherche
*
*/
$mesg='';
$nbpage=floor($total_lines/$viewline)+($total_lines % $viewline > 0?1:0); // Nombre de page total
if ($limitsql > $viewline)
{
$mesg.='<a href="account.php?account='.$acct->id.'&amp;page='.($page+1).'">'.img_previous().'</a>';
}
$mesg.= ' Page '.($nbpage-$page).'/'.$nbpage.' ';
if ($total_lines > $limitsql )
{
$mesg.= '<a href="account.php?account='.$acct->id.'&amp;page='.($page-1).'">'.img_next().'</a>';
}
$titre=$langs->trans("FinancialAccount")." : ".$acct->label;
print_fiche_titre($titre,$mesg);
// Onglets
$head=bank_prepare_head($acct);
dolibarr_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0);
$db->free($result); print '<table class="notopnoleftnoright" width="100%">';
}
else {
dolibarr_print_error($db);
}
if ($page > 0 && $mode_search == 0) /*
{ * Affiche tableau des transactions bancaires
$limitsql = $nbline - ($page * $viewline); *
if ($limitsql < $viewline) */
// Formulaire de saisie d'une opération hors factures
if ($user->rights->banque->modifier && $_GET["action"]=='addline')
{ {
$limitsql = $viewline; $html=new Form($db);
print '<form method="post" action="account.php">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="vline" value="' . $vline . '">';
print '<input type="hidden" name="account" value="' . $acct->id . '">';
print "<tr class=\"noborder\"><td colspan=\"8\">&nbsp;</td></tr>\n";
print '<tr>';
print '<td align="left" colspan="8"><b>'.$langs->trans("AddBankRecordLong").'</b></td>';
print '</tr>';
print '<tr class="liste_titre">';
print '<td><small>YYYY MMDD</small></td><td colspan="2">'.$langs->trans("Type").'</td><td>'.$langs->trans("Description").'</td><td align=right>'.$langs->trans("Debit").'</td><td align=right>'.$langs->trans("Credit").'</td>';
print '<td colspan="2" align="center">&nbsp;';
print '</td></tr>';
print '<tr '.$bc[false].'>';
print '<td nowrap>';
print '<input name="dateoy" class="flat" type="text" size="2" value="'.strftime("%Y",time()).'" maxlength="4">';
print '<input name="dateo" class="flat" type="text" size="2" maxlength="4"></td>';
print '<td colspan="2" nowrap>';
$html->select_types_paiements('','operation','1,2',1);
print '<input name="num_chq" class="flat" type="text" size="4"></td>';
print '<td>';
print '<input name="label" class="flat" type="text" size="40">';
if ($nbcategories)
{
print '<br>'.$langs->trans("Category").': <select class="flat" name="cat1">'.$options.'</select>';
}
print '</td>';
print '<td align=right><input name="debit" class="flat" type="text" size="6"></td>';
print '<td align=right><input name="credit" class="flat" type="text" size="6"></td>';
print '<td colspan="2" align="center">';
print '<input type="submit" name="save" class="button" value="'.$langs->trans("Add").'"><br>';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
print "</form>";
print "<tr class=\"noborder\"><td colspan=\"8\">&nbsp;</td></tr>\n";
} }
$nbline = $limitsql;
}
else
{
$page = 0;
$limitsql = $nbline;
}
/** // Ligne de titre tableau des acritures
* Formulaire de recherche print '<tr class="liste_titre">';
* print '<td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Value").'</td><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Description").'</td>';
*/ print '<td align="right">'.$langs->trans("Debit").'</td><td align="right">'.$langs->trans("Credit").'</td>';
$mesg=''; print '<td align="right" width="80">'.$langs->trans("BankBalance").'</td>';
print '<td align="center" width="60">';
$nbpage=floor($total_lines/$viewline)+($total_lines % $viewline > 0?1:0); // Nombre de page total if ($acct->type != 2 && $acct->rappro) print $langs->trans("AccountStatementShort");
if ($limitsql > $viewline) else print '&nbsp;';
{ print '</td></tr>';
$mesg.='<a href="account.php?account='.$acct->id.'&amp;page='.($page+1).'">'.img_previous().'</a>';
}
$mesg.= ' Page '.($nbpage-$page).'/'.$nbpage.' ';
if ($total_lines > $limitsql )
{
$mesg.= '<a href="account.php?account='.$acct->id.'&amp;page='.($page-1).'">'.img_next().'</a>';
}
print '<form method="post" action="account.php">';
print_fiche_titre("Journal de trésorerie du compte : " .$acct->label,$mesg); print '<input type="hidden" name="action" value="search">';
print '<input type="hidden" name="account" value="' . $acct->id . '">';
print '<br>'; print '<tr class="liste_titre">';
print '<table class="notopnoleftnoright" width="100%">'; print '<td colspan="3">&nbsp;</td>';
print '<td><input type="text" class="flat" name="req_desc" value="'.$_POST["req_desc"].'" size="40"></td>';
/* print '<td align="right"><input type="text" class="flat" name="req_debit" value="'.$_POST["req_debit"].'" size="6"></td>';
* Affiche tableau des transactions bancaires print '<td align="right"><input type="text" class="flat" name="req_credit" value="'.$_POST["req_credit"].'" size="6"></td>';
* print '<td align="center">&nbsp;</td>';
*/ print '<td align="center" width="40"><input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'"></td>';
print "</tr>\n";
print "</form>\n";
// Formulaire de saisie d'une opération hors factures /* Another solution
if ($user->rights->banque->modifier && $_GET["action"]=='rappro') * create temporary table solde type=heap select amount from llx_bank limit 100 ;
{ * select sum(amount) from solde ;
$html=new Form($db); */
print '<form method="post" action="account.php">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="vline" value="' . $vline . '">';
print '<input type="hidden" name="account" value="' . $acct->id . '">';
print '<tr>';
print '<td align="left" colspan="8"><b>'.$langs->trans("AddBankRecordLong").'</b></td>';
print '</tr>';
print '<tr class="liste_titre">'; $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type";
print '<td><small>YYYY MMDD</small></td><td colspan="2">'.$langs->trans("Type").'</td><td>'.$langs->trans("Description").'</td><td align=right>'.$langs->trans("Debit").'</td><td align=right>'.$langs->trans("Credit").'</td>'; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
print '<td colspan="2" align="center">&nbsp;'; $sql.= " WHERE fk_account=".$acct->id;
print '</td></tr>'; if ($req_debit) $sql .= " AND b.amount = -".$req_debit;
if ($req_credit) $sql .= " AND b.amount = ".$req_credit;
$sql.= $sql_rech;
if ($vue)
{
if ($vue == 'credit')
{
$sql .= " AND b.amount >= 0 ";
}
else
{
$sql .= " AND b.amount < 0 ";
}
}
$sql.= " ORDER BY b.datev ASC";
$sql.= $db->plimit($limitsql, 0);
print '<tr '.$bc[false].'>'; $result = $db->query($sql);
print '<td nowrap>'; if ($result)
print '<input name="dateoy" class="flat" type="text" size="2" value="'.strftime("%Y",time()).'" maxlength="4">'; {
print '<input name="dateo" class="flat" type="text" size="2" maxlength="4"></td>'; $total = _print_lines($db, $result, $sql, $acct);
print '<td colspan="2" nowrap>'; if ($page == 0)
$html->select_types_paiements('','operation','1,2',1); {
print '<input name="num_chq" class="flat" type="text" size="4"></td>'; print '<tr class="liste_total"><td align="left" colspan="6">'.$langs->trans("CurrentBalance").'</td>';
print '<td>'; print '<td align="right" nowrap>'.price($total).'</td>';
print '<input name="label" class="flat" type="text" size="40">'; print '<td>&nbsp;</td>';
if ($nbcategories) print '</tr>';
{ }
print '<br>'.$langs->trans("Category").': <select class="flat" name="cat1">'.$options.'</select>'; $db->free($result);
} }
print '</td>';
print '<td align=right><input name="debit" class="flat" type="text" size="6"></td>';
print '<td align=right><input name="credit" class="flat" type="text" size="6"></td>';
print '<td colspan="2" align="center">';
print '<input type="submit" name="save" class="button" value="'.$langs->trans("Add").'"><br>';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
print "</form>";
print "<tr class=\"noborder\"><td colspan=\"8\">&nbsp;</td></tr>\n";
}
// Ligne de titre tableau des acritures
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Value").'</td><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("Debit").'</td><td align="right">'.$langs->trans("Credit").'</td>';
print '<td align="right" width="80">'.$langs->trans("BankBalance").'</td>';
print '<td align="center" width="60">';
if ($acct->type != 2 && $acct->rappro) print $langs->trans("AccountStatementShort");
else print '&nbsp;';
print '</td></tr>';
print '<form method="post" action="account.php">';
print '<input type="hidden" name="action" value="search">';
print '<input type="hidden" name="account" value="' . $acct->id . '">';
print '<tr class="liste_titre">';
print '<td colspan="3"><a href="graph.php?id='.$acct->id.'">Graph</a></td>';
print '<td><input type="text" class="flat" name="req_desc" value="'.$_POST["req_desc"].'" size="40"></td>';
print '<td align="right"><input type="text" class="flat" name="req_debit" value="'.$_POST["req_debit"].'" size="6"></td>';
print '<td align="right"><input type="text" class="flat" name="req_credit" value="'.$_POST["req_credit"].'" size="6"></td>';
print '<td align="center">&nbsp;</td>';
print '<td align="center" width="40"><input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'"></td>';
print "</tr>\n";
print "</form>\n";
/* Another solution
* create temporary table solde type=heap select amount from llx_bank limit 100 ;
* select sum(amount) from solde ;
*/
$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE fk_account=".$acct->id;
if ($req_debit) $sql .= " AND b.amount = -".$req_debit;
if ($req_credit) $sql .= " AND b.amount = ".$req_credit;
$sql.= $sql_rech;
if ($vue)
{
if ($vue == 'credit')
{
$sql .= " AND b.amount >= 0 ";
}
else
{
$sql .= " AND b.amount < 0 ";
}
}
$sql.= " ORDER BY b.datev ASC";
$sql.= $db->plimit($limitsql, 0);
$result = $db->query($sql);
if ($result)
{
$total = _print_lines($db, $result, $sql, $acct);
if ($page == 0)
{
print '<tr class="liste_total"><td align="right" colspan="6">'.$langs->trans("Balance").'</td>';
print '<td align="right" nowrap>'.price($total).'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
}
$db->free($result);
}
print "</table>";
/* print "</table>";
* Boutons actions
*/ print "\n</div>\n";
if ($_GET["action"] != 'rappro')
{ /*
print '<div class="tabsAction">'; * Boutons actions
*/
if ($user->rights->banque->modifier && $acct->type != 2 && $acct->rappro) // Si non compte cash et rapprochable if ($_GET["action"] != 'addline')
{ {
print '<a class="tabAction" href="rappro.php?account='.$acct->id.'">'.$langs->trans("Conciliate").'</a>'; print '<div class="tabsAction">';
}
if ($user->rights->banque->modifier && $acct->type != 2 && $acct->rappro) // Si non compte cash et rapprochable
if ($user->rights->banque->modifier) {
{ print '<a class="tabAction" href="rappro.php?account='.$acct->id.'">'.$langs->trans("Conciliate").'</a>';
print '<a class="tabAction" href="account.php?action=rappro&amp;account='.$acct->id.'&amp;page='.$page.'">'.$langs->trans("AddBankRecord").'</a>'; }
}
if ($user->rights->banque->modifier)
print '</div>'; {
} print '<a class="tabAction" href="account.php?action=addline&amp;account='.$acct->id.'&amp;page='.$page.'">'.$langs->trans("AddBankRecord").'</a>';
}
print '</div>';
}
print '<br>';
print '<br>';
} }
else else
{ {
print $langs->trans("ErrorBankAccountNotFound"); print $langs->trans("ErrorBankAccountNotFound");
} }
$db->close(); $db->close();

View File

@ -22,13 +22,14 @@
*/ */
/** /**
\file htdocs/compta/bank/annuel.php \file htdocs/compta/bank/annuel.php
\ingroup banque \ingroup banque
\brief Page reporting mensuel Entrées/Sorties d'un compte bancaire \brief Page reporting mensuel Entrées/Sorties d'un compte bancaire
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
if (!$user->rights->banque->lire) accessforbidden(); if (!$user->rights->banque->lire) accessforbidden();
@ -44,6 +45,13 @@ else
$year_end=$year_start+2; $year_end=$year_start+2;
} }
// Sécurité accés client
if ($user->societe_id > 0)
{
$socidp = $user->societe_id;
}
llxHeader(); llxHeader();
@ -51,17 +59,6 @@ llxHeader();
$acct = new Account($db); $acct = new Account($db);
$acct->fetch($_GET["account"]); $acct->fetch($_GET["account"]);
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$socidp = $user->societe_id;
}
$title=$langs->trans("IOMonthlyReporting").", ".$langs->trans("FinancialAccount")." : <a href=\"account.php?account=".$acct->id."\">".$acct->label."</a>";
$lien=($year_start?"<a href='annuel.php?account=".$acct->id."&year_start=".($year_start-1)."'>".img_previous()."</a> <a href='annuel.php?account=".$acct->id."&year_start=".($year_start+1)."'>".img_next()."</a>":"");
print_fiche_titre($title,$lien);
print '<br>';
# Ce rapport de trésorerie est basé sur llx_bank (car doit inclure les transactions sans facture) # Ce rapport de trésorerie est basé sur llx_bank (car doit inclure les transactions sans facture)
# plutot que sur llx_paiement + llx_paiementfourn # plutot que sur llx_paiement + llx_paiementfourn
@ -75,16 +72,18 @@ $sql .= " GROUP BY dm";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$encaiss[$row[1]] = $row[0]; $encaiss[$row[1]] = $row[0];
$i++; $i++;
} }
} else { }
dolibarr_print_error($db); else
{
dolibarr_print_error($db);
} }
$sql = "SELECT sum(f.amount), date_format(f.dateo,'%Y-%m') as dm"; $sql = "SELECT sum(f.amount), date_format(f.dateo,'%Y-%m') as dm";
@ -95,17 +94,28 @@ $sql .= " GROUP BY dm";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$decaiss[$row[1]] = -$row[0]; $decaiss[$row[1]] = -$row[0];
$i++; $i++;
} }
} else {
dolibarr_print_error($db);
} }
else
{
dolibarr_print_error($db);
}
$title=$langs->trans("FinancialAccount")." : ".$acct->label;
$lien=($year_start?"<a href='annuel.php?account=".$acct->id."&year_start=".($year_start-1)."'>".img_previous()."</a> <a href='annuel.php?account=".$acct->id."&year_start=".($year_start+1)."'>".img_next()."</a>":"");
print_fiche_titre($title,$lien);
// Onglets
$head=bank_prepare_head($acct);
dolibarr_fiche_head($head,'annual',$langs->trans("FinancialAccount"),0);
// Affiche tableau // Affiche tableau
@ -169,7 +179,6 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
$nbcol+=2; $nbcol+=2;
} }
print "</tr>\n"; print "</tr>\n";
print '<td colspan="'.$nbcol.'">&nbsp;</td>';
// Solde actuel // Solde actuel
$balance=0; $balance=0;
@ -191,6 +200,7 @@ print "</tr>\n";
print "</table>"; print "</table>";
print "\n</div>\n";
$db->close(); $db->close();

View File

@ -1,86 +0,0 @@
<?php
/* Copyright (C) 2000,2001 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
*
* $Id$
* $Source$
*
* 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.
* or see http://www.gnu.org/
*/
/*! \file htdocs/compta/bank/bank.lib.php
\ingroup banque
\brief librairie contenant les fonctions bancaires.
\author Laurent Destailleur
\version $Revision$
Ensemble des fonctions en rapport avec les modules bancaires
*/
/*!
\brief Verifie le RIB d'un compte bancaire grace à sa clé
\param code_banque code banque
\param code_guichet code guichet
\param num_compte numero de compte
\param cle cle
\param iban Ne sert pas pour le calcul de cle mais sert pour determiner le pays
\return int true si les infos sont bonnes, false si la clé ne correspond pas
*/
function verif_rib($code_banque , $code_guichet , $num_compte , $cle, $iban)
{
if (eregi("^FR",$iban))
{ // Cas de la France
$coef = array(62, 34, 3) ;
// Concatenation des differents codes.
$rib = strtolower(trim($code_banque).trim($code_guichet).trim($num_compte).trim($cle));
// On remplace les eventuelles lettres par des chiffres.
//Ne marche pas
//$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678");
$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678923456789");
// Separation du rib en 3 groupes de 7 + 1 groupe de 2.
// Multiplication de chaque groupe par les coef du tableau
for ($i=0, $s=0; $i<3; $i++)
{
$code = substr($rib, 7 * $i, 7) ;
$s += (0 + $code) * $coef[$i] ;
}
// Soustraction du modulo 97 de $s à 97 pour obtenir la clé RIB
$cle_rib = 97 - ($s % 97) ;
if ($cle_rib == $cle)
{
return true;
}
return false;
}
return true;
}
?>

View File

@ -29,6 +29,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
$langs->load("banks"); $langs->load("banks");
@ -103,21 +104,11 @@ $form = new Form($db);
/* /*
* Affichage onglets * Affichage onglets
*/ */
$h=0; $titre=$langs->trans("FinancialAccount")." : ".$account->label;
print_fiche_titre($titre,$mesg);
$head[$h][0] = 'fiche.php?id='.$account->id; // Onglets
$head[$h][1] = $langs->trans("AccountCard"); $head=bank_prepare_head($account);
$head[$h][2] = 'bankname';
$h++;
if ($account->type == 0 || $account->type == 1)
{
$head[$h][0] = 'bankid_fr.php?id='.$account->id;
$head[$h][1] = $langs->trans("RIB");
$head[$h][2] = 'bankid';
$h++;
}
dolibarr_fiche_head($head, 'bankid', $langs->trans("FinancialAccount")); dolibarr_fiche_head($head, 'bankid', $langs->trans("FinancialAccount"));
/* /*
@ -186,7 +177,7 @@ $form = new Form($db);
print '</table>'; print '</table>';
print '</div>'; print "\n</div>\n";
/* /*

View File

@ -21,7 +21,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require("./bank.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
$user->getrights('compta'); $user->getrights('compta');

View File

@ -28,11 +28,12 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require("./bank.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
if (!$user->rights->banque->configurer) if (!$user->rights->banque->configurer)
accessforbidden(); accessforbidden();
llxHeader(); llxHeader();
print_titre($langs->trans("AccountSetup")); print_titre($langs->trans("AccountSetup"));

View File

@ -29,6 +29,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
$langs->load("banks"); $langs->load("banks");
@ -215,8 +216,11 @@ if ($_GET["action"] == 'create')
print '<tr><td valign="top">'.$langs->trans("Web").'</td>'; print '<tr><td valign="top">'.$langs->trans("Web").'</td>';
print '<td colspan="3"><input size="50" type="text" class="flat" name="url" value="'.$_POST["url"].'"></td></tr>'; print '<td colspan="3"><input size="50" type="text" class="flat" name="url" value="'.$_POST["url"].'"></td></tr>';
// Comment
print '<tr><td valign="top">'.$langs->trans("Comment").'</td>'; print '<tr><td valign="top">'.$langs->trans("Comment").'</td>';
print '<td colspan="3"><textarea cols="70" class="flat" name="account_comment">'.$account->comment.'</textarea></td></tr>'; print '<td colspan="3">';
print '<textarea cols="70" class="flat" name="account_comment">'.$account->comment.'</textarea>';
print '</td></tr>';
// Solde // Solde
print '<tr><td colspan="4"><b>'.$langs->trans("InitialBankBalance").'...</b></td></tr>'; print '<tr><td colspan="4"><b>'.$langs->trans("InitialBankBalance").'...</b></td></tr>';
@ -254,21 +258,11 @@ else
/* /*
* Affichage onglets * Affichage onglets
*/ */
$h=0; $titre=$langs->trans("FinancialAccount")." : ".$account->label;
print_fiche_titre($titre,$mesg);
$head[$h][0] = 'fiche.php?id='.$account->id;
$head[$h][1] = $langs->trans("AccountCard");
$head[$h][2] = 'bankname';
$h++;
if ($account->type == 0 || $account->type == 1) // Onglets
{ $head=bank_prepare_head($account);
$head[$h][0] = 'bankid_fr.php?id='.$account->id;
$head[$h][1] = $langs->trans("RIB");
$head[$h][2] = 'bankid';
$h++;
}
dolibarr_fiche_head($head, 'bankname', $langs->trans("FinancialAccount")); dolibarr_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"));
/* /*
@ -433,13 +427,16 @@ else
print '<tr><td valign="top">'.$langs->trans("BalanceMinimalDesired").'</td>'; print '<tr><td valign="top">'.$langs->trans("BalanceMinimalDesired").'</td>';
print '<td colspan="3"><input size="12" type="text" class="flat" name="account_min_desired" value="'.$account->min_desired.'"></td></tr>'; print '<td colspan="3"><input size="12" type="text" class="flat" name="account_min_desired" value="'.$account->min_desired.'"></td></tr>';
// Web
print '<tr><td valign="top">'.$langs->trans("Web").'</td>'; print '<tr><td valign="top">'.$langs->trans("Web").'</td>';
print '<td colspan="3"><input size="50" type="text" class="flat" name="url" value="'.$account->url.'">'; print '<td colspan="3"><input size="50" type="text" class="flat" name="url" value="'.$account->url.'">';
print '</td></tr>'; print '</td></tr>';
// Comment
print '<tr><td valign="top">'.$langs->trans("Comment").'</td>'; print '<tr><td valign="top">'.$langs->trans("Comment").'</td>';
print '<td colspan="3"><textarea cols="70" class="flat" name="account_comment">'.$account->comment.'</textarea></td></tr>'; print '<td colspan="3">';
print '<textarea cols="70" class="flat" name="account_comment">'.$account->comment.'</textarea>';
print '</td></tr>';
print '<tr><td align="center" colspan="4"><input value="'.$langs->trans("Modify").'" type="submit" class="button">'; print '<tr><td align="center" colspan="4"><input value="'.$langs->trans("Modify").'" type="submit" class="button">';
print ' &nbsp; <input name="cancel" value="'.$langs->trans("Cancel").'" type="submit" class="button">'; print ' &nbsp; <input name="cancel" value="'.$langs->trans("Cancel").'" type="submit" class="button">';

View File

@ -26,18 +26,19 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
if (!$user->rights->banque->lire) if (!$user->rights->banque->lire)
accessforbidden(); accessforbidden();
$account = $_GET["account"];
llxHeader(); llxHeader();
$account = $_GET["id"];
if ($account > 0) if ($account > 0)
{ {
$datetime = time(); $datetime = time();
$month = strftime("%m", $datetime); $month = strftime("%m", $datetime);
$year = strftime("%Y", $datetime); $year = strftime("%Y", $datetime);
@ -45,23 +46,28 @@ if ($account > 0)
$acct = new Account($db); $acct = new Account($db);
$acct->fetch($account); $acct->fetch($account);
print_fiche_titre("Journal de trésorerie du compte: " .$acct->getNomUrl(0),$mesg);
$titre=$langs->trans("FinancialAccount")." : ".$acct->label;
print '<table class="notopnoleftnoright" width="100%">'; print_fiche_titre($titre,$mesg);
// Onglets
$head=bank_prepare_head($acct);
dolibarr_fiche_head($head,'graph',$langs->trans("FinancialAccount"),0);
print '<table class="notopnoleftnoright" width="100%">';
print '<tr><td>'; print '<tr><td>';
$file = "solde.$account.$year.png"; $file = "solde.$account.$year.png";
/* Bug if (! file_exists($conf->banque->dir_images."/".$file))
if (! file_exists($conf->$file)) {
{ print "Pour générer ou regénérer les graphiques, lancer le script ./scripts/banque/graph-solde.php en ligne de commande.<br>";
print "Pour générer ou regénérer les graphiques, lancer le script ./scripts/banque/graph-solde.php en ligne de commande.<br>"; print '<br>';
print '<br>'; }
} else
else {
{ print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">'; }
}
*/
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
print '</td></tr><tr><td>'; print '</td></tr><tr><td>';
@ -76,6 +82,9 @@ if ($account > 0)
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
print '</td></tr></table>'; print '</td></tr></table>';
print "\n</div>\n";
} }
?> ?>

View File

@ -27,10 +27,8 @@
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
require("./bank.lib.php");
require("../../tva.class.php"); require("../../tva.class.php");
require("../../chargesociales.class.php"); require("../../chargesociales.class.php");

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -19,13 +19,12 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**
\file htdocs/compta/bank/pre.inc.php \file htdocs/compta/bank/pre.inc.php
\ingroup compta \ingroup compta
\brief Fichier gestionnaire du menu compta banque \brief Fichier gestionnaire du menu compta banque
*/ */
require_once("../../main.inc.php"); require_once("../../main.inc.php");
@ -57,9 +56,10 @@ function llxHeader($head = "")
while ($i < $numr) while ($i < $numr)
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$menu->add(DOL_URL_ROOT."/compta/bank/account.php?account=" . $objp->rowid, $objp->label); $menu->add(DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid, $objp->label);
if ($objp->courant != 2) $menu->add_submenu(DOL_URL_ROOT."/compta/bank/releve.php?account=" . $objp->rowid ,$langs->trans("AccountStatements")); $menu->add_submenu(DOL_URL_ROOT."/compta/bank/annuel.php?account=".$objp->rowid ,$langs->trans("IOMonthlyReporting"));
$menu->add_submenu(DOL_URL_ROOT."/compta/bank/annuel.php?account=" . $objp->rowid ,$langs->trans("IOMonthlyReporting")); $menu->add_submenu(DOL_URL_ROOT."/compta/bank/graph.php?account=".$objp->rowid ,$langs->trans("Graph"));
if ($objp->courant != 2) $menu->add_submenu(DOL_URL_ROOT."/compta/bank/releve.php?account=".$objp->rowid ,$langs->trans("AccountStatements"));
$i++; $i++;
} }
} }

View File

@ -28,6 +28,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
$langs->load("companies"); $langs->load("companies");
@ -49,6 +50,18 @@ if ($_GET["action"] == 'dvprev')
} }
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
$page=isset($_GET["page"])?$_GET["page"]:$_POST["page"];
if ($page == -1) { $page = 0; }
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="s.nom";
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
llxHeader(); llxHeader();
@ -58,294 +71,295 @@ $acct->fetch($_GET["account"]);
if (! isset($_GET["num"])) if (! isset($_GET["num"]))
{ {
/* /*
* Vue liste tous relevés confondus * Vue liste tous relevés confondus
* */
*/ $sql = "SELECT distinct(b.num_releve) as numr";
if ($page == -1) { $page = 0 ; } $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE fk_account = ".$_GET["account"];
$sql.= " ORDER BY numr DESC";
$sql.= $db->plimit($conf->liste_limit+1,$offset);
$limit = $conf->liste_limit; $result = $db->query($sql);
$offset = $limit * $page ; if ($result)
$pageprev = $page - 1;
$pagenext = $page + 1;
$sql = "SELECT distinct(b.num_releve) as numr";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE fk_account = ".$_GET["account"];
$sql .= " ORDER BY numr DESC";
// $sql .= $db->plimit($limit,$offset); // retrait de la limite tant qu'il n'y a pas de pagination
$result = $db->query($sql);
if ($result)
{
$var=True;
$numrows = $db->num_rows($result);
$i = 0;
print_barre_liste($langs->trans("AccountStatements").", ".$langs->trans("BankAccount")." : <a href=\"account.php?account=".$acct->id."\">".$acct->label."</a>", $page, "releve.php","&amp;account=".$_GET["account"],$sortfield,$sortorder,'',$numrows);
print '<br>';
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td>'.$langs->trans("AccountStatement").'</td></tr>';
//while ($i < min($numrows,$limit)) // retrait de la limite tant qu'il n'y a pas de pagination
while ($i < min($numrows,$limit))
{ {
$objp = $db->fetch_object($result); $var=True;
$var=!$var; $numrows = $db->num_rows($result);
if (! isset($objp->numr)) $i = 0;
{
// $titre=$langs->trans("FinancialAccount")." : ".$acct->label;
} print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], "&amp;account=".$_GET["account"], $sortfield, $sortorder,'',$numrows);
else
{ // Onglets
print "<tr $bc[$var]><td><a href=\"releve.php?num=$objp->numr&amp;account=".$_GET["account"]."\">$objp->numr</a></td></tr>\n"; $head=bank_prepare_head($acct);
} dolibarr_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0);
$i++;
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td>'.$langs->trans("AccountStatement").'</td></tr>';
//while ($i < min($numrows,$conf->liste_limit)) // retrait de la limite tant qu'il n'y a pas de pagination
while ($i < min($numrows,$conf->liste_limit))
{
$objp = $db->fetch_object($result);
$var=!$var;
if (! isset($objp->numr))
{
//
}
else
{
print "<tr $bc[$var]><td><a href=\"releve.php?num=$objp->numr&amp;account=".$_GET["account"]."\">$objp->numr</a></td></tr>\n";
}
$i++;
}
print "</table>\n";
print "\n</div>\n";
}
else
{
dolibarr_print_error($db);
} }
print "</table>\n";
}
} }
else else
{ {
/** /**
* Affiche liste ecritures d'un releve * Affiche liste ecritures d'un releve
*/ */
if ($_GET["rel"] == 'prev') if ($_GET["rel"] == 'prev')
{ {
// Recherche valeur pour num = numéro relevé précédent // Recherche valeur pour num = numéro relevé précédent
$sql = "SELECT distinct(num_releve) as num"; $sql = "SELECT distinct(num_releve) as num";
$sql.= " FROM ".MAIN_DB_PREFIX."bank"; $sql.= " FROM ".MAIN_DB_PREFIX."bank";
$sql.= " WHERE num_releve < ".$_GET["num"]." AND fk_account = ".$_GET["account"]; $sql.= " WHERE num_releve < ".$_GET["num"]." AND fk_account = ".$_GET["account"];
$sql.= " ORDER BY num_releve DESC"; $sql.= " ORDER BY num_releve DESC";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$var=True; $var=True;
$numrows = $db->num_rows($result); $numrows = $db->num_rows($result);
$i = 0; $i = 0;
if ($numrows > 0) if ($numrows > 0)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$num = $obj->num; $num = $obj->num;
} }
} }
} }
elseif ($_GET["rel"] == 'next') elseif ($_GET["rel"] == 'next')
{ {
// Recherche valeur pour num = numéro relevé précédent // Recherche valeur pour num = numéro relevé précédent
$sql = "SELECT distinct(num_releve) as num"; $sql = "SELECT distinct(num_releve) as num";
$sql.= " FROM ".MAIN_DB_PREFIX."bank"; $sql.= " FROM ".MAIN_DB_PREFIX."bank";
$sql.= " WHERE num_releve > ".$_GET["num"]." AND fk_account = ".$_GET["account"]; $sql.= " WHERE num_releve > ".$_GET["num"]." AND fk_account = ".$_GET["account"];
$sql.= " ORDER BY num_releve ASC"; $sql.= " ORDER BY num_releve ASC";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$var=True; $var=True;
$numrows = $db->num_rows($result); $numrows = $db->num_rows($result);
$i = 0; $i = 0;
if ($numrows > 0) if ($numrows > 0)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$num = $obj->num; $num = $obj->num;
} }
} }
} }
else { else {
// On veut le relevé num // On veut le relevé num
$num=$_GET["num"]; $num=$_GET["num"];
} }
$ve=$_GET["ve"]; $ve=$_GET["ve"];
$mesprevnext ="<a href=\"releve.php?rel=prev&amp;num=$num&amp;ve=$ve&amp;account=$acct->id\">".img_previous()."</a> &nbsp;";
$mesprevnext.= $langs->trans("AccountStatement")." $num";
$mesprevnext.=" &nbsp; <a href=\"releve.php?rel=next&amp;num=$num&amp;ve=$ve&amp;account=$acct->id\">".img_next()."</a>";
print_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : <a href="account.php?account='.$acct->id.'">'.$acct->label.'</a>',$mesprevnext);
print '<br>';
print "<form method=\"post\" action=\"releve.php\">";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print '<table class="border" width="100%">'; $mesprevnext ="<a href=\"releve.php?rel=prev&amp;num=$num&amp;ve=$ve&amp;account=$acct->id\">".img_previous()."</a> &nbsp;";
print '<tr class="liste_titre">'; $mesprevnext.= $langs->trans("AccountStatement")." $num";
print '<td align="center">'.$langs->trans("DateOperationShort").'</td>'; $mesprevnext.=" &nbsp; <a href=\"releve.php?rel=next&amp;num=$num&amp;ve=$ve&amp;account=$acct->id\">".img_next()."</a>";
print '<td align="center">'.$langs->trans("DateValueShort").'</td>'; print_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$acct->getNomUrl(0),$mesprevnext);
print '<td>'.$langs->trans("Type").'</td>'; print '<br>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right" width="60">'.$langs->trans("Debit").'</td>';
print '<td align="right" width="60">'.$langs->trans("Credit").'</td>';
print '<td align="right">'.$langs->trans("Balance").'</td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
// Calcul du solde de départ du relevé
$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank";
$sql.= " WHERE num_releve < ".$num." AND fk_account = ".$acct->id;
$resql=$db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
$total = $obj->amount;
$db->free($resql);
}
// Recherche les écritures pour le relevé
$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE num_releve='".$num."'";
if (!isset($num))
{
$sql .= " or num_releve is null";
}
$sql .= " AND fk_account = ".$acct->id;
$sql .= " ORDER BY datev ASC";
$result = $db->query($sql);
if ($result) print "<form method=\"post\" action=\"releve.php\">";
{ print "<input type=\"hidden\" name=\"action\" value=\"add\">";
$var=True;
$numrows = $db->num_rows($result); print '<table class="border" width="100%">';
$i = 0; print '<tr class="liste_titre">';
print '<td align="center">'.$langs->trans("DateOperationShort").'</td>';
// Ligne Solde début releve print '<td align="center">'.$langs->trans("DateValueShort").'</td>';
print "<tr><td colspan=\"4\"><a href=\"releve.php?num=$num&amp;ve=1&amp;rel=$rel&amp;account=".$acct->id."\">&nbsp;</a></td>"; print '<td>'.$langs->trans("Type").'</td>';
print "<td align=\"right\" colspan=\"2\"><b>".$langs->trans("InitialBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td>&nbsp;</td></tr>\n"; print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right" width="60">'.$langs->trans("Debit").'</td>';
while ($i < $numrows) print '<td align="right" width="60">'.$langs->trans("Credit").'</td>';
{ print '<td align="right">'.$langs->trans("Balance").'</td>';
$objp = $db->fetch_object($result); print '<td>&nbsp;</td>';
$total = $total + $objp->amount; print "</tr>\n";
$var=!$var; // Calcul du solde de départ du relev
print "<tr $bc[$var]>"; $sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank";
$sql.= " WHERE num_releve < ".$num." AND fk_account = ".$acct->id;
// Date operation $resql=$db->query($sql);
print '<td nowrap="nowrap" align="center">'.dolibarr_print_date($objp->do,"%d/%m/%Y").'</td>'; if ($resql)
{
// Date de valeur $obj=$db->fetch_object($resql);
print '<td align="center" valign="center" nowrap="nowrap">'; $total = $obj->amount;
print '<a href="releve.php?action=dvprev&amp;num='.$num.'&amp;account='.$_GET["account"].'&amp;dvid='.$objp->rowid.'">'; $db->free($resql);
print img_previous().'</a> '; }
print dolibarr_print_date($objp->dv,"%d/%m/%Y") .' ';
print '<a href="releve.php?action=dvnext&amp;num='.$num.'&amp;account='.$_GET["account"].'&amp;dvid='.$objp->rowid.'">'; // Recherche les écritures pour le relev
print img_next().'</a>'; $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type";
print "</td>\n"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE num_releve='".$num."'";
// Num chq if (!isset($num))
print '<td nowrap="nowrap">'.$objp->fk_type.' '.($objp->num_chq?$objp->num_chq:'').'</td>'; {
$sql .= " or num_releve is null";
// Libelle }
print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'">'; $sql .= " AND fk_account = ".$acct->id;
$sql .= " ORDER BY datev ASC";
$result = $db->query($sql);
if ($result)
{
$var=True;
$numrows = $db->num_rows($result);
$i = 0;
// Ligne Solde début releve
print "<tr><td colspan=\"4\"><a href=\"releve.php?num=$num&amp;ve=1&amp;rel=$rel&amp;account=".$acct->id."\">&nbsp;</a></td>";
print "<td align=\"right\" colspan=\"2\"><b>".$langs->trans("InitialBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td>&nbsp;</td></tr>\n";
while ($i < $numrows)
{
$objp = $db->fetch_object($result);
$total = $total + $objp->amount;
$var=!$var;
print "<tr $bc[$var]>";
// Date operation
print '<td nowrap="nowrap" align="center">'.dolibarr_print_date($objp->do,"%d/%m/%Y").'</td>';
// Date de valeur
print '<td align="center" valign="center" nowrap="nowrap">';
print '<a href="releve.php?action=dvprev&amp;num='.$num.'&amp;account='.$_GET["account"].'&amp;dvid='.$objp->rowid.'">';
print img_previous().'</a> ';
print dolibarr_print_date($objp->dv,"%d/%m/%Y") .' ';
print '<a href="releve.php?action=dvnext&amp;num='.$num.'&amp;account='.$_GET["account"].'&amp;dvid='.$objp->rowid.'">';
print img_next().'</a>';
print "</td>\n";
// Num chq
print '<td nowrap="nowrap">'.$objp->fk_type.' '.($objp->num_chq?$objp->num_chq:'').'</td>';
// Libelle
print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'">';
$reg=array(); $reg=array();
eregi('\((.+)\)',$objp->label,$reg); // Si texte entouré de parenthèe on tente recherche de traduction eregi('\((.+)\)',$objp->label,$reg); // Si texte entouré de parenthèe on tente recherche de traduction
if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]);
else print $objp->label; else print $objp->label;
print '</a>'; print '</a>';
/*
* Ajout les liens (societe, company...)
*/
$newline=1;
$links = $acct->get_url($objp->rowid);
foreach($links as $key=>$val)
{
if (! $newline) print ' - ';
else print '<br>';
if ($links[$key]['type']=='payment')
{
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
$newline=0;
}
elseif ($links[$key]['type']=='payment_supplier') {
print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
$newline=0;
}
elseif ($links[$key]['type']=='company') {
print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowCustomer'),'company').' ';
print dolibarr_trunc($links[$key]['label'],24);
print '</a>';
$newline=0;
}
else {
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
print $links[$key]['label'];
print '</a>';
$newline=0;
}
}
// Catégories
if ($ve)
{
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."bank_categ as ct, ".MAIN_DB_PREFIX."bank_class as cl";
$sql.= " WHERE ct.rowid=cl.fk_categ AND cl.lineid=".$objp->rowid;
$resc = $db->query($sql);
if ($resc)
{
$numc = $db->num_rows($resc);
$ii = 0;
if ($numc && ! $newline) print '<br>';
while ($ii < $numc)
{
$objc = $db->fetch_object($resc);
print "<br>-&nbsp;<i>$objc->label</i>";
$ii++;
}
}
else
{
dolibarr_print_error($db);
}
}
print "</td>";
if ($objp->amount < 0)
{
$totald = $totald + abs($objp->amount);
print '<td align="right" nowrap=\"nowrap\">'.price($objp->amount * -1)."</td><td>&nbsp;</td>\n";
}
else
{
$totalc = $totalc + abs($objp->amount);
print "<td>&nbsp;</td><td align=\"right\" nowrap=\"nowrap\">".price($objp->amount)."</td>\n";
}
print "<td align=\"right\" nowrap=\"nowrap\">".price($total)."</td>\n";
if ($user->rights->banque->modifier)
{
print "<td align=\"center\"><a href=\"ligne.php?rowid=$objp->rowid&amp;account=".$acct->id."\">";
print img_edit();
print "</a></td>";
}
else
{
print "<td align=\"center\">&nbsp;</td>";
}
print "</tr>";
$i++;
}
$db->free($result);
}
// Ligne Total /*
print "<tr><td align=\"right\" colspan=\"4\">".$langs->trans("Total")." :</td><td align=\"right\">".price($totald)."</td><td align=\"right\">".price($totalc)."</td><td>&nbsp;</td><td>&nbsp;</td></tr>"; * Ajout les liens (societe, company...)
*/
$newline=1;
$links = $acct->get_url($objp->rowid);
foreach($links as $key=>$val)
{
if (! $newline) print ' - ';
else print '<br>';
if ($links[$key]['type']=='payment')
{
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
$newline=0;
}
elseif ($links[$key]['type']=='payment_supplier') {
print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
$newline=0;
}
elseif ($links[$key]['type']=='company') {
print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowCustomer'),'company').' ';
print dolibarr_trunc($links[$key]['label'],24);
print '</a>';
$newline=0;
}
else {
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
print $links[$key]['label'];
print '</a>';
$newline=0;
}
}
// Ligne Solde // Catégories
print "<tr><td align=\"right\" colspan=\"4\">&nbsp;</td><td align=\"right\" colspan=\"2\"><b>".$langs->trans("EndBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td>&nbsp;</td></tr>\n"; if ($ve)
print "</table></form>\n"; {
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."bank_categ as ct, ".MAIN_DB_PREFIX."bank_class as cl";
$sql.= " WHERE ct.rowid=cl.fk_categ AND cl.lineid=".$objp->rowid;
$resc = $db->query($sql);
if ($resc)
{
$numc = $db->num_rows($resc);
$ii = 0;
if ($numc && ! $newline) print '<br>';
while ($ii < $numc)
{
$objc = $db->fetch_object($resc);
print "<br>-&nbsp;<i>$objc->label</i>";
$ii++;
}
}
else
{
dolibarr_print_error($db);
}
}
print "</td>";
if ($objp->amount < 0)
{
$totald = $totald + abs($objp->amount);
print '<td align="right" nowrap=\"nowrap\">'.price($objp->amount * -1)."</td><td>&nbsp;</td>\n";
}
else
{
$totalc = $totalc + abs($objp->amount);
print "<td>&nbsp;</td><td align=\"right\" nowrap=\"nowrap\">".price($objp->amount)."</td>\n";
}
print "<td align=\"right\" nowrap=\"nowrap\">".price($total)."</td>\n";
if ($user->rights->banque->modifier)
{
print "<td align=\"center\"><a href=\"ligne.php?rowid=$objp->rowid&amp;account=".$acct->id."\">";
print img_edit();
print "</a></td>";
}
else
{
print "<td align=\"center\">&nbsp;</td>";
}
print "</tr>";
$i++;
}
$db->free($result);
}
// Ligne Total
print "<tr><td align=\"right\" colspan=\"4\">".$langs->trans("Total")." :</td><td align=\"right\">".price($totald)."</td><td align=\"right\">".price($totalc)."</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
// Ligne Solde
print "<tr><td align=\"right\" colspan=\"4\">&nbsp;</td><td align=\"right\" colspan=\"2\"><b>".$langs->trans("EndBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td>&nbsp;</td></tr>\n";
print "</table></form>\n";
} }
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');

View File

@ -28,7 +28,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require("./bank.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
$user->getrights('banque'); $user->getrights('banque');

View File

@ -28,7 +28,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require("./bank.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
$user->getrights('banque'); $user->getrights('banque');

View File

@ -85,4 +85,5 @@ ConciliatedBy=Conciliated by
DateConciliating=Conciliate date DateConciliating=Conciliate date
BankLineConciliated=Transaction conciliated BankLineConciliated=Transaction conciliated
CustomerInvoicePayment=Customer payment CustomerInvoicePayment=Customer payment
SupplierInvoicePayment=Supplier payment SupplierInvoicePayment=Supplier payment
FinancialAccountJournal=Financial account journal

View File

@ -85,4 +85,5 @@ ConciliatedBy=Rapproch
DateConciliating=Date rapprochement DateConciliating=Date rapprochement
BankLineConciliated=Ecriture rapprochée BankLineConciliated=Ecriture rapprochée
CustomerInvoicePayment=Règlement client CustomerInvoicePayment=Règlement client
SupplierInvoicePayment=Règlement fournisseur SupplierInvoicePayment=Règlement fournisseur
FinancialAccountJournal=Journal de trésorerie du compte

View File

@ -234,10 +234,11 @@ function dolibarr_syslog($message, $level=LOG_INFO)
\param links Tableau de titre d'onglets \param links Tableau de titre d'onglets
\param active 0=onglet non actif, 1=onglet actif \param active 0=onglet non actif, 1=onglet actif
\param title Titre tabelau ("" par defaut) \param title Titre tabelau ("" par defaut)
\param notab 0=Add tab header, 1=no tab header
*/ */
function dolibarr_fiche_head($links, $active='0', $title='') function dolibarr_fiche_head($links, $active='0', $title='', $notab=0)
{ {
print '<div class="tabs">'."\n"; print "\n".'<div class="tabs">'."\n";
// Affichage titre // Affichage titre
if ($title) if ($title)
@ -275,7 +276,7 @@ function dolibarr_fiche_head($links, $active='0', $title='')
print "</div>\n"; print "</div>\n";
print '<div class="tabBar">'."\n\n"; if (! $notab) print '<div class="tabBar">'."\n\n";
} }
/** /**
@ -1580,7 +1581,7 @@ function dol_delete_dir($dir)
\param titre titre de la page \param titre titre de la page
\param page numéro de la page \param page numéro de la page
\param file lien \param file lien
\param options options cellule td ('' par defaut) \param options parametres complementaires lien ('' par defaut)
\param sortfield champ de tri ('' par defaut) \param sortfield champ de tri ('' par defaut)
\param sortorder ordre de tri ('' par defaut) \param sortorder ordre de tri ('' par defaut)
\param center chaine du centre ('' par defaut) \param center chaine du centre ('' par defaut)
@ -1603,7 +1604,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
if ($page > 0 || $num > $conf->liste_limit) if ($page > 0 || $num > $conf->liste_limit)
{ {
print '<tr><td><div class="titre">'.$titre.' - page '.($page+1); print '<tr><td class="notopnoleftnoright"><div class="titre">'.$titre.' - page '.($page+1);
print '</div></td>'; print '</div></td>';
} }
else else

View File

@ -31,7 +31,7 @@ require("../../conf/conf.php");
header('Content-type: text/css'); header('Content-type: text/css');
// Important: Avoid page request by browser and dynamic build at // Important: Avoid page request by browser and dynamic build at
// each Dolibarr page access. // each Dolibarr page access.
header('Cache-Control: max-age=3600, must-revalidate'); header('Cache-Control: max-age=3600, public, must-revalidate');
?> ?>

View File

@ -21,17 +21,17 @@
*/ */
/** /**
\file scripts/banque/graph-solde.php \file scripts/banque/graph-solde.php
\ingroup banque \ingroup banque
\brief Script de génération des images des soldes des comptes \brief Script de génération des images des soldes des comptes
*/ */
// Test si mode batch // Test si mode batch
$sapi_type = php_sapi_name(); $sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') { if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer graph-solde.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n"; echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer graph-solde.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
exit; exit;
} }
@ -43,9 +43,9 @@ require_once($path."../../htdocs/master.inc.php");
// Vérifie que chemin vers JPGRAHP est connu et defini $jpgraph // Vérifie que chemin vers JPGRAHP est connu et defini $jpgraph
if (! $conf->global->JPGRAPH_DIR && ! defined('JPGRAPH_PATH')) if (! $conf->global->JPGRAPH_DIR && ! defined('JPGRAPH_PATH'))
{ {
print 'Erreur: Définissez la constante JPGRAPH_PATH sur la valeur du répertoire contenant JPGraph'; print 'Erreur: Définissez la constante JPGRAPH_PATH sur la valeur du répertoire contenant JPGraph';
exit; exit;
} }
if (! $conf->global->JPGRAPH_DIR) $conf->global->JPGRAPH_DIR=JPGRAPH_PATH; if (! $conf->global->JPGRAPH_DIR) $conf->global->JPGRAPH_DIR=JPGRAPH_PATH;
$jpgraphdir=$conf->global->JPGRAPH_DIR; $jpgraphdir=$conf->global->JPGRAPH_DIR;
if (! eregi('[\\\/]$',$jpgraphdir)) $jpgraphdir.='/'; if (! eregi('[\\\/]$',$jpgraphdir)) $jpgraphdir.='/';
@ -56,7 +56,7 @@ if (! file_exists($jpgraphdir."jpgraph.php"))
print 'Vérifier la variable JPGRAPH_PATH'; print 'Vérifier la variable JPGRAPH_PATH';
if ($conf->global->JPGRAPH_DIR) print ' ('.$conf->global->JPGRAPH_DIR.')'."\n"; if ($conf->global->JPGRAPH_DIR) print ' ('.$conf->global->JPGRAPH_DIR.')'."\n";
elseif (defined('JPGRAPH_PATH')) print ' ('.JPGRAPH_PATH.')'."\n"; elseif (defined('JPGRAPH_PATH')) print ' ('.JPGRAPH_PATH.')'."\n";
exit; exit;
} }
include_once($jpgraphdir."jpgraph.php"); include_once($jpgraphdir."jpgraph.php");
@ -71,18 +71,18 @@ $error = 0;
// Initialise opt, tableau des parametres // Initialise opt, tableau des parametres
if (function_exists("getopt")) if (function_exists("getopt"))
{ {
// getopt existe sur ce PHP // getopt existe sur ce PHP
$opt = getopt("m:y:"); $opt = getopt("m:y:");
} }
else else
{ {
// getopt n'existe sur ce PHP // getopt n'existe sur ce PHP
$opt=array('m'=>$argv[1]); $opt=array('m'=>$argv[1]);
} }
if (!$conf->banque->dir_images) if (!$conf->banque->dir_images)
{ {
$conf->banque->dir_images = DOL_DATA_ROOT."/graph/banque/"; $conf->banque->dir_images = DOL_DATA_ROOT."/graph/banque/";
} }
// Crée répertoire accueil // Crée répertoire accueil
@ -93,33 +93,33 @@ $datetime = time();
if ($opt['m'] > 0) if ($opt['m'] > 0)
{ {
$month = $opt['m']; $month = $opt['m'];
} }
else else
{ {
$month = strftime("%m", $datetime); $month = strftime("%m", $datetime);
} }
$year = strftime("%Y", $datetime); $year = strftime("%Y", $datetime);
if ($month == 1) if ($month == 1)
{ {
$monthprev = "12"; $monthprev = "12";
$yearprev = $year - 1; $yearprev = $year - 1;
} }
else else
{ {
$monthprev = substr("00".($month - 1), -2) ; $monthprev = substr("00".($month - 1), -2) ;
$yearprev = $year ; $yearprev = $year ;
} }
if ($month == 12) if ($month == 12)
{ {
$monthnext = "01"; $monthnext = "01";
$yearnext = $year + 1; $yearnext = $year + 1;
} }
else else
{ {
$monthnext = substr("00".($month + 1), -2) ; $monthnext = substr("00".($month + 1), -2) ;
} }
$sql = "SELECT distinct(fk_account)"; $sql = "SELECT distinct(fk_account)";
@ -132,442 +132,442 @@ $accounts = array();
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
array_push($accounts, $row[0]); array_push($accounts, $row[0]);
$i++; $i++;
} }
} }
$account = 1; $account = 1;
foreach ($accounts as $account) foreach ($accounts as $account)
{ {
$labels = array(); $labels = array();
$datas = array(); $datas = array();
$amounts = array(); $amounts = array();
$sql = "SELECT sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account;
$sql .= " AND datev < '".$year."-".$month."-01';";
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$solde = $row[0];
}
else
{
print $sql ;
}
$sql = "SELECT sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account;
$sql .= " AND datev < '".$year."-".$month."-01';";
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)"; $resql = $db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."bank"; if ($resql)
$sql .= " WHERE fk_account = ".$account;
$sql .= " AND date_format(datev,'%Y%m') = '".$year.$month."'";
$sql .= " GROUP BY date_format(datev,'%Y%m%d');";
$resql = $db->query($sql);
$amounts = array();
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$amounts[$row[0]] = $row[1]; $solde = $row[0];
$i++;
}
}
else
{
print $sql ;
}
$subtotal = 0;
$day = mktime(1,1,1,$month,1,$year);
$xmonth = substr("00".strftime("%m",$day), -2);
$i = 0;
while ($xmonth == $month)
{
//print strftime ("%e %d %m %y",$day)."\n";
$subtotal = $subtotal + $amounts[strftime("%Y%m%d",$day)];
if ($day > time())
{
$datas[$i] = 0;
} }
else else
{ {
$datas[$i] = $solde + $subtotal; print $sql ;
} }
$labels[$i] = strftime("%d",$day);
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
$day += 86400; $sql .= " FROM ".MAIN_DB_PREFIX."bank";
$xmonth = substr("00".strftime("%m",$day), -2); $sql .= " WHERE fk_account = ".$account;
$i++; $sql .= " AND date_format(datev,'%Y%m') = '".$year.$month."'";
} $sql .= " GROUP BY date_format(datev,'%Y%m%d');";
$width = 750; $resql = $db->query($sql);
$height = 350;
$amounts = array();
$graph = new Graph($width, $height,"auto");
$graph->SetScale("textlin"); if ($resql)
{
$graph->yaxis->scale->SetGrace(2); $num = $db->num_rows($resql);
$graph->SetFrame(1); $i = 0;
$graph->img->SetMargin(60,20,20,35);
while ($i < $num)
$b2plot = new BarPlot($datas); {
$row = $db->fetch_row($resql);
$b2plot->SetColor("blue"); $amounts[$row[0]] = $row[1];
//$b2plot->SetWeight(2); $i++;
}
$graph->title->Set("Solde $month $year"); }
else
$graph->xaxis->SetTickLabels($labels); {
//$graph->xaxis->title->Set(strftime("%d/%m/%y %H:%M:%S", time())); print $sql ;
}
$graph->Add($b2plot);
$graph->img->SetImgFormat("png"); $subtotal = 0;
$file= $conf->banque->dir_images."/solde.$account.$year.$month.png"; $day = mktime(1,1,1,$month,1,$year);
$graph->Stroke($file); $xmonth = substr("00".strftime("%m",$day), -2);
$i = 0;
while ($xmonth == $month)
{
//print strftime ("%e %d %m %y",$day)."\n";
$subtotal = $subtotal + $amounts[strftime("%Y%m%d",$day)];
if ($day > time())
{
$datas[$i] = 0;
}
else
{
$datas[$i] = $solde + $subtotal;
}
$labels[$i] = strftime("%d",$day);
$day += 86400;
$xmonth = substr("00".strftime("%m",$day), -2);
$i++;
}
$width = 750;
$height = 350;
$graph = new Graph($width, $height,"auto");
$graph->SetScale("textlin");
$graph->yaxis->scale->SetGrace(2);
$graph->SetFrame(1);
$graph->img->SetMargin(60,20,20,35);
$b2plot = new BarPlot($datas);
$b2plot->SetColor("blue");
//$b2plot->SetWeight(2);
$graph->title->Set("Solde $month $year");
$graph->xaxis->SetTickLabels($labels);
//$graph->xaxis->title->Set(strftime("%d/%m/%y %H:%M:%S", time()));
$graph->Add($b2plot);
$graph->img->SetImgFormat("png");
$file= $conf->banque->dir_images."/solde.$account.$year.$month.png";
$graph->Stroke($file);
} }
/* /*
* Graph annuels * Graph annuels
* *
*/ */
foreach ($accounts as $account) foreach ($accounts as $account)
{ {
$labels = array(); $labels = array();
$datas = array(); $datas = array();
$amounts = array(); $amounts = array();
$sql = "SELECT sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account;
$sql .= " AND datev < '".$year."-01-01';";
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$solde = $row[0];
}
else
{
print $sql ;
}
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)"; $sql = "SELECT sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank"; $sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account; $sql .= " WHERE fk_account = ".$account;
$sql .= " AND date_format(datev,'%Y') = '".$year."'"; $sql .= " AND datev < '".$year."-01-01';";
$sql .= " GROUP BY date_format(datev,'%Y%m%d');";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql)
$amounts = array();
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$amounts[$row[0]] = $row[1]; $solde = $row[0];
$i++;
}
}
else
{
dolibarr_syslog("graph-solde.php Error");
}
$subtotal = 0;
$day = mktime(1,1,1,1,1,$year);
$xyear = strftime("%Y",$day);
$i = 0;
while ($xyear == $year)
{
//print strftime ("%e %d %m %y",$day)."\n";
$subtotal = $subtotal + $amounts[strftime("%Y%m%d",$day)];
if ($day > time())
{
$datas[$i] = 'x'; // Valeur spéciale permettant de ne pas tracer le graph
} }
else else
{ {
$datas[$i] = $solde + $subtotal; print $sql ;
} }
if (strftime("%d",$day) == 1) $sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account;
$sql .= " AND date_format(datev,'%Y') = '".$year."'";
$sql .= " GROUP BY date_format(datev,'%Y%m%d');";
$resql = $db->query($sql);
$amounts = array();
if ($resql)
{ {
$labels[$i] = strftime("%d",$day); $num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$amounts[$row[0]] = $row[1];
$i++;
}
} }
else else
{ {
dolibarr_syslog("graph-solde.php Error");
} }
$day += 86400;
$xyear = strftime("%Y",$day);
$i++;
}
$width = 750;
$height = 350;
$graph = new Graph($width, $height,"auto");
$graph->SetScale("textlin");
$graph->yaxis->scale->SetGrace(2);
$graph->SetFrame(1);
$graph->img->SetMargin(60,20,20,35);
$b2plot = new LinePlot($datas);
$b2plot->SetColor("blue");
//$b2plot->SetWeight(2);
$graph->title->Set("Solde $year");
$graph->xaxis->SetTickLabels($labels);
$graph->xaxis->Hide(); $subtotal = 0;
//$graph->xaxis->HideTicks();
$day = mktime(1,1,1,1,1,$year);
$xyear = strftime("%Y",$day);
$i = 0;
while ($xyear == $year)
{
//print strftime ("%e %d %m %y",$day)."\n";
$subtotal = $subtotal + $amounts[strftime("%Y%m%d",$day)];
if ($day > time())
{
$datas[$i] = 'x'; // Valeur spéciale permettant de ne pas tracer le graph
}
else
{
$datas[$i] = $solde + $subtotal;
}
if (strftime("%d",$day) == 1)
{
$labels[$i] = strftime("%d",$day);
}
else
{
}
$day += 86400;
$xyear = strftime("%Y",$day);
$i++;
}
$width = 750;
$height = 350;
$graph = new Graph($width, $height,"auto");
$graph->SetScale("textlin");
$graph->yaxis->scale->SetGrace(2);
$graph->SetFrame(1);
$graph->img->SetMargin(60,20,20,35);
$b2plot = new LinePlot($datas);
$b2plot->SetColor("blue");
//$b2plot->SetWeight(2);
$graph->title->Set("Solde $year");
$graph->xaxis->SetTickLabels($labels);
$graph->xaxis->Hide();
//$graph->xaxis->HideTicks();
//$graph->xaxis->title->Set(strftime("%d/%m/%y %H:%M:%S", time())); //$graph->xaxis->title->Set(strftime("%d/%m/%y %H:%M:%S", time()));
$graph->Add($b2plot); $graph->Add($b2plot);
$graph->img->SetImgFormat("png"); $graph->img->SetImgFormat("png");
$file= $conf->banque->dir_images."/solde.$account.$year.png"; $file= $conf->banque->dir_images."/solde.$account.$year.png";
$graph->Stroke($file); $graph->Stroke($file);
} }
/* /*
* Graph annuels * Graph annuels
* *
*/ */
foreach ($accounts as $account) foreach ($accounts as $account)
{ {
$labels = array(); $labels = array();
$datas = array(); $datas = array();
$amounts = array(); $amounts = array();
$sql = "SELECT min(".$db->pdate("datev")."),max(".$db->pdate("datev").")";
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account;
$resql = $db->query($sql); $sql = "SELECT min(".$db->pdate("datev")."),max(".$db->pdate("datev").")";
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account;
if ($resql) $resql = $db->query($sql);
{
$num = $db->num_rows($resql);
$row = $db->fetch_row($resql);
$min = $row[0];
$max = $row[1];
}
else
{
dolibarr_syslog("graph-solde.php Error");
}
if ($resql)
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account;
$sql .= " GROUP BY date_format(datev,'%Y%m%d');";
$resql = $db->query($sql);
$amounts = array();
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{ {
$row = $db->fetch_row($resql); $num = $db->num_rows($resql);
$amounts[$row[0]] = $row[1]; $row = $db->fetch_row($resql);
$i++; $min = $row[0];
} $max = $row[1];
} }
else else
{ {
dolibarr_syslog("graph-solde.php Error"); dolibarr_syslog("graph-solde.php Error");
} }
$subtotal = 0;
$day = $min;
$i = 0;
while ($day <= $max)
{
//print strftime ("%e %d %m %y",$day)."\n";
$subtotal = $subtotal + $amounts[strftime("%Y%m%d",$day)];
$datas[$i] = $solde + $subtotal;
$labels[$i] = strftime("%d",$day); $sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account;
$sql .= " GROUP BY date_format(datev,'%Y%m%d');";
$day += 86400; $resql = $db->query($sql);
$i++;
}
if (sizeof($amounts) > 3) $amounts = array();
{
$width = 750;
$height = 350;
$graph = new Graph($width, $height,"auto"); if ($resql)
$graph->SetScale("textlin"); {
$num = $db->num_rows($resql);
$graph->yaxis->scale->SetGrace(2); $i = 0;
$graph->SetFrame(1);
$graph->img->SetMargin(60,20,20,35); while ($i < $num)
{
$b2plot = new LinePlot($datas); $row = $db->fetch_row($resql);
$amounts[$row[0]] = $row[1];
$b2plot->SetColor("blue"); $i++;
}
$graph->title->Set("Solde"); }
else
$graph->xaxis->SetTickLabels($labels); {
dolibarr_syslog("graph-solde.php Error");
$graph->xaxis->Hide(); }
$graph->Add($b2plot); $subtotal = 0;
$graph->img->SetImgFormat("png");
$day = $min;
$file= $conf->banque->dir_images."/solde.$account.png";
$i = 0;
$graph->Stroke($file); while ($day <= $max)
} {
//print strftime ("%e %d %m %y",$day)."\n";
$subtotal = $subtotal + $amounts[strftime("%Y%m%d",$day)];
$datas[$i] = $solde + $subtotal;
$labels[$i] = strftime("%d",$day);
$day += 86400;
$i++;
}
if (sizeof($amounts) > 3)
{
$width = 750;
$height = 350;
$graph = new Graph($width, $height,"auto");
$graph->SetScale("textlin");
$graph->yaxis->scale->SetGrace(2);
$graph->SetFrame(1);
$graph->img->SetMargin(60,20,20,35);
$b2plot = new LinePlot($datas);
$b2plot->SetColor("blue");
$graph->title->Set("Solde");
$graph->xaxis->SetTickLabels($labels);
$graph->xaxis->Hide();
$graph->Add($b2plot);
$graph->img->SetImgFormat("png");
$file= $conf->banque->dir_images."/solde.$account.png";
$graph->Stroke($file);
}
} }
foreach ($accounts as $account) foreach ($accounts as $account)
{ {
$labels = array(); $labels = array();
$datas = array(); $datas = array();
$amounts = array(); $amounts = array();
$credits = array(); $credits = array();
$debits = array(); $debits = array();
$sql = "SELECT date_format(datev,'%m'), sum(amount)"; $sql = "SELECT date_format(datev,'%m'), sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank"; $sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account; $sql .= " WHERE fk_account = ".$account;
$sql .= " AND date_format(datev,'%Y') = '".$year."'"; $sql .= " AND date_format(datev,'%Y') = '".$year."'";
$sql .= " AND amount > 0"; $sql .= " AND amount > 0";
$sql .= " GROUP BY date_format(datev,'%m');"; $sql .= " GROUP BY date_format(datev,'%m');";
$resql = $db->query($sql); $resql = $db->query($sql);
$amounts = array(); $amounts = array();
if ($resql) if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{ {
$row = $db->fetch_row($resql); $num = $db->num_rows($resql);
$credits[$row[0]] = $row[1]; $i = 0;
$i++;
}
}
else
{
print $sql ;
}
$sql = "SELECT date_format(datev,'%m'), sum(amount)"; while ($i < $num)
$sql .= " FROM ".MAIN_DB_PREFIX."bank"; {
$sql .= " WHERE fk_account = ".$account; $row = $db->fetch_row($resql);
$sql .= " AND date_format(datev,'%Y') = '".$year."'"; $credits[$row[0]] = $row[1];
$sql .= " AND amount < 0"; $i++;
$sql .= " GROUP BY date_format(datev,'%m');"; }
}
$resql = $db->query($sql); else
if ($resql)
{
while ($row = $db->fetch_row($resql))
{ {
$debits[$row[0]] = abs($row[1]); print $sql ;
} }
}
else
{
print $sql ;
}
for ($i = 0 ; $i < 12 ; $i++) $sql = "SELECT date_format(datev,'%m'), sum(amount)";
{ $sql .= " FROM ".MAIN_DB_PREFIX."bank";
$data_credit[$i] = $credits[substr("0".($i+1),-2)]; $sql .= " WHERE fk_account = ".$account;
$data_debit[$i] = $debits[substr("0".($i+1),-2)]; $sql .= " AND date_format(datev,'%Y') = '".$year."'";
$labels[$i] = $i+1; $sql .= " AND amount < 0";
} $sql .= " GROUP BY date_format(datev,'%m');";
$width = 750; $resql = $db->query($sql);
$height = 350; if ($resql)
{
$graph = new Graph($width, $height,"auto"); while ($row = $db->fetch_row($resql))
$graph->SetScale("textlin"); {
$debits[$row[0]] = abs($row[1]);
$graph->yaxis->scale->SetGrace(2); }
//$graph->SetFrame(1); }
$graph->img->SetMargin(60,20,20,35); else
{
$bsplot = new BarPlot($data_debit); print $sql ;
$bsplot->SetColor("red"); }
$beplot = new BarPlot($data_credit);
$beplot->SetColor("green");
$bg = new GroupBarPlot(array($beplot, $bsplot)); for ($i = 0 ; $i < 12 ; $i++)
{
$data_credit[$i] = $credits[substr("0".($i+1),-2)];
$data_debit[$i] = $debits[substr("0".($i+1),-2)];
$labels[$i] = $i+1;
}
$graph->title->Set("Mouvements $year"); $width = 750;
$height = 350;
$graph->xaxis->SetTickLabels($labels);
$graph = new Graph($width, $height,"auto");
$graph->Add($bg); $graph->SetScale("textlin");
$graph->img->SetImgFormat("png");
$graph->yaxis->scale->SetGrace(2);
$file= DOL_DATA_ROOT."/graph/banque/mouvement.$account.$year.png"; //$graph->SetFrame(1);
$graph->img->SetMargin(60,20,20,35);
$graph->Stroke($file);
$bsplot = new BarPlot($data_debit);
$bsplot->SetColor("red");
$beplot = new BarPlot($data_credit);
$beplot->SetColor("green");
$bg = new GroupBarPlot(array($beplot, $bsplot));
$graph->title->Set("Mouvements $year");
$graph->xaxis->SetTickLabels($labels);
$graph->Add($bg);
$graph->img->SetImgFormat("png");
$file= $conf->banque->dir_images."/mouvement.$account.$year.png";
$graph->Stroke($file);
} }
?> ?>