diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index 6d7dfd5305e..5b47c933ae6 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * * This program is free software; you can redistribute it and/or modify @@ -17,15 +17,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/account.class.php \ingroup banque \brief Fichier de la classe des comptes bancaires - \version $Revision$ + \version $Id$ */ require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php"); @@ -164,16 +162,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 operation \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 User that create \param $emetteur Nom emetteur \param $banque Banque emettrice - \return int Rowid de l'entr�e ajout�e, <0 si erreur + \return int Rowid of added entry, <0 si erreur */ function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user, $emetteur='',$banque='') { @@ -257,8 +255,9 @@ class Account extends CommonObject } else { + $this->error=$this->db->lasterror(); + dolibarr_syslog("Account::addline ".$this->error, LOG_ERR); $this->db->rollback(); - $this->error=$this->db->error(); return -2; } } diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 1658441b977..2c1434879cb 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -76,10 +76,11 @@ if ($action == 'add_paiement') } } + // Effectue les vérifications des parametres if ($_POST['paiementid'] <= 0) { - $fiche_erreur_message = '
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('PaymentMode')).'
'; + $mesg = '
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('PaymentMode')).'
'; $error++; } @@ -89,7 +90,7 @@ if ($action == 'add_paiement') // d'un paiement if (! $_POST['accountid']) { - $fiche_erreur_message = '
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'
'; + $mesg = '
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'
'; $error++; } } @@ -98,7 +99,7 @@ if ($action == 'add_paiement') \TODO A activer qd gestion avoir active et que creation facture fournisseur negative interdit if ($total <= 0) { - $fiche_erreur_message = '
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Amount')).'
'; + $mesg = '
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Amount')).'
'; $error++; } */ @@ -110,7 +111,7 @@ if ($action == 'add_paiement') // Creation de la ligne paiement $paiement = new PaiementFourn($db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Tableau de montant + $paiement->amounts = $amounts; // Array of amounts $paiement->paiementid = $_POST['paiementid']; $paiement->num_paiement = $_POST['num_paiement']; $paiement->note = $_POST['comment']; @@ -149,7 +150,7 @@ if ($action == 'add_paiement') DOL_URL_ROOT.'/fourn/paiement/fiche.php?id=', '(paiement)', 'payment_supplier'); - $acc->add_url_line($bank_line_id, + $acc->add_url_line($bank_line_id, $fac->fournisseur->id, DOL_URL_ROOT.'/fourn/fiche.php?socid=', $fac->fournisseur->nom, @@ -164,7 +165,7 @@ if ($action == 'add_paiement') } else { - $fiche_erreur_message = '
'.$langs->trans("Error").'
'; + $mesg = '
'.$langs->trans($paiement->error).'
'; $error++; } @@ -190,9 +191,9 @@ llxHeader(); $html=new Form($db); -if ($fiche_erreur_message) +if ($mesg) { - print ''.$fiche_erreur_message.''; + print ''.$mesg.''; } if ($action == 'create' || $action == 'add_paiement') diff --git a/htdocs/fourn/facture/paiementfourn.class.php b/htdocs/fourn/facture/paiementfourn.class.php index a3bd5c2868f..1234817cde8 100644 --- a/htdocs/fourn/facture/paiementfourn.class.php +++ b/htdocs/fourn/facture/paiementfourn.class.php @@ -65,8 +65,8 @@ class PaiementFourn } /** - * \brief R�cup�re l'objet paiement - * \param id id du paiement a r�cup�rer + * \brief Load payment object + * \param id id paiement to get * \return int <0 si ko, >0 si ok */ function fetch($id) @@ -112,7 +112,7 @@ class PaiementFourn } /** - * \brief Creta payment in database + * \brief Create payment in database * \param user Object of creating user * \return int id of created payment, < 0 if error */ @@ -132,14 +132,18 @@ class PaiementFourn $this->total += $val; } $this->total = price2num($this->total); - + $this->db->begin(); - if ($this->total <> 0) // On accepte les montants n�gatifs + if ($this->total <> 0) // On accepte les montants negatifs { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author)'; - $sql .= ' VALUES (now(), '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn ('; + $sql.= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; + $sql.= ' VALUES (now(),'; + $sql.= ' '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.', 0)'; + + dolibarr_syslog("PaiementFourn::create sql=".$sql); $resql = $this->db->query($sql); if ($resql) { @@ -162,7 +166,7 @@ class PaiementFourn } else { - dolibarr_syslog('PaiementFourn::Create Montant non num�rique'); + dolibarr_syslog('PaiementFourn::Create Montant non numerique',LOG_ERR); } } @@ -178,12 +182,19 @@ class PaiementFourn } else { - dolibarr_syslog('PaiementFourn::Create Erreur INSERT dans paiementfourn'); + $this->error=$this->db->lasterror(); + dolibarr_syslog('PaiementFourn::Create Error '.$this->error, LOG_ERR); $error++; } } + else + { + $this->error="ErrorTotalIsNull"; + dolibarr_syslog('PaiementFourn::Create Error '.$this->error, LOG_ERR); + $error++; + } - if ( $this->total <> 0 && $error == 0 ) // On accepte les montants n�gatifs + if ($this->total <> 0 && $error == 0) // On accepte les montants negatifs { $this->db->commit(); dolibarr_syslog('PaiementFourn::Create Ok Total = '.$this->total); @@ -192,7 +203,6 @@ class PaiementFourn else { $this->db->rollback(); - dolibarr_syslog('PaiementFourn::Create Erreur'); return -1; } } diff --git a/mysql/migration/2.2.0-2.4.0.sql b/mysql/migration/2.2.0-2.4.0.sql index effdc12bf6f..b75fb213688 100644 --- a/mysql/migration/2.2.0-2.4.0.sql +++ b/mysql/migration/2.2.0-2.4.0.sql @@ -290,5 +290,6 @@ create table llx_ecm_document private smallint DEFAULT 0 ) type=innodb; +ALTER TABLE llx_bank modify num_chq varchar(50); ALTER TABLE llx_menu_const ADD UNIQUE KEY uk_menu_const(fk_menu, fk_constraint); diff --git a/mysql/tables/llx_bank.sql b/mysql/tables/llx_bank.sql index 6faac8d8af3..647433e3f0e 100644 --- a/mysql/tables/llx_bank.sql +++ b/mysql/tables/llx_bank.sql @@ -1,6 +1,6 @@ -- =================================================================== -- Copyright (C) 2000-2006 Rodolphe Quiedeville --- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2005-2008 Laurent Destailleur -- -- 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 @@ -32,7 +32,7 @@ create table llx_bank fk_user_rappro integer, fk_type varchar(4), -- CB, Virement, cheque num_releve varchar(50), - num_chq int, + num_chq varchar(50), rappro tinyint default 0, note text, fk_bordereau integer DEFAULT 0,