From fc01bfe0e351df0be273de82fe07caf719c275d3 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Mon, 3 Mar 2008 00:05:30 +0000
Subject: [PATCH] Fix: Save of conciliate account option

---
 htdocs/compta/bank/account.class.php | 50 ++++++++++++++--------------
 htdocs/compta/bank/fiche.php         | 16 ++++-----
 2 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php
index d540ad4d16f..f431a067524 100644
--- a/htdocs/compta/bank/account.class.php
+++ b/htdocs/compta/bank/account.class.php
@@ -103,7 +103,7 @@ class Account extends CommonObject
      *      \param      line_id     Id ecriture bancaire
      *      \param      url_id      Id parametre url
      *      \param      url         Url
-     *      \param      label       Libell� du lien
+     *      \param      label       Libell� du lien
      *      \param      type        Type de lien (payment, company, member, ...)
      *      \return     int         <0 si ko, id line si ok
      */
@@ -127,7 +127,7 @@ class Account extends CommonObject
 
     /**
      *      \brief      Renvoi tableau des liens
-     *      \param      line_id         Id ligne �criture
+     *      \param      line_id         Id ligne �criture
      *      \retuen     array           Tableau des liens
      */
     function get_url($line_id)
@@ -146,7 +146,7 @@ class Account extends CommonObject
             while ($i < $num)
             {
                 $obj = $this->db->fetch_object($result);
-                // Anciens liens (pour compatibilit�)
+                // Anciens liens (pour compatibilit�)
                 $lines[$i][0] = $obj->url;
                 $lines[$i][1] = $obj->url_id;
                 $lines[$i][2] = $obj->label;
@@ -164,16 +164,16 @@ class Account extends CommonObject
 
 	/**
 		\brief     	Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
-		\param		$date			Date TMS op�ration
+		\param		$date			Date TMS op�ration
 		\param		$oper			1,2,3,4...
 		\param		$label			Descripton
 		\param		$amount			Montant
 		\param		$num_chq		Numero cheque ou virement
 		\param		$categorie		Categorie optionnelle
-		\param		$user			Utilisateur qui cr�e
+		\param		$user			Utilisateur qui cr�e
 		\param		$emetteur		Nom emetteur
 		\param		$banque			Banque emettrice
-		\return		int				Rowid de l'entr�e ajout�e, <0 si erreur
+		\return		int				Rowid de l'entr�e ajout�e, <0 si erreur
 	*/
 	function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user, $emetteur='',$banque='')
 	{
@@ -279,7 +279,7 @@ class Account extends CommonObject
         require_once DOL_DOCUMENT_ROOT.'/lib/bank.lib.php';
 
         if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) {
-            $this->error="Le contr�le de la cl� indique que les informations de votre compte bancaire sont incorrectes.";
+            $this->error="Le controle de la cle indique que les informations de votre compte bancaire sont incorrectes.";
             return 0;
         }
 
@@ -290,14 +290,14 @@ class Account extends CommonObject
         }
 
         $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account (";
-        $sql.= "datec, ref, label, account_number, currency_code,";
-        $sql.= "min_allowed, min_desired,";
+        $sql.= "datec, ref, label, account_number, currency_code, ";
+        $sql.= "rappro, min_allowed, min_desired, ";
         $sql.= "comment";
         $sql.= ") values (";
-        $sql.= "now(),'" . addslashes($this->ref) . "', '" . addslashes($this->label) . "',";
-        $sql.= "'".addslashes($this->account_number) . "','".$this->currency_code."',";
-        $sql.= "min_allowed=".price2num($this->min_allowed).",min_desired=".price2num($this->min_desired).",";
-        $sql.= "comment='".addslashes($this->comment)."'";
+        $sql.= "now(),'" . addslashes($this->ref) . "', '" . addslashes($this->label) . "', ";
+        $sql.= "'".addslashes($this->account_number) . "', '".$this->currency_code."', ";
+        $sql.= $this->rappro.", ".price2num($this->min_allowed).", ".price2num($this->min_desired).", ";
+        $sql.= "'".addslashes($this->comment)."'";
         $sql.= ")";
 
 		dolibarr_syslog("Account::create sql=".$sql);
@@ -400,7 +400,7 @@ class Account extends CommonObject
 
         // Verification parametres
         if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) {
-            $this->error="Le contr�le de la cl� indique que les informations de votre compte bancaire sont incorrectes.";
+            $this->error="Le contr�le de la cl� indique que les informations de votre compte bancaire sont incorrectes.";
             return 0;
         }
 
@@ -441,8 +441,8 @@ class Account extends CommonObject
     
     /*
      *      \brief      Charge un compte en memoire depuis la base
-     *      \param      id      Id du compte � r�cup�rer
-     *      \param      ref     Ref du compte � r�cup�rer
+     *      \param      id      Id du compte � r�cup�rer
+     *      \param      ref     Ref du compte � r�cup�rer
      */
     function fetch($id,$ref='')
     {
@@ -527,8 +527,8 @@ class Account extends CommonObject
 
 
 	/**
-	 *    \brief      Retourne le libell� du statut d'une facture (brouillon, valid�e, abandonn�e, pay�e)
-	 *    \param      mode          0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long
+	 *    \brief      Retourne le libell� du statut d'une facture (brouillon, valid�e, abandonn�e, pay�e)
+	 *    \param      mode          0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long
 	 *    \return     string        Libelle
 	 */
 	function getLibStatut($mode=0)
@@ -537,10 +537,10 @@ class Account extends CommonObject
 	}
 
 	/**
-	 *    	\brief      Renvoi le libell� d'un statut donn�
+	 *    	\brief      Renvoi le libell� d'un statut donn�
 	 *    	\param      statut        	Id statut
-	 *    	\param      mode          	0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long, 5=Libell� court + Picto
-	 *    	\return     string        	Libell� du statut
+	 *    	\param      mode          	0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long, 5=Libell� court + Picto
+	 *    	\return     string        	Libell� du statut
 	 */
 	function LibStatut($statut,$mode=0)
 	{
@@ -582,7 +582,7 @@ class Account extends CommonObject
 	
 	/*
      *    \brief      Renvoi si un compte peut etre supprimer ou non (sans mouvements)
-     *    \return     boolean     vrai si peut etre supprim�, faux sinon
+     *    \return     boolean     vrai si peut etre supprim�, faux sinon
      */
     function can_be_deleted()
     {
@@ -779,7 +779,7 @@ class AccountLine
 
     /**
      *      \brief      Charge en memoire depuis la base, une ecriture sur le compte
-     *      \param      id      Id de la ligne �criture � r�cup�rer
+     *      \param      id      Id de la ligne �criture � r�cup�rer
 	 *		\return		int		<0 if KO, >0 if OK
      */
     function fetch($rowid)
@@ -839,7 +839,7 @@ class AccountLine
         
 		if ($this->rappro)
 		{
-			// Protection pour eviter tout suppression d'une ligne consolid�e
+			// Protection pour eviter tout suppression d'une ligne consolid�e
 			$this->error="DeleteNotPossibleLineIsConsolidated";
 			return -1;
 		}
@@ -940,7 +940,7 @@ class AccountLine
 				}
 
 				$this->date_creation     = $obj->datec;
-				//$this->date_rappro       = $obj->daterappro;    // \todo pas encore g�r�e
+				//$this->date_rappro       = $obj->daterappro;    // \todo pas encore g�r�e
 			}
 			$this->db->free($result);
 		}
diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php
index c6ffdcacea8..6dc4a3a9e01 100644
--- a/htdocs/compta/bank/fiche.php
+++ b/htdocs/compta/bank/fiche.php
@@ -16,15 +16,13 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
  */
 
 /**
 	    \file       htdocs/compta/bank/fiche.php
         \ingroup    banque
-		\brief      Fiche cr�ation compte bancaire
-		\version    $Revision$
+		\brief      Fiche creation compte bancaire
+		\version    $Id$
 */
 
 require("./pre.inc.php");
@@ -48,7 +46,7 @@ if ($_POST["action"] == 'add')
     $account->label         = trim($_POST["label"]);
     $account->courant       = $_POST["type"];
     $account->clos          = $_POST["clos"];
-    $account->rappro        = $_POST["norappro"]?1:0;
+    $account->rappro        = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
     $account->url           = $_POST["url"];
     
     $account->account_number  = trim($_POST["account_number"]);
@@ -90,7 +88,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
     $account->label           = trim($_POST["label"]);
     $account->courant         = $_POST["type"];
     $account->clos            = $_POST["clos"];
-    $account->rappro          = (isset($_POST["norappro"]) && $_POST["norappro"]=='on')?0:1;
+    $account->rappro          = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
     $account->url             = trim($_POST["url"]);
 
     $account->bank            = trim($_POST["bank"]);
@@ -150,7 +148,7 @@ $form = new Form($db);
 
 /* ************************************************************************** */
 /*                                                                            */
-/* Affichage page en mode cr�ation                                            */
+/* Affichage page en mode cr�ation                                            */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -217,7 +215,7 @@ if ($_GET["action"] == 'create')
 	// Comment
 	print '<tr><td valign="top">'.$langs->trans("Comment").'</td>';
 	print '<td colspan="3">';
-   // �diteur wysiwyg
+   // �diteur wysiwyg
 	if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING)
 	{
 		require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
@@ -456,7 +454,7 @@ else
 		// Comment
 		print '<tr><td valign="top">'.$langs->trans("Comment").'</td>';
 		print '<td colspan="3">';
-	   // �diteur wysiwyg
+	   // �diteur wysiwyg
 		if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING)
 		{
 			require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
-- 
GitLab