Erg: Les fonctions compte bancaires sont regroupes en onglets
This commit is contained in:
parent
ffed30c84b
commit
bf255eaf3d
@ -50,11 +50,11 @@ $stcomm=isset($_GET["stcomm"])?$_GET["stcomm"]:$_POST["stcomm"];
|
||||
$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 ($page == -1) { $page = 0; }
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="s.nom";
|
||||
|
||||
$offset = $conf->liste_limit * $page ;
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
|
||||
@ -185,7 +185,7 @@ class CompanyBankAccount
|
||||
*/
|
||||
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)
|
||||
|
||||
@ -271,7 +271,7 @@ class Account
|
||||
if (! $this->min_desired) $this->min_desired=0;
|
||||
|
||||
// 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)) {
|
||||
$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;
|
||||
|
||||
// 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");
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
if (!$user->rights->banque->lire)
|
||||
accessforbidden();
|
||||
@ -67,6 +68,7 @@ if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]))
|
||||
if ($insertid)
|
||||
{
|
||||
Header("Location: account.php?account=" . $account);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -85,259 +87,266 @@ llxHeader();
|
||||
|
||||
if ($account > 0)
|
||||
{
|
||||
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\"> </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 )
|
||||
if ($vline)
|
||||
{
|
||||
$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\"> </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.'&page='.($page+1).'">'.img_previous().'</a>';
|
||||
}
|
||||
$mesg.= ' Page '.($nbpage-$page).'/'.$nbpage.' ';
|
||||
if ($total_lines > $limitsql )
|
||||
{
|
||||
$mesg.= '<a href="account.php?account='.$acct->id.'&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);
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
|
||||
if ($page > 0 && $mode_search == 0)
|
||||
{
|
||||
$limitsql = $nbline - ($page * $viewline);
|
||||
if ($limitsql < $viewline)
|
||||
/*
|
||||
* Affiche tableau des transactions bancaires
|
||||
*
|
||||
*/
|
||||
|
||||
// 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\"> </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"> ';
|
||||
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\"> </td></tr>\n";
|
||||
}
|
||||
$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.'&page='.($page+1).'">'.img_previous().'</a>';
|
||||
}
|
||||
$mesg.= ' Page '.($nbpage-$page).'/'.$nbpage.' ';
|
||||
if ($total_lines > $limitsql )
|
||||
{
|
||||
$mesg.= '<a href="account.php?account='.$acct->id.'&page='.($page-1).'">'.img_next().'</a>';
|
||||
}
|
||||
// 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 ' ';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print_fiche_titre("Journal de trésorerie du compte : " .$acct->label,$mesg);
|
||||
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 '<br>';
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
|
||||
/*
|
||||
* Affiche tableau des transactions bancaires
|
||||
*
|
||||
*/
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3"> </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"> </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
|
||||
if ($user->rights->banque->modifier && $_GET["action"]=='rappro')
|
||||
{
|
||||
$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>';
|
||||
/* Another solution
|
||||
* create temporary table solde type=heap select amount from llx_bank limit 100 ;
|
||||
* select sum(amount) from solde ;
|
||||
*/
|
||||
|
||||
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"> ';
|
||||
print '</td></tr>';
|
||||
$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);
|
||||
|
||||
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\"> </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 ' ';
|
||||
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"> </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> </td>';
|
||||
print '</tr>';
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
|
||||
print "</table>";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$total = _print_lines($db, $result, $sql, $acct);
|
||||
if ($page == 0)
|
||||
{
|
||||
print '<tr class="liste_total"><td align="left" colspan="6">'.$langs->trans("CurrentBalance").'</td>';
|
||||
print '<td align="right" nowrap>'.price($total).'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
if ($_GET["action"] != 'rappro')
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->banque->modifier && $acct->type != 2 && $acct->rappro) // Si non compte cash et rapprochable
|
||||
{
|
||||
print '<a class="tabAction" href="rappro.php?account='.$acct->id.'">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->banque->modifier)
|
||||
{
|
||||
print '<a class="tabAction" href="account.php?action=rappro&account='.$acct->id.'&page='.$page.'">'.$langs->trans("AddBankRecord").'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
if ($_GET["action"] != 'addline')
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->banque->modifier && $acct->type != 2 && $acct->rappro) // Si non compte cash et rapprochable
|
||||
{
|
||||
print '<a class="tabAction" href="rappro.php?account='.$acct->id.'">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->banque->modifier)
|
||||
{
|
||||
print '<a class="tabAction" href="account.php?action=addline&account='.$acct->id.'&page='.$page.'">'.$langs->trans("AddBankRecord").'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorBankAccountNotFound");
|
||||
print $langs->trans("ErrorBankAccountNotFound");
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -22,13 +22,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/bank/annuel.php
|
||||
\ingroup banque
|
||||
\brief Page reporting mensuel Entrées/Sorties d'un compte bancaire
|
||||
\version $Revision$
|
||||
\file htdocs/compta/bank/annuel.php
|
||||
\ingroup banque
|
||||
\brief Page reporting mensuel Entrées/Sorties d'un compte bancaire
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
if (!$user->rights->banque->lire) accessforbidden();
|
||||
|
||||
@ -44,6 +45,13 @@ else
|
||||
$year_end=$year_start+2;
|
||||
}
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
@ -51,17 +59,6 @@ llxHeader();
|
||||
$acct = new Account($db);
|
||||
$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)
|
||||
# plutot que sur llx_paiement + llx_paiementfourn
|
||||
@ -75,16 +72,18 @@ $sql .= " GROUP BY dm";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$encaiss[$row[1]] = $row[0];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dolibarr_print_error($db);
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$encaiss[$row[1]] = $row[0];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
$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);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$decaiss[$row[1]] = -$row[0];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dolibarr_print_error($db);
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$decaiss[$row[1]] = -$row[0];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
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
|
||||
@ -169,7 +179,6 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
|
||||
$nbcol+=2;
|
||||
}
|
||||
print "</tr>\n";
|
||||
print '<td colspan="'.$nbcol.'"> </td>';
|
||||
|
||||
// Solde actuel
|
||||
$balance=0;
|
||||
@ -191,6 +200,7 @@ print "</tr>\n";
|
||||
|
||||
print "</table>";
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
$langs->load("banks");
|
||||
|
||||
@ -103,21 +104,11 @@ $form = new Form($db);
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
$head[$h][0] = 'bankid_fr.php?id='.$account->id;
|
||||
$head[$h][1] = $langs->trans("RIB");
|
||||
$head[$h][2] = 'bankid';
|
||||
$h++;
|
||||
}
|
||||
|
||||
// Onglets
|
||||
$head=bank_prepare_head($account);
|
||||
dolibarr_fiche_head($head, 'bankid', $langs->trans("FinancialAccount"));
|
||||
|
||||
/*
|
||||
@ -186,7 +177,7 @@ $form = new Form($db);
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
print "\n</div>\n";
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require("./bank.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
$user->getrights('compta');
|
||||
|
||||
|
||||
@ -28,11 +28,12 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require("./bank.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
if (!$user->rights->banque->configurer)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_titre($langs->trans("AccountSetup"));
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
$langs->load("banks");
|
||||
|
||||
@ -215,8 +216,11 @@ if ($_GET["action"] == 'create')
|
||||
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>';
|
||||
|
||||
// Comment
|
||||
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
|
||||
print '<tr><td colspan="4"><b>'.$langs->trans("InitialBankBalance").'...</b></td></tr>';
|
||||
@ -254,21 +258,11 @@ else
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = 'fiche.php?id='.$account->id;
|
||||
$head[$h][1] = $langs->trans("AccountCard");
|
||||
$head[$h][2] = 'bankname';
|
||||
$h++;
|
||||
$titre=$langs->trans("FinancialAccount")." : ".$account->label;
|
||||
print_fiche_titre($titre,$mesg);
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
// Onglets
|
||||
$head=bank_prepare_head($account);
|
||||
dolibarr_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"));
|
||||
|
||||
/*
|
||||
@ -433,13 +427,16 @@ else
|
||||
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>';
|
||||
|
||||
// Web
|
||||
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></tr>';
|
||||
|
||||
// Comment
|
||||
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 ' <input name="cancel" value="'.$langs->trans("Cancel").'" type="submit" class="button">';
|
||||
|
||||
@ -26,18 +26,19 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
if (!$user->rights->banque->lire)
|
||||
accessforbidden();
|
||||
|
||||
$account = $_GET["account"];
|
||||
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
$account = $_GET["id"];
|
||||
|
||||
if ($account > 0)
|
||||
{
|
||||
|
||||
$datetime = time();
|
||||
$month = strftime("%m", $datetime);
|
||||
$year = strftime("%Y", $datetime);
|
||||
@ -45,23 +46,28 @@ if ($account > 0)
|
||||
$acct = new Account($db);
|
||||
$acct->fetch($account);
|
||||
|
||||
print_fiche_titre("Journal de trésorerie du compte: " .$acct->getNomUrl(0),$mesg);
|
||||
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
|
||||
$titre=$langs->trans("FinancialAccount")." : ".$acct->label;
|
||||
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>';
|
||||
$file = "solde.$account.$year.png";
|
||||
|
||||
/* Bug
|
||||
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 '<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
|
||||
}
|
||||
*/
|
||||
if (! file_exists($conf->banque->dir_images."/".$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 '<br>';
|
||||
}
|
||||
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 '</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 '</td></tr></table>';
|
||||
print '</td></tr></table>';
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -27,10 +27,8 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
require("./bank.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
require("../../tva.class.php");
|
||||
require("../../chargesociales.class.php");
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -19,13 +19,12 @@
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/bank/pre.inc.php
|
||||
\ingroup compta
|
||||
\brief Fichier gestionnaire du menu compta banque
|
||||
\file htdocs/compta/bank/pre.inc.php
|
||||
\ingroup compta
|
||||
\brief Fichier gestionnaire du menu compta banque
|
||||
*/
|
||||
|
||||
require_once("../../main.inc.php");
|
||||
@ -57,9 +56,10 @@ function llxHeader($head = "")
|
||||
while ($i < $numr)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$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(DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid, $objp->label);
|
||||
$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++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
$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();
|
||||
|
||||
|
||||
@ -58,294 +71,295 @@ $acct->fetch($_GET["account"]);
|
||||
|
||||
if (! isset($_GET["num"]))
|
||||
{
|
||||
/*
|
||||
* Vue liste tous relevés confondus
|
||||
*
|
||||
*/
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
/*
|
||||
* Vue liste tous relevés confondus
|
||||
*/
|
||||
$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($conf->liste_limit+1,$offset);
|
||||
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
$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","&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))
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
if (! isset($objp->numr))
|
||||
{
|
||||
//
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr $bc[$var]><td><a href=\"releve.php?num=$objp->numr&account=".$_GET["account"]."\">$objp->numr</a></td></tr>\n";
|
||||
}
|
||||
$i++;
|
||||
$var=True;
|
||||
$numrows = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
$titre=$langs->trans("FinancialAccount")." : ".$acct->label;
|
||||
print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], "&account=".$_GET["account"], $sortfield, $sortorder,'',$numrows);
|
||||
|
||||
// Onglets
|
||||
$head=bank_prepare_head($acct);
|
||||
dolibarr_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0);
|
||||
|
||||
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&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
|
||||
{
|
||||
/**
|
||||
* Affiche liste ecritures d'un releve
|
||||
*/
|
||||
if ($_GET["rel"] == 'prev')
|
||||
{
|
||||
// Recherche valeur pour num = numéro relevé précédent
|
||||
$sql = "SELECT distinct(num_releve) as num";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " WHERE num_releve < ".$_GET["num"]." AND fk_account = ".$_GET["account"];
|
||||
$sql.= " ORDER BY num_releve DESC";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$var=True;
|
||||
$numrows = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if ($numrows > 0)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$num = $obj->num;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($_GET["rel"] == 'next')
|
||||
{
|
||||
// Recherche valeur pour num = numéro relevé précédent
|
||||
$sql = "SELECT distinct(num_releve) as num";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " WHERE num_releve > ".$_GET["num"]." AND fk_account = ".$_GET["account"];
|
||||
$sql.= " ORDER BY num_releve ASC";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$var=True;
|
||||
$numrows = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if ($numrows > 0)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$num = $obj->num;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// On veut le relevé num
|
||||
$num=$_GET["num"];
|
||||
}
|
||||
$ve=$_GET["ve"];
|
||||
|
||||
$mesprevnext ="<a href=\"releve.php?rel=prev&num=$num&ve=$ve&account=$acct->id\">".img_previous()."</a> ";
|
||||
$mesprevnext.= $langs->trans("AccountStatement")." $num";
|
||||
$mesprevnext.=" <a href=\"releve.php?rel=next&num=$num&ve=$ve&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\">";
|
||||
/**
|
||||
* Affiche liste ecritures d'un releve
|
||||
*/
|
||||
if ($_GET["rel"] == 'prev')
|
||||
{
|
||||
// Recherche valeur pour num = numéro relevé précédent
|
||||
$sql = "SELECT distinct(num_releve) as num";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " WHERE num_releve < ".$_GET["num"]." AND fk_account = ".$_GET["account"];
|
||||
$sql.= " ORDER BY num_releve DESC";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$var=True;
|
||||
$numrows = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if ($numrows > 0)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$num = $obj->num;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($_GET["rel"] == 'next')
|
||||
{
|
||||
// Recherche valeur pour num = numéro relevé précédent
|
||||
$sql = "SELECT distinct(num_releve) as num";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " WHERE num_releve > ".$_GET["num"]." AND fk_account = ".$_GET["account"];
|
||||
$sql.= " ORDER BY num_releve ASC";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$var=True;
|
||||
$numrows = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if ($numrows > 0)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$num = $obj->num;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// On veut le relevé num
|
||||
$num=$_GET["num"];
|
||||
}
|
||||
$ve=$_GET["ve"];
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="center">'.$langs->trans("DateOperationShort").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateValueShort").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
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> </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);
|
||||
$mesprevnext ="<a href=\"releve.php?rel=prev&num=$num&ve=$ve&account=$acct->id\">".img_previous()."</a> ";
|
||||
$mesprevnext.= $langs->trans("AccountStatement")." $num";
|
||||
$mesprevnext.=" <a href=\"releve.php?rel=next&num=$num&ve=$ve&account=$acct->id\">".img_next()."</a>";
|
||||
print_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$acct->getNomUrl(0),$mesprevnext);
|
||||
print '<br>';
|
||||
|
||||
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&ve=1&rel=$rel&account=".$acct->id."\"> </a></td>";
|
||||
print "<td align=\"right\" colspan=\"2\"><b>".$langs->trans("InitialBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td> </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&num='.$num.'&account='.$_GET["account"].'&dvid='.$objp->rowid.'">';
|
||||
print img_previous().'</a> ';
|
||||
print dolibarr_print_date($objp->dv,"%d/%m/%Y") .' ';
|
||||
print '<a href="releve.php?action=dvnext&num='.$num.'&account='.$_GET["account"].'&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.'&account='.$acct->id.'">';
|
||||
print "<form method=\"post\" action=\"releve.php\">";
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="center">'.$langs->trans("DateOperationShort").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateValueShort").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
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> </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)
|
||||
{
|
||||
$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&ve=1&rel=$rel&account=".$acct->id."\"> </a></td>";
|
||||
print "<td align=\"right\" colspan=\"2\"><b>".$langs->trans("InitialBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td> </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&num='.$num.'&account='.$_GET["account"].'&dvid='.$objp->rowid.'">';
|
||||
print img_previous().'</a> ';
|
||||
print dolibarr_print_date($objp->dv,"%d/%m/%Y") .' ';
|
||||
print '<a href="releve.php?action=dvnext&num='.$num.'&account='.$_GET["account"].'&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.'&account='.$acct->id.'">';
|
||||
$reg=array();
|
||||
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]);
|
||||
else print $objp->label;
|
||||
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>- <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> </td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$totalc = $totalc + abs($objp->amount);
|
||||
print "<td> </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&account=".$acct->id."\">";
|
||||
print img_edit();
|
||||
print "</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td align=\"center\"> </td>";
|
||||
}
|
||||
print "</tr>";
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
print '</a>';
|
||||
|
||||
// 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> </td><td> </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
|
||||
print "<tr><td align=\"right\" colspan=\"4\"> </td><td align=\"right\" colspan=\"2\"><b>".$langs->trans("EndBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td> </td></tr>\n";
|
||||
print "</table></form>\n";
|
||||
// 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>- <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> </td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$totalc = $totalc + abs($objp->amount);
|
||||
print "<td> </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&account=".$acct->id."\">";
|
||||
print img_edit();
|
||||
print "</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td align=\"center\"> </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> </td><td> </td></tr>";
|
||||
|
||||
// Ligne Solde
|
||||
print "<tr><td align=\"right\" colspan=\"4\"> </td><td align=\"right\" colspan=\"2\"><b>".$langs->trans("EndBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td> </td></tr>\n";
|
||||
print "</table></form>\n";
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require("./bank.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
$user->getrights('banque');
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require("./bank.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
|
||||
$user->getrights('banque');
|
||||
|
||||
|
||||
@ -85,4 +85,5 @@ ConciliatedBy=Conciliated by
|
||||
DateConciliating=Conciliate date
|
||||
BankLineConciliated=Transaction conciliated
|
||||
CustomerInvoicePayment=Customer payment
|
||||
SupplierInvoicePayment=Supplier payment
|
||||
SupplierInvoicePayment=Supplier payment
|
||||
FinancialAccountJournal=Financial account journal
|
||||
@ -85,4 +85,5 @@ ConciliatedBy=Rapproch
|
||||
DateConciliating=Date rapprochement
|
||||
BankLineConciliated=Ecriture rapprochée
|
||||
CustomerInvoicePayment=Règlement client
|
||||
SupplierInvoicePayment=Règlement fournisseur
|
||||
SupplierInvoicePayment=Règlement fournisseur
|
||||
FinancialAccountJournal=Journal de trésorerie du compte
|
||||
@ -234,10 +234,11 @@ function dolibarr_syslog($message, $level=LOG_INFO)
|
||||
\param links Tableau de titre d'onglets
|
||||
\param active 0=onglet non actif, 1=onglet actif
|
||||
\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
|
||||
if ($title)
|
||||
@ -275,7 +276,7 @@ function dolibarr_fiche_head($links, $active='0', $title='')
|
||||
|
||||
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 page numéro de la page
|
||||
\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 sortorder ordre de tri ('' 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)
|
||||
{
|
||||
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>';
|
||||
}
|
||||
else
|
||||
|
||||
@ -31,7 +31,7 @@ require("../../conf/conf.php");
|
||||
header('Content-type: text/css');
|
||||
// Important: Avoid page request by browser and dynamic build at
|
||||
// each Dolibarr page access.
|
||||
header('Cache-Control: max-age=3600, must-revalidate');
|
||||
header('Cache-Control: max-age=3600, public, must-revalidate');
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@ -21,17 +21,17 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file scripts/banque/graph-solde.php
|
||||
\ingroup banque
|
||||
\brief Script de génération des images des soldes des comptes
|
||||
\file scripts/banque/graph-solde.php
|
||||
\ingroup banque
|
||||
\brief Script de génération des images des soldes des comptes
|
||||
*/
|
||||
|
||||
|
||||
// Test si mode batch
|
||||
$sapi_type = php_sapi_name();
|
||||
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";
|
||||
exit;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -43,9 +43,9 @@ require_once($path."../../htdocs/master.inc.php");
|
||||
// Vérifie que chemin vers JPGRAHP est connu et defini $jpgraph
|
||||
if (! $conf->global->JPGRAPH_DIR && ! defined('JPGRAPH_PATH'))
|
||||
{
|
||||
print 'Erreur: Définissez la constante JPGRAPH_PATH sur la valeur du répertoire contenant JPGraph';
|
||||
exit;
|
||||
}
|
||||
print 'Erreur: Définissez la constante JPGRAPH_PATH sur la valeur du répertoire contenant JPGraph';
|
||||
exit;
|
||||
}
|
||||
if (! $conf->global->JPGRAPH_DIR) $conf->global->JPGRAPH_DIR=JPGRAPH_PATH;
|
||||
$jpgraphdir=$conf->global->JPGRAPH_DIR;
|
||||
if (! eregi('[\\\/]$',$jpgraphdir)) $jpgraphdir.='/';
|
||||
@ -56,7 +56,7 @@ if (! file_exists($jpgraphdir."jpgraph.php"))
|
||||
print 'Vérifier la variable JPGRAPH_PATH';
|
||||
if ($conf->global->JPGRAPH_DIR) print ' ('.$conf->global->JPGRAPH_DIR.')'."\n";
|
||||
elseif (defined('JPGRAPH_PATH')) print ' ('.JPGRAPH_PATH.')'."\n";
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once($jpgraphdir."jpgraph.php");
|
||||
@ -71,18 +71,18 @@ $error = 0;
|
||||
// Initialise opt, tableau des parametres
|
||||
if (function_exists("getopt"))
|
||||
{
|
||||
// getopt existe sur ce PHP
|
||||
$opt = getopt("m:y:");
|
||||
// getopt existe sur ce PHP
|
||||
$opt = getopt("m:y:");
|
||||
}
|
||||
else
|
||||
{
|
||||
// getopt n'existe sur ce PHP
|
||||
$opt=array('m'=>$argv[1]);
|
||||
}
|
||||
// getopt n'existe sur ce PHP
|
||||
$opt=array('m'=>$argv[1]);
|
||||
}
|
||||
|
||||
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
|
||||
@ -93,33 +93,33 @@ $datetime = time();
|
||||
|
||||
if ($opt['m'] > 0)
|
||||
{
|
||||
$month = $opt['m'];
|
||||
$month = $opt['m'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$month = strftime("%m", $datetime);
|
||||
$month = strftime("%m", $datetime);
|
||||
}
|
||||
$year = strftime("%Y", $datetime);
|
||||
|
||||
if ($month == 1)
|
||||
{
|
||||
$monthprev = "12";
|
||||
$yearprev = $year - 1;
|
||||
$monthprev = "12";
|
||||
$yearprev = $year - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$monthprev = substr("00".($month - 1), -2) ;
|
||||
$yearprev = $year ;
|
||||
$monthprev = substr("00".($month - 1), -2) ;
|
||||
$yearprev = $year ;
|
||||
}
|
||||
|
||||
if ($month == 12)
|
||||
{
|
||||
$monthnext = "01";
|
||||
$yearnext = $year + 1;
|
||||
$monthnext = "01";
|
||||
$yearnext = $year + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$monthnext = substr("00".($month + 1), -2) ;
|
||||
$monthnext = substr("00".($month + 1), -2) ;
|
||||
}
|
||||
|
||||
$sql = "SELECT distinct(fk_account)";
|
||||
@ -132,442 +132,442 @@ $accounts = array();
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
array_push($accounts, $row[0]);
|
||||
$i++;
|
||||
}
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
array_push($accounts, $row[0]);
|
||||
$i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$account = 1;
|
||||
|
||||
$account = 1;
|
||||
|
||||
foreach ($accounts as $account)
|
||||
{
|
||||
$labels = array();
|
||||
$datas = 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 ;
|
||||
}
|
||||
$labels = array();
|
||||
$datas = array();
|
||||
$amounts = array();
|
||||
|
||||
$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)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$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)
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$amounts[$row[0]] = $row[1];
|
||||
$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;
|
||||
$row = $db->fetch_row($resql);
|
||||
$solde = $row[0];
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$datas[$i] = $solde + $subtotal;
|
||||
print $sql ;
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
$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%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);
|
||||
$amounts[$row[0]] = $row[1];
|
||||
$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
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$labels = array();
|
||||
$datas = 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 ;
|
||||
}
|
||||
$labels = array();
|
||||
$datas = array();
|
||||
$amounts = array();
|
||||
|
||||
$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');";
|
||||
$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);
|
||||
|
||||
$amounts = array();
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$amounts[$row[0]] = $row[1];
|
||||
$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
|
||||
$row = $db->fetch_row($resql);
|
||||
$solde = $row[0];
|
||||
}
|
||||
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();
|
||||
//$graph->xaxis->HideTicks();
|
||||
$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
|
||||
{
|
||||
$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->Add($b2plot);
|
||||
$graph->img->SetImgFormat("png");
|
||||
|
||||
$file= $conf->banque->dir_images."/solde.$account.$year.png";
|
||||
|
||||
$graph->Stroke($file);
|
||||
//$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.png";
|
||||
|
||||
$graph->Stroke($file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Graph annuels
|
||||
*
|
||||
*/
|
||||
* Graph annuels
|
||||
*
|
||||
*/
|
||||
foreach ($accounts as $account)
|
||||
{
|
||||
$labels = array();
|
||||
$datas = array();
|
||||
$amounts = array();
|
||||
|
||||
$sql = "SELECT min(".$db->pdate("datev")."),max(".$db->pdate("datev").")";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql .= " WHERE fk_account = ".$account;
|
||||
$labels = array();
|
||||
$datas = array();
|
||||
$amounts = array();
|
||||
|
||||
$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)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$row = $db->fetch_row($resql);
|
||||
$min = $row[0];
|
||||
$max = $row[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("graph-solde.php Error");
|
||||
}
|
||||
$resql = $db->query($sql);
|
||||
|
||||
|
||||
$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)
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$amounts[$row[0]] = $row[1];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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)];
|
||||
$num = $db->num_rows($resql);
|
||||
$row = $db->fetch_row($resql);
|
||||
$min = $row[0];
|
||||
$max = $row[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("graph-solde.php Error");
|
||||
}
|
||||
|
||||
$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;
|
||||
$i++;
|
||||
}
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if (sizeof($amounts) > 3)
|
||||
{
|
||||
$width = 750;
|
||||
$height = 350;
|
||||
$amounts = array();
|
||||
|
||||
$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);
|
||||
}
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$amounts[$row[0]] = $row[1];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
|
||||
$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)
|
||||
{
|
||||
$labels = array();
|
||||
$datas = array();
|
||||
$amounts = array();
|
||||
$credits = array();
|
||||
$debits = array();
|
||||
$labels = array();
|
||||
$datas = array();
|
||||
$amounts = array();
|
||||
$credits = array();
|
||||
$debits = array();
|
||||
|
||||
$sql = "SELECT date_format(datev,'%m'), sum(amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql .= " WHERE fk_account = ".$account;
|
||||
$sql .= " AND date_format(datev,'%Y') = '".$year."'";
|
||||
$sql .= " AND amount > 0";
|
||||
$sql .= " GROUP BY date_format(datev,'%m');";
|
||||
$sql = "SELECT date_format(datev,'%m'), sum(amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql .= " WHERE fk_account = ".$account;
|
||||
$sql .= " AND date_format(datev,'%Y') = '".$year."'";
|
||||
$sql .= " AND amount > 0";
|
||||
$sql .= " GROUP BY date_format(datev,'%m');";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
$amounts = array();
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
$resql = $db->query($sql);
|
||||
|
||||
$amounts = array();
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$credits[$row[0]] = $row[1];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $sql ;
|
||||
}
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$sql = "SELECT date_format(datev,'%m'), sum(amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql .= " WHERE fk_account = ".$account;
|
||||
$sql .= " AND date_format(datev,'%Y') = '".$year."'";
|
||||
$sql .= " AND amount < 0";
|
||||
$sql .= " GROUP BY date_format(datev,'%m');";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($row = $db->fetch_row($resql))
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$credits[$row[0]] = $row[1];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$debits[$row[0]] = abs($row[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $sql ;
|
||||
}
|
||||
print $sql ;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
$sql = "SELECT date_format(datev,'%m'), sum(amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql .= " WHERE fk_account = ".$account;
|
||||
$sql .= " AND date_format(datev,'%Y') = '".$year."'";
|
||||
$sql .= " AND amount < 0";
|
||||
$sql .= " GROUP BY date_format(datev,'%m');";
|
||||
|
||||
$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);
|
||||
|
||||
$bsplot = new BarPlot($data_debit);
|
||||
$bsplot->SetColor("red");
|
||||
|
||||
$beplot = new BarPlot($data_credit);
|
||||
$beplot->SetColor("green");
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($row = $db->fetch_row($resql))
|
||||
{
|
||||
$debits[$row[0]] = abs($row[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $sql ;
|
||||
}
|
||||
|
||||
$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");
|
||||
|
||||
$graph->xaxis->SetTickLabels($labels);
|
||||
|
||||
$graph->Add($bg);
|
||||
$graph->img->SetImgFormat("png");
|
||||
|
||||
$file= DOL_DATA_ROOT."/graph/banque/mouvement.$account.$year.png";
|
||||
|
||||
$graph->Stroke($file);
|
||||
$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);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user