';
- //}
-
+ }
}
else
{
@@ -378,17 +463,20 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
-if ($search_ref) $sql.=natural_search("b.rowid", $search_ref);
if ($account > 0) $sql.=" AND b.fk_account = ".$account;
+// Search period criteria
+if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'";
+if (dol_strlen($search_dt_end)>0) $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'";
+// Search period criteria
+if (dol_strlen($search_dv_start)>0) $sql .= " AND b.datev >= '" . $db->idate($search_dv_start) . "'";
+if (dol_strlen($search_dv_end)>0) $sql .= " AND b.datev <= '" . $db->idate($search_dv_end) . "'";
+if ($search_ref) $sql.=natural_search("b.rowid", $search_ref);
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.= 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
-if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'";
-if (dol_strlen($search_dt_end)>0) $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'";
// Search criteria amount
$debit = price2num(str_replace('-','',$debit));
$credit = price2num(str_replace('-','',$credit));
@@ -415,7 +503,8 @@ $sql.=$hookmanager->resPrint;
$sql.= $db->order($sortfield,$sortorder);
$nbtotalofrecords = 0;
-if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST) || ! empty($arrayfields['balance']['checked']))
+$nbtotalofpages = 0;
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
@@ -431,21 +520,12 @@ if (($id > 0 || ! empty($ref)) && GETPOST("page",'int') === '')
if ($page < 0) $page = 0;
}
-// Calculate balance start
-$balance = 0; // For balance
-if (! empty($arrayfields['balance']['checked']))
-{
- //Loop on each record
- $sign = 1;
- $i = 0;
- while ($i < $offset)
- {
- $objp = $db->fetch_object($result);
- $balance = price2num($balance + ($sign * $objp->amount),'MT');
- $i++;
- }
-}
-
+if (! empty($search_ref)) $mode_balance_ok=false;
+if (! empty($req_nb)) $mode_balance_ok=false;
+if (! empty($type)) $mode_balance_ok=false;
+if (! empty($debit)) $mode_balance_ok=false;
+if (! empty($credit)) $mode_balance_ok=false;
+if (! empty($thirdparty)) $mode_balance_ok=false;
$sql.= $db->plimit($limit+1,$offset);
@@ -458,32 +538,6 @@ if ($resql)
$arrayofselected=is_array($toselect)?$toselect:array();
- $param='';
- if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
- if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
- if ($id > 0) $param.='&id='.urlencode($id);
- if (!empty($ref)) $param.='&ref='.urlencode($ref);
- if (!empty($search_ref)) $param.='&search_ref='.urlencode($search_ref);
- if (!empty($description)) $param.='&description='.urlencode($description);
- if (!empty($type)) $param.='&type='.urlencode($type);
- if (!empty($debit)) $param.='&debit='.$debit;
- if (!empty($credit)) $param.='&credit='.$credit;
- if (!empty($account)) $param.='&account='.$account;
- if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve);
- if (!empty($bid)) $param.='&bid='.$bid;
- if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int');
- if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int');
- if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb);
- if (GETPOST("thirdparty")) $param.='&thirdparty='.urlencode(GETPOST("thirdparty"));
- if ($optioncss != '') $param.='&optioncss='.$optioncss;
- // Add $param from extra fields
- foreach ($search_array_options as $key => $val)
- {
- $crit=$val;
- $tmpkey=preg_replace('/search_options_/','',$key);
- if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
- }
-
// List of mass actions available
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
@@ -507,7 +561,7 @@ if ($resql)
if ($optioncss != '') print '';
print '';
print '';
- print '';
+ print '';
print '';
print '';
print '';
@@ -515,7 +569,62 @@ if ($resql)
print '';
if (! empty($_REQUEST['bid'])) print '';
-
+ // Form to reconcile
+ if ($user->rights->banque->consolidate && $action == 'reconcile')
+ {
+// print '
';
+// print '
';
+// print '
';
+ print '
';
+ print ''.$langs->trans("InputReceiptNumber").': ';
+ print ''; // The only default value is value we just entered
+ print '
';
+ if ($options) {
+ print $langs->trans("EventualyAddCategory").': ';
+ print Form::selectarray('cat', $options, GETPOST('cat'), 1);
+ }
+ print ' '.$langs->trans("ThenCheckLinesAndConciliate").' ';
+ print '';
+ print ' '.$langs->trans("or").' ';
+ print '';
+
+ // Show last bank statements
+ $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year)
+ $liste="";
+ $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
+ $sql.= " WHERE fk_account=".$id." AND num_releve IS NOT NULL";
+ $sql.= $db->order("num_releve","DESC");
+ $sql.= $db->plimit($nbmax+1);
+ print '
';
+ }
+
// Form to add a transaction with no invoice
if ($user->rights->banque->modifier && $action == 'addline')
{
@@ -533,9 +642,9 @@ if ($resql)
print '
';
$parameters=array();
@@ -643,6 +780,7 @@ if ($resql)
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
+ print_liste_field_titre('', $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print "
\n";
@@ -650,7 +788,7 @@ if ($resql)
if (! empty($arrayfields['b.rowid']['checked']))
{
print '
';
- print '';
+ print '';
print '
';
}
if (! empty($arrayfields['description']['checked']))
@@ -712,13 +850,18 @@ if ($resql)
// Numero statement
print '
';
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index ac5430c74be..f786158ccbe 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -1535,7 +1535,7 @@ class AccountLine extends CommonObject
var $fk_user_rappro;
var $fk_type;
var $rappro; // Is it conciliated
- var $num_releve; // If conciliated, what is bank receipt
+ var $num_releve; // If conciliated, what is bank statement
var $num_chq; // Num of cheque
var $bank_chq; // Bank of cheque
var $fk_bordereau; // Id of cheque receipt
@@ -1805,8 +1805,20 @@ class AccountLine extends CommonObject
*/
function update_conciliation(User $user, $cat)
{
+ global $conf;
+
$this->db->begin();
+ // Check statement field
+ if (! empty($conf->global->BANK_STATEMENT_REGEX_RULE))
+ {
+ if (! preg_match('/'.$conf->global->BANK_STATEMENT_REGEX_RULE.'/', $this->num_releve))
+ {
+ $this->errors[]=$langs->trans("ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE);
+ return -1;
+ }
+ }
+
$sql = "UPDATE ".MAIN_DB_PREFIX."bank SET";
$sql.= " rappro = 1";
$sql.= ", num_releve = '".$this->num_releve."'";
diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php
index e3ef2ea5a57..f266c0a7723 100644
--- a/htdocs/compta/bank/rappro.php
+++ b/htdocs/compta/bank/rappro.php
@@ -184,7 +184,7 @@ if ($resql)
print load_fiche_titre($langs->trans("Reconciliation").': '.$acct->label.'', '', 'title_bank.png');
print ' ';
- // Show last bank receipts
+ // Show last bank statements
$nbmax=15; // We accept to show last 15 receipts (so we can have more than one year)
$liste="";
$sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php
index 06c213485f8..0acaecb875e 100644
--- a/htdocs/compta/bank/releve.php
+++ b/htdocs/compta/bank/releve.php
@@ -21,7 +21,7 @@
/**
* \file htdocs/compta/bank/releve.php
* \ingroup banque
- * \brief Page to show a bank receipt report
+ * \brief Page to show a bank statement report
*/
require('../../main.inc.php');
@@ -275,7 +275,7 @@ else
$mesprevnext.='