diff --git a/ChangeLog b/ChangeLog index b757d59dd45..4e9772b5586 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,7 @@ For users: - New: Task #10796: Add Spain ProfId1 Verification - New: Page "supplier summary" is now available. - New: Task #10611: Add option to choose order of field in bank account info on PDF +- New: If a transaction was reconciliated and should not, there was no way to reverse error. - Perf: Avoid reading database to determine country code after each page call. - Fix: Special chars are now supported in ECM module for filename (not yet for diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 5f61b9b38dc..3c58896ac6b 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -23,7 +23,7 @@ /** * \file htdocs/compta/bank/account.php * \ingroup banque - * \brief List of detail of bank transaction for an account + * \brief List of details of bank transactions for an account * \version $Id$ */ @@ -646,12 +646,12 @@ if ($account || $_GET["ref"]) print '-'; } - // Receipt conciliate or edit link + // Transaction reconciliated or edit link if ($objp->rappro && $acct->type != 2) // Si non compte cash { print ""; print ''; - print img_view(); + print img_edit(); print ''; print "  "; print "num_releve&account=$acct->id\">$objp->num_releve"; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 14937f6dce9..bba6df04494 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -49,119 +49,133 @@ $html = new Form($db); if ($user->rights->banque->consolidate && $_GET["action"] == 'dvnext') { - $ac = new Account($db); - $ac->datev_next($_GET["rowid"]); + $ac = new Account($db); + $ac->datev_next($_GET["rowid"]); } if ($user->rights->banque->consolidate && $_GET["action"] == 'dvprev') { - $ac = new Account($db); - $ac->datev_previous($_GET["rowid"]); + $ac = new Account($db); + $ac->datev_previous($_GET["rowid"]); } if ($_POST["action"] == 'confirm_delete_categ' && $_POST["confirm"] == "yes") { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_GET["cat1"]; - if (! $db->query($sql)) - { - dol_print_error($db); - } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_GET["cat1"]; + if (! $db->query($sql)) + { + dol_print_error($db); + } } if ($_POST["action"] == 'class') { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_POST["cat1"]; - if (! $db->query($sql)) - { - dol_print_error($db); - } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_POST["cat1"]; + if (! $db->query($sql)) + { + dol_print_error($db); + } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$_GET["rowid"].", ".$_POST["cat1"].")"; - if (! $db->query($sql)) - { - dol_print_error($db); - } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$_GET["rowid"].", ".$_POST["cat1"].")"; + if (! $db->query($sql)) + { + dol_print_error($db); + } } 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 ("Conciliation of a line already conciliated is not possible"); - } + // 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 ("Conciliation of a line already conciliated is not possible"); + } - $db->begin(); + $db->begin(); - $amount = price2num($_POST['amount']); - $dateop = dol_mktime(12,0,0,$_POST["dateomonth"],$_POST["dateoday"],$_POST["dateoyear"]); - $dateval= dol_mktime(12,0,0,$_POST["datevmonth"],$_POST["datevday"],$_POST["datevyear"]); - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET label='".addslashes($_POST["label"])."',"; - if (isset($_POST['amount'])) $sql.=" amount='$amount',"; - $sql.= " dateo = '".$db->idate($dateop)."', datev = '".$db->idate($dateval)."',"; - $sql.= " fk_account = ".$_POST['accountid']; - $sql.= " WHERE rowid = ".$rowid; + $amount = price2num($_POST['amount']); + $dateop = dol_mktime(12,0,0,$_POST["dateomonth"],$_POST["dateoday"],$_POST["dateoyear"]); + $dateval= dol_mktime(12,0,0,$_POST["datevmonth"],$_POST["datevday"],$_POST["datevyear"]); + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET label='".addslashes($_POST["label"])."',"; + if (isset($_POST['amount'])) $sql.=" amount='$amount',"; + $sql.= " dateo = '".$db->idate($dateop)."', datev = '".$db->idate($dateval)."',"; + $sql.= " fk_account = ".$_POST['accountid']; + $sql.= " WHERE rowid = ".$rowid; - $result = $db->query($sql); - if ($result) - { - $db->commit(); - } - else - { - $db->rollback(); - dol_print_error($db); - } + $result = $db->query($sql); + if ($result) + { + $db->commit(); + } + else + { + $db->rollback(); + dol_print_error($db); + } } if ($_POST["action"] == 'type') { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank set fk_type='".$_POST["value"]."', num_chq='".$_POST["num_chq"]."' WHERE rowid = $rowid;"; - $result = $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."bank set fk_type='".$_POST["value"]."', num_chq='".$_POST["num_chq"]."' WHERE rowid = $rowid;"; + $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); + $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); + $sql = "UPDATE ".MAIN_DB_PREFIX."bank set emetteur='".addslashes($_POST["emetteur"])."' WHERE rowid = $rowid;"; + $result = $db->query($sql); } -if ($user->rights->banque->consolidate && $_POST["action"] == 'num_releve') +// Reconcile +if ($user->rights->banque->consolidate && ($_POST["action"] == 'num_releve' || $_POST["action"] == 'setreconcile')) { - $db->begin(); + $num_rel=trim($_POST["num_rel"]); + $rappro=$_POST['reconciled']?1:0; - $num_rel=trim($_POST["num_rel"]); + // Check parameters + if ($rappro && empty($num_rel)) + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountStatement")); + $error++; + } - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET num_releve=".($num_rel?"'".$num_rel."'":"null"); - if (! $num_rel) $sql.= ", rappro = 0"; - $sql.= " WHERE rowid = ".$rowid; + if (! $error) + { + $db->begin(); - dol_syslog("ligne.php sql=".$sql, LOG_DEBUG); - $result = $db->query($sql); - if ($result) - { - $db->commit(); - } - else - { - $db->rollback(); - dol_print_error($db); - } + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET num_releve=".($num_rel?"'".$num_rel."'":"null"); + if (empty($num_rel)) $sql.= ", rappro = 0"; + else $sql.=", rappro = ".$rappro; + $sql.= " WHERE rowid = ".$rowid; + + dol_syslog("ligne.php sql=".$sql, LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + $db->commit(); + } + else + { + $db->rollback(); + dol_print_error($db); + } + } } + /* * View */ @@ -175,17 +189,17 @@ $sql.= " ORDER BY label"; $result = $db->query($sql); if ($result) { - $var=True; - $num = $db->num_rows($result); - $i = 0; - $options = ""; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $options .= "\n"; - $i++; - } - $db->free($result); + $var=True; + $num = $db->num_rows($result); + $i = 0; + $options = ""; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $options .= "\n"; + $i++; + } + $db->free($result); } $var=False; @@ -203,6 +217,7 @@ $h++; dol_fiche_head($head, $hselected, $langs->trans('LineRecord'),0,'account'); +if ($mesg) print '
'.$mesg.'

'; $sql = "SELECT b.rowid,b.dateo as do,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"; @@ -213,54 +228,48 @@ $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') - { - $ret=$html->form_confirm("ligne.php?rowid=".$_GET["rowid"]."&cat1=".$_GET["fk_categ"]."&orig_account=".$orig_account,$langs->trans("RemoveFromRubrique"),$langs->trans("RemoveFromRubriqueConfirm"),"confirm_delete_categ"); - if ($ret == 'html') print '
'; - } + // Confirmations + if ($_GET["action"] == 'delete_categ') + { + $ret=$html->form_confirm("ligne.php?rowid=".$_GET["rowid"]."&cat1=".$_GET["fk_categ"]."&orig_account=".$orig_account,$langs->trans("RemoveFromRubrique"),$langs->trans("RemoveFromRubriqueConfirm"),"confirm_delete_categ"); + if ($ret == 'html') print '
'; + } - print ''; + print '
'; - $objp = $db->fetch_object($result); - $total = $total + $objp->amount; + $objp = $db->fetch_object($result); + $total = $total + $objp->amount; - $acct=new Account($db); - $acct->fetch($objp->fk_account); - $account = $acct->id; + $acct=new Account($db); + $acct->fetch($objp->fk_account); + $account = $acct->id; - $bankline = new AccountLine($db); - $bankline->fetch($rowid,$ref); + $bankline = new AccountLine($db); + $bankline->fetch($rowid,$ref); - $links=$acct->get_url($rowid); + $links=$acct->get_url($rowid); $bankline->load_previous_next_ref('','rowid'); - // Ref - print '"; - print '"; + print ''; - print ''; + print ''; + print ''; $i++; - print ''; - print ''; - print ""; - print ""; - // Account - print ""; - print ''; - print ''; + print ""; + print ''; + print ''; // Show links of bank transactions if (sizeof($links)) @@ -327,177 +336,218 @@ if ($result) print ''; } + // Type of payment / Number + print "'; + } + print ""; + + // Bank + print "'; + } + print ""; + + // Transmitter + print "'; + } + print ""; + + print ''; + print ''; + print ""; + print ""; + print ''; + // Date ope - print ''; - if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) - { - print ''; - } - else - { - print ''; + print ''; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } + else + { + print ''; - // Value date - print ""; - if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) - { - print ''; - print ''; - } - else - { - print ''; - } - print ""; + // Value date + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } + print ""; - // Description - print ""; - if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) - { - print ''; - print ''; + // Description + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; - // Amount - print ""; - if (! $objp->rappro && $user->rights->banque->modifier) - { - print '"; + // Amount + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } + else + { + print '"; - print ""; + print ""; + print "
'.$langs->trans("Ref")."'; + // Ref + print '
'.$langs->trans("Ref")."'; print $html->showrefnav($bankline,'rowid','',1,'rowid','rowid'); - print '
".$langs->trans("Account")."'; - print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.''; - print ''; - print '
".$langs->trans("Account")."'; + print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.''; + print '
".$langs->trans("Type")." / ".$langs->trans("Numero").""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print "rowid\">"; + print ''; + print ''; + print ""; + print $html->select_types_paiements($objp->fk_type,"value",'',2); + print ''; + print ''; + print ""; + } + else + { + print $objp->fk_type.' '.$objp->num_chq.' 
".$langs->trans("Bank").""; + if ($user->rights->banque->modifier) + { + print "
rowid\">"; + print ''; + print ''; + print ""; + print ''; + print '
'; + print ""; + } + else + { + print $objp->banque.'  
".$langs->trans("CheckTransmitter").""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print "
rowid\">"; + print ''; + print ''; + print ""; + print ''; + print '
'; + print ""; + } + else + { + print $objp->emetteur.'  
'.$langs->trans("DateOperation").''; - $html->select_date($db->jdate($objp->do),'dateo','','','','update'); - print ''; - print dol_print_date($db->jdate($objp->do),"day"); - } - print '
'.$langs->trans("DateOperation").''; + if ($objp->rappro) print dol_print_date($db->jdate($objp->do),"day"); + else $html->select_date($db->jdate($objp->do),'dateo','','','','update'); + print 'rappro?' disabled="true"':'').'>'; + print dol_print_date($db->jdate($objp->do),"day"); + } + print '
".$langs->trans("DateValue")."'; - $html->select_date($db->jdate($objp->dv),'datev','','','','update'); - print '   '; - print ''; - print img_edit_remove() . " "; - print ''; - print img_edit_add() .""; - print ''; - print dol_print_date($db->jdate($objp->dv),"day"); - print '
".$langs->trans("DateValue")."'; + if ($objp->rappro) print dol_print_date($db->jdate($objp->dv),"day"); + else + { + $html->select_date($db->jdate($objp->dv),'datev','','','','update'); + print '   '; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + } + } + else + { + print ''; + print dol_print_date($db->jdate($objp->dv),"day"); + print '
".$langs->trans("Label")."'; - print ''; - print ''; - } - else - { - print ''; - if (preg_match('/^\((.*)\)$/i',$objp->label,$reg)) - { - // Label generique car entre parentheses. On l'affiche en le traduisant - print $langs->trans($reg[1]); - } - else - { - print $objp->label; - } - } - print '
".$langs->trans("Label")."'; + if ($objp->rappro) + { + if (preg_match('/^\((.*)\)$/i',$objp->label,$reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + print $langs->trans($reg[1]); + } + else + { + print $objp->label; + } + } + else + { + print ''; + } + } + else + { + print ''; + if (preg_match('/^\((.*)\)$/i',$objp->label,$reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + print $langs->trans($reg[1]); + } + else + { + print $objp->label; + } + } + print '
".$langs->trans("Amount")."'; - print ' '.$langs->trans("Currency".$conf->monnaie); - print ''; - } - else - { - print ''; - print price($objp->amount); - } - print "
".$langs->trans("Amount")."'; + if ($objp->rappro) print price($objp->amount); + else print ' '.$langs->trans("Currency".$conf->monnaie); + print ''; + print price($objp->amount); + } + print "
"; - // Type paiement - print "".$langs->trans("Type")." / ".$langs->trans("Numero").""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print "
rowid\">"; - print ''; - print ''; - print ""; - print $html->select_types_paiements($objp->fk_type,"value",'',2); - print ''; - print ''; - print "
"; - } - else - { - print $objp->fk_type.' '.$objp->num_chq.' '; - } - print ""; + // Releve rappro + if ($acct->rappro) // Si compte rapprochable + { + print '
'."\n"; + print_fiche_titre($langs->trans("Reconciliation"),'',''); + print "
rowid\">"; + print ''; + print ''; + print ""; - // Banque - print "".$langs->trans("Bank").""; - if ($user->rights->banque->modifier) - { - print "rowid\">"; - print ''; - print ''; - print ""; - print ''; - print ''; - print "
"; - } - else - { - print $objp->banque.'  '; - } - print ""; + print ''; - // Emetteur - print "'; - } - print ""; + print '"; + if ($user->rights->banque->consolidate) + { + print ''; + } + else + { + print ''; + } + print ''; + print ""; + if ($user->rights->banque->consolidate) + { + print ''; + } + else + { + print ''; + } + print ''; - // Releve rappro - if ($acct->rappro) // Si compte rapprochable - { - print ""; - if ($user->rights->banque->consolidate) - { - print "rowid\">"; - print ''; - print ''; - print ""; - print ''; - print ''; - } - else - { - print ''; - } - print ''; - } + print "
".$langs->trans("CheckTransmitter").""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print "
rowid\">"; - print ''; - print ''; - print ""; - print ''; - print '
'; - print ""; - } - else - { - print $objp->emetteur.'  
'.$langs->trans("Conciliation")."'; + print $langs->trans("AccountStatement").' '; + print ''.$objp->num_releve.' 
".$langs->trans("BankLineConciliated")."'; + print 'rappro?' checked="true"':'')).'">'; + print ''.yn($objp->rappro).'
".$langs->trans("Conciliation")."
'; - print $langs->trans("AccountStatement").' '; - print ''.$objp->num_releve.' 
"; + print ''; + } - print ""; + } - } - - $db->free($result); + $db->free($result); } print ''; @@ -525,24 +575,24 @@ $sql.= " ORDER BY c.label"; $result = $db->query($sql); if ($result) { - $var=True; - $num = $db->num_rows($result); - $i = 0; $total = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); + $var=True; + $num = $db->num_rows($result); + $i = 0; $total = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); - $var=!$var; - print ""; + $var=!$var; + print ""; - print "$objp->label"; - print "rowid\">".$langs->trans("ListBankTransactions").""; - print "rowid\">".img_delete($langs->trans("Remove")).""; - print ""; + print "$objp->label"; + print "rowid\">".$langs->trans("ListBankTransactions").""; + print "rowid\">".img_delete($langs->trans("Remove")).""; + print ""; - $i++; - } - $db->free($result); + $i++; + } + $db->free($result); } print ""; diff --git a/htdocs/compta/paiement/cheque/liste.php b/htdocs/compta/paiement/cheque/liste.php index f30f3a146f4..c9fca7c773d 100644 --- a/htdocs/compta/paiement/cheque/liste.php +++ b/htdocs/compta/paiement/cheque/liste.php @@ -84,7 +84,7 @@ if ($resql) print ''; print ''; print_liste_field_titre($langs->trans("Ref"),"liste.php","bc.number","",$paramlist,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),"liste.php","dp","",$paramlist,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),"liste.php","dp","",$paramlist,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Account"),"liste.php","ba.label","",$paramlist,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("NbOfCheques"),"liste.php","bc.nbcheque","",$paramlist,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Amount"),"liste.php","bc.amount","",$paramlist,'align="right"',$sortfield,$sortorder);