diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 677c71d31dee7..3b6fe148f5e85 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -395,7 +395,7 @@ public function getErrorString($error) * * @param int $rowid Id of object to load * @param string $ref Ref of direct debit - * @return int >0 if OK, <0 if KO + * @return int >0 if OK, 0=Not found, <0 if KO */ public function fetch($rowid, $ref = '') { @@ -448,11 +448,11 @@ public function fetch($rowid, $ref = '') return 1; } else { - dol_syslog(get_class($this) . "::Fetch Erreur aucune ligne retournee"); - return -1; + dol_syslog(get_class($this) . "::Fetch no record found"); + return 0; } } else { - return -2; + return -1; } } diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 827e2e9fc0780..534051f96f3b5 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -94,112 +94,116 @@ llxHeader('', $langs->trans("WithdrawalsReceipts")); if ($id > 0 || $ref) { - if ($object->fetch($id, $ref) >= 0) { - $head = prelevement_prepare_head($object); + $object->fetch($id, $ref); + if (empty($object->id)) { + $langs->load('errors'); + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; + llxFooter(); + exit; + } - print dol_get_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); + $head = prelevement_prepare_head($object); - $linkback = ''.$langs->trans("BackToList").''; + print dol_get_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref'); + $linkback = ''.$langs->trans("BackToList").''; - print '
'; - print '
'; - print ''."\n"; + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref'); - //print ''; - print ''; - print ''; + print '
'; + print '
'; + print '
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec, 'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'."\n"; - if (!empty($object->date_trans)) { - $muser = new User($db); - $muser->fetch($object->user_trans); + //print ''; + print ''; + print ''; - print ''; - print ''; - } - if (!empty($object->date_credit)) { - print ''; - } + if (!empty($object->date_trans)) { + $muser = new User($db); + $muser->fetch($object->user_trans); - print '
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec, 'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans("TransData").''; - print dol_print_date($object->date_trans, 'day'); - print '   '.$langs->trans("By").' '.$muser->getNomUrl(-1).'
'.$langs->trans("TransMetod").''; - print $object->methodes_trans[$object->method_trans]; - print '
'.$langs->trans('CreditDate').''; - print dol_print_date($object->date_credit, 'day'); - print '
'; + print ''.$langs->trans("TransData").''; + print dol_print_date($object->date_trans, 'day'); + print '   '.$langs->trans("By").' '.$muser->getNomUrl(-1).''; + print ''.$langs->trans("TransMetod").''; + print $object->methodes_trans[$object->method_trans]; + print ''; + } + if (!empty($object->date_credit)) { + print ''.$langs->trans('CreditDate').''; + print dol_print_date($object->date_credit, 'day'); + print ''; + } - print '
'; + print ''; - print '
'; - print ''; + print '
'; - // Get bank account for the payment - $acc = new Account($db); - $fk_bank_account = $object->fk_bank_account; - if (empty($fk_bank_account)) { - $fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT')); - } - if ($fk_bank_account > 0) { - $result = $acc->fetch($fk_bank_account); - } + print '
'; + print '
'; - $labelofbankfield = "BankToReceiveWithdraw"; - if ($object->type == 'bank-transfer') { - $labelofbankfield = 'BankToPayCreditTransfer'; - } + // Get bank account for the payment + $acc = new Account($db); + $fk_bank_account = $object->fk_bank_account; + if (empty($fk_bank_account)) { + $fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT')); + } + if ($fk_bank_account > 0) { + $result = $acc->fetch($fk_bank_account); + } - print ''; + $labelofbankfield = "BankToReceiveWithdraw"; + if ($object->type == 'bank-transfer') { + $labelofbankfield = 'BankToPayCreditTransfer'; + } - print ''; - print ''; + print ''; - $modulepart = 'prelevement'; - if ($object->type == 'bank-transfer') { - $modulepart = 'paymentbybanktransfer'; - } + print ''; + print ''; - print '
'; - print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield)); - print ''; - if ($acc->id > 0) { - print $acc->getNomUrl(1); - } - print '
'; + print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield)); + print ''; + if ($acc->id > 0) { + print $acc->getNomUrl(1); + } + print '
'; - $labelfororderfield = 'WithdrawalFile'; - if ($object->type == 'bank-transfer') { - $labelfororderfield = 'CreditTransferFile'; - } - print $langs->trans($labelfororderfield).''; + $modulepart = 'prelevement'; + if ($object->type == 'bank-transfer') { + $modulepart = 'paymentbybanktransfer'; + } - if (isModEnabled('multicompany')) { - $labelentity = $conf->entity; - $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml'; + print '
'; + $labelfororderfield = 'WithdrawalFile'; + if ($object->type == 'bank-transfer') { + $labelfororderfield = 'CreditTransferFile'; + } + print $langs->trans($labelfororderfield).''; - if ($type != 'bank-transfer') { - $dir = $conf->prelevement->dir_output; - } else { - $dir = $conf->paymentbybanktransfer->dir_output; - } - if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility - $relativepath = 'receipts/'.$object->ref.'.xml'; - } + if (isModEnabled('multicompany')) { + $labelentity = $conf->entity; + $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml'; + + if ($type != 'bank-transfer') { + $dir = $conf->prelevement->dir_output; } else { + $dir = $conf->paymentbybanktransfer->dir_output; + } + if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility $relativepath = 'receipts/'.$object->ref.'.xml'; } + } else { + $relativepath = 'receipts/'.$object->ref.'.xml'; + } - print ''.$relativepath; - print img_picto('', 'download', 'class="paddingleft"'); - print ''; - print '
'; + print ''.$relativepath; + print img_picto('', 'download', 'class="paddingleft"'); + print ''; + print ''; - print '
'; + print ''; - print dol_get_fiche_end(); - } else { - dol_print_error($db); - } + print dol_get_fiche_end(); }