diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 959803bea31..7eff952c81d 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2001-2006 Rodolphe Quiedeville * Copyright (C) 2003 Xavier DUTOIT * Copyright (C) 2004-2006 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles @@ -23,10 +23,10 @@ */ /** - \file htdocs/compta/bank/ligne.php - \ingroup compta - \brief Page édition d'une écriture bancaire - \version $Revision$ + \file htdocs/compta/bank/ligne.php + \ingroup compta + \brief Page édition d'une écriture bancaire + \version $Revision$ */ require("./pre.inc.php"); @@ -37,13 +37,11 @@ if (!$user->rights->banque->modifier) $langs->load("banks"); $langs->load("bills"); - $rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; $orig_account=isset($_GET["orig_account"])?$_GET["orig_account"]:$_POST["orig_account"]; $html = new Form($db); - /* * Actions */ @@ -86,38 +84,38 @@ if ($_POST["action"] == 'class') if ($_POST["action"] == "update") { - // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche - $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid; - $result = $db->query($sql); - if ($result) - { - $objp = $db->fetch_object($result); - if ($objp->rappro) - die ("Vous ne pouvez pas modifier une écriture déjà rapprochée"); - } - + // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche + $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid; + $result = $db->query($sql); + if ($result) + { + $objp = $db->fetch_object($result); + if ($objp->rappro) + die ("Vous ne pouvez pas modifier une écriture déjà rapprochée"); + } + $db->begin(); - $amount = price2num($_POST['amount']); - $dateop = $_POST["dateoyear"].'-'.$_POST["dateomonth"].'-'.$_POST["dateoday"]; - $dateval= $_POST["datevyear"].'-'.$_POST["datevmonth"].'-'.$_POST["datevday"]; - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET label='".$_POST["label"]."',"; - if (isset($_POST['amount'])) $sql.=" amount='$amount',"; - $sql.= " dateo = '".$dateop."', datev = '".$dateval."',"; - $sql.= " fk_account = ".$_POST['accountid']; - $sql.= " WHERE rowid = ".$rowid; - - $result = $db->query($sql); - if ($result) - { + $amount = price2num($_POST['amount']); + $dateop = $_POST["dateoyear"].'-'.$_POST["dateomonth"].'-'.$_POST["dateoday"]; + $dateval= $_POST["datevyear"].'-'.$_POST["datevmonth"].'-'.$_POST["datevday"]; + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET label='".$_POST["label"]."',"; + if (isset($_POST['amount'])) $sql.=" amount='$amount',"; + $sql.= " dateo = '".$dateop."', datev = '".$dateval."',"; + $sql.= " fk_account = ".$_POST['accountid']; + $sql.= " WHERE rowid = ".$rowid; + + $result = $db->query($sql); + if ($result) + { $db->commit(); - } + } else - { + { $db->rollback(); - dolibarr_print_error($db); - } + dolibarr_print_error($db); + } } if ($_POST["action"] == 'type') @@ -126,26 +124,38 @@ if ($_POST["action"] == 'type') $result = $db->query($sql); } +if ($_POST["action"] == 'banque') +{ + $sql = "UPDATE ".MAIN_DB_PREFIX."bank set banque='".addslashes($_POST["banque"])."' WHERE rowid = $rowid;"; + $result = $db->query($sql); +} + +if ($_POST["action"] == 'emetteur') +{ + $sql = "UPDATE ".MAIN_DB_PREFIX."bank set emetteur='".addslashes($_POST["emetteur"])."' WHERE rowid = $rowid;"; + $result = $db->query($sql); +} + if ($_POST["action"] == 'num_releve') { - $num_rel=trim($_POST["num_rel"]); - - $db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET num_releve=".($num_rel?"'".$num_rel."'":"null"); - $sql.= " WHERE rowid = ".$rowid; - - $result = $db->query($sql); - if ($result) - { - $db->commit(); + $num_rel=trim($_POST["num_rel"]); + + $db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET num_releve=".($num_rel?"'".$num_rel."'":"null"); + $sql.= " WHERE rowid = ".$rowid; + + $result = $db->query($sql); + if ($result) + { + $db->commit(); } - else + else { - $db->rollback(); - dolibarr_print_error($db); - } + $db->rollback(); + dolibarr_print_error($db); + } } @@ -193,241 +203,263 @@ dolibarr_fiche_head($head, $hselected, $langs->trans('LineRecord').': '.$_GET["r $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro,"; $sql.= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account"; +$sql.= ",b.emetteur,b.banque"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " WHERE rowid=".$rowid; $sql.= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { - $i = 0; $total = 0; - if ($db->num_rows($result)) + $i = 0; $total = 0; + if ($db->num_rows($result)) { - - // Confirmations - if ($_GET["action"] == 'delete_categ') + + // Confirmations + if ($_GET["action"] == 'delete_categ') { - $html->form_confirm("ligne.php?rowid=".$_GET["rowid"]."&cat1=".$_GET["fk_categ"]."&orig_account=".$orig_account,"Supprimer dans la catégorie","Etes-vous sûr de vouloir supprimer le classement dans la catégorie ?","confirm_delete_categ"); - print '
'; + $html->form_confirm("ligne.php?rowid=".$_GET["rowid"]."&cat1=".$_GET["fk_categ"]."&orig_account=".$orig_account,"Supprimer dans la catégorie","Etes-vous sûr de vouloir supprimer le classement dans la catégorie ?","confirm_delete_categ"); + print '
'; } - - print ''; - - $objp = $db->fetch_object($result); - $total = $total + $objp->amount; - - $acct=new Account($db,$objp->fk_account); - $acct->fetch($objp->fk_account); - $account = $acct->id; - - $links=$acct->get_url($rowid); - - // Tableau sur 4 colonne si déja rapproché, sinon sur 5 colonnes - - // Author - print '"; - if ($objp->fk_user_author) + + print '
'.$langs->trans("Author")."
'; + + $objp = $db->fetch_object($result); + $total = $total + $objp->amount; + + $acct=new Account($db,$objp->fk_account); + $acct->fetch($objp->fk_account); + $account = $acct->id; + + $links=$acct->get_url($rowid); + + // Tableau sur 4 colonne si déja rapproché, sinon sur 5 colonnes + + // Author + print '"; + if ($objp->fk_user_author) { - $author=new User($db,$objp->fk_user_author); - $author->fetch(); - print ''; + $author=new User($db,$objp->fk_user_author); + $author->fetch(); + print ''; } - else + else { - print ''; + print ''; } - print ""; - - $i++; - - print "rowid\">"; - print ""; - print ""; - - // Account - print ""; -/* + print ""; + + $i++; + + print "rowid\">"; + print ""; + print ""; + + // Account + print ""; + /* if (! $objp->rappro) { - if ($user->rights->banque->modifier && $acct->type != 2 && $acct->rappro) // Si non compte cash et si rapprochable - { - print ''; - //print ''; + if ($user->rights->banque->modifier && $acct->type != 2 && $acct->rappro) // Si non compte cash et si rapprochable + { + print ''; + //print ''; } else { - print ''; + print ''; } print ''; + } + else + { + */ + print ''; + /* + } + */ + print ''; + + // Date ope + print ''; + if (! $objp->rappro) + { + print ''; } - else + else { -*/ - print ''; -/* + print ''; - - // Date ope - print ''; - if (! $objp->rappro) + print ''; + + // Value date + print ""; + if (! $objp->rappro) { - print ''; + print ''; - - // Value date - print ""; - if (! $objp->rappro) - { - print '"; - - // Description - print ""; - if (! $objp->rappro) - { - print '"; + + // Description + print ""; + if (! $objp->rappro) + { + print ''; - print ''; + print ''; + print ''; + + // Affiche liens + if (sizeof($links)) { + print ""; + print ''; + } + + // Amount + print ""; + if (! $objp->rappro) + { + print '"; + + print ""; + + // Type paiement + print ""; + + // Banque + print ""; - // Affiche liens - if (sizeof($links)) { - print ""; - print ''; - } - - // Amount - print ""; - if (! $objp->rappro) + // Emetteur + print ""; + + + // Releve rappro + if ($acct->rappro) // Si compte rapprochable { - print '"; + print "rowid\">"; + print ''; + print ""; + print ''; + print ''; + print ''; } - else - { - print '"; - - print ""; - - // Type paiement - print ""; - - // Releve rappro - if ($acct->rappro) // Si compte rapprochable - { - print ""; - print "rowid\">"; - print ''; - print ""; - print ''; - print ''; - print ''; - } - - print "
'.$langs->trans("Author")."'; - print img_object($langs->trans("ShowUser"),'user').' '.$author->fullname.''; + print img_object($langs->trans("ShowUser"),'user').' '.$author->fullname.'  
".$langs->trans("Account")."
".$langs->trans("Account")."'; - $html->select_comptes($acct->id,'accountid',0); - print ''; - //print ''; - //print ''; + $html->select_comptes($acct->id,'accountid',0); + print ''; + //print ''; + //print ''; - $html->select_comptes($acct->id,'accountid',0); - print ''; + $html->select_comptes($acct->id,'accountid',0); + print ''; + print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.''; + print ''; + print '
'.$langs->trans("DateOperation").''; + $html->select_date($objp->do,'dateo','','','','update'); + print ''; - print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.''; - print ''; - print ''; + print dolibarr_print_date($objp->do); } -*/ - print '
'.$langs->trans("DateOperation").'
".$langs->trans("DateValue")."'; - $html->select_date($objp->do,'dateo','','','','update'); - print ''; + $html->select_date($objp->dv,'datev','','','','update'); + print '   '; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; } - else + else { - print ''; - print dolibarr_print_date($objp->do); + print ''; + print dolibarr_print_date($objp->dv); } - print '
".$langs->trans("DateValue")."'; - $html->select_date($objp->dv,'datev','','','','update'); - print '   '; - print ''; - print img_edit_remove() . " "; - print ''; - print img_edit_add() .""; - print ''; - } - else - { - print ''; - print dolibarr_print_date($objp->dv); - } - print "
".$langs->trans("Label")."'; - print '
".$langs->trans("Label")."'; + print ''; - print ''; + print '" size="50">'; + print ''; } - else + else { - print ''; - if (eregi('^\((.*)\)$',$objp->label,$reg)) - { - // Label générique car entre parenthèses. On l'affiche en le traduisant - print $langs->trans($reg[1]); - } - else - { - print $objp->label; + print ''; + if (eregi('^\((.*)\)$',$objp->label,$reg)) + { + // Label générique car entre parenthèses. On l'affiche en le traduisant + print $langs->trans($reg[1]); + } + else + { + print $objp->label; } } - print '
".$langs->trans("Links")."'; + foreach($links as $key=>$val) + { + if ($key) print '
'; + if ($links[$key]['type']=='payment') { + print ''; + print img_object($langs->trans('ShowPayment'),'payment').' '; + print $langs->trans("Payment"); + print ''; + } + else if ($links[$key]['type']=='payment_supplier') { + print ''; + print img_object($langs->trans('ShowPayment'),'payment').' '; + print $langs->trans("Payment"); + print ''; + } + else if ($links[$key]['type']=='company') { + print ''; + print img_object($langs->trans('ShowCustomer'),'company').' '; + print $links[$key]['label']; + print ''; + } + else { + print ''; + print $links[$key]['label']; + print ''; + } + } + print '
 
".$langs->trans("Amount")."'; + print ' '.$langs->trans("Currency".$conf->monnaie); + print ''; + } + else + { + print ''; + print price($objp->amount); + } + print "
".$langs->trans("Type")." / ".$langs->trans("Numero").""; + print "
rowid\">"; + print ''; + print ""; + print $html->select_types_paiements($objp->fk_type,"value",'',2); + print ''; + print '
'; + print ""; + print "
".$langs->trans("Bank").""; + print "
rowid\">"; + print ''; + print ""; + print ''; + print '
'; + print ""; + print "
".$langs->trans("Links")."'; - foreach($links as $key=>$val) - { - if ($key) print '
'; - if ($links[$key]['type']=='payment') { - print ''; - print img_object($langs->trans('ShowPayment'),'payment').' '; - print $langs->trans("Payment"); - print ''; - } - else if ($links[$key]['type']=='payment_supplier') { - print ''; - print img_object($langs->trans('ShowPayment'),'payment').' '; - print $langs->trans("Payment"); - print ''; - } - else if ($links[$key]['type']=='company') { - print ''; - print img_object($langs->trans('ShowCustomer'),'company').' '; - print $links[$key]['label']; - print ''; - } - else { - print ''; - print $links[$key]['label']; - print ''; - } - } - print '
 
".$langs->trans("Amount")."
".$langs->trans("CheckTransmitter").""; + print "
rowid\">"; + print ''; + print ""; + print ''; + print '
'; + print ""; + print "
'; - print ' '.$langs->trans("Currency".$conf->monnaie); - print ''; + print "
".$langs->trans("Conciliation")."
'; + print $langs->trans("AccountStatement").' '; + print '
'; - print price($objp->amount); - } - print "
".$langs->trans("Type")." / ".$langs->trans("Numero").""; - print "
rowid\">"; - print ''; - print ""; - print $html->select_types_paiements($objp->fk_type,"value",'',2); - print ''; - print '
'; - print ""; - print "
".$langs->trans("Conciliation")."
'; - print $langs->trans("AccountStatement").' '; - print '
"; - + + print ""; + } - - $db->free($result); + + $db->free($result); } print ''; @@ -490,7 +522,6 @@ if ($result) } print ""; - $db->close(); llxFooter('$Date$ - $Revision$');