From c89fd4b1e75cf66a2c8e60b282546ba23dced5f0 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Wed, 15 Feb 2012 12:16:33 +0100
Subject: [PATCH] New: Can conciliate several lines in one operation.

---
 ChangeLog                                  |   1 +
 htdocs/compta/bank/class/account.class.php | 191 +++++++++++----------
 htdocs/compta/bank/ligne.php               |  16 +-
 htdocs/compta/bank/rappro.php              | 148 ++++++++++------
 htdocs/compta/bank/releve.php              |  14 +-
 htdocs/core/ajax/bankconciliate.php        |  74 ++++++++
 htdocs/langs/fr_FR/banks.lang              |   6 +-
 htdocs/langs/fr_FR/errors.lang             |   2 +-
 htdocs/langs/fr_FR/main.lang               |   2 +-
 9 files changed, 299 insertions(+), 155 deletions(-)
 create mode 100644 htdocs/core/ajax/bankconciliate.php

diff --git a/ChangeLog b/ChangeLog
index 2a6f3dc64f8..e7f69509f37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,7 @@ For users:
 - New: Add hidden option FOURN_PRODUCT_AVAILABILITY.
 - New: task #11123: Add best supplier price.
 - New: Enhancement in styles.
+- New: Can conciliate several lines in one operation.
 - New: task #11289 : Modify third party accountancy code generator aquarium.
 - New: task #10606 : more comprehensive message error.
 - New: task #11278 : Option into point of sale module to add services in list.
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 08093a8f6fd..8b2e472b257 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -1,23 +1,23 @@
 <?php
 /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
- * Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2004      Christophe Combelles <ccomb@free.fr>
- * Copyright (C) 2005-2010 Regis Houssin        <regis@dolibarr.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+* Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
+* Copyright (C) 2004      Christophe Combelles <ccomb@free.fr>
+* Copyright (C) 2005-2010 Regis Houssin        <regis@dolibarr.fr>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
 
 /**
  *	\file       htdocs/compta/bank/class/account.class.php
@@ -189,8 +189,11 @@ class Account extends CommonObject
 
         $sql = "SELECT fk_bank, url_id, url, label, type";
         $sql.= " FROM ".MAIN_DB_PREFIX."bank_url";
-        if ($fk_bank > 0) { $sql.= " WHERE fk_bank = ".$fk_bank; }
-        else { $sql.= " WHERE url_id = ".$url_id." AND type = '".$type."'"; }
+        if ($fk_bank > 0) {
+            $sql.= " WHERE fk_bank = ".$fk_bank;
+        }
+        else { $sql.= " WHERE url_id = ".$url_id." AND type = '".$type."'";
+        }
         $sql.= " ORDER BY type, label";
 
         dol_syslog(get_class($this)."::get_url sql=".$sql);
@@ -581,8 +584,8 @@ class Account extends CommonObject
 
         if (empty($id) && empty($ref) && empty($ref_ext))
         {
-        	$this->error="ErrorBadParameters";
-        	return -1;
+            $this->error="ErrorBadParameters";
+            return -1;
         }
 
         $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,";
@@ -780,8 +783,9 @@ class Account extends CommonObject
 
     /**
      * 	Return current sold
-     * 	@param		option		1=Exclude future operation date (this is to exclude input made in advance and have real account sold)
-     *	@return		int			Current sold (value date <= today)
+     *
+     * 	@param	int		$option		1=Exclude future operation date (this is to exclude input made in advance and have real account sold)
+     *	@return	int					Current sold (value date <= today)
      */
     function solde($option=0)
     {
@@ -803,62 +807,12 @@ class Account extends CommonObject
         }
     }
 
-    /**
-     *	@param	rowid
-     *	@param	sign	1 or -1
-     */
-    function datev_change($rowid,$sign=1)
-    {
-        $sql = "SELECT datev FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid;
-        $resql = $this->db->query($sql);
-        if ($resql)
-        {
-        	$obj=$this->db->fetch_object($resql);
-        	$newdate=$this->db->jdate($obj->datev)+(3600*24*$sign);
-
-	    	$sql = "UPDATE ".MAIN_DB_PREFIX."bank SET ";
-	        $sql.= " datev = '".$this->db->idate($newdate)."'";
-	        $sql.= " WHERE rowid = ".$rowid;
-
-	        $result = $this->db->query($sql);
-	        if ($result)
-	        {
-	            if ($this->db->affected_rows($result))
-	            {
-	                return 1;
-	            }
-	        }
-	        else
-	        {
-	            dol_print_error($this->db);
-	            return 0;
-	        }
-        }
-        else dol_print_error($this->db);
-		return 0;
-    }
-
-    /**
-     *	@param	rowid
-     */
-    function datev_next($rowid)
-    {
-    	return $this->datev_change($rowid,1);
-    }
-
-    /**
-     *	@param	rowid
-     */
-    function datev_previous($rowid)
-    {
-    	return $this->datev_change($rowid,-1);
-    }
-
     /**
      *      Load indicators for dashboard (this->nbtodo and this->nbtodolate)
-     *      @param      user        		Objet user
-     *		@param		filteraccountid		To get info for a particular account id
-     *      @return     int         		<0 if KO, 0=Nothing to show, >0 if OK
+     *
+     *      @param	User	$user        		Objet user
+     *		@param	int		$filteraccountid	To get info for a particular account id
+     *      @return int         				<0 if KO, 0=Nothing to show, >0 if OK
      */
     function load_board($user,$filteraccountid=0)
     {
@@ -1067,16 +1021,13 @@ class AccountLine extends CommonObject
 
 
     /**
-     *  Constructeur
+     *  Constructor
+     *
+     *  @param	DoliDB	$db		Database handler
      */
-    function AccountLine($DB, $rowid=0)
+    function AccountLine($db)
     {
-        global $langs;
-
-        $this->db = $DB;
-        $this->rowid = $rowid;
-
-        return 1;
+        $this->db = $db;
     }
 
     /**
@@ -1152,6 +1103,7 @@ class AccountLine extends CommonObject
 
     /**
      *      Delete transaction bank line record
+     *
      *		@param		user	User object that delete
      *      @return		int 	<0 if KO, >0 if OK
      */
@@ -1172,7 +1124,7 @@ class AccountLine extends CommonObject
         $result=$this->delete_urls();
         if ($result < 0)
         {
-             $nbko++;
+            $nbko++;
         }
 
         $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".$this->rowid;
@@ -1200,6 +1152,7 @@ class AccountLine extends CommonObject
 
     /**
      *      Delete bank line records
+     *
      *		@param		user	User object that delete
      *      @return		int 	<0 if KO, >0 if OK
      */
@@ -1236,6 +1189,7 @@ class AccountLine extends CommonObject
 
     /**
      *		Update bank account record in database
+     *
      *		@param 		user			Object user making update
      *		@param 		notrigger		0=Disable all triggers
      *		@return		int				<0 if KO, >0 if OK
@@ -1269,6 +1223,7 @@ class AccountLine extends CommonObject
 
     /**
      *		Update conciliation field
+     *
      *		@param 		user			Objet user making update
      *		@param 		cat				Category id
      *		@return		int				<0 if KO, >0 if OK
@@ -1315,8 +1270,71 @@ class AccountLine extends CommonObject
         }
     }
 
+
+    /**
+     * 	Increase/decrease value date of a rowid
+     *
+     *	@param	int		$rowid
+     *	@param	int		sign		1 or -1
+     *	@return	int					>0 if OK, 0 if KO
+     */
+    function datev_change($rowid,$sign=1)
+    {
+        $sql = "SELECT datev FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid;
+        $resql = $this->db->query($sql);
+        if ($resql)
+        {
+            $obj=$this->db->fetch_object($resql);
+            $newdate=$this->db->jdate($obj->datev)+(3600*24*$sign);
+
+            $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET";
+            $sql.= " datev = '".$this->db->idate($newdate)."'";
+            $sql.= " WHERE rowid = ".$rowid;
+
+            $result = $this->db->query($sql);
+            if ($result)
+            {
+                if ($this->db->affected_rows($result))
+                {
+                    return 1;
+                }
+            }
+            else
+            {
+                dol_print_error($this->db);
+                return 0;
+            }
+        }
+        else dol_print_error($this->db);
+        return 0;
+    }
+
+    /**
+     * 	Increase value date of a rowid
+     *
+     *	@param	int		$rowid		Id of line to change
+     *	@return	int					>0 if OK, 0 if KO
+     */
+    function datev_next($rowid)
+    {
+        return $this->datev_change($rowid,1);
+    }
+
+    /**
+     * 	Decrease value date of a rowid
+     *
+     *	@param	int		$rowid		Id of line to change
+     *	@return	int					>0 if OK, 0 if KO
+     */
+    function datev_previous($rowid)
+    {
+        return $this->datev_change($rowid,-1);
+    }
+
+
     /**
      *      Charge les informations d'ordre info dans l'objet
+     *
      *      @param     rowid       Id of object
      */
     function info($rowid)
@@ -1361,6 +1379,7 @@ class AccountLine extends CommonObject
 
     /**
      *    	Renvoie nom clicable (avec eventuellement le picto)
+     *
      *		@param		withpicto		0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
      *		@param		maxlen			Longueur max libelle
      *		@param		option			Option ('showall')
diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php
index f124b035245..5ae6bef31bc 100644
--- a/htdocs/compta/bank/ligne.php
+++ b/htdocs/compta/bank/ligne.php
@@ -25,9 +25,9 @@
  */
 
 require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
 
-if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate)
-accessforbidden();
+if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) accessforbidden();
 
 $langs->load("banks");
 $langs->load("compta");
@@ -48,16 +48,16 @@ $form = new Form($db);
  * Actions
  */
 
-if ($user->rights->banque->consolidate && $_GET["action"] == 'dvnext')
+if ($user->rights->banque->consolidate && $action == 'dvnext')
 {
-    $ac = new Account($db);
-    $ac->datev_next($_GET["rowid"]);
+    $al = new AccountLine($db);
+    $al->datev_next($_GET["rowid"]);
 }
 
-if ($user->rights->banque->consolidate && $_GET["action"] == 'dvprev')
+if ($user->rights->banque->consolidate && $action == 'dvprev')
 {
-    $ac = new Account($db);
-    $ac->datev_previous($_GET["rowid"]);
+    $al = new AccountLine($db);
+    $al->datev_previous($_GET["rowid"]);
 }
 
 if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier)
diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php
index 0d083c0d0a2..dd7f10677c8 100644
--- a/htdocs/compta/bank/rappro.php
+++ b/htdocs/compta/bank/rappro.php
@@ -43,18 +43,6 @@ if (! $user->rights->banque->consolidate) accessforbidden();
  * Actions
  */
 
-if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $_GET["action"] == 'dvnext')
-{
-	$ac = new Account($db);
-	$ac->datev_next($_GET["rowid"]);
-}
-
-if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $_GET["action"] == 'dvprev')
-{
-	$ac = new Account($db);
-	$ac->datev_previous($_GET["rowid"]);
-}
-
 // Conciliation
 if ($user->rights->banque->consolidate && $_POST["action"] == 'rappro')
 {
@@ -64,11 +52,20 @@ if ($user->rights->banque->consolidate && $_POST["action"] == 'rappro')
     if ($num_releve)
     {
         $bankline=new AccountLine($db);
-        $result=$bankline->fetch($_POST["rowid"]);
-        $bankline->num_releve=$_POST["num_releve"];
 
-        $result=$bankline->update_conciliation($user,$_POST["cat"]);
-        if ($result < 0) $mesg=$bankline->error;
+		if (isset($_POST["rowid"]) && is_array($_POST["rowid"]))
+		{
+			foreach($_POST["rowid"] as $row)
+			{
+				if($row > 0)
+				{
+					$result=$bankline->fetch($row);
+					$bankline->num_releve=$num_releve; //$_POST["num_releve"];
+					$result=$bankline->update_conciliation($user,$_POST["cat"]);
+					if ($result < 0) $mesg.=$bankline->error;
+				}
+			}
+        }
     }
     else
     {
@@ -92,21 +89,26 @@ if ($_GET["action"] == 'del')
 }
 
 
-// Charge categories
+// Load bank groups
 $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ ORDER BY label";
 $resql = $db->query($sql);
 $options="";
-if ($resql) {
+if ($resql)
+{
     $var=True;
     $num = $db->num_rows($resql);
+    if ($num > 0) $options .= '<option value="0"'.(GETPOST('cat')?'':' selected="true"').'>&nbsp;</option>';
     $i = 0;
-    while ($i < $num) {
-        if ($options == "") { $options = "<option value=\"0\" selected=\"true\">&nbsp;</option>"; }
+    while ($i < $num)
+    {
         $obj = $db->fetch_object($resql);
-        $options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++;
+        $options .= '<option value="'.$obj->rowid.'"'.(GETPOST('cat')==$obj->rowid?' selected="true"':'').'>'.$obj->label.'</option>'."\n";
+        $i++;
     }
     $db->free($resql);
+    //print $options;
 }
+else dol_print_error($db);
 
 
 /*
@@ -135,6 +137,26 @@ $sql.= " WHERE rappro=0 AND fk_account=".$_GET["account"];
 $sql.= " ORDER BY dateo ASC";
 $sql.= " LIMIT 1000";	// Limit to avoid page overload
 
+/// ajax adjust value date
+print '
+<script type="text/javascript">
+$(function() {
+	$("a.ajax").each(function(){
+		var current = $(this);
+		current.click(function()
+		{
+			$.get("'.DOL_URL_ROOT.'/core/ajax/bankconciliate.php?"+current.attr("href").split("?")[1], function(data)
+			{
+				current.parent().prev().replaceWith(data);
+			});
+			return false;
+		});
+	});
+});
+</script>
+
+';
+
 $resql = $db->query($sql);
 if ($resql)
 {
@@ -168,7 +190,6 @@ if ($resql)
         }
         if ($numr >= $nbmax) $liste="... &nbsp; ".$liste;
         print $liste;
-
         if ($numr > 0) print '<br><br>';
         else print '<b>'.$langs->trans("None").'</b><br><br>';
     }
@@ -177,31 +198,49 @@ if ($resql)
         dol_print_error($db);
     }
 
+
+	print '<form method="post" action="rappro.php?account='.$_GET["account"].'">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print "<input type=\"hidden\" name=\"action\" value=\"rappro\">";
+	print "<input type=\"hidden\" name=\"account\" value=\"".$_GET["account"]."\">";
+
+    print $langs->trans("InputReceiptNumber").': ';
+    print '<input class="flat" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):$objp->num_releve).'" size="10">';
+    print '<br>';
+    if ($options)
+    {
+        print $langs->trans("EventualyAddCategory").': <select class="flat" name="cat">'.$options.'</select><br>';
+    }
+    print $langs->trans("ThenCheckLinesAndConciliate").' ';
+    print "<input class=\"button\" type=\"submit\" value=\"".$langs->trans("Conciliate")."\"><br>";
+
+    print '<br>';
+
     print '<table class="liste" width="100%">';
-    print "<tr class=\"liste_titre\">\n";
+    print '<tr class="liste_titre">'."\n";
     print '<td align="center">'.$langs->trans("DateOperationShort").'</td>';
     print '<td align="center">'.$langs->trans("DateValueShort").'</td>';
     print '<td>'.$langs->trans("Type").'</td>';
     print '<td>'.$langs->trans("Description").'</td>';
-    print '<td align="right" width="60" nowrap>'.$langs->trans("Debit").'</td>';
-    print '<td align="right" width="60" nowrap>'.$langs->trans("Credit").'</td>';
-    print '<td align="center" width="40">'.$langs->trans("Action").'</td>';
-    print '<td align="center">'.$langs->trans("AccountStatement").'<br>(Ex: YYYYMM)</td>';
+    print '<td align="right" width="60" nowrap="nowrap">'.$langs->trans("Debit").'</td>';
+    print '<td align="right" width="60" nowrap="nowrap">'.$langs->trans("Credit").'</td>';
+    print '<td align="center" width="80">'.$langs->trans("Action").'</td>';
+    print '<td align="center" width="60" nowrap="nowrap">'.$langs->trans("ToConciliate").'</td>';
     print "</tr>\n";
 
 
+
     $i = 0;
     while ($i < $num)
     {
         $objp = $db->fetch_object($resql);
 
         $var=!$var;
-        print "<tr $bc[$var]>";
-        print '<form method="post" action="rappro.php?account='.$_GET["account"].'">';
-        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-        print "<input type=\"hidden\" name=\"action\" value=\"rappro\">";
-        print "<input type=\"hidden\" name=\"account\" value=\"".$_GET["account"]."\">";
-        print "<input type=\"hidden\" name=\"rowid\" value=\"".$objp->rowid."\">";
+        print "<tr ".$bc[$var].">";
+//         print '<form method="post" action="rappro.php?account='.$_GET["account"].'">';
+//         print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+//         print "<input type=\"hidden\" name=\"rowid\" value=\"".$objp->rowid."\">";
 
         // Date op
         print '<td align="center" nowrap="nowrap">'.dol_print_date($db->jdate($objp->do),"day").'</td>';
@@ -210,12 +249,12 @@ if ($resql)
 		if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate))
 		{
 			print '<td align="center" nowrap="nowrap">';
-			print dol_print_date($db->jdate($objp->dv),"day");
-			print ' &nbsp; ';
-			print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$_GET["account"].'&amp;rowid='.$objp->rowid.'">';
+			print '<span id="datevalue_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->dv),"day")."</span>";
+			print ' <span>&nbsp; ';
+			print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$_GET["account"].'&amp;rowid='.$objp->rowid.'">';
 			print img_edit_remove() . "</a> ";
-			print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$_GET["account"].'&amp;rowid='.$objp->rowid.'">';
-			print img_edit_add() ."</a>";
+			print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$_GET["account"].'&amp;rowid='.$objp->rowid.'">';
+			print img_edit_add() ."</a></span>";
 			print '</td>';
 		}
 		else
@@ -362,15 +401,17 @@ if ($resql)
         // Affiche zone saisie releve + bouton "Rapprocher"
         if ($db->jdate($objp->do) <= $now)
         {
+
             print '<td align="center" nowrap="nowrap">';
-            print '<input class="flat" name="num_releve" type="text" value="'.$objp->num_releve.'" size="8">';
-            print ' &nbsp; ';
-            print "<input class=\"button\" type=\"submit\" value=\"".$langs->trans("Conciliate")."\">";
-            if ($options)
-            {
-                print "<br><select class=\"flat\" name=\"cat\">$options";
-                print "</select>";
-            }
+            print '<input class="flat" name="rowid[]" type="checkbox" value="'.$objp->rowid.'" size="1">';
+//             print '<input class="flat" name="num_releve" type="text" value="'.$objp->num_releve.'" size="8">';
+//             print ' &nbsp; ';
+//             print "<input class=\"button\" type=\"submit\" value=\"".$langs->trans("Conciliate")."\">";
+//             if ($options)
+//             {
+//                 print "<br><select class=\"flat\" name=\"cat\">$options";
+//                 print "</select>";
+//             }
             print "</td>";
         }
         else
@@ -381,23 +422,26 @@ if ($resql)
         }
 
         print "</tr>\n";
-        print "</form>\n";
+
         $i++;
     }
     $db->free($resql);
 
-    if ($num != 0)
-    {
-        print "</table><br>\n";
-    }
 
+	print "</form>\n";
+
+	if ($num != 0)
+	{
+        print "</table><br>\n";
+	}
 }
 else
 {
   dol_print_error($db);
 }
 
-$db->close();
 
 llxFooter();
+
+$db->close();
 ?>
diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php
index c36cfb0fd40..2531c7639ef 100644
--- a/htdocs/compta/bank/releve.php
+++ b/htdocs/compta/bank/releve.php
@@ -26,6 +26,8 @@
 require("./pre.inc.php");
 require_once(DOL_DOCUMENT_ROOT."/core/lib/bank.lib.php");
 
+$action=GETPOST('action');
+
 $langs->load("companies");
 $langs->load("banks");
 $langs->load("bills");
@@ -39,16 +41,16 @@ $fieldid = isset($_GET["ref"])?'ref':'rowid';
 if ($user->societe_id) $socid=$user->societe_id;
 $result=restrictedArea($user,'banque',$id,'bank_account','','',$fieldid);
 
-if ($_GET["action"] == 'dvnext')
+if ($user->rights->banque->consolidate && $action == 'dvnext')
 {
-	$ac = new Account($db);
-	$ac->datev_next($_GET["dvid"]);
+	$al = new AccountLine($db);
+	$al->datev_next($_GET["dvid"]);
 }
 
-if ($_GET["action"] == 'dvprev')
+if ($user->rights->banque->consolidate && $action == 'dvprev')
 {
-	$ac = new Account($db);
-	$ac->datev_previous($_GET["dvid"]);
+	$al = new AccountLine($db);
+	$al->datev_previous($_GET["dvid"]);
 }
 
 
diff --git a/htdocs/core/ajax/bankconciliate.php b/htdocs/core/ajax/bankconciliate.php
new file mode 100644
index 00000000000..d32dbd777fd
--- /dev/null
+++ b/htdocs/core/ajax/bankconciliate.php
@@ -0,0 +1,74 @@
+<?php
+/* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/core/ajax/bankconciliate.php
+ *       \brief      File to set data for bank concilation
+ */
+
+if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
+if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
+if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
+if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
+if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
+//if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');    // Required to knwo date format for dol_print_date
+
+require('../../main.inc.php');
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
+
+$action=GETPOST('action');
+
+
+/*
+ * View
+ */
+
+// Ajout directives pour resoudre bug IE
+//header('Cache-Control: Public, must-revalidate');
+//header('Pragma: public');
+
+//top_htmlhead("", "", 1);  // Replaced with top_httphead. An ajax page does not need html header.
+top_httphead();
+
+//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
+
+if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvnext')
+{
+	// Increase date
+	$al =new AccountLine($db);
+    $al->datev_next($_GET["rowid"]);
+    $al->fetch($_GET["rowid"]);
+
+    print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>';
+
+    exit;
+}
+
+if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev')
+{
+	// Decrease date
+	$al =new AccountLine($db);
+    $al->datev_previous($_GET["rowid"]);
+    $al->fetch($_GET["rowid"]);
+
+    print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>';
+
+    exit;
+}
+
+?>
diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang
index ee6af3267c7..b2b7d965db0 100644
--- a/htdocs/langs/fr_FR/banks.lang
+++ b/htdocs/langs/fr_FR/banks.lang
@@ -142,4 +142,8 @@ AllAccounts=Tous les comptes bancaires/caisses
 BackToAccount=Retour au compte
 ShowAllAccounts=Afficher pour tous les comptes
 FutureTransaction=Transaction future. Pas moyen de concilier.
-SelectChequeTransactionAndGenerate=Sélectionner/filtrer les chèques à inclure dans le bordereau de remise et cliquer sur "Créer".
\ No newline at end of file
+SelectChequeTransactionAndGenerate=Sélectionner/filtrer les chèques à inclure dans le bordereau de remise et cliquer sur "Créer".
+InputReceiptNumber=Saisissez le relevé bancaire concerné par le rapprochement. Utilisez une valeur numérique triable (par exemple YYYYMM)
+EventualyAddCategory=Eventuellement, saisissez une catégorie dans laquelle classer les écritures
+ToConciliate=A rapprocher ?
+ThenCheckLinesAndConciliate=Ensuite, cochez les lignes présentes sur le relevé et cliquez sur
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang
index 3d6cb1bf4dc..ac8ac411651 100644
--- a/htdocs/langs/fr_FR/errors.lang
+++ b/htdocs/langs/fr_FR/errors.lang
@@ -62,7 +62,7 @@ ErrorLDAPSetupNotComplete=Le matching Dolibarr-LDAP est incomplet.
 ErrorLDAPMakeManualTest=Un fichier .ldif a été généré dans le répertoire %s. Essayez de charger ce fichier en manuel depuis la ligne de commande pour plus de détail sur l'erreur.
 ErrorCantSaveADoneUserWithZeroPercentage=Impossible de sauver une action à l'état non commencé avec un utilisateur défini comme ayant fait l'action.
 ErrorRefAlreadyExists=La référence utilisée pour la création existe déjà
-ErrorPleaseTypeBankTransactionReportName=Veuillez saisir le nom de relevé bancaire sur lequel l'écriture est constatée (Format AAAAMM ou AAAMMJJ)
+ErrorPleaseTypeBankTransactionReportName=Veuillez saisir le nom de relevé bancaire sur lequel l'écriture est constatée (Format AAAAMM de préférence ou AAAAMMJJ)
 ErrorRecordHasChildren=Impossible de supprimer l'enregistrement car il possède des enregistrements fils.
 ErrorModuleRequireJavascript=Le javascript ne doit pas être désactivé pour que cette fonctionnalité soit utilisable. Pour activer/désactiver l'utilisation de javascript, allez dans le menu Accueil->Configuration->Affichage.
 ErrorPasswordsMustMatch=Les 2 mots de passe saisis doivent correspondre
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index 5e2187a3d09..5068d2fb7e4 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -175,7 +175,7 @@ Info=Suivi
 Family=Famille
 Description=Description
 Designation=Désignation
-Action=Evénement
+Action=Action
 Model=Modèle
 DefaultModel=Modèle par défaut
 About=À propos
-- 
GitLab