From 6732c12910b75f542207a74b2ad8e9a6be50b940 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 20 Apr 2011 15:42:48 +0000 Subject: [PATCH] Task #11003: checkbox on checks to deposit --- .../cheque/class/remisecheque.class.php | 33 ++++++--- htdocs/compta/paiement/cheque/fiche.php | 67 ++++++++++--------- 2 files changed, 58 insertions(+), 42 deletions(-) diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 1457c7f9c9f..296f9826260 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006 Rodolphe Quiedeville * Copyright (C) 2007-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2011 Juanjo Menent * * 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 @@ -117,9 +118,10 @@ class RemiseCheque extends CommonObject * @param user User making creation * @param account_id Bank account for cheque receipt * @param limit Limit number of cheque to this + * @param toRemise array with cheques to remise * @return int <0 if KO, >0 if OK */ - function create($user, $account_id, $limit=40) + function create($user, $account_id, $limit=40,$toRemise) { global $conf; @@ -207,19 +209,28 @@ class RemiseCheque extends CommonObject } if ($this->id > 0 && $this->errno == 0) - { + { foreach ($lines as $lineid) { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET fk_bordereau = ".$this->id; - $sql.= " WHERE rowid = ".$lineid; - - dol_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) + $checkremise=false; + foreach ($toRemise as $linetoremise) { - $this->errno = -18; - dol_syslog("RemiseCheque::Create Error update bank ".$this->errno, LOG_ERR); + if($linetoremise==$lineid) $checkremise=true; + } + + if($checkremise==true) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET fk_bordereau = ".$this->id; + $sql.= " WHERE rowid = ".$lineid; + + dol_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->errno = -18; + dol_syslog("RemiseCheque::Create Error update bank ".$this->errno, LOG_ERR); + } } } } diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php index 8fa4af37784..1ce13c9b76e 100644 --- a/htdocs/compta/paiement/cheque/fiche.php +++ b/htdocs/compta/paiement/cheque/fiche.php @@ -84,42 +84,42 @@ if ($_POST['action'] == 'setdate' && $user->rights->banque->cheque) } } -if ($_GET['action'] == 'create' && $_GET["accountid"] > 0 && $user->rights->banque->cheque) +if ($_POST['action'] == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->cheque) { - - $remisecheque = new RemiseCheque($db); - //$result = $remisecheque->create($user, $_GET["accountid"], 0); - if (is_array($_POST['toRemise'])) - $result = $remisecheque->create($user, $_GET["accountid"], 0); // $result = $remisecheque->create($user, $_GET["accountid"], 0, $_POST['toRemise']); - - else - $result = $remisecheque->create($user, $_GET["accountid"], 0); - - if ($result > 0) { - if ($remisecheque->statut == 1) // If statut is validated, we build doc - { - $remisecheque->fetch($remisecheque->id); // To force to reload all properties in correct property name - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $remisecheque->generatePdf($_POST["model"], $outputlangs); - } + $remisecheque = new RemiseCheque($db); + $result = $remisecheque->create($user, $_POST["accountid"], 0, $_POST['toRemise']); + if ($result > 0) + { + if ($remisecheque->statut == 1) // If statut is validated, we build doc + { + $remisecheque->fetch($remisecheque->id); // To force to reload all properties in correct property name + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result = $remisecheque->generatePdf($_POST["model"], $outputlangs); + } - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id); - exit; + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id); + exit; + } + else + { + $mesg='
'.$remisecheque->error.'
'; + } } else { - $mesg='
'.$remisecheque->error.'
'; + Header("Location: ".$_SERVER["PHP_SELF"]."?action=new"); + exit; } } @@ -343,7 +343,11 @@ if ($_GET['action'] == 'new') foreach ($accounts as $bid => $account_label) { $num = $db->num_rows($resql); - + print '
'; + print ''; + print ''; + print ''; + print ''; print ''; print '\n"; @@ -384,13 +388,14 @@ if ($_GET['action'] == 'new') print '
'; if ($user->rights->banque->cheque) { - print ''.$langs->trans('NewCheckDepositOn',$account_label).''; + print ''; } else { print ''.$langs->trans('NewCheckDepositOn',$account_label).''; } print '

'; + print ''; } }
'.$langs->trans("DateChequeReceived")."