diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7082f9fe451..91e4f621e21 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -671,9 +671,11 @@ if (empty($reshook)) { } if (!$error) { - $newremaintopay = $object->getRemainToPay(0); - if ($newremaintopay == 0) { - $object->setPaid($user); + if ($object->status == Facture::STATUS_VALIDATED) { + $newremaintopay = $object->getRemainToPay(0); + if ($newremaintopay == 0) { + $object->setPaid($user); + } } } } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index c165adee7a0..c67ac46b3ab 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -821,30 +821,36 @@ if ($object->id > 0) { //print $langs->trans('CustomerIBAN').' '; // if societe rib in model invoice, we preselect it - $selectedRib = ''; + $selectedRibId = 0; if ($object->element == 'invoice' && $object->fk_fac_rec_source) { $facturerec = new FactureRec($db); $facturerec->fetch($object->fk_fac_rec_source); if ($facturerec->fk_societe_rib) { $companyBankAccount = new CompanyBankAccount($db); $res = $companyBankAccount->fetch($facturerec->fk_societe_rib); - $selectedRib = $companyBankAccount->id; + $selectedRibId = $companyBankAccount->id; } } - $selectedRib = $form->selectRib($selectedRib, 'accountcustomerid', 'fk_soc='.$object->socid, $langs->trans("CustomerIBAN"), '', 1, 'maxwidth500 maxwidth250onsmartphone'); - - $defaultRibId = $object->thirdparty->getDefaultRib(); - if ($defaultRibId) { - $companyBankAccount = new CompanyBankAccount($db); - $res = $companyBankAccount->fetch($defaultRibId); - if ($res > 0 && !$companyBankAccount->verif()) { - print img_warning('Error on default bank number for IBAN : '.$langs->trans($companyBankAccount->error)); - } - } elseif (($type != 'bank-transfer' && $object->mode_reglement_code == 'PRE') || ($type == 'bank-transfer' && $object->mode_reglement_code == 'VIR')) { - print img_warning($langs->trans("NoDefaultIBANFound")); + $defaultRibId = 0; + if (empty($selectedRibId)) { + $defaultRibId = $object->thirdparty->getDefaultRib(); + $selectedRibId = (int) $defaultRibId; } + $selectedRib = $form->selectRib($selectedRibId, 'accountcustomerid', 'fk_soc='.$object->socid, $langs->trans("CustomerIBAN"), '', 1, 'maxwidth500 maxwidth250onsmartphone'); + + if (empty($selectedRibId)) { + if ($defaultRibId) { + $companyBankAccount = new CompanyBankAccount($db); + $res = $companyBankAccount->fetch($defaultRibId); + if ($res > 0 && !$companyBankAccount->verif()) { + print img_warning('Error on default bank number for IBAN : '.$langs->trans($companyBankAccount->error)); + } + } elseif (($type != 'bank-transfer' && $object->mode_reglement_code == 'PRE') || ($type == 'bank-transfer' && $object->mode_reglement_code == 'VIR')) { + print img_warning($langs->trans("NoDefaultIBANFound")); + } + } // Bank Transfer Amount if (getDolOptimizeSmallScreen()) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 288a29987b5..ce7d90a528b 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1431,7 +1431,7 @@ class FormFile // Show title of list of existing files $morehtmlright = ''; if (!empty($moreoptions['showhideaddbutton']) && $conf->use_javascript_ajax) { - $tmpurlforbutton = 'javascript:console.log("open add file form");jQuery(".divattachnewfile").toggle(); if (!jQuery(".divattachnewfile").is(":hidden")) { jQuery("input[type=\'file\']").click(); } void(0);'; + $tmpurlforbutton = 'javascript:console.log("open add file form");jQuery(".divattachnewfile").toggle(); if (!jQuery(".divattachnewfile").is(":hidden")) { jQuery(".divattachnewfile input[type=\'file\']").first().click();} void(0);'; // scope file picker click to the just-shown form to avoid triggering native file dialog twice when other input[type=file] exist on the page $morehtmlright .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $tmpurlforbutton, '', $permtoeditline); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c208581a422..db3588850ec 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -15331,8 +15331,7 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '', $us //var_dump($element_prop); //var_dump($element_prop['module'].' '.$ismodenabled); if (is_array($element_prop) && (empty($element_prop['module']) || $ismodenabled)) { - if ( - $useCache === 1 + if ($useCache === 1 && $element_id > 0 && !empty($conf->cache['fetchObjectByElement'][$element_type]) && !empty($conf->cache['fetchObjectByElement'][$element_type][$element_id]) && is_object($conf->cache['fetchObjectByElement'][$element_type][$element_id]) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index d6571077427..3a1120e4ded 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -120,7 +120,7 @@ print '