diff --git a/ChangeLog b/ChangeLog index c5d08add8f0..ad388c36239 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ For users: - Can add contacts to a supplier invoice. - Fixed: When an invoice is changed back to status draft, warehouse is increased back. +- Fixed: Category of a bank transaction was not saved. For translators: - Added ca_ES language files diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index 00a201aef66..a4bac6c2f0a 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -789,16 +789,21 @@ class AccountLine var $error; var $db; - var $rowid; - var $rappro; + var $id; + var $ref; var $datec; var $dateo; var $datev; var $amount; var $label; - var $note; var $fk_account; - + var $note; + var $fk_user_author; + var $fk_user_rappro; + var $num_releve; + var $num_chq; + var $rappro; + var $bank_account_label; @@ -837,6 +842,7 @@ class AccountLine { $obj = $this->db->fetch_object($result); + $this->id = $rowid; $this->rowid = $rowid; $this->ref = $rowid; @@ -932,7 +938,7 @@ class AccountLine $sql.= " dateo='".$this->db->idate($this->dateo)."'"; $sql.= " WHERE rowid = ".$this->rowid; - dolibarr_syslog("AccountLine::update sql=".$sql); + dol_syslog("AccountLine::update sql=".$sql); $resql = $this->db->query($sql); if ($resql) { @@ -943,12 +949,54 @@ class AccountLine { $this->db->rollback(); $this->error=$this->db->error(); - dolibarr_syslog("AccountLine::update ".$this->error); + dol_syslog("AccountLine::update ".$this->error); return -1; } } + /** + * \brief Update conciliation field + * \param user Objet user making update + * \param cat Category id + * \param int <0 if KO, >0 if OK + */ + function update_conciliation($user,$cat) + { + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " set rappro=1, num_releve='".$this->num_releve."',"; + $sql.= " fk_user_rappro=".$user->id; + $sql.= " WHERE rowid=".$this->id; + + dol_syslog("AccountLine::update_conciliation sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (! empty($cat)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ)"; + $sql.= " VALUES (".$this->id.", ".$cat.")"; + + dol_syslog("AccountLine::update_conciliation sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + + // No error check. Can fail if category already affected + } + + $bankline->rappro=1; + + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + /** * \brief Charge les informations d'ordre info dans l'objet facture * \param id Id de la facture a charger diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index edb30d8cbef..7754e26b9be 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Xavier DUTOIT - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * * This program is free software; you can redistribute it and/or modify @@ -22,7 +22,7 @@ /** * \file htdocs/compta/bank/ligne.php * \ingroup compta - * \brief Page edition d'une ecriture bancaire + * \brief Page to edit a bank transaction record * \version $Id$ */ @@ -136,7 +136,7 @@ if ($_POST["action"] == 'emetteur') $result = $db->query($sql); } -if ($_POST["action"] == 'num_releve') +if ($user->rights->banque->consolidate && $_POST["action"] == 'num_releve') { $db->begin(); @@ -147,6 +147,7 @@ if ($_POST["action"] == 'num_releve') if (! $num_rel) $sql.= ", rappro = 0"; $sql.= " WHERE rowid = ".$rowid; + dol_syslog("ligne.php sql=".$sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index a485f19038f..3f3f19d6e45 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2009 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 @@ -18,11 +18,11 @@ */ /** - \file htdocs/compta/bank/rappro.php - \ingroup banque - \brief Page de rapprochement bancaire - \version $Id$ -*/ + * \file htdocs/compta/bank/rappro.php + * \ingroup banque + * \brief Page de rapprochement bancaire + * \version $Id$ + */ require("./pre.inc.php"); @@ -53,50 +53,21 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $ if ($user->rights->banque->consolidate && $_POST["action"] == 'rappro') { // Definition, nettoyage parametres - $valrappro=1; $num_releve=trim($_POST["num_releve"]); if ($num_releve) { - $db->begin(); + $bankline=new AccountLine($db); + $result=$bankline->fetch($_POST["rowid"]); + $bankline->num_releve=$_POST["num_releve"]; - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " set rappro=".$valrappro.", num_releve='".$_POST["num_releve"]."',"; - $sql.= " fk_user_rappro=".$user->id; - $sql.= " WHERE rowid=".$_POST["rowid"]; - - $resql = $db->query($sql); - if ($resql) - { - if ($cat1 && $_POST["action"]) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ)"; - $sql.= " VALUES ($rowid, $cat1)"; - $resql = $db->query($sql); - - if ($resql) - { - $db->commit(); - } - else - { - $db->rollback(); - dolibarr_print_error($db); - } - } - else - { - $db->commit(); - } - } - else - { - $db->rollback(); - dolibarr_print_error($db); - } + $result=$bankline->update_conciliation($user,$_POST["cat"]); + if ($result < 0) $mesg=$bankline->error; } - else { - $msg="Erreur: Saisissez le relevé qui référence la transaction pour la rapprocher."; + else + { + $langs->load("errors"); + $mesg='
'.$langs->trans("ErrorPleaseTypeBankTransactionReportName").'
'; } } @@ -135,6 +106,7 @@ if ($resql) { /* * View */ + $form=new Form($db); llxHeader(); @@ -157,9 +129,7 @@ if ($resql) print_titre($langs->trans("Reconciliation").': '.$acct->label.''); print '
'; - if ($msg) { - print "$msg

"; - } + if ($mesg) print $mesg."
"; // Affiche nom des derniers relevés $nbmax=5; @@ -183,7 +153,7 @@ if ($resql) $liste=''.$objr->num_releve.'   '.$liste; } if ($num >= $nbmax) $liste="...   ".$liste; - print "$liste"; + print $liste; if ($num > 0) print '

'; else print $langs->trans("None").'

'; } @@ -365,15 +335,15 @@ if ($resql) // Affiche zone saisie relevé + bouton "Rapprocher" - if ($objp->do <= mktime()) + if ($objp->do <= gmmktime()) { print ''; - print ""; + print ''; print '   '; print "trans("Rapprocher")."\">"; if ($options) { - print "
$options"; print ""; } print ""; @@ -381,7 +351,7 @@ if ($resql) else { print ''; - print 'Ecriture future. Ne peut pas encore être rapprochée.'; + print 'Transaction in futur. No way to conciliate.'; print ''; } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index adf97281318..84f26a1f605 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -42,4 +42,5 @@ ErrorExportDuplicateProfil=This profil name already exists for this export set. ErrorLDAPSetupNotComplete=Dolibarr-LDAP matching is not complete. ErrorLDAPMakeManualTest=A .ldif file has been generated in directory %s. Try to load it manually from command line to have more informations on errors. ErrorCantSaveADoneUserWithZeroPercentage=Can't save an action with "statut not started" if field "done by" is also filled. -ErrorBillRefAlreadyExists=Ref used for creation already exists. \ No newline at end of file +ErrorBillRefAlreadyExists=Ref used for creation already exists. +ErrorPleaseTypeBankTransactionReportName=Please type bank receipt name where transaction is reported (Format YYYYMM or YYYYMMDD) diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index bd9129fcf1e..0c8a7e86b2a 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -42,4 +42,5 @@ ErrorExportDuplicateProfil=Ce nom de profil existe d ErrorLDAPSetupNotComplete=Le matching Dolibarr-LDAP est incomplet. ErrorLDAPMakeManualTest=Un fichier .ldif a été généré dans le répertoire %s. Essayer de charger ce fichier en manuel depuis la ligne de commande pour plus de détail sur l'erreur. ErrorCantSaveADoneUserWithZeroPercentage=Impossible sauver une action à l'état non commencé avec un utilisateur défini comme ayant fait l'action. -ErrorBillRefAlreadyExists=La référence utilisée pour la création existe déjà \ No newline at end of file +ErrorBillRefAlreadyExists=La référence utilisée pour la création existe déjà +ErrorPleaseTypeBankTransactionReportName=Veuiller saisir le nom de relevé bancaire sur lequel l'écriture est constaté (Format AAAAMM ou AAAMMJJ) \ No newline at end of file