Qual: Remove duplciate code

New: Add navigation on bank transaction list
This commit is contained in:
Laurent Destailleur 2009-01-02 15:12:13 +00:00
parent 28214bc8b9
commit deda7a9ccd
8 changed files with 591 additions and 264 deletions

View File

@ -0,0 +1,378 @@
<?php
/* Copyright (C) 2008 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
* 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.
*/
/**
* \file compta/bank/bankcateg.class.php
* \ingroup banque
* \brief This file is CRUD class file (Create/Read/Update/Delete) for bank categories
* \version $Id$
* \author Laurent Destailleur
* \remarks Initialy built by build_class_from_table on 2009-01-02 15:26
*/
// Put here all includes required by your class file
//require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
//require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
//require_once(DOL_DOCUMENT_ROOT."/product.class.php");
/**
* \class Bank_categ
* \brief Put here description of your class
* \remarks Initialy built by build_class_from_table on 2009-01-02 15:26
*/
class BankCateg // extends CommonObject
{
var $db; //!< To store db handler
var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages)
//var $element='bank_categ'; //!< Id that identify managed objects
//var $table_element='bank_categ'; //!< Name of table without prefix where object is stored
var $id;
var $label;
/**
* \brief Constructor
* \param DB Database handler
*/
function BankCateg($DB)
{
$this->db = $DB;
return 1;
}
/**
* \brief Create in database
* \param user User that create
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, Id of created object if OK
*/
function create($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->label)) $this->label=trim($this->label);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ(";
$sql.= "label";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->label)?'NULL':"'".addslashes($this->label)."'")."";
$sql.= ")";
$this->db->begin();
dolibarr_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_categ");
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dolibarr_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return $this->id;
}
}
/**
* \brief Load object in memory from database
* \param id id object
* \return int <0 if KO, >0 if OK
*/
function fetch($id)
{
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.label";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as t";
$sql.= " WHERE t.rowid = ".$id;
dolibarr_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->label = $obj->label;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1;
}
}
/**
* \brief Update database
* \param user User that modify
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->label)) $this->label=trim($this->label);
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ SET";
$sql.= " label=".(isset($this->label)?"'".addslashes($this->label)."'":"null")."";
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dolibarr_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dolibarr_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* \brief Delete object in database
* \param user User that delete
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ";
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dolibarr_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dolibarr_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* \brief Load an object from its id and create a new one in database
* \param fromid Id of object to clone
* \return int New id of clone
*/
function createFromClone($fromid)
{
global $user,$langs;
$error=0;
$object=new Bank_categ($this->db);
$this->db->begin();
// Load source object
$object->fetch($fromid);
$object->id=0;
$object->statut=0;
// Clear fields
// ...
// Create clone
$result=$object->create($user);
// Other options
if ($result < 0)
{
$this->error=$object->error;
$error++;
}
if (! $error)
{
}
// End
if (! $error)
{
$this->db->commit();
return $object->id;
}
else
{
$this->db->rollback();
return -1;
}
}
/**
* \brief Initialise object with example values
* \remarks id must be 0 if object instance is a specimen.
*/
function initAsSpecimen()
{
$this->id=0;
$this->label='';
}
}
?>

View File

@ -38,134 +38,58 @@ if (!$user->rights->banque->lire)
*
*/
$companystatic=new Societe($db);
llxHeader();
if ($_GET["bid"] == 0)
// List movements bu category for bank transactions
print_fiche_titre($langs->trans("BankTransactionByCategories"));
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td>'.$langs->trans("Rubrique").'</td>';
print '<td align="right">'.$langs->trans("Nb").'</td>';
print '<td align="right">'.$langs->trans("Total").'</td>';
print '<td align="right">'.$langs->trans("Average").'</td>';
print "</tr>\n";
$sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid ";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c, ".MAIN_DB_PREFIX."bank_class as l, ".MAIN_DB_PREFIX."bank as d";
$sql .= " WHERE d.rowid=l.lineid AND c.rowid = l.fk_categ GROUP BY c.label, c.rowid ORDER BY c.label";
$result = $db->query($sql);
if ($result)
{
/*
* Liste mouvements par catégories d'écritures financières
*/
print_fiche_titre($langs->trans("BankTransactionByCategories"));
$num = $db->num_rows($result);
$i = 0; $total = 0;
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("Nb").'</td>';
print '<td align="right">'.$langs->trans("Total").'</td>';
print '<td align="right">'.$langs->trans("Average").'</td>';
print "</tr>\n";
$sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid ";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c, ".MAIN_DB_PREFIX."bank_class as l, ".MAIN_DB_PREFIX."bank as d";
$sql .= " WHERE d.rowid=l.lineid AND c.rowid = l.fk_categ GROUP BY c.label, c.rowid ORDER BY c.label";
$result = $db->query($sql);
if ($result)
$var=true;
while ($i < $num)
{
$num = $db->num_rows($result);
$i = 0; $total = 0;
$var=true;
while ($i < $num)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td><a href=\"budget.php?bid=$objp->rowid\">$objp->label</a></td>";
print '<td align="right">'.$objp->nombre.'</td>';
print '<td align="right">'.price(abs($objp->somme))."</td>";
print '<td align="right">'.price(abs($objp->somme / $objp->nombre))."</td>";
print "</tr>";
$i++;
$total = $total + abs($objp->somme);
}
$db->free($result);
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").'</td>';
print '<td align="right"><b>'.price($total).'</b></td><td colspan="2">&nbsp;</td></tr>';
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td><a href=\"".DOL_URL_ROOT."/compta/bank/search.php?bid=$objp->rowid\">$objp->label</a></td>";
print '<td align="right">'.$objp->nombre.'</td>';
print '<td align="right">'.price(abs($objp->somme))."</td>";
print '<td align="right">'.price(abs(price2num($objp->somme / $objp->nombre,'MT')))."</td>";
print "</tr>";
$i++;
$total = $total + abs($objp->somme);
}
else
{
dolibarr_print_error($db);
}
print "</table>";
$db->free($result);
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").'</td>';
print '<td align="right"><b>'.price($total).'</b></td><td colspan="2">&nbsp;</td></tr>';
}
else
{
/*
* Rapport mouvements pour une catégorie donnée
*/
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."bank_categ WHERE rowid=".$_GET["bid"];
$resql=$db->query($sql);
if ($resql)
{
if ($db->num_rows($resql))
{
$obj=$db->fetch_object($resql);
$budget_name = $obj->label;
}
$db->free($resql);
}
print_fiche_titre($langs->trans("BankTransactionForCategory",$budget_name));
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td align="left">'.$langs->trans("Date").'</td>';
print '<td align="left">'.$langs->trans("Bank").'</td>';
print '<td width="60%">'.$langs->trans("Description").'</td><td align="right">'.$langs->trans("Amount").'</td><td>&nbsp;</td>';
print "</tr>\n";
$sql = "SELECT b.amount, b.label, ".$db->pdate("b.dateo")." as do, b.rowid, ba.label as labelcompte, ba.rowid as bankid";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_class as l, ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.rowid=l.lineid AND l.fk_categ=".$_GET["bid"];
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " ORDER BY b.dateo DESC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0; $total = 0;
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print "<td align=\"left\">".dolibarr_print_date($objp->do,'day')."</td>\n";
print "<td><a href=\"account.php?account=$objp->bankid\">$objp->labelcompte</a></td>";
// Description
print "<td><a href=\"ligne.php?rowid=$objp->rowid\">".img_object($langs->trans("ShowPayment"),"payment").' ';
$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 dolibarr_trunc($objp->label,60);
print '</a></td>';
// Montant
print "<td align=\"right\">".price(0 - $objp->amount)."</td><td>&nbsp;</td>";
print "</tr>";
$i++;
$total = $total + (0 - $objp->amount);
}
$db->free();
print '<tr class="liste_total"><td colspan="3" align="right">'.$langs->trans("Total")."</td><td align=\"right\"><b>".price(abs($total))."</b></td><td>".$langs->trans("Currency".$conf->monnaie)."</td></tr>";
}
else
{
dolibarr_print_error($db);
}
print "</table>";
dolibarr_print_error($db);
}
print "</table>";
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -67,8 +67,8 @@ function llxHeader($head = "")
$menu->add_submenu(DOL_URL_ROOT."/compta/bank/fiche.php?action=create",$langs->trans("MenuNewFinancialAccount"),1,$user->rights->banque->configurer);
$menu->add_submenu(DOL_URL_ROOT."/compta/bank/categ.php",$langs->trans("Rubriques"),1,$user->rights->banque->configurer);
$menu->add_submenu(DOL_URL_ROOT."/compta/bank/search.php",$langs->trans("SearchTransaction"),1,$user->rights->banque->lire);
$menu->add_submenu(DOL_URL_ROOT."/compta/bank/budget.php",$langs->trans("ByRubriques"),1,$user->rights->banque->lire);
$menu->add_submenu(DOL_URL_ROOT."/compta/bank/search.php",$langs->trans("ListTransactions"),1,$user->rights->banque->lire);
$menu->add_submenu(DOL_URL_ROOT."/compta/bank/budget.php",$langs->trans("ListTransactionsByCategory"),1,$user->rights->banque->lire);
if ($user->rights->banque->transfer)
{

View File

@ -18,29 +18,51 @@
*/
/**
\file htdocs/compta/bank/search.php
\ingroup banque
\brief Page de recherche de transactions bancaires
\version $Id$
*/
* \file htdocs/compta/bank/search.php
* \ingroup banque
* \brief List of bank transactions
* \version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/bank/bankcateg.class.php");
if (!$user->rights->banque->lire)
accessforbidden();
accessforbidden();
$description=$_POST["description"];
$debit=$_POST["debit"];
$credit=$_POST["credit"];
$type=$_POST["type"];
$account=$_POST["account"];
$description=$_REQUEST["description"];
$debit=$_REQUEST["debit"];
$credit=$_REQUEST["credit"];
$type=$_REQUEST["type"];
$account=$_REQUEST["account"];
$param='';
if (! empty($_REQUEST["description"])) $param.='&description='.$_REQUEST["description"];
if (! empty($_REQUEST["type"])) $param.='&type='.$_REQUEST["type"];
if (! empty($_REQUEST["debit"])) $param.='&debit='.$_REQUEST["debit"];
if (! empty($_REQUEST["credit"])) $param.='&credit='.$_REQUEST["credit"];
if (! empty($_REQUEST["account"])) $param.='&account='.$_REQUEST["account"];
if (! empty($_REQUEST["bid"])) $param.='&bid='.$_REQUEST["bid"];
$page =$_GET['page'];
$sortorder=$_GET['sortorder'];
$sortfield=$_GET['sortfield'];
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if (! $sortorder) $sortorder='DESC';
if (! $sortfield) $sortfield='b.dateo';
/*
* View
*/
$companystatic=new Societe($db);
$bankaccountstatic=new Account($db);
llxHeader();
$html = new Form($db);
@ -48,161 +70,159 @@ $html = new Form($db);
if ($vline) $viewline = $vline;
else $viewline = 50;
print_fiche_titre($langs->trans("SearchBankMovement"));
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print '<td class="liste_titre" align="left">'.$langs->trans("Date").'</td>';
print '<td class="liste_titre">'.$langs->trans("Description").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("Debit").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("Credit").'</td>';
print '<td class="liste_titre" align="center">'.$langs->trans("Type").'</td>';
print '<td class="liste_titre" align="left">'.$langs->trans("Account").'</td>';
print "</tr>\n";
print '<form method="post" action="search.php">';
print '<tr class="liste_titre">';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="description" size="40" value="'.$description.'">';
print '</td>';
print '<td class="liste_titre" align="right">';
print '<input type="text" class="flat" name="debit" size="6" value="'.$debit.'">';
print '</td>';
print '<td class="liste_titre" align="right">';
print '<input type="text" class="flat" name="credit" size="6" value="'.$credit.'">';
print '</td>';
print '<td class="liste_titre" align="center">';
$html->select_types_paiements(empty($_POST['type'])?'':$_POST['type'],'type','',0,0,1);
print '</td>';
print '<td class="liste_titre" align="right">';
print '<input type="hidden" name="action" value="search">';
print '<input type="image" class="liste_titre" name="submit" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
print '</td>';
print '</tr>';
// Compte le nombre total d'écritures
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."bank";
if ($account) { $sql .= " WHERE b.fk_account=".$account; }
$resql=$db->query($sql);
if ($resql)
$sql = "SELECT b.rowid, b.dateo as do, b.amount, b.label, b.rappro, b.num_releve, b.num_chq,";
$sql.= " b.fk_account, b.fk_type,";
$sql.= " ba.rowid as bankid, ba.label as bankref,";
$sql.= " bu.label as labelurl, bu.url_id";
$sql.= " FROM (";
if (! empty($_REQUEST["bid"])) $sql.= MAIN_DB_PREFIX."bank_class as l, ";
$sql.= MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu on (bu.fk_bank = b.rowid AND type ='company')";
$sql.= " WHERE b.fk_account=ba.rowid";
if (! empty($_REQUEST["bid"]))
{
$obj = $db->fetch_object($resql);
$nbline = $obj->nb;
$db->free($resql);
$sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$_REQUEST["bid"];
}
else
if(! empty($type))
{
dolibarr_print_error($db);
$sql .= " AND b.fk_type = '" . $type ."' ";
}
// Defini la liste des catégories dans $options
$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"; $i++;
}
$db->free($result);
}
else {
dolibarr_print_error($db);
}
$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_account, b.fk_type, ba.label as labelaccount, p.libelle as payment_type ";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba, ".MAIN_DB_PREFIX."c_paiement as p ";
$sql .= " WHERE b.fk_account=ba.rowid AND p.code = b.fk_type ";
if(!empty($type))
{
$sql .= " AND p.id = " . $type ." ";
}
// Search criteria amount
$si=0;
$debit = price2num(str_replace('-','',$debit));
$credit = price2num(str_replace('-','',$credit));
if (is_numeric($debit)) {
$si++;
$sqlw[$si] .= " b.amount = -" . $debit;
$si++;
$sqlw[$si] .= " b.amount = -" . $debit;
}
if (is_numeric($credit)) {
$si++;
$sqlw[$si] .= " b.amount = " . $credit;
$si++;
$sqlw[$si] .= " b.amount = " . $credit;
}
// Search criteria description
if ($description) {
$si++;
$sqlw[$si] .= " b.label like '%" . $description . "%'";
$si++;
$sqlw[$si] .= " b.label like '%" . $description . "%'";
}
// Other search criteria
for ($i = 1 ; $i <= $si; $i++) {
$sql .= " AND " . $sqlw[$i];
$sql .= " AND " . $sqlw[$i];
}
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit+1,$offset);
$sql .= " ORDER BY b.dateo ASC";
$result = $db->query($sql);
if ($result)
$resql = $db->query($sql);
if ($resql)
{
$var=True;
$num = $db->num_rows($result);
$i = 0;
while ($i < $num) {
$objp = $db->fetch_object($result);
$var=True;
$num = $db->num_rows($resql);
$i = 0;
$var=!$var;
// Title
$bankcateg=new BankCateg($db);
if (! empty($_REQUEST["bid"]))
{
$result=$bankcateg->fetch($_REQUEST["bid"]);
print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->nom:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
}
else
{
print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
}
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('DateOperation'),$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="left"',$sortfield,$sortorder);
print '<td class="liste_titre">'.$langs->trans("Description").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("Debit").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("Credit").'</td>';
print '<td class="liste_titre" align="center">'.$langs->trans("Type").'</td>';
print '<td class="liste_titre" align="left">'.$langs->trans("Account").'</td>';
print "</tr>\n";
print '<form method="post" action="search.php">';
print '<tr class="liste_titre">';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="description" size="40" value="'.$description.'">';
print '</td>';
print '<td class="liste_titre" align="right">';
print '<input type="text" class="flat" name="debit" size="6" value="'.$debit.'">';
print '</td>';
print '<td class="liste_titre" align="right">';
print '<input type="text" class="flat" name="credit" size="6" value="'.$credit.'">';
print '</td>';
print '<td class="liste_titre" align="center">';
$html->select_types_paiements(empty($_REQUEST["type"])?'':$_REQUEST["type"], 'type', '', 2, 0, 1);
print '</td>';
print '<td class="liste_titre" align="right">';
print '<input type="hidden" name="action" value="search">';
if (! empty($_REQUEST['bid'])) print '<input type="hidden" name="bid" value="'.$_REQUEST["bid"].'">';
print '<input type="image" class="liste_titre" name="submit" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
print '</td>';
print '</tr>';
// Loop on each record
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
print "<tr $bc[$var]>";
print '<td align="left">'.dolibarr_print_date($objp->do,"day")."</td>\n";
print "<td><a href=\"ligne.php?rowid=$objp->rowid&amp;account=$objp->fk_account\">";
$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>&nbsp;";
if ($objp->amount < 0)
{
print "<td align=\"right\">".price($objp->amount * -1)."</td><td>&nbsp;</td>\n";
}
else
{
print "<td>&nbsp;</td><td align=\"right\">".price($objp->amount)."</td>\n";
}
print "<td align=\"center\">".$objp->payment_type."</td>\n";
$var=!$var;
print "<td align=\"left\"><small>".$objp->labelaccount."</small></td>\n";
print "</tr>";
$i++;
}
print "<tr $bc[$var]>";
$db->free($result);
// Ref
print '<td align="left" nowrap="nowrap">';
print "<a href=\"ligne.php?rowid=".$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid."</a> &nbsp; ";
print '</td>';
// Date
print '<td align="left" nowrap="nowrap">'.dolibarr_print_date($db->jdate($objp->do),"day")." &nbsp; </td>\n";
print "<td><a href=\"ligne.php?rowid=$objp->rowid&amp;account=$objp->fk_account\">";
$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 dolibarr_trunc($objp->label,40);
print "</a>&nbsp;";
if ($objp->amount < 0)
{
print "<td align=\"right\">".price($objp->amount * -1)."</td><td>&nbsp;</td>\n";
}
else
{
print "<td>&nbsp;</td><td align=\"right\">".price($objp->amount)."</td>\n";
}
print "<td align=\"center\">".$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle')."</td>\n";
// Bank account
print "<td align=\"left\">";
$bankaccountstatic->id=$objp->bankid;
$bankaccountstatic->label=$objp->bankref;
print $bankaccountstatic->getNomUrl(1);
print "</td>\n";
print "</tr>";
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
dolibarr_print_error($db);
dolibarr_print_error($db);
}
print "</table>";
// Si accès issu d'une recherche et rien de trouvé
if ($_POST["action"] == "search" && ! $num) {
print "Aucune écriture bancaire répondant aux critères n'a été trouvée.";
if ($_POST["action"] == "search" && ! $num)
{
print $langs->trans("NoRecordFound");
}

View File

@ -231,8 +231,8 @@ insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`,
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2600__+MAX_llx_menu__, 'accountancy', '', 6__+MAX_llx_menu__, '/compta/bank/index.php?leftmenu=bank', 'MenuBankCash', 0, 'banks', '$user->rights->banque->lire', '', 0, 10);
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2601__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/fiche.php?action=create', 'MenuNewFinancialAccount', 1, 'banks', '$user->rights->banque->configurer', '', 0, 0);
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2602__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/categ.php', 'Categories', 1, 'banks', '$user->rights->banque->configurer', '', 0, 1);
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2603__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/search.php', 'SearchTransaction', 1, 'banks', '$user->rights->banque->lire', '', 0, 2);
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2604__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/budget.php', 'ByRubriques', 1, 'banks', '$user->rights->banque->lire', '', 0, 3);
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2603__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/search.php', 'ListTransactions', 1, 'banks', '$user->rights->banque->lire', '', 0, 2);
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2604__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/budget.php', 'ListTransactionsByCategory', 1, 'banks', '$user->rights->banque->lire', '', 0, 3);
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2606__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/virement.php', 'BankTransfers', 1, 'banks', '$user->rights->banque->modifier', '', 0, 5);
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2700__+MAX_llx_menu__, 'accountancy', '', 6__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 0, 'main', '$user->rights->compta->resultat->lire || $user->rights->comptaexpert->comptarapport->lire', '', 0, 11);
insert into `llx_menu` (`menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position) values ('auguria', 'left', 2701__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'Résultat / Exercice', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->comptaexpert->comptarapport->lire', '', 0, 0);

View File

@ -73,12 +73,14 @@ ByCategories=By categories
ByRubriques=By categories
BankTransactionByCategories=Bank transactions by categories
BankTransactionForCategory=Bank transactions for category <b>%s</b>
RemoveFromRubrique=Remove link with categorie
RemoveFromRubrique=Remove link with category
RemoveFromRubriqueConfirm=Are you sure you want to remove link between the transaction and the category ?
ListBankTransactions=List of bank transactions
IdTransaction=Transaction ID
BankTransactions=Bank transactions
SearchTransaction=Search transaction
ListTransactions=List transactions
ListTransactionsByCategory=List transaction/category
TransactionsToConciliate=Transactions to conciliate
Conciliable=Conciliable
Conciliate=Conciliate

View File

@ -77,8 +77,10 @@ RemoveFromRubrique=Supprimer lien avec rubrique
RemoveFromRubriqueConfirm=Etes-vous sur de vouloir supprimer le lien entre la transaction et la rubrique ?
ListBankTransactions=Liste des transactions
IdTransaction=Id transaction
BankTransactions=Transactions bancaires
BankTransactions=Ecritures bancaires
SearchTransaction=Recherche écriture
ListTransactions=Liste écritures
ListTransactionsByCategory=Liste écritures/rubrique
TransactionsToConciliate=Ecritures à rapprocher
Conciliable=Rapprochable
Conciliate=Rapprocher

View File

@ -526,7 +526,7 @@ class Translate {
* \brief Return a label for a key. Store key-label in a cache.
* \param db Database handler
* \param key Key to get label
* \param tablename Table name
* \param tablename Table name without prefix
* \param fieldkey Field for key
* \param fieldlabel Field for label
* \return string Label
@ -543,9 +543,9 @@ class Translate {
}
// Check in cache
if (! empty($this->cache_labels[$tablename][$key]))
if (isset($this->cache_labels[$tablename][$key])) // Can be defined to 0 or ''
{
return $this->cache_labels[$tablename][$key]; // Found in cache
return $this->cache_labels[$tablename][$key]; // Found in cache
}
$sql = "SELECT ".$fieldlabel." as label";
@ -556,7 +556,8 @@ class Translate {
if ($resql)
{
$obj = $db->fetch_object($resql);
$this->cache_labels[$tablename][$key]=$obj->label;
if ($obj) $this->cache_labels[$tablename][$key]=$obj->label;
else $this->cache_labels[$tablename][$key]='';
$db->free($resql);
return $this->cache_labels[$tablename][$key];
}