diff --git a/ChangeLog b/ChangeLog index ecd5a6b7160..dd037efb3df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ For users: saved clicks again). - When creating a contract, sales representative are preset to user. This save 2 clicks. + - Can edit several fields in bank transaction line page into one update. - New: Add graph using Jquery Flot. - New: Usage of Jquery Notify to show result or error messages on action. - New: If a service contains subproducts, subrpoducts are decrease when service @@ -58,6 +59,8 @@ For users: - New: Can filter on date when building cheque receipts. - New: Paypal module can show paypal list of transaction and convert one into an order. +- New: task #10958 : Add link to cheque receipts into bank transaction + line if exists - Fix: Better Postgresql compatibility. - Fix: Numbering module for invoices use same number for invoice and credit note if mask is same. diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 0afaa00a754..7f812bb2c1e 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -37,9 +37,12 @@ $langs->load("bills"); $langs->load("categories"); if ($conf->adherent->enabled) $langs->load("members"); -$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; -$ref=isset($_GET["ref"])?$_GET["ref"]:$_POST["ref"]; -$orig_account=isset($_GET["orig_account"])?$_GET["orig_account"]:$_POST["orig_account"]; +$action=GETPOST('action'); +$rowid=GETPOST("rowid"); +$ref=GETPOST("ref"); +$orig_account=GETPOST("orig_account"); +$accountid=GETPOST('accountid'); +$confirm=GETPOST('confirm'); $html = new Form($db); @@ -59,18 +62,18 @@ if ($user->rights->banque->consolidate && $_GET["action"] == 'dvprev') $ac->datev_previous($_GET["rowid"]); } -if ($_POST["action"] == 'confirm_delete_categ' && $_POST["confirm"] == "yes") +if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_GET["cat1"]; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".GETPOST("cat1"); if (! $db->query($sql)) { dol_print_error($db); } } -if ($_POST["action"] == 'class') +if ($action == 'class') { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_POST["cat1"]; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".$_POST["cat1"]; if (! $db->query($sql)) { dol_print_error($db); @@ -83,16 +86,16 @@ if ($_POST["action"] == 'class') } } -if ($_POST["action"] == "update") +if ($action == "update") { // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche + $conciliated=0; $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"); + $conciliated=$objp->rappro; } $db->begin(); @@ -101,15 +104,27 @@ if ($_POST["action"] == "update") $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='".$db->escape($_POST["label"])."',"; - if (isset($_POST['amount'])) $sql.=" amount='$amount',"; - $sql.= " dateo = '".$db->idate($dateop)."', datev = '".$db->idate($dateval)."',"; - $sql.= " fk_account = ".$_POST['accountid']; + $sql.= " SET "; + // Always opened + if (isset($_POST['value'])) $sql.=" fk_type='".$db->escape($_POST['value'])."',"; + if (isset($_POST['num_chq'])) $sql.=" num_chq='".$db->escape($_POST["num_chq"])."',"; + if (isset($_POST['banque'])) $sql.=" banque='".$db->escape($_POST["banque"])."',"; + if (isset($_POST['emetteur'])) $sql.=" emetteur='".$db->escape($_POST["emetteur"])."',"; + // Blocked when conciliated + if (! $conciliated) + { + if (isset($_POST['label'])) $sql.=" label='".$db->escape($_POST["label"])."',"; + if (isset($_POST['amount'])) $sql.=" amount='".$amount."',"; + if (isset($_POST['dateomonth'])) $sql.=" dateo = '".$db->idate($dateop)."',"; + if (isset($_POST['datevmonth'])) $sql.=" datev = '".$db->idate($dateval)."',"; + } + $sql.= " fk_account = ".$accountid; $sql.= " WHERE rowid = ".$rowid; $result = $db->query($sql); if ($result) { + $mesg=$langs->trans("RecordSaved"); $db->commit(); } else @@ -119,26 +134,8 @@ if ($_POST["action"] == "update") } } -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); -} - -if ($_POST["action"] == 'banque') -{ - $sql = "UPDATE ".MAIN_DB_PREFIX."bank set banque='".$db->escape($_POST["banque"])."' WHERE rowid = $rowid;"; - $result = $db->query($sql); -} - -if ($_POST["action"] == 'emetteur') -{ - $sql = "UPDATE ".MAIN_DB_PREFIX."bank set emetteur='".$db->escape($_POST["emetteur"])."' WHERE rowid = $rowid;"; - $result = $db->query($sql); -} - // Reconcile -if ($user->rights->banque->consolidate && ($_POST["action"] == 'num_releve' || $_POST["action"] == 'setreconcile')) +if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == 'setreconcile')) { $num_rel=trim($_POST["num_rel"]); $rappro=$_POST['reconciled']?1:0; @@ -164,6 +161,7 @@ if ($user->rights->banque->consolidate && ($_POST["action"] == 'num_releve' || $ $result = $db->query($sql); if ($result) { + $mesg=$langs->trans("RecordSaved"); $db->commit(); } else @@ -217,11 +215,12 @@ $h++; dol_fiche_head($head, $hselected, $langs->trans('LineRecord'),0,'account'); -if ($mesg) print '
'.$mesg.'

'; +if (! preg_match('/class="error"/i',$mesg)) dol_htmloutput_mesg($mesg); +else dol_htmloutput_errors($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"; -$sql.= ",b.emetteur,b.banque"; +$sql.= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,"; +$sql.= " b.emetteur,b.banque"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " WHERE rowid=".$rowid; $sql.= " ORDER BY dateo ASC"; @@ -231,17 +230,8 @@ if ($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 '
'; - } - - print ''; - $objp = $db->fetch_object($result); + $total = $total + $objp->amount; $acct=new Account($db); @@ -254,6 +244,21 @@ if ($result) $links=$acct->get_url($rowid); $bankline->load_previous_next_ref('','rowid'); + // Confirmations + if ($action == 'delete_categ') + { + $ret=$html->form_confirm("ligne.php?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); + if ($ret == 'html') print '
'; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + // Ref print '"; print ''; } + $rowspan=0; + + //$user->rights->banque->modifier=false; + //$user->rights->banque->consolidate=true; + // Type of payment / Number - print ""; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { - print "rowid\">"; - print ''; - print ''; - print ""; + print ''; + $rowspan=7; + print ''; } else { - print $objp->fk_type.' '.$objp->num_chq.''; + print ''; } - print ""; + print ""; // Bank of cheque - print "'; - } - print ""; - - // Transmitter - print ""; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { - print "rowid\">"; - print ''; - print ''; - print ""; - print ''; - print ''; } else { - print $objp->emetteur.' '; + print ''; } - print ""; + print ""; - print ''; - print ''; - print ""; - print ""; - print ''; + // Transmitter + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } + else + { + print ''; + } + print ""; // Date ope print ''; @@ -403,14 +408,15 @@ if ($result) { print ''; + print ''; } else { - print ''; } - print ''; + print ''; // Value date print ""; @@ -426,10 +432,11 @@ if ($result) print ''; print img_edit_add() .""; } + print ''; } else { - print ''; } @@ -451,10 +458,11 @@ if ($result) print $objp->label; } print '" size="50">'; + print ''; } else { - print ''; } - print ''; + print ''; // Amount print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + if ($user->rights->banque->modifier) { print ''; } - print ""; + print ""; - print ""; print "
'.$langs->trans("Ref")."'; @@ -329,6 +334,7 @@ if ($result) } else { print ''; + print img_object('','generic').' '; print $links[$key]['label']; print ''; } @@ -336,66 +342,65 @@ if ($result) print '
".$langs->trans("Type")." / ".$langs->trans("Numero").""; + print "
".$langs->trans("Type")." / ".$langs->trans("Numero"); + print "'; print $html->select_types_paiements($objp->fk_type,"value",'',2); print ''; - print ''; - print ""; + if ($objp->receiptid) + { + include_once(DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'); + $receipt=new RemiseCheque($db); + $receipt->fetch($objp->receiptid); + print '     '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2); + + } + print ''; + 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").""; + print "
".$langs->trans("Bank")."
'; - print ""; + print ''; + print ''; + print ' '.$objp->banque.'
".$langs->trans("CheckTransmitter")."'; + print ''; + print ''.$objp->emetteur.'
'.$langs->trans("DateOperation").''; print $html->select_date($db->jdate($objp->do),'dateo','','','','update',1,0,1,$objp->rappro); - print 'rappro?' disabled="true"':'').'>'; + print ''; print dol_print_date($db->jdate($objp->do),"day"); + print '
".$langs->trans("DateValue")."'; + print ''; print dol_print_date($db->jdate($objp->dv),"day"); print ''; + print ''; if (preg_match('/^\((.*)\)$/i',$objp->label,$reg)) { // Label generique car entre parentheses. On l'affiche en le traduisant @@ -464,12 +472,13 @@ if ($result) { print $objp->label; } + print '
".$langs->trans("Amount")."'; print 'rappro?' disabled="true"':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$conf->monnaie); @@ -477,13 +486,14 @@ if ($result) } else { - print ''; + print ''; print price($objp->amount); + print '
"; + print ""; // Releve rappro if ($acct->canBeConciliated() > 0) // Si compte rapprochable @@ -539,6 +549,7 @@ if ($result) $db->free($result); } +else dol_print_error($db); print ''; @@ -573,11 +584,14 @@ if ($result) $objp = $db->fetch_object($result); $var=!$var; - print ""; + print ""; - print "$objp->label"; - print "rowid\">".$langs->trans("ListBankTransactions").""; - print "rowid\">".img_delete($langs->trans("Remove")).""; + print "".$objp->label.""; + print "rowid."\">".$langs->trans("ListBankTransactions").""; + if ($user->rights->banque->modifier) + { + print "rowid\">".img_delete($langs->trans("Remove")).""; + } print ""; $i++; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 296f9826260..322aef28074 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -209,7 +209,7 @@ class RemiseCheque extends CommonObject } if ($this->id > 0 && $this->errno == 0) - { + { foreach ($lines as $lineid) { $checkremise=false; @@ -217,7 +217,7 @@ class RemiseCheque extends CommonObject { if($linetoremise==$lineid) $checkremise=true; } - + if($checkremise==true) { $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; @@ -713,21 +713,21 @@ class RemiseCheque extends CommonObject /** - * \brief Renvoie nom clicable (avec eventuellement le picto) - * \param withpicto Inclut le picto dans le lien - * \param option Sur quoi pointe le lien - * \return string Chaine avec URL + * Renvoie nom clicable (avec eventuellement le picto) + * @param withpicto Inclut le picto dans le lien + * @param option Sur quoi pointe le lien + * @return string Chaine avec URL */ function getNomUrl($withpicto=0,$option='') { - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + global $langs; $result=''; - $number=$this->number; - if ($this->statut == 0) $number='(PROV'.$this->rowid.')'; + $number=$this->ref; + if ($this->statut == 0) $number='(PROV'.$this->id.')'; - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowCheckReceipt"),'payment').$lienfin.' '); diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index bac84594523..1968220f7da 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -118,9 +118,10 @@ ValidateCheckReceipt=Validate this check receipt ? ConfirmValidateCheckReceipt=Are you sure you want to validate this check receipt, no change will be possible once this is done ? DeleteCheckReceipt=Delete this check receipt ? ConfirmDeleteCheckReceipt=Are you sure you want to delete this check receipt ? -BankChecks=Bank cheques -BankChecksToReceipt=Cheques waiting for deposit -NumberOfCheques=Nb of cheques +BankChecks=Bank checks +BankChecksToReceipt=Checks waiting for deposit +ShowCheckReceipt=Show check deposit receipt +NumberOfCheques=Nb of check DeleteTransaction=Delete transaction ConfirmDeleteTransaction=Are you sure you want to delete this transaction ? ThisWillAlsoDeleteBankRecord=This will also delete generated bank transactions @@ -140,5 +141,5 @@ AllAccounts=All bank/cash accounts BackToAccount=Back to account ShowAllAccounts=Show for all accounts FutureTransaction=Transaction in futur. No way to conciliate. -SelectChequeTransactionAndGenerate=Select/filter cheques to include into the cheque receipt and click on "Create". +SelectChequeTransactionAndGenerate=Select/filter checks to include into the check deposit receipt and click on "Create". diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index 8bf846d669b..ee6af3267c7 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -120,6 +120,7 @@ DeleteCheckReceipt=Supprimer ce bordereau de remise ? ConfirmDeleteCheckReceipt=Êtes-vous sûr de vouloir supprimer ce bordereau ? BankChecks=Chèques BankChecksToReceipt=Chèques à déposer +ShowCheckReceipt=Afficher bordereau remise chèque NumberOfCheques=Nb de chèques DeleteTransaction=Supprimer l'écriture ConfirmDeleteTransaction=Êtes-vous sûr de vouloir supprimer cette écriture ?