* Copyright (C) 2004-2006 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 * 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/bank/virement.php \ingroup banque \brief Page de saisie d'un virement \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php"); $langs->load("banks"); $user->getrights('banque'); if (!$user->rights->banque->modifier) accessforbidden(); /* * Action ajout d'un virement */ if ($_POST["action"] == 'add') { $mesg=''; $dateo = $_POST["reyear"]."-".$_POST["remonth"]."-".$_POST["reday"]; $label = $_POST["label"]; $amount= $_POST["amount"]; if (! $label) { $error=1; $mesg.="
".$langs->trans("ErrorFieldRequired",$langs->trans("Label"))."
"; } if (! $amount) { $error=1; $mesg.="
".$langs->trans("ErrorFieldRequired",$langs->trans("Amount"))."
"; } if (! $error) { $db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, datev, dateo, label, amount, fk_user_author,fk_account, fk_type)"; $sql .= " VALUES (now(), '$dateo', '$dateo', '".addslashes($label)."', '".price2num(-1*price2num($amount))."', $user->id, ".$_POST["account_from"].", 'VIR')"; dolibarr_syslog("Virement insert bank sql=".$sql); $result = $db->query($sql); if (!$result) { $db->rollback(); dolibarr_print_error($db); } $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, datev, dateo, label, amount, fk_user_author,fk_account, fk_type)"; $sql .= " VALUES (now(), '$dateo', '$dateo', '".addslashes($label)."', '".price2num($amount)."',$user->id, ".$_POST["account_to"].", 'VIR')"; dolibarr_syslog("Virement insert bank sql=".$sql); $result = $db->query($sql); if ($result) { $accountfrom=new Account($db); $accountfrom->fetch($_POST["account_from"]); $accountto=new Account($db); $accountto->fetch($_POST["account_to"]); $mesg.="
Le virement depuis « id."\">".$accountfrom->label." » vers « id."\">".$accountto->label." » de ".$amount." ".$langs->trans("Currency".$conf->monnaie)." a été créé.
"; $db->commit(); } else { $mesg.="
".$db->lasterror()."
"; $db->rollback(); } } } /* * Affichage */ llxHeader(); $html=new Form($db); print_titre($langs->trans("BankTransfer")); print '
'; if ($mesg) { print "$mesg
"; } print $langs->trans("TransferDesc"); print "

"; print "
"; print ''; print ''; print ''; print ''; print ''; $var=false; print '\n"; print "\n"; print ''; print ''; print "
'.$langs->trans("TransferFrom").''.$langs->trans("TransferTo").''.$langs->trans("Date").''.$langs->trans("Description").''.$langs->trans("Amount").'
'; print "\n"; print '"; $html->select_date('','','','','','add'); print "
"; print '
'; print "
"; $db->close(); llxFooter('$Date$ - $Revision$'); ?>