diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 44e7a7e57b0..123ca44a7cf 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -93,18 +93,29 @@ if ($_POST["action"] == "update") if ($objp->rappro) die ("Vous ne pouvez pas modifier une écriture déjà rapprochée"); } - if (!empty($_POST['amount'])) - { - $amount = str_replace(' ','',$_POST['amount']); - $dateop = $_POST["reyear"].'-'.$_POST["remonth"].'-'.$_POST["reday"]; - $sql = "UPDATE ".MAIN_DB_PREFIX."bank set label='".$_POST["label"]."', dateo = '".$dateop."', amount='$amount' WHERE rowid = $rowid;"; - } - else - $sql = "UPDATE ".MAIN_DB_PREFIX."bank set label='".$_POST["label"]."', dateo = '".$dateop."' WHERE rowid = $rowid;"; + + $db->begin(); + + $amount = str_replace(' ','',$_POST['amount']); + $amount = str_replace(',','.',$amount); + + $dateop = $_POST["doyear"].'-'.$_POST["domonth"].'-'.$_POST["doday"]; + $dateval= $_POST["dvyear"].'-'.$_POST["dvmonth"].'-'.$_POST["dvday"]; + $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) + if ($result) { + $db->commit(); + } + else + { + $db->rollback(); dolibarr_print_error($db); } } @@ -155,7 +166,7 @@ $head[$h][1] = $langs->trans('Card'); $hselected=$h; $h++; -dolibarr_fiche_head($head, $hselected, $langs->trans('LineRecord').' : '.$_GET["rowid"]); +dolibarr_fiche_head($head, $hselected, $langs->trans('LineRecord').': '.$_GET["rowid"]); $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro,"; @@ -186,87 +197,106 @@ if ($result) $acct->fetch($objp->fk_account); $account = $acct->id; - // Account - print "".$langs->trans("Account")."".$acct->label.""; - - print "
rowid\">"; - print ""; - - // Date - if (! $objp->rappro) + // Author + print "".$langs->trans("Author").""; + if ($objp->fk_user_author) { - print "".$langs->trans("Date").""; - $html->select_date($objp->do); - print '  '; - print ""; + $author=new User($db,$objp->fk_user_author); + $author->fetch(); + print ''; + print img_object($langs->trans("ShowUser"),'user').' '.$author->fullname.''; } + else + { + print " "; + } + print ""; + + $i++; + } - // Value date - print ""; - print ''.$langs->trans("DateValue").''.strftime("%d %b %Y",$objp->dv)."   "; + print "rowid\">"; + print ""; + + // Account + print "".$langs->trans("Account").""; + if (! $objp->rappro) + { + $html->select_comptes($acct->id,'accountid',0); + print ''; + } + else + { + print "id."\">".$acct->label.""; + } + print ""; + + // Date ope + if (! $objp->rappro) + { + print ''.$langs->trans("Date").""; + $html->select_date($objp->do,'do'); + print ''; + print ''; + } + + // Value date + if (! $objp->rappro) + { + print "".$langs->trans("DateValue").""; + $html->select_date($objp->dv,'dv'); + print '   '; print ''; print img_edit_remove() . " "; print ''; - print img_edit_add() .""; + print img_edit_add() .""; + print ''; print ''; - - // Description - print "".$langs->trans("Label").""; - print ''; - print '  '; - print ""; - - // Amount - if (! $objp->rappro) - { - print "".$langs->trans("Amount").""; - print ''; - print '  '; - print ""; - } - - print "
"; - - // Type paiement - print "".$langs->trans("Type").""; - print "
rowid\">"; - print ''; - print $html->select_types_paiements($objp->fk_type,"value",'',2); - print ''; - print '  '; - print "
"; - print ""; - - // Author - print "".$langs->trans("Author").""; - if ($objp->fk_user_author) { - $author=new User($db,$objp->fk_user_author); - $author->fetch(); - print "".$author->fullname.""; - } else { - print " "; - } - print ""; - - $i++; - } - - // Releve rappro - if ($acct->rappro) - { - print "
rowid\">"; - print ''; - print "".$langs->trans("Conciliation").""; - print $langs->trans("AccountStatement").' '; - print '  '; - print ""; - print "
"; - } - - print ""; - - $db->free($result); } + + // Description + print "".$langs->trans("Label").""; + print ''; + print ''; + print ''; + + // Amount + if (! $objp->rappro) + { + print "".$langs->trans("Amount").""; + print ''; + print ''; + print ''; + } + + print ""; + + // Type paiement + print "".$langs->trans("Type").""; + print "
rowid\">"; + print ''; + print $html->select_types_paiements($objp->fk_type,"value",'',2); + print ''; + print ''; + print "
"; + print ""; + + // Releve rappro + if ($acct->rappro) + { + print "
rowid\">"; + print ''; + print "".$langs->trans("Conciliation").""; + print $langs->trans("AccountStatement").' '; + print ''; + print ''; + print '
'; + } + + print ""; + + $db->free($result); +} print ''; print '
';