diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 74db4005126..1d59be355c0 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1081,6 +1081,8 @@ class Account extends CommonObject $this->db->begin(); + // @TODO Check there is no child into llx_payment_various, ... to allow deletion ? + // Delete link between tag and bank account if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; @@ -1903,7 +1905,6 @@ class AccountLine extends CommonObject $sql .= " b.fk_user_author, b.fk_user_rappro,"; $sql .= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,"; $sql .= " b.fk_bordereau, b.banque, b.emetteur,"; - //$sql.= " b.author"; // Is this used ? $sql .= " ba.ref as bank_account_ref, ba.label as bank_account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b,"; $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 3d07c280559..f2a71b22e9b 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -126,6 +126,22 @@ class PaymentVarious extends CommonObject public $fk_user_modif; + /** + * @var int Type of bank account if the payment is on a bank account + */ + public $fk_type; + + /** + * @var int 1 if the payment is on a bank account line that is conciliated + */ + public $rappro; + + /** + * @var string ID of bank receipt + */ + public $bank_num_releve; + + /** * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" @@ -251,7 +267,6 @@ class PaymentVarious extends CommonObject */ public function fetch($id, $user = null) { - global $langs; $sql = "SELECT"; $sql .= " v.rowid,"; $sql .= " v.tms,"; @@ -262,7 +277,7 @@ class PaymentVarious extends CommonObject $sql .= " v.fk_typepayment,"; $sql .= " v.num_payment,"; $sql .= " v.label,"; - $sql .= " v.note,"; + $sql .= " v.note as note_private,"; $sql .= " v.accountancy_code,"; $sql .= " v.subledger_account,"; $sql .= " v.fk_projet as fk_project,"; @@ -271,7 +286,8 @@ class PaymentVarious extends CommonObject $sql .= " v.fk_user_modif,"; $sql .= " b.fk_account,"; $sql .= " b.fk_type,"; - $sql .= " b.rappro"; + $sql .= " b.rappro,"; + $sql .= " b.num_releve as bank_num_releve"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; $sql .= " WHERE v.rowid = ".((int) $id); @@ -292,7 +308,8 @@ class PaymentVarious extends CommonObject $this->type_payment = $obj->fk_typepayment; $this->num_payment = $obj->num_payment; $this->label = $obj->label; - $this->note = $obj->note; + $this->note = $obj->note_private; // For backward compatibility + $this->note_private = $obj->note_private; $this->subledger_account = $obj->subledger_account; $this->accountancy_code = $obj->accountancy_code; $this->fk_project = $obj->fk_project; @@ -302,6 +319,7 @@ class PaymentVarious extends CommonObject $this->fk_account = $obj->fk_account; $this->fk_type = $obj->fk_type; $this->rappro = $obj->rappro; + $this->bank_num_releve = $obj->bank_num_releve; } $this->db->free($resql); diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index f94eb38f27d..1eb552fd711 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -643,18 +643,28 @@ if ($id) { print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); print ''; - if (isModEnabled("banque")) { - if ($object->fk_account > 0) { - $bankline = new AccountLine($db); - $bankline->fetch($object->fk_bank); + $bankaccountnotfound = 0; - print ''; - print ''.$langs->trans('BankTransactionLine').''; - print ''; - print $bankline->getNomUrl(1, 0, 'showall'); - print ''; - print ''; + if (isModEnabled('banque')) { + print ''; + print ''.$langs->trans('BankTransactionLine').''; + print ''; + if ($object->fk_bank > 0) { + $bankline = new AccountLine($db); + $result = $bankline->fetch($object->fk_bank); + + if ($result <= 0) { + $bankaccountnotfound = 1; + } else { + print $bankline->getNomUrl(1, 0, 'showall'); + } + } else { + $bankaccountnotfound = 1; + + print ''.$langs->trans("NoRecordfound").''; } + print ''; + print ''; } // Other attributes @@ -684,7 +694,7 @@ if ($id) { } // Delete - if (empty($object->rappro)) { + if (empty($object->rappro) || $bankaccountnotfound) { if (!empty($user->rights->banque->modifier)) { if ($alreadyaccounted) { print '
'.$langs->trans("Delete").'
'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index db5e163f62d..3bd65a6a703 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8963,6 +8963,9 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1' } } } + if (is_array($s) || $s === 'Array') { + return 'Bad string syntax to evaluate (value is Array) '.var_export($s, true); + } if (strpos($s, '::') !== false) { if ($returnvalue) { return 'Bad string syntax to evaluate (double : char is forbidden): '.$s; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 26469449a0b..47e4f808fc5 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -217,6 +217,10 @@ DELETE from llx_bank_url where type = 'company' and url_id not in (select rowid --SELECT * from llx_bank where rappro = 0 and label LIKE '(CustomerInvoicePayment%)' and rowid not in (select fk_bank from llx_bank_url where type = 'payment'); --SELECT * from llx_bank where rappro = 0 and label LIKE '(SupplierInvoicePayment%)' and rowid not in (select fk_bank from llx_bank_url where type = 'payment_supplier'); +-- Fix: delete orphelins in llx_bank +DELETE FROM llx_bank WHERE fk_account NOT IN (select rowid from llx_bank_account); + + -- Fix link on parent that were removed DROP table tmp_user; CREATE TABLE tmp_user as (select * from llx_user);