';
diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php
index 4c2182bb1e8..0878474dcb5 100644
--- a/htdocs/compta/bank/document.php
+++ b/htdocs/compta/bank/document.php
@@ -139,6 +139,7 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes') {
/*
* View
*/
+
$title = $langs->trans("FinancialAccount").' - '.$langs->trans("Documents");
$helpurl = "";
llxHeader('',$title,$helpurl);
@@ -152,8 +153,7 @@ if ($id > 0 || !empty($ref)) {
// Onglets
$head = bank_prepare_head($object);
- dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), 0,
- 'account');
+ dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), 0, 'account');
// Construit liste des fichiers
@@ -166,29 +166,25 @@ if ($id > 0 || !empty($ref)) {
}
$linkback = '
';
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
- print '
';
-
- // Ref
- print '| ' . $langs->trans("Ref") . ' | ';
- print '';
- print $form->showrefnav($object, 'ref', $linkback, 1, 'ref');
- print ' |
';
-
- // Label
- print '| ' . $langs->trans("Label") . ' | ';
- print '' . $object->label . ' |
';
-
- // Status
- print '| ' . $langs->trans("Status") . ' | ';
- print '' . $object->getLibStatut(4) . ' |
';
- print '| ' . $langs->trans("NbOfAttachedFiles") . ' | ' . count($filearray) . ' |
';
+
+ print '';
+ print '
';
+
+ print '
';
+ print '| ' . $langs->trans("NbOfAttachedFiles") . ' | ' . count($filearray) . ' |
';
print '| ' . $langs->trans("TotalSizeOfAttachedFiles") . ' | ' . $totalsize . ' ' . $langs->trans("bytes") . ' |
';
print "
\n";
- print "
\n";
+
+ print '';
+
+ dol_fiche_end();
dol_htmloutput_mesg($mesg, $mesgs);
+
/*
* Confirmation suppression fichier
*/
diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php
index 66aff20f40c..5f00a500c31 100644
--- a/htdocs/compta/bank/graph.php
+++ b/htdocs/compta/bank/graph.php
@@ -67,15 +67,15 @@ if (! empty($_GET["year"])) $year=sprintf("%04d",$_GET["year"]);
if (! empty($_GET["month"])) $month=sprintf("%02d",$_GET["month"]);
-$acct = new Account($db);
+$object = new Account($db);
if ($_GET["account"] && ! preg_match('/,/',$_GET["account"])) // if for a particular account and not a list
{
- $result=$acct->fetch($_GET["account"]);
+ $result=$object->fetch($_GET["account"]);
}
if ($_GET["ref"])
{
- $result=$acct->fetch(0,$_GET["ref"]);
- $account=$acct->id;
+ $result=$object->fetch(0,$_GET["ref"]);
+ $account=$object->id;
}
$result=dol_mkdir($conf->bank->dir_temp);
@@ -202,8 +202,8 @@ else
{
$datas[$i] = $solde + $subtotal;
}
- $datamin[$i] = $acct->min_desired;
- $dataall[$i] = $acct->min_allowed;
+ $datamin[$i] = $object->min_desired;
+ $dataall[$i] = $object->min_allowed;
//$labels[$i] = strftime("%d",$day);
$labels[$i] = $xday;
@@ -230,15 +230,15 @@ else
foreach($datas as $i => $val)
{
$graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
- if ($acct->min_desired) array_push($graph_datas[$i],$datamin[$i]);
- if ($acct->min_allowed) array_push($graph_datas[$i],$dataall[$i]);
+ if ($object->min_desired) array_push($graph_datas[$i],$datamin[$i]);
+ if ($object->min_allowed) array_push($graph_datas[$i],$dataall[$i]);
}
$px1 = new DolGraph();
$px1->SetData($graph_datas);
$arraylegends=array($langs->transnoentities("Balance"));
- if ($acct->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired"));
- if ($acct->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed"));
+ if ($object->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired"));
+ if ($object->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed"));
$px1->SetLegend($arraylegends);
$px1->SetLegendWidthMin(180);
$px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue());
@@ -346,8 +346,8 @@ else
{
$datas[$i] = $solde + $subtotal;
}
- $datamin[$i] = $acct->min_desired;
- $dataall[$i] = $acct->min_allowed;
+ $datamin[$i] = $object->min_desired;
+ $dataall[$i] = $object->min_allowed;
if ($xday == '15')
{
$labels[$i] = dol_print_date($day,"%b");
@@ -367,14 +367,14 @@ else
foreach($datas as $i => $val)
{
$graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
- if ($acct->min_desired) array_push($graph_datas[$i],$datamin[$i]);
- if ($acct->min_allowed) array_push($graph_datas[$i],$dataall[$i]);
+ if ($object->min_desired) array_push($graph_datas[$i],$datamin[$i]);
+ if ($object->min_allowed) array_push($graph_datas[$i],$dataall[$i]);
}
$px2 = new DolGraph();
$px2->SetData($graph_datas);
$arraylegends=array($langs->transnoentities("Balance"));
- if ($acct->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired"));
- if ($acct->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed"));
+ if ($object->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired"));
+ if ($object->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed"));
$px2->SetLegend($arraylegends);
$px2->SetLegendWidthMin(180);
$px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue());
@@ -462,8 +462,8 @@ else
{
$datas[$i] = '' + $solde + $subtotal;
}
- $datamin[$i] = $acct->min_desired;
- $dataall[$i] = $acct->min_allowed;
+ $datamin[$i] = $object->min_desired;
+ $dataall[$i] = $object->min_allowed;
if (substr($textdate,6,2) == '01' || $i == 0)
{
$labels[$i] = substr($textdate,4,2);
@@ -482,15 +482,15 @@ else
foreach($datas as $i => $val)
{
$graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
- if ($acct->min_desired) array_push($graph_datas[$i],$datamin[$i]);
- if ($acct->min_allowed) array_push($graph_datas[$i],$dataall[$i]);
+ if ($object->min_desired) array_push($graph_datas[$i],$datamin[$i]);
+ if ($object->min_allowed) array_push($graph_datas[$i],$dataall[$i]);
}
$px3 = new DolGraph();
$px3->SetData($graph_datas);
$arraylegends=array($langs->transnoentities("Balance"));
- if ($acct->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired"));
- if ($acct->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed"));
+ if ($object->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired"));
+ if ($object->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed"));
$px3->SetLegend($arraylegends);
$px3->SetLegendWidthMin(180);
$px3->SetMaxValue($px3->GetCeilMaxValue()<0?0:$px3->GetCeilMaxValue());
@@ -605,7 +605,7 @@ else
$data_credit[$i] = isset($credits[substr("0".($i+1),-2)]) ? $credits[substr("0".($i+1),-2)] : 0;
$data_debit[$i] = isset($debits[substr("0".($i+1),-2)]) ? $debits[substr("0".($i+1),-2)] : 0;
$labels[$i] = sprintf("%02d",$i+1);
- $datamin[$i] = $acct->min_desired;
+ $datamin[$i] = $object->min_desired;
}
// Fabrication tableau 4a
@@ -714,7 +714,7 @@ else
$data_credit[$i] = isset($credits[substr("0".($i+1),-2)]) ? $credits[substr("0".($i+1),-2)] : 0;
$data_debit[$i] = isset($debits[substr("0".($i+1),-2)]) ? $debits[substr("0".($i+1),-2)] : 0;
$labels[$i] = dol_print_date(dol_mktime(12,0,0,$i+1,1,2000),"%b");
- $datamin[$i] = $acct->min_desired;
+ $datamin[$i] = $object->min_desired;
}
// Fabrication tableau 4b
@@ -754,36 +754,33 @@ else
// Onglets
-$head=bank_prepare_head($acct);
+$head=bank_prepare_head($object);
dol_fiche_head($head,'graph',$langs->trans("FinancialAccount"),0,'account');
-print '';
$linkback = ''.$langs->trans("BackToList").'';
-// Ref
-print '| '.$langs->trans("Ref").' | ';
-print '';
if ($account)
{
if (! preg_match('/,/',$account))
{
$moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':'');
+
if ($_GET["option"]!='all')
{
$morehtml=''.$langs->trans("ShowAllAccounts").'';
- print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam);
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam);
}
else
{
$morehtml=''.$langs->trans("BackToAccount").'';
- print $langs->trans("All");
+ print $langs->trans("AllAccounts");
//print $morehtml;
}
}
else
{
- $bankaccount=new Account($db);
+ $bankaccount=new Account($db);
$listid=explode(',',$account);
foreach($listid as $key => $id)
{
@@ -795,25 +792,9 @@ if ($account)
}
}
else
-{
- print $langs->trans("All");
-}
-print ' |
';
-
-// Label
-print '| '.$langs->trans("Label").' | ';
-print '';
-if ($account && $_GET["option"]!='all')
-{
- print $acct->label;
-}
-else
{
print $langs->trans("AllAccounts");
}
-print ' |
';
-
-print '
';
dol_fiche_end();
diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php
index b0447db68c2..4b03250e76a 100644
--- a/htdocs/compta/bank/search.php
+++ b/htdocs/compta/bank/search.php
@@ -33,6 +33,16 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
+require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
+require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
+require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
+
$langs->load("banks");
$langs->load("bills");
$langs->load("categories");
@@ -61,6 +71,8 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
+$pageplusone = GETPOST("pageplusone",'int');
+if ($pageplusone) $page = $pageplusone - 1;
if ($page == -1) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
@@ -68,6 +80,16 @@ $pagenext = $page + 1;
if (! $sortorder) $sortorder='DESC';
if (! $sortfield) $sortfield='b.dateo';
+$mode_balance_ok=false;
+//if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected
+if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid') && $account > 0)
+{
+ $sortfield = 'b.datev, b.dateo, b.rowid';
+ $mode_balance_ok = true;
+}
+if (strtolower($sortorder) == 'desc') $mode_balance_ok = false;
+
+
// Initialize technical object to manage context to save list fields
$contextpage='banktransactionlist';
@@ -81,15 +103,16 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search
$arrayfields=array(
'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
+ 'description'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1),
'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1),
'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1),
- 'description'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
'bu.label'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>500),
+ 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1, 'position'=>1000),
'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600),
'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605),
- 'ba.ref'=>array('label'=>$langs->trans("Account"), 'checked'=>1, 'position'=>1000),
+ 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1000),
'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010),
);
// Extra fields
@@ -148,22 +171,35 @@ if (empty($reshook))
* View
*/
-$companystatic=new Societe($db);
-$bankaccountstatic=new Account($db);
-
-llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param);
-
$form = new Form($db);
$formother = new FormOther($db);
-if ($vline) $viewline = $vline;
-else $viewline = 50;
+$companystatic=new Societe($db);
+$bankaccountstatic=new Account($db);
+
+$societestatic=new Societe($db);
+$userstatic=new User($db);
+$chargestatic=new ChargeSociales($db);
+$loanstatic=new Loan($db);
+$memberstatic=new Adherent($db);
+$paymentstatic=new Paiement($db);
+$paymentsupplierstatic=new PaiementFourn($db);
+$paymentvatstatic=new TVA($db);
+$paymentsalstatic=new PaymentSalary($db);
+$donstatic=new Don($db);
+$expensereportstatic=new ExpenseReport($db);
+$bankstatic=new Account($db);
+$banklinestatic=new AccountLine($db);
+
+$now = dol_now();
+
+llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param);
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, 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.ref as bankref,";
$sql.= " bu.url_id,";
-$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
+$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@@ -183,7 +219,8 @@ if ($search_ref) $sql.=natural_search("b.rowid", $search_ref);
if ($account > 0) $sql.=" AND b.fk_account = ".$account;
if ($search_req_nb) $sql.= natural_search("b.num_chq", $search_req_nb);
if ($search_num_releve) $sql.= natural_search("b.num_releve", $search_num_releve);
-if ($search_thirdparty) $sql.=" AND s.nom LIKE '%".$db->escape($search_thirdparty)."%'";
+if ($search_thirdparty) $sql.= natural_search("s.nom", $search_thirdparty);
+if ($description) $sql.= natural_search("b.label", $description); // Warning some text are just translation keys, not translated strings
if ($bid) $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$bid;
if (! empty($type)) $sql.= " AND b.fk_type = '".$db->escape($type)."' ";
// Search period criteria
@@ -219,6 +256,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
+ $nbtotalofpages = ceil($nbtotalofrecords/$limit);
}
$sql.= $db->plimit($limit+1,$offset);
@@ -280,14 +318,20 @@ if ($resql)
// Title
$bankcateg=new BankCateg($db);
+ $morehtml='';
+ $morehtml.= ' "; // ' Page ';
+ $morehtml.='';
+ $morehtml.='/'.$nbtotalofpages.' ';
+ $morehtml.='
';
+
if (GETPOST("bid"))
{
$result=$bankcateg->fetch(GETPOST("bid"));
- print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, '', '', $limit);
+ print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, $morehtml, '', $limit);
}
else
{
- print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, '', '', $limit);
+ print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, $morehtml, '', $limit);
}
$moreforfilter = '';
@@ -320,16 +364,17 @@ if ($resql)
// Fields title
print '';
if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder);
+ if (! empty($arrayfields['description']['checked'])) print_liste_field_titre($arrayfields['description']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'],$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="center"',$sortfield,$sortorder);
- if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev','',$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev, b.dateo, b.rowid','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'],$_SERVER['PHP_SELF'],'b.num_chq','',$param,'align="center"',$sortfield,$sortorder);
- if (! empty($arrayfields['description']['checked'])) print_liste_field_titre($arrayfields['description']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'],$_SERVER['PHP_SELF'],'bu.label','',$param,'',$sortfield,$sortorder);
+ if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'],$_SERVER['PHP_SELF'],'ba.ref','',$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'],$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'],$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder);
- if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'],$_SERVER['PHP_SELF'],'ba.ref','',$param,'align="right"',$sortfield,$sortorder);
- if (! empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'],$_SERVER['PHP_SELF'],'b.num_releve','',$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'],$_SERVER['PHP_SELF'],'balance','',$param,'align="right"',$sortfield,$sortorder);
+ if (! empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'],$_SERVER['PHP_SELF'],'b.num_releve','',$param,'align="center"',$sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
@@ -356,6 +401,12 @@ if ($resql)
print '';
print '';
}
+ if (! empty($arrayfields['description']['checked']))
+ {
+ print '| ';
+ //print '';
+ print ' | ';
+ }
if (! empty($arrayfields['b.dateo']['checked']))
{
print ' | ';
@@ -367,7 +418,7 @@ if ($resql)
if (! empty($arrayfields['type']['checked']))
{
print '';
- $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1);
+ $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1, 0, 1, 'maxwidth100');
print ' | ';
}
if (! empty($arrayfields['b.num_chq']['checked']))
@@ -375,16 +426,16 @@ if ($resql)
// Numero
print ' | ';
}
- if (! empty($arrayfields['description']['checked']))
- {
- print '';
- print '';
- print ' | ';
- }
if (! empty($arrayfields['bu.label']['checked']))
{
print ' | ';
}
+ if (! empty($arrayfields['ba.ref']['checked']))
+ {
+ print '';
+ $form->select_comptes($account,'account',0,'',1);
+ print ' | ';
+ }
if (! empty($arrayfields['b.debit']['checked']))
{
print '';
@@ -397,16 +448,17 @@ if ($resql)
print '';
print ' | ';
}
- if (! empty($arrayfields['ba.ref']['checked']))
+ if (! empty($arrayfields['balance']['checked']))
{
print '';
- $form->select_comptes($account,'account',0,'',1);
+ $htmltext=$langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
+ print $form->textwithpicto('', $htmltext, 1);
print ' | ';
}
if (! empty($arrayfields['b.num_releve']['checked']))
{
- // Numero
- print ' | ';
+ // Numero statement
+ print ' | ';
}
print '';
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
@@ -415,168 +467,346 @@ if ($resql)
print " |
\n";
// Loop on each record
+ $total = 0; // For balance
+ $sign = 1;
+
$totalarray=array();
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
- // Why this ?
- $printline=false;
- //Search Description
- if ($description) {
- preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction
- if ($reg[1]) {
- if ($langs->transnoentities($reg[1])==$description) {
- $printline=true;
- }
- } elseif ($objp->label==$description) {
- $printline=true;
- }
- } else {
- $printline=true;
+ $total = price2num($total + ($sign * $objp->amount),'MT');
+
+ if (empty($cachebankaccount[$objp->bankid]))
+ {
+ $bankaccounttmp = new Account($db);
+ $bankaccounttmp->fetch($objp->bankid);
+ $cachebankaccount[$objp->bankid]=$bankaccounttmp;
+ $bankaccount = $bankaccounttmp;
}
- if ($printline) {
-
- $var=!$var;
+ else
+ {
+ $bankaccount = $cachebankaccount[$objp->bankid];
+ }
+
+ $var=!$var;
- print "";
+ print "
";
- // Ref
- if (! empty($arrayfields['b.rowid']['checked']))
- {
- print '| ';
- print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'payment', 'class="classfortooltip"').' '.$objp->rowid." ";
- print ' | ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Date ope
- if (! empty($arrayfields['b.dateo']['checked']))
- {
- print ''.dol_print_date($db->jdate($objp->do),"day")." | \n";
- if (! $i) $totalarray['nbfield']++;
- }
-
- // Date value
- if (! empty($arrayfields['b.datev']['checked']))
- {
- print ''.dol_print_date($db->jdate($objp->dv),"day")." | \n";
- if (! $i) $totalarray['nbfield']++;
- }
-
- // Payment type
- if (! empty($arrayfields['type']['checked']))
- {
- print '';
- $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle');
- if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance");
- else print $labeltype;
- print " | \n";
- if (! $i) $totalarray['nbfield']++;
- }
-
- // Num cheque
- if (! empty($arrayfields['b.num_releve']['checked']))
- {
- print ''.($objp->num_chq?$objp->num_chq:"")." | \n";
- if (! $i) $totalarray['nbfield']++;
- }
-
- // Description
- if (! empty($arrayfields['description']['checked']))
- {
- print "";
-
- print "rowid."&account=".$objp->fk_account."\">";
- $reg=array();
- preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction
- if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]);
- else print dol_trunc($objp->label,40);
- print " ";
-
- print ' | ';
- if (! $i) $totalarray['nbfield']++;
- }
-
- // Third party
- if (! empty($arrayfields['bu.label']['checked']))
- {
- print "";
- if ($objp->url_id)
- {
- $companystatic->id=$objp->url_id;
- $companystatic->name=$objp->nom;
- $companystatic->name_alias=$objp->name_alias;
- $companystatic->client=$objp->client;
- $companystatic->fournisseur=$objp->fournisseur;
- $companystatic->code_client=$objp->code_client;
- $companystatic->code_fournisseur=$objp->code_fournisseur;
- print $companystatic->getNomUrl(1);
- }
- else
- {
- print ' ';
- }
- print ' | ';
+ // Ref
+ if (! empty($arrayfields['b.rowid']['checked']))
+ {
+ print '';
+ print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid." ";
+ print ' | ';
if (! $i) $totalarray['nbfield']++;
- }
-
- // Debit
- if (! empty($arrayfields['b.debit']['checked']))
- {
- print '';
- if ($objp->amount < 0)
- {
- print price($objp->amount * -1);
- $totalarray['totaldeb'] += $objp->amount;
- }
- print " | \n";
- if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield'];
- }
- // Credit
- if (! empty($arrayfields['b.credit']['checked']))
- {
- print '';
- if ($objp->amount > 0)
- {
- print price($objp->amount);
- $totalarray['totalcred'] += $objp->amount;
- }
- print " | \n";
- if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield'];
- }
-
- // Bank account
- if (! empty($arrayfields['ba.ref']['checked']))
- {
- print '';
- $bankaccountstatic->id=$objp->bankid;
- $bankaccountstatic->label=$objp->bankref;
- print $bankaccountstatic->getNomUrl(1);
- print " | \n";
+ }
+
+ // Description
+ if (! empty($arrayfields['description']['checked']))
+ {
+ print "";
+
+ //print "rowid."&account=".$objp->fk_account."\">";
+ $reg=array();
+ preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction
+ if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]);
+ else print dol_trunc($objp->label,40);
+ //print " ";
+
+ // Add links after description
+ $links = $bankaccountstatic->get_url($objp->rowid);
+ $cachebankaccount=array();
+ foreach($links as $key=>$val)
+ {
+ if ($links[$key]['type']=='payment')
+ {
+ $paymentstatic->id=$links[$key]['url_id'];
+ $paymentstatic->ref=$links[$key]['url_id'];
+ print ' '.$paymentstatic->getNomUrl(2);
+ }
+ elseif ($links[$key]['type']=='payment_supplier')
+ {
+ $paymentsupplierstatic->id=$links[$key]['url_id'];
+ $paymentsupplierstatic->ref=$links[$key]['url_id'];
+ print ' '.$paymentsupplierstatic->getNomUrl(2);
+ }
+ elseif ($links[$key]['type']=='payment_sc')
+ {
+ print '';
+ print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
+ //print $langs->trans("SocialContributionPayment");
+ print '';
+ }
+ elseif ($links[$key]['type']=='payment_vat')
+ {
+ $paymentvatstatic->id=$links[$key]['url_id'];
+ $paymentvatstatic->ref=$links[$key]['url_id'];
+ print ' '.$paymentvatstatic->getNomUrl(2);
+ }
+ elseif ($links[$key]['type']=='payment_salary')
+ {
+ $paymentsalstatic->id=$links[$key]['url_id'];
+ $paymentsalstatic->ref=$links[$key]['url_id'];
+ print ' '.$paymentsalstatic->getNomUrl(2);
+ }
+ elseif ($links[$key]['type']=='payment_loan')
+ {
+ print '';
+ print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
+ print '';
+ }
+ elseif ($links[$key]['type']=='payment_donation')
+ {
+ print '';
+ print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
+ print '';
+ }
+ elseif ($links[$key]['type']=='payment_expensereport')
+ {
+ print '';
+ print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
+ print '';
+ }
+ elseif ($links[$key]['type']=='banktransfert')
+ {
+ // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
+ if ($objp->amount > 0)
+ {
+ $banklinestatic->fetch($links[$key]['url_id']);
+ $bankstatic->id=$banklinestatic->fk_account;
+ $bankstatic->label=$banklinestatic->bank_account_ref;
+ print ' ('.$langs->trans("TransferFrom").' ';
+ print $bankstatic->getNomUrl(1,'transactions');
+ print ' '.$langs->trans("toward").' ';
+ $bankstatic->id=$objp->bankid;
+ $bankstatic->label=$objp->bankref;
+ print $bankstatic->getNomUrl(1,'');
+ print ')';
+ }
+ else
+ {
+ $bankstatic->id=$objp->bankid;
+ $bankstatic->label=$objp->bankref;
+ print ' ('.$langs->trans("TransferFrom").' ';
+ print $bankstatic->getNomUrl(1,'');
+ print ' '.$langs->trans("toward").' ';
+ $banklinestatic->fetch($links[$key]['url_id']);
+ $bankstatic->id=$banklinestatic->fk_account;
+ $bankstatic->label=$banklinestatic->bank_account_ref;
+ print $bankstatic->getNomUrl(1,'transactions');
+ print ')';
+ }
+ //var_dump($links);
+ }
+ elseif ($links[$key]['type']=='company')
+ {
+
+ }
+ elseif ($links[$key]['type']=='user')
+ {
+
+ }
+ elseif ($links[$key]['type']=='member')
+ {
+
+ }
+ elseif ($links[$key]['type']=='sc')
+ {
+
+ }
+ else
+ {
+ // Show link with label $links[$key]['label']
+ if (! empty($objp->label) && ! empty($links[$key]['label'])) print ' - ';
+ print '';
+ if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg))
+ {
+ // Label generique car entre parentheses. On l'affiche en le traduisant
+ if ($reg[1]=='paiement') $reg[1]='Payment';
+ print ' '.$langs->trans($reg[1]);
+ }
+ else
+ {
+ print ' '.$links[$key]['label'];
+ }
+ print '';
+ }
+ }
+
+ print ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Date ope
+ if (! empty($arrayfields['b.dateo']['checked']))
+ {
+ print ''.dol_print_date($db->jdate($objp->do),"day")." | \n";
if (! $i) $totalarray['nbfield']++;
- }
-
- if (! empty($arrayfields['b.num_releve']['checked']))
- {
- print ''.($objp->num_releve?$objp->num_releve:"")." | \n";
+ }
+
+ // Date value
+ if (! empty($arrayfields['b.datev']['checked']))
+ {
+ print ''.dol_print_date($db->jdate($objp->dv),"day")." | \n";
if (! $i) $totalarray['nbfield']++;
- }
-
- // Action column
- print '';
- if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- {
- $selected=0;
- if (in_array($obj->rowid, $arrayofselected)) $selected=1;
- print '';
- }
- print ' | ';
+ }
+
+ // Payment type
+ if (! empty($arrayfields['type']['checked']))
+ {
+ print '';
+ $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle');
+ if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance");
+ else print $labeltype;
+ print " | \n";
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Num cheque
+ if (! empty($arrayfields['b.num_releve']['checked']))
+ {
+ print ''.($objp->num_chq?$objp->num_chq:"")." | \n";
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Third party
+ if (! empty($arrayfields['bu.label']['checked']))
+ {
+ print "";
+ if ($objp->url_id)
+ {
+ $companystatic->id=$objp->url_id;
+ $companystatic->name=$objp->nom;
+ $companystatic->name_alias=$objp->name_alias;
+ $companystatic->client=$objp->client;
+ $companystatic->fournisseur=$objp->fournisseur;
+ $companystatic->code_client=$objp->code_client;
+ $companystatic->code_fournisseur=$objp->code_fournisseur;
+ $companystatic->code_compta=$objp->code_compta;
+ $companystatic->code_compta_fournisseur=$objp->code_compta_fournisseur;
+ print $companystatic->getNomUrl(1);
+ }
+ else
+ {
+ print ' ';
+ }
+ print ' | ';
if (! $i) $totalarray['nbfield']++;
-
- print "
";
- }
+ }
+
+ // Bank account
+ if (! empty($arrayfields['ba.ref']['checked']))
+ {
+ print '';
+ print $bankaccount->getNomUrl(1);
+ print " | \n";
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Debit
+ if (! empty($arrayfields['b.debit']['checked']))
+ {
+ print '';
+ if ($objp->amount < 0)
+ {
+ print price($objp->amount * -1);
+ $totalarray['totaldeb'] += $objp->amount;
+ }
+ print " | \n";
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield'];
+ }
+ // Credit
+ if (! empty($arrayfields['b.credit']['checked']))
+ {
+ print '';
+ if ($objp->amount > 0)
+ {
+ print price($objp->amount);
+ $totalarray['totalcred'] += $objp->amount;
+ }
+ print " | \n";
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield'];
+ }
+
+ // Balance
+ if (! empty($arrayfields['balance']['checked']))
+ {
+ if ($mode_balance_ok)
+ {
+ if ($total >= 0)
+ {
+ print ' '.price($total).' | ';
+ }
+ else
+ {
+ print ' '.price($total).' | ';
+ }
+ }
+ else
+ {
+ print '- | ';
+ }
+ }
+
+ // Transaction reconciliated or edit link
+ if ($objp->rappro && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated
+ {
+ print '';
+ print '';
+ print img_edit();
+ print '';
+ print " ";
+ print ''.$objp->num_releve.'';
+ print " | ";
+ }
+ else
+ {
+ print '';
+ if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
+ {
+ print '';
+ print img_edit();
+ print '';
+ }
+ else
+ {
+ print '';
+ print img_view();
+ print '';
+ }
+ if ($bankaccount->canBeConciliated() > 0 && empty($objp->rappro))
+ {
+ if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay))
+ {
+ print ' '.img_warning($langs->trans("Late"));
+ }
+ }
+ print ' ';
+ if ($user->rights->banque->modifier)
+ {
+ print 'rowid.'&id='.$object->id.'&page='.$page.'">';
+ print img_delete();
+ print '';
+ }
+ print ' | ';
+ }
+
+ // Action column
+ print '';
+ if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ {
+ $selected=0;
+ if (in_array($obj->rowid, $arrayofselected)) $selected=1;
+ print '';
+ }
+ print ' | ';
+ if (! $i) $totalarray['nbfield']++;
+
+ print "";
+
$i++;
}
diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php
index 2b3593cd5bd..3de977f29cf 100644
--- a/htdocs/compta/bank/treso.php
+++ b/htdocs/compta/bank/treso.php
@@ -22,7 +22,7 @@
/**
* \file htdocs/compta/bank/treso.php
* \ingroup banque
- * \brief Page de detail du budget de tresorerie
+ * \brief Page to estimate future balance
*/
require '../../main.inc.php';
@@ -77,42 +77,32 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$viewline = 20;
}
- $acct = new Account($db);
+ $object = new Account($db);
if ($_GET["account"])
{
- $result=$acct->fetch($_GET["account"]);
+ $result=$object->fetch($_GET["account"]);
}
if ($_GET["ref"])
{
- $result=$acct->fetch(0,$_GET["ref"]);
- $_GET["account"]=$acct->id;
+ $result=$object->fetch(0,$_GET["ref"]);
+ $_GET["account"]=$object->id;
}
// Onglets
- $head=bank_prepare_head($acct);
+ $head=bank_prepare_head($object);
dol_fiche_head($head,'cash',$langs->trans("FinancialAccount"),0,'account');
print '';
$linkback = ''.$langs->trans("BackToList").'';
- // Ref
- print '| '.$langs->trans("Ref").' | ';
- print '';
- print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref');
- print ' |
';
-
- // Label
- print '| '.$langs->trans("Label").' | ';
- print ''.$acct->label.' |
';
-
- print '
';
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_fiche_end();
- $solde = $acct->solde(0);
+ $solde = $object->solde(0);
/*
* Affiche tableau des echeances a venir
@@ -154,7 +144,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid
- $sql.= " AND (f.fk_account IN (0, ".$acct->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice
+ $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice
$sql.= " ORDER BY dlr ASC";
// Supplier invoices
@@ -164,7 +154,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid";
$sql2.= " WHERE ff.entity = ".$conf->entity;
$sql2.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid
- $sql2.= " AND (ff.fk_account IN (0, ".$acct->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice
+ $sql2.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice
$sql2.= " ORDER BY dlr ASC";
// Social contributions
@@ -174,7 +164,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$sql3.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id";
$sql3.= " WHERE cs.entity = ".$conf->entity;
$sql3.= " AND cs.paye = 0"; // Not paid
- $sql3.= " AND (cs.fk_account IN (0, ".$acct->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution
+ $sql3.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution
$sql3.= " ORDER BY dlr ASC";
$error=0;
@@ -332,8 +322,8 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
// Solde actuel
$var=!$var;
print '';
- print '| '.$langs->trans("FutureBalance").' ('.$acct->currency_code.') | ';
- print ''.price($solde, 0, $langs, 0, 0, -1, $acct->currency_code).' | ';
+ print ''.$langs->trans("FutureBalance").' ('.$object->currency_code.') | ';
+ print ''.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).' | ';
print '
';
print "
";
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index ceac1fc4b44..b5d9ead05e3 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2814,9 +2814,10 @@ class Form
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $maxlength Max length of label
* @param int $active Active or not, -1 = all
+ * @param string $morecss Add more css
* @return void
*/
- function select_types_paiements($selected='', $htmlname='paiementtype', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $active=1)
+ function select_types_paiements($selected='', $htmlname='paiementtype', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $active=1, $morecss='')
{
global $langs,$user;
@@ -2829,7 +2830,7 @@ class Form
$this->load_cache_types_paiements();
- print '