diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php new file mode 100644 index 00000000000..6b1322f8a3a --- /dev/null +++ b/htdocs/compta/paiement/cheque/fiche.php @@ -0,0 +1,329 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/compta/paiement/fiche.php + \ingroup facture + \brief Onglet paiement d'un paiement client + \remarks Fichier presque identique a fournisseur/paiement/fiche.php + \version $Revision$ +*/ + +require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT.'/paiement.class.php'); +require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php"); +if ($conf->banque->enabled) require_once(DOL_DOCUMENT_ROOT.'/compta/bank/account.class.php'); + +$user->getrights('banque'); + +$langs->load('bills'); +$langs->load('banks'); +$langs->load('companies'); + +$mesg=''; + + +/* + * Actions + */ + +if ($_GET['action'] == 'create' && $_GET["accountid"] > 0 && $user->rights->banque) +{ + $remise = new RemiseCheque($db); + $result = $remise->Create($user, $_GET["accountid"]); + if ($result === 0) + { + Header("Location: index.php"); + exit; + } + else + { + $mesg='
'.$paiement->error.'
'; + } +} + +if ($_GET['action'] == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $user->rights->banque) +{ + $remise = new RemiseCheque($db); + $remise->id = $_GET["id"]; + $result = $remise->RemoveCheck($_GET["lineid"]); + if ($result === 0) + { + + } + else + { + $mesg='
'.$paiement->error.'
'; + } +} + +if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->banque) +{ + $remise = new RemiseCheque($db); + $remise->id = $_GET["id"]; + $result = $remise->Delete(); + if ($result == 0) + { + Header("Location: index.php"); + exit; + } + else + { + $mesg='
'.$paiement->error.'
'; + } +} + + +/* + * Visualisation de la fiche + */ + +llxHeader(); + +$html = new Form($db); + +if ($_GET['action'] == 'new') +{ + $h=0; + $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/fiche.php?action=new'; + $head[$h][1] = $langs->trans("NewCheckReceipt"); + $hselected = $h; + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("CheckReceipt")); +} +else +{ + $remise = new RemiseCheque($db); + $result = $remise->Fetch($_GET["id"]); + + $h=0; + $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/fiche.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("CheckReceipt"); + $hselected = $h; + $h++; + // $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$_GET["id"]; + // $head[$h][1] = $langs->trans("Info"); + // $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("CheckReceipt")); + + + /* + * Confirmation de la suppression du bordereau + */ + if ($_GET['action'] == 'delete') + { + $html->form_confirm('fiche.php?id='.$remise->id, $langs->trans("DeleteCheckReceipt"), 'Etes-vous sûr de vouloir supprimer ce bordereau ?', 'confirm_delete'); + print '
'; + } + + /* + * Confirmation de la validation du bordereau + */ + if ($_GET['action'] == 'valide') + { + $facid = $_GET['facid']; + $html->form_confirm('fiche.php?id='.$paiement->id.'&facid='.$facid, $langs->trans("ValidatePayment"), 'Etes-vous sûr de vouloir valider ce règlement, auncune modification n\'est possible une fois le règlement validé ?', 'confirm_valide'); + print '
'; + } +} + +if ($mesg) print $mesg.'
'; + +/* + * + * + * + */ +if ($_GET['action'] == 'new') +{ + $accounts = array(); + $lines = array(); + $sql = "SELECT ba.rowid as bid, ".$db->pdate("b.dateo")." as date,"; + $sql.= " b.amount, ba.label, b.emetteur"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b "; + $sql.= ",".MAIN_DB_PREFIX."bank_account as ba "; + $sql.= " WHERE b.fk_type = 'CHQ' AND b.fk_account = ba.rowid"; + $sql.= " AND b.fk_bordereau = 0 AND b.amount > 0"; + $sql.= " ORDER BY ba.rowid ASC, b.dateo ASC;"; + + + $resql = $db->query($sql); + + if ($resql) + { + $i = 0; + while ( $obj = $db->fetch_object($resql) ) + { + $accounts[$obj->bid] = $obj->label; + $lines[$obj->bid][$i]["date"] = $obj->date; + $lines[$obj->bid][$i]["amount"] = $obj->amount; + $lines[$obj->bid][$i]["emetteur"] = $obj->emetteur; + $i++; + } + } + + foreach ($accounts as $bid => $account_label) + { + $num = $db->num_rows($resql); + + print ''; + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + + $var=true; + + foreach ($lines[$bid] as $lid => $value) + { + $var=!$var; + + $account_id = $objp->bid; + $accounts[$objp->bid] += 1; + + print ""; + print ''; + print '\n"; + print ''; + print ''; + $i++; + } + print "
'.$langs->trans("Date")."'.$langs->trans("CheckTransmitter")."'.$langs->trans("Amount")."
'.dolibarr_print_date($value["date"]).''.stripslashes($value["emetteur"])."'.price($value["amount"]).'
"; + + print '
'; + print ''; + print $langs->trans('NewCheckReceipt'); + print ' : '.stripslashes($account_label).''; + print '

'; + } + +} +else +{ + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans('Numero').''.$remise->number.'
'.$langs->trans('Date').''.dolibarr_print_date($remise->date_bordereau).'
'.$langs->trans('Account').''; + print ''.img_object($langs->trans("ShowAccount"),'account').' '.$remise->account_label.''; + + print '

'; + + $sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount,b.banque,b.emetteur,"; + $sql.= " p.statut, p.num_paiement,"; + $sql.= " c.code as paiement_code,"; + $sql.= " ba.rowid as bid, ba.label"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as c,"; + $sql.= " ".MAIN_DB_PREFIX."paiement as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql.= " WHERE p.fk_paiement = c.id AND c.code = 'CHQ'"; + $sql.= " AND b.fk_bordereau = ".$remise->id; + $sql.= " AND p.statut = 1"; + $sql.= " ORDER BY p.datep ASC;"; + + $resql = $db->query($sql); + + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $total = 0; + print ''; + print ''; + print_liste_field_titre($langs->trans("Date"),"liste.php","dp","",$paramlist,'align="center"',$sortfield); + print_liste_field_titre($langs->trans("Type"),"liste.php","c.libelle","",$paramlist,"",$sortfield); + print_liste_field_titre($langs->trans("Amount"),"liste.php","p.amount","",$paramlist,'align="right"',$sortfield); + print_liste_field_titre($langs->trans("Bank"),"liste.php","p.amount","",$paramlist,'align="right"',$sortfield); + print_liste_field_titre($langs->trans("CheckTransmitter"),"liste.php","p.amount","",$paramlist,'align="right"',$sortfield); + print "\n"; + + $var=true; + while ( $objp = $db->fetch_object($resql) ) + { + $account_id = $objp->bid; + $accounts[$objp->bid] += 1; + + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $total += $objp->amount; + $i++; + $var=!$var; + } + + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "
'.dolibarr_print_date($objp->dp).''.$langs->trans("PaymentTypeShort".$objp->paiement_code).' '.$objp->num_paiement.''.price($objp->amount).''.stripslashes($objp->banque).''.stripslashes($objp->emetteur).'
 '.$langs->trans("Total").''.price($total).'  
"; + } + else + { + dolibarr_print_error($db); + } + + + +} + +print ''; + + +/* + * Boutons Actions + */ + +print '
'; + +if ($user->societe_id == 0 && sizeof($accounts) == 1 && $_GET['action'] == 'new') +{ + print ''.$langs->trans('NewCheckReceipt').''; +} + +if ($user->societe_id == 0 && $remise->statut == 0 && $_GET['action'] == '') +{ + print ''.$langs->trans('Valid').''; +} + +if ($user->societe_id == 0 && $remise->statut == 0 && $_GET['action'] == '') +{ + print ''.$langs->trans('Delete').''; + +} +print '
'; + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php new file mode 100644 index 00000000000..24f35999372 --- /dev/null +++ b/htdocs/compta/paiement/cheque/index.php @@ -0,0 +1,169 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/compta/paiement/cheque/liste.php + \ingroup compta + \brief Page liste des bordereau de remise de cheque + \version $Revision$ +*/ + +require("./pre.inc.php"); + +$langs->load("banks"); + +$user->getrights("facture"); + +// Sécurité accés client +if (! $user->rights->facture->lire) + accessforbidden(); + +$socid=0; +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + +/* + * Affichage + */ + +llxHeader('',$langs->trans("CheckReceipt")); + +print_titre($langs->trans("CheckReceipt") ); + +print '\n"; +print '\n"; +print "
'; + +$sql = "SELECT bc.rowid,".$db->pdate("bc.date_bordereau")." as db, bc.amount,"; +$sql.= " bc.statut, ba.label, ba.rowid as bid"; +$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc"; +$sql.= ",".MAIN_DB_PREFIX."bank_account as ba"; +$sql.= " WHERE ba.rowid=bc.fk_bank_account"; +$sql.= " ORDER BY bc.rowid DESC LIMIT 10;"; + +$resql = $db->query($sql); + +if ($resql) +{ + $i = 0; + + print ''; + print '"; + print ''; + print ''; + print "\n"; + + $var=true; + while ( $objp = $db->fetch_object($resql) ) + { + $var=!$var; + print "\n"; + print ''; + + print ''; + print ''; + $i++; + } + print "
'.$langs->trans("Date")."'.$langs->trans("Account").''.$langs->trans("Amount").'
'; + print ''; + print dolibarr_print_date($objp->db,'%d/%m').''; + print ''.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.''; + + print ''.price($objp->amount).'
"; +} +else +{ + dolibarr_print_error($db); +} + +print "
'; + +$page=$_GET["page"]; +$sortorder=$_GET["sortorder"]; +$sortfield=$_GET["sortfield"]; + +$limit = $conf->liste_limit; +$offset = $limit * $page ; +if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="p.rowid"; + +$sql = "SELECT b.amount,b.emetteur,".$db->pdate("b.dateo")." as date,"; +$sql.= " c.code as paiement_code,"; +$sql.= " ba.rowid as bid, ba.label"; +$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as c"; +$sql.= ",".MAIN_DB_PREFIX."bank as b"; +$sql.= ",".MAIN_DB_PREFIX."bank_account as ba"; +$sql.= " WHERE c.code = 'CHQ' AND c.code = b.fk_type AND b.fk_bordereau = 0 AND b.fk_account = ba.rowid"; +$sql.= " AND b.amount > 0"; +//$sql .= " ORDER BY $sortfield $sortorder"; +$sql .= $db->plimit( $limit+1 ,$offset); +//print "$sql"; + +$resql = $db->query($sql); + +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + $paramlist=($_GET["orphelins"]?"&orphelins=1":""); + + print ''; + print ''; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + + print "\n"; + + $var=true; + while ($i < min($num,$limit)) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print ""; + print ''; + print ''; + print ''; + print ''; + $i++; + } + print "
'.$langs->trans("Date")."'.$langs->trans("Account")."'.$langs->trans("Amount")."'.$langs->trans("CheckTransmitter")."
'.dolibarr_print_date($objp->date).''; + + if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.''; + else print ' '; + print ''.price($objp->amount).''.$objp->emetteur.'
"; +} +else +{ + dolibarr_print_error($db); +} + +print "
\n"; + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/compta/paiement/cheque/liste.php b/htdocs/compta/paiement/cheque/liste.php new file mode 100644 index 00000000000..45a58aa5b64 --- /dev/null +++ b/htdocs/compta/paiement/cheque/liste.php @@ -0,0 +1,163 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/compta/paiement/cheque/liste.php + \ingroup compta + \brief Page liste des bordereau de remise de cheque + \version $Revision$ +*/ + +require("./pre.inc.php"); + +$langs->load("bills"); + +$user->getrights("facture"); + +// Sécurité accés client +if (! $user->rights->facture->lire) + accessforbidden(); + +$socid=0; +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + + +/* + * Affichage + */ + +llxHeader('',$langs->trans("CheckReceipt")); + +$page=$_GET["page"]; +$sortorder=$_GET["sortorder"]; +$sortfield=$_GET["sortfield"]; + +$limit = $conf->liste_limit; +$offset = $limit * $page ; +if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="p.rowid"; + +$sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount,"; +$sql.= " p.statut, p.num_paiement,"; +$sql.= " c.code as paiement_code,"; +$sql.= " ba.rowid as bid, ba.label"; +$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as c,"; +$sql.= " ".MAIN_DB_PREFIX."paiement as p"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; +if ($socid) +{ + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; +} +$sql.= " WHERE p.fk_paiement = c.id AND c.code = 'CHQ'"; +if ($socid) +{ + $sql.= " AND f.fk_soc = ".$socid; +} +if ($_GET["search_montant"]) +{ + $sql .=" AND p.amount=".price2num($_GET["search_montant"]); +} + +$sql .= " ORDER BY $sortfield $sortorder"; +$sql .= $db->plimit( $limit+1 ,$offset); +//print "$sql"; + +$resql = $db->query($sql); + +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + $paramlist=($_GET["orphelins"]?"&orphelins=1":""); + print_barre_liste($langs->trans("CheckReceipt"), $page, "liste.php",$paramlist,$sortfield,$sortorder,'',$num); + + print ''; + print ''; + print_liste_field_titre($langs->trans("Ref"),"liste.php","p.rowid","",$paramlist,"",$sortfield); + print_liste_field_titre($langs->trans("Date"),"liste.php","dp","",$paramlist,'align="center"',$sortfield); + print_liste_field_titre($langs->trans("Type"),"liste.php","c.libelle","",$paramlist,"",$sortfield); + print_liste_field_titre($langs->trans("Account"),"liste.php","ba.label","",$paramlist,"",$sortfield); + print_liste_field_titre($langs->trans("Amount"),"liste.php","p.amount","",$paramlist,'align="right"',$sortfield); + print_liste_field_titre($langs->trans("Status"),"liste.php","p.statut","",$paramlist,'align="center"',$sortfield); + print "\n"; + + // Lignes des champs de filtre + print ''; + print ''; + print ''; + print ''; + print "\n"; + print ''; + + $var=true; + while ($i < min($num,$limit)) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print ""; + print ''; + + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + print "
 '; + print ''; + print ''; + print ''; + print '
'.img_object($langs->trans("ShowPayment"),"payment").''; + + print ' '.$objp->rowid.''.dolibarr_print_date($objp->dp).''.$objp->paiement_type.' '.$objp->num_paiement.''.$langs->trans("PaymentTypeShort".$objp->paiement_code).' '.$objp->num_paiement.''; + if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.''; + else print ' '; + print ''.price($objp->amount).''; + + if ($objp->statut == 0) + { + print ''.$langs->trans("ToValidate").''; + } + else + { + print img_tick(); + } + + print '
"; +} +else +{ + dolibarr_print_error($db); +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/compta/paiement/cheque/pre.inc.php b/htdocs/compta/paiement/cheque/pre.inc.php new file mode 100644 index 00000000000..6d4d8410f67 --- /dev/null +++ b/htdocs/compta/paiement/cheque/pre.inc.php @@ -0,0 +1,54 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ +require("../../../main.inc.php"); + +$langs->load("bills"); +$langs->load("compta"); + +require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/remisecheque.class.php'); + +function llxHeader($head = "", $title="") +{ + global $user, $langs; + $langs->load("bills"); + + top_menu($head, $title); + + $menu = new Menu(); + + $menu->add("/compta/paiement/liste.php",$langs->trans("Payments")); + + $menu->add(DOL_URL_ROOT."/compta/paiement/cheque/index.php",$langs->trans("CheckReceipt")); + $menu->add_submenu(DOL_URL_ROOT."/compta/paiement/cheque/fiche.php?action=new",$langs->trans("New")); + $menu->add_submenu(DOL_URL_ROOT."/compta/paiement/cheque/liste.php",$langs->trans("List")); + + $menu->add("rapport.php",$langs->trans("Reportings")); + + $menu->add(DOL_URL_ROOT."/compta/facture.php",$langs->trans("Bills")); + $menu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed")); + + $menu->add_submenu("avalider.php",$langs->trans("MenuToValid")); + + left_menu($menu->liste); +} + +?> diff --git a/htdocs/compta/paiement/cheque/remisecheque.class.php b/htdocs/compta/paiement/cheque/remisecheque.class.php index e34602f3a9b..3e3acc947cf 100644 --- a/htdocs/compta/paiement/cheque/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/remisecheque.class.php @@ -94,7 +94,7 @@ class RemiseCheque \param user utilisateur qui effectue l'operation \param account_id Compte bancaire concerne */ - function create($user, $account_id) + function Create($user, $account_id) { $this->errno = 0; $this->db->begin(); @@ -122,7 +122,7 @@ class RemiseCheque $resql = $this->db->query($sql); if (!$resql) { - $this->errno = -19; + $this->errno = -25; dolibarr_syslog("RemiseCheque::Create ERREUR UPDATE ($this->errno)"); } } @@ -133,7 +133,7 @@ class RemiseCheque $sql = "SELECT b.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " WHERE b.fk_type = 'CHQ'"; - $sql.= " AND b.fk_bordereau = 0"; + $sql.= " AND b.fk_bordereau = 0 AND b.fk_account='$account_id';"; $resql = $this->db->query($sql); @@ -169,6 +169,14 @@ class RemiseCheque } } + if ($this->id > 0 && $this->errno === 0) + { + if ($this->UpdateAmount() <> 0) + { + $this->errno = -19; + dolibarr_syslog("RemiseCheque::Create ERREUR ($this->errno)"); + } + } } else { @@ -239,8 +247,54 @@ class RemiseCheque } return $this->errno; + } + /** + \brief Mets a jour le montant total + \return int, 0 en cas de succes + */ + function UpdateAmount() + { + $this->errno = 0; + $this->db->begin(); + + $sql = "SELECT sum(amount) "; + $sql.= " FROM ".MAIN_DB_PREFIX."bank"; + $sql.= " WHERE fk_bordereau = $this->id;"; + + $resql = $this->db->query($sql); + if ( $resql ) + { + $row = $this->db->fetch_row($resql); + $total = $row[0]; + $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql.= " SET amount='$total'"; + $sql.= " WHERE rowid='".$this->id."';"; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->errno = -31; + dolibarr_syslog("RemiseCheque::UpdateAmount ERREUR UPDATE ($this->errno)"); + } + } + else + { + $this->errno = -33; + dolibarr_syslog("RemiseCheque::UpdateAmount ERREUR SELECT ($this->errno)"); + } + + if ($this->errno === 0) + { + $this->db->commit(); + } + else + { + $this->db->rollback(); + dolibarr_syslog("RemiseCheque::UpdateAmount ROLLBACK ($this->errno)"); + } + + return $this->errno; } /**