diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 08fed83acc082bca1abf8f691703b450eef9cde8..9a5a19a1e09481de18d359b197018c952fb876bf 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -92,30 +92,35 @@ if ($negpage) if ($page > GETPOST("nbpage")) $page = GETPOST("nbpage"); } +$sortfield = "b.datev, b.datec, b.rowid"; + $object = new Account($db); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers -{ - $paiementtype=""; - $req_nb=""; - $thirdparty=""; - $req_desc=""; - $req_debit=""; - $req_credit=""; - $req_stdtmonth=""; - $req_stdtday=""; - $req_stdtyear=""; - $req_stdt = ""; - $req_enddtmonth=""; - $req_enddtday=""; - $req_enddtyear=""; - $req_enddt = ""; - $search_reconciled = ''; -} + /* * Action */ + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $paiementtype=""; + $req_nb=""; + $thirdparty=""; + $req_desc=""; + $req_debit=""; + $req_credit=""; + $req_stdtmonth=""; + $req_stdtday=""; + $req_stdtyear=""; + $req_stdt = ""; + $req_enddtmonth=""; + $req_enddtday=""; + $req_enddtyear=""; + $req_enddt = ""; + $search_reconciled = ''; +} + $dateop=-1; if ($action == 'add' && $id && ! isset($_POST["cancel"]) && $user->rights->banque->modifier) @@ -340,23 +345,10 @@ if ($id > 0 || ! empty($ref)) $head=bank_prepare_head($object); dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); - - print '<table class="border" width="100%">'; - $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>'; - - // Ref - print '<tr><td width="25%">'.$langs->trans("Ref").'</td>'; - print '<td colspan="3">'; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref'); - print '</td></tr>'; - - // Label - print '<tr><td>'.$langs->trans("Label").'</td>'; - print '<td colspan="3">'.$object->label.'</td></tr>'; - - print '</table>'; - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_fiche_end(); @@ -507,7 +499,7 @@ if ($id > 0 || ! empty($ref)) // Ligne de titre tableau des ecritures print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Date").'</td>'; - print '<td>'.$langs->trans("Value").'</td>'; + print_liste_field_titre($langs->trans("Value"), '', 'b.datev, b.datec, b.rowid','',$param,'',$sortfield,$sortorder); print '<td>'.$langs->trans("Type").'</td>'; print '<td>'.$langs->trans("Numero").'</td>'; print '<td>'.$langs->trans("Description").'</td>'; @@ -603,7 +595,7 @@ if ($id > 0 || ! empty($ref)) $sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; $sql.= $sql_rech; - $sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day + $sql.= $db->order($sortfield, "ASC"); // We add date of creation to have correct order when everything is done the same day $sql.= $db->plimit($limitsql, 0); dol_syslog("account.php get transactions -", LOG_DEBUG); diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index bfda1fb9c1b04bb283e3ea5ede2f1eccf397ff9c..6115c0f6c843fb983a990470882c62865382b20e 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $langs->load("banks"); $langs->load("categories"); -$id=GETPOST('account'); +$id=GETPOST('account')?GETPOST('account','alpha'):GETPOST('id'); $ref=GETPOST('ref'); // Security check @@ -60,16 +60,16 @@ llxHeader('',$title,$helpurl); $form = new Form($db); // Get account informations -$acct = new Account($db); +$object = new Account($db); if ($id > 0 && ! preg_match('/,/', $id)) // if for a particular account and not a list { - $result=$acct->fetch($id); - $id=$acct->id; + $result=$object->fetch($id); + $id=$object->id; } if (! empty($ref)) { - $result=$acct->fetch(0, $ref); - $id=$acct->id; + $result=$object->fetch(0, $ref); + $id=$object->id; } @@ -134,58 +134,38 @@ else // Onglets -$head=bank_prepare_head($acct); +$head=bank_prepare_head($object); dol_fiche_head($head,'annual',$langs->trans("FinancialAccount"),0,'account'); -$title=$langs->trans("FinancialAccount")." : ".$acct->label; -$link=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?account=".$acct->id."&year_start=".($year_start-1)."'>".img_previous()."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$acct->id."&year_start=".($year_start+1)."'>".img_next()."</a>":""); - -print '<table class="border" width="100%">'; +$title=$langs->trans("FinancialAccount")." : ".$object->label; +$link=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?account=".$object->id."&year_start=".($year_start-1)."'>".img_previous()."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$acct->id."&year_start=".($year_start+1)."'>".img_next()."</a>":""); $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>'; -// Ref -print '<tr><td width="25%">'.$langs->trans("Ref").'</td>'; -print '<td colspan="3">'; -if (!empty($id)) -{ - if (! preg_match('/,/', $id)) - { - print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref'); - } - else - { - $bankaccount=new Account($db); - $listid=explode(',', $id); - foreach($listid as $key => $aId) - { - $bankaccount->fetch($aId); - $bankaccount->label=$bankaccount->ref; - print $bankaccount->getNomUrl(1); - if ($key < (count($listid)-1)) print ', '; - } - } -} -else -{ - print $langs->trans("ALL"); -} -print '</td></tr>'; -// Label -print '<tr><td>'.$langs->trans("Label").'</td>'; -print '<td colspan="3">'; -if (! empty($id)) +if (!empty($id)) { - print $acct->label; + if (! preg_match('/,/', $id)) + { + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + } + else + { + $bankaccount=new Account($db); + $listid=explode(',', $id); + foreach($listid as $key => $aId) + { + $bankaccount->fetch($aId); + $bankaccount->label=$bankaccount->ref; + print $bankaccount->getNomUrl(1); + if ($key < (count($listid)-1)) print ', '; + } + } } else { print $langs->trans("AllAccounts"); } -print '</td></tr>'; - -print '</table>'; dol_fiche_end(); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 07a1548bd478887b029ddb757a9da73d86aa352f..a56d69138c1473c6711daa998cd798c0bf754f33 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -655,31 +655,6 @@ else if ($object->url) print '</a>'; print "</td></tr>\n"; - // Categories - if ($conf->categorie->enabled) { - print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; - print $form->showCategories($object->id,'account',1); - print "</td></tr>"; - } - - print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>'; - print '<td>'.dol_htmlentitiesbr($object->comment).'</td></tr>'; - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '</table>'; - - - print '</div>'; - print '<div class="fichehalfright">'; - print '<div class="ficheaddleft">'; - print '<div class="underbanner clearboth"></div>'; - - - print '<table class="border centpercent">'; - // Accountancy code print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>'; print '<td>'; @@ -697,6 +672,31 @@ else print '<td>'.$object->accountancy_journal.'</td></tr>'; } + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '</table>'; + + + print '</div>'; + print '<div class="fichehalfright">'; + print '<div class="ficheaddleft">'; + print '<div class="underbanner clearboth"></div>'; + + + print '<table class="border centpercent">'; + + // Categories + if ($conf->categorie->enabled) { + print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; + print $form->showCategories($object->id,'account',1); + print "</td></tr>"; + } + + print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>'; + print '<td>'.dol_htmlentitiesbr($object->comment).'</td></tr>'; + print '</table>'; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 4c2182bb1e8279ef593abb7c14ca6d945e240a71..0878474dcb58372f2a860541a5ffb82a24724f99 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 = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + - print '<table class="border"width="100%">'; - - // Ref - print '<tr><td valign="top" width="25%">' . $langs->trans("Ref") . '</td>'; - print '<td colspan="3">'; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref'); - print '</td></tr>'; - - // Label - print '<tr><td valign="top">' . $langs->trans("Label") . '</td>'; - print '<td colspan="3">' . $object->label . '</td></tr>'; - - // Status - print '<tr><td valign="top">' . $langs->trans("Status") . '</td>'; - print '<td colspan="3">' . $object->getLibStatut(4) . '</td></tr>'; - print '<tr><td>' . $langs->trans("NbOfAttachedFiles") . '</td><td colspan="3">' . count($filearray) . '</td></tr>'; + print '<div class="fichecenter">'; + print '<div class="underbanner clearboth"></div>'; + + print '<table class="border" width="100%">'; + print '<tr><td class="titlefield">' . $langs->trans("NbOfAttachedFiles") . '</td><td colspan="3">' . count($filearray) . '</td></tr>'; print '<tr><td>' . $langs->trans("TotalSizeOfAttachedFiles") . '</td><td colspan="3">' . $totalsize . ' ' . $langs->trans("bytes") . '</td></tr>'; print "</table>\n"; - print "</div>\n"; + + print '</div>'; + + 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 66aff20f40c4583d425339c56e8b6e35c692a7da..5f00a500c31f11a658b9e991c765dab657f2569a 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 '<table class="border" width="100%">'; $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>'; -// Ref -print '<tr><td width="25%">'.$langs->trans("Ref").'</td>'; -print '<td colspan="3">'; if ($account) { if (! preg_match('/,/',$account)) { $moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':''); + if ($_GET["option"]!='all') { $morehtml='<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.'&option=all'.$moreparam.'">'.$langs->trans("ShowAllAccounts").'</a>'; - print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam); } else { $morehtml='<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.$moreparam.'">'.$langs->trans("BackToAccount").'</a>'; - 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 '</td></tr>'; - -// Label -print '<tr><td>'.$langs->trans("Label").'</td>'; -print '<td colspan="3">'; -if ($account && $_GET["option"]!='all') -{ - print $acct->label; -} -else { print $langs->trans("AllAccounts"); } -print '</td></tr>'; - -print '</table>'; dol_fiche_end(); diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index b0447db68c2a920bdc31680e3cce0b919b96baf2..4b03250e76a3748b75fee45c9fd52984a951ce1c 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 */ +$form = new Form($db); +$formother = new FormOther($db); + $companystatic=new Societe($db); $bankaccountstatic=new Account($db); -llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param); +$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(); -$form = new Form($db); -$formother = new FormOther($db); - -if ($vline) $viewline = $vline; -else $viewline = 50; +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='<div data-role="fieldcontain">'; + $morehtml.= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page '; + $morehtml.='<input type="text" name="pageplusone" id="pageplusone" size="1" class="flat" value="'.($page+1).'">'; + $morehtml.='/'.$nbtotalofpages.' '; + $morehtml.='</div>'; + 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 '<tr class="liste_titre">'; 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 '<input type="text" class="flat" name="search_ref" size="4" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } + if (! empty($arrayfields['description']['checked'])) + { + print '<td class="liste_titre">'; + //print '<input type="text" class="flat" name="description" size="10" value="'.dol_escape_htmltag($description).'">'; + print '</td>'; + } if (! empty($arrayfields['b.dateo']['checked'])) { print '<td class="liste_titre"> </td>'; @@ -367,7 +418,7 @@ if ($resql) if (! empty($arrayfields['type']['checked'])) { print '<td class="liste_titre" align="center">'; - $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 '</td>'; } if (! empty($arrayfields['b.num_chq']['checked'])) @@ -375,16 +426,16 @@ if ($resql) // Numero print '<td class="liste_titre" align="center"><input type="text" class="flat" name="req_nb" value="'.dol_escape_htmltag($search_req_nb).'" size="2"></td>'; } - if (! empty($arrayfields['description']['checked'])) - { - print '<td class="liste_titre">'; - print '<input type="text" class="flat" name="description" size="10" value="'.dol_escape_htmltag($description).'">'; - print '</td>'; - } if (! empty($arrayfields['bu.label']['checked'])) { print '<td class="liste_titre"><input type="text" class="flat" name="thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'" size="10"></td>'; } + if (! empty($arrayfields['ba.ref']['checked'])) + { + print '<td align="right">'; + $form->select_comptes($account,'account',0,'',1); + print '</td>'; + } if (! empty($arrayfields['b.debit']['checked'])) { print '<td class="liste_titre" align="right">'; @@ -397,16 +448,17 @@ if ($resql) print '<input type="text" class="flat" name="credit" size="4" value="'.dol_escape_htmltag($credit).'">'; print '</td>'; } - if (! empty($arrayfields['ba.ref']['checked'])) + if (! empty($arrayfields['balance']['checked'])) { print '<td align="right">'; - $form->select_comptes($account,'account',0,'',1); + $htmltext=$langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue")); + print $form->textwithpicto('', $htmltext, 1); print '</td>'; } if (! empty($arrayfields['b.num_releve']['checked'])) { - // Numero - print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_num_releve" value="'.dol_escape_htmltag($search_num_releve).'" size="2"></td>'; + // Numero statement + print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_num_releve" value="'.dol_escape_htmltag($search_num_releve).'" size="3"></td>'; } print '<td class="liste_titre" align="middle">'; $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); @@ -415,168 +467,346 @@ if ($resql) print "</tr>\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; - - print "<tr ".$bc[$var].">"; - - // Ref - if (! empty($arrayfields['b.rowid']['checked'])) - { - print '<td align="left" class="nowrap">'; - print "<a href=\"ligne.php?rowid=".$objp->rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'payment', 'class="classfortooltip"').' '.$objp->rowid."</a> "; - print '</td>'; - if (! $i) $totalarray['nbfield']++; - } - // Date ope - if (! empty($arrayfields['b.dateo']['checked'])) - { - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->do),"day")."</td>\n"; - if (! $i) $totalarray['nbfield']++; - } - - // Date value - if (! empty($arrayfields['b.datev']['checked'])) - { - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->dv),"day")."</td>\n"; - if (! $i) $totalarray['nbfield']++; - } + else + { + $bankaccount = $cachebankaccount[$objp->bankid]; + } + + $var=!$var; - // Payment type - if (! empty($arrayfields['type']['checked'])) - { - print '<td align="center" class="nowrap">'; - $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 "</td>\n"; - if (! $i) $totalarray['nbfield']++; - } + print "<tr ".$bc[$var].">"; - // Num cheque - if (! empty($arrayfields['b.num_releve']['checked'])) - { - print '<td class="nowrap" align="center">'.($objp->num_chq?$objp->num_chq:"")."</td>\n"; - if (! $i) $totalarray['nbfield']++; - } - - // Description - if (! empty($arrayfields['description']['checked'])) - { - print "<td>"; - - print "<a href=\"ligne.php?rowid=".$objp->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 "</a> "; - - print '</td>'; - if (! $i) $totalarray['nbfield']++; - } + // Ref + if (! empty($arrayfields['b.rowid']['checked'])) + { + print '<td align="left" class="nowrap">'; + print "<a href=\"ligne.php?rowid=".$objp->rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid."</a> "; + print '</td>'; + if (! $i) $totalarray['nbfield']++; + } + + // Description + if (! empty($arrayfields['description']['checked'])) + { + print "<td>"; + + //print "<a href=\"ligne.php?rowid=".$objp->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 "</a> "; + + // 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 '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">'; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + //print $langs->trans("SocialContributionPayment"); + print '</a>'; + } + 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 '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">'; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print '</a>'; + } + elseif ($links[$key]['type']=='payment_donation') + { + print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$links[$key]['url_id'].'">'; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print '</a>'; + } + elseif ($links[$key]['type']=='payment_expensereport') + { + print '<a href="'.DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$links[$key]['url_id'].'">'; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print '</a>'; + } + 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 '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">'; + 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 '</a>'; + } + } + + print '</td>'; + if (! $i) $totalarray['nbfield']++; + } + + // Date ope + if (! empty($arrayfields['b.dateo']['checked'])) + { + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->do),"day")."</td>\n"; + if (! $i) $totalarray['nbfield']++; + } - // Third party - if (! empty($arrayfields['bu.label']['checked'])) - { - print "<td>"; - 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 '</td>'; + // Date value + if (! empty($arrayfields['b.datev']['checked'])) + { + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->dv),"day")."</td>\n"; if (! $i) $totalarray['nbfield']++; - } - - // Debit - if (! empty($arrayfields['b.debit']['checked'])) + } + + // Payment type + if (! empty($arrayfields['type']['checked'])) + { + print '<td align="center" class="nowrap">'; + $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 "</td>\n"; + if (! $i) $totalarray['nbfield']++; + } + + // Num cheque + if (! empty($arrayfields['b.num_releve']['checked'])) + { + print '<td class="nowrap" align="center">'.($objp->num_chq?$objp->num_chq:"")."</td>\n"; + if (! $i) $totalarray['nbfield']++; + } + + // Third party + if (! empty($arrayfields['bu.label']['checked'])) + { + print "<td>"; + 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 '</td>'; + if (! $i) $totalarray['nbfield']++; + } + + // Bank account + if (! empty($arrayfields['ba.ref']['checked'])) + { + print '<td align="right" class="nowrap">'; + print $bankaccount->getNomUrl(1); + print "</td>\n"; + if (! $i) $totalarray['nbfield']++; + } + + // Debit + if (! empty($arrayfields['b.debit']['checked'])) + { + print '<td align="right">'; + if ($objp->amount < 0) + { + print price($objp->amount * -1); + $totalarray['totaldeb'] += $objp->amount; + } + print "</td>\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield']; + } + // Credit + if (! empty($arrayfields['b.credit']['checked'])) + { + print '<td align="right">'; + if ($objp->amount > 0) + { + print price($objp->amount); + $totalarray['totalcred'] += $objp->amount; + } + print "</td>\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield']; + } + + // Balance + if (! empty($arrayfields['balance']['checked'])) + { + if ($mode_balance_ok) { - print '<td align="right">'; - if ($objp->amount < 0) + if ($total >= 0) { - print price($objp->amount * -1); - $totalarray['totaldeb'] += $objp->amount; + print '<td align="right" class="nowrap"> '.price($total).'</td>'; } - print "</td>\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield']; - } - // Credit - if (! empty($arrayfields['b.credit']['checked'])) - { - print '<td align="right">'; - if ($objp->amount > 0) + else { - print price($objp->amount); - $totalarray['totalcred'] += $objp->amount; + print '<td align="right" class="error nowrap"> '.price($total).'</td>'; } - print "</td>\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield']; } - - // Bank account - if (! empty($arrayfields['ba.ref']['checked'])) + else { - print '<td align="right" class="nowrap">'; - $bankaccountstatic->id=$objp->bankid; - $bankaccountstatic->label=$objp->bankref; - print $bankaccountstatic->getNomUrl(1); - print "</td>\n"; - if (! $i) $totalarray['nbfield']++; - } - - if (! empty($arrayfields['b.num_releve']['checked'])) - { - print '<td class="nowrap" align="center">'.($objp->num_releve?$objp->num_releve:"")."</td>\n"; - if (! $i) $totalarray['nbfield']++; + print '<td align="right">-</td>'; } - - // Action column - print '<td class="nowrap" align="center">'; - 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 '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; - } - print '</td>'; - if (! $i) $totalarray['nbfield']++; - - print "</tr>"; - } + } + + // Transaction reconciliated or edit link + if ($objp->rappro && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated + { + print '<td align="center" class="nowrap">'; + print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&account='.$object->id.'&page='.$page.'">'; + print img_edit(); + print '</a>'; + print " "; + print '<a href="releve.php?num='.$objp->num_releve.'&account='.$object->id.'">'.$objp->num_releve.'</a>'; + print "</td>"; + } + else + { + print '<td align="center">'; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&account='.$object->id.'&page='.$page.'">'; + print img_edit(); + print '</a>'; + } + else + { + print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&account='.$object->id.'&page='.$page.'">'; + print img_view(); + print '</a>'; + } + 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 '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&rowid='.$objp->rowid.'&id='.$object->id.'&page='.$page.'">'; + print img_delete(); + print '</a>'; + } + print '</td>'; + } + + // Action column + print '<td class="nowrap" align="center">'; + 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 '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + } + print '</td>'; + if (! $i) $totalarray['nbfield']++; + + print "</tr>"; + $i++; } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 2b3593cd5bdff5b7e27f7432fd061b6748088817..3de977f29cf82e3252f730025845862bb72df272 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 '<table class="border" width="100%">'; $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>'; - // Ref - print '<tr><td width="25%">'.$langs->trans("Ref").'</td>'; - print '<td colspan="3">'; - print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref'); - print '</td></tr>'; - - // Label - print '<tr><td>'.$langs->trans("Label").'</td>'; - print '<td colspan="3">'.$acct->label.'</td></tr>'; - - print '</table>'; + 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 '<tr class="liste_total">'; - print '<td align="left" colspan="5">'.$langs->trans("FutureBalance").' ('.$acct->currency_code.')</td>'; - print '<td align="right" class="nowrap">'.price($solde, 0, $langs, 0, 0, -1, $acct->currency_code).'</td>'; + print '<td align="left" colspan="5">'.$langs->trans("FutureBalance").' ('.$object->currency_code.')</td>'; + print '<td align="right" class="nowrap">'.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).'</td>'; print '</tr>'; print "</table>"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ceac1fc4b44ef1f00a9c1688e81f67448cc4b4b1..b5d9ead05e36b1b8a4c8371d3dccbe3bc29c9274 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 '<select id="select'.$htmlname.'" class="flat selectpaymenttypes" name="'.$htmlname.'">'; + print '<select id="select'.$htmlname.'" class="flat selectpaymenttypes'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">'; if ($empty) print '<option value=""> </option>'; foreach($this->cache_types_paiements as $id => $arraytypes) { diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c6f56630745bfc473e49b5783bdebbd45790b7a8..bd410e7b7264337fbe1cf4a75f0a1a8286195785 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -86,6 +86,7 @@ Refund=Refund SocialContributionsPayments=Social/fiscal taxes payments ShowVatPayment=Show VAT payment TotalToPay=Total to pay +BalanceVisibilityDependsOnSortAndFilters=Balance is visible in this list only if table is sorted ascending on %s and filtered for 1 bank account CustomerAccountancyCode=Customer accountancy code SupplierAccountancyCode=Supplier accountancy code CustomerAccountancyCodeShort=Cust. account. code diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index ee60baaa39517e9aa43885956074a19be92b6965..1d8ac3ff98a668afc0d4344416612dd51826ba18 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1904,7 +1904,11 @@ class Societe extends CommonObject $label.= '<br><b>' . $langs->trans('CustomerCode') . ':</b> '. $this->code_client; if (! empty($this->code_fournisseur) && $this->fournisseur) $label.= '<br><b>' . $langs->trans('SupplierCode') . ':</b> '. $this->code_fournisseur; - + if (! empty($conf->accounting->enabled) && $this->client) + $label.= '<br><b>' . $langs->trans('CustomerAccountancyCode') . ':</b> '. $this->code_compta_client; + if (! empty($conf->accounting->enabled) && $this->fournisseur) + $label.= '<br><b>' . $langs->trans('SupplierAccountancyCode') . ':</b> '. $this->code_compta_fournisseur; + if (! empty($this->logo)) { $label.= '</br><div class="photointooltip">';