27require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/loan/class/paymentloan.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/loan.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
43$langs->loadLangs(array(
"bills",
"banks",
"companies",
"loan"));
47$action =
GETPOST(
'action',
'aZ09');
50 $socid = $user->socid;
57 $result = $payment->fetch($id);
59 dol_print_error($db,
'Failed to get payment id '.$id);
63if (!$user->hasRight(
'loan',
'read')) {
69if ($payment->id > 0) {
79if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'loan',
'delete')) {
82 $fk_loan = $payment->fk_loan;
84 $result = $payment->delete($user);
87 header(
"Location: ".DOL_URL_ROOT.
"/loan/card.php?id=".urlencode((
string) ($fk_loan)));
90 setEventMessages($payment->error, $payment->errors,
'errors');
100$form =
new Form($db);
102$title = $langs->trans(
'Loans');
103$help_url =
"EN:Module_Loan|FR:Module_Emprunt";
105llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-loan page-payment-card');
111$head[$h][0] = DOL_URL_ROOT.
'/loan/payment/card.php?id='.
$id;
112$head[$h][1] = $langs->trans(
"PaymentLoan");
113$hselected = (string) $h;
116print
dol_get_fiche_head($head, $hselected, $langs->trans(
"PaymentLoan"), -1,
'payment');
121if ($action ==
'delete') {
122 print $form->formconfirm(
'card.php?id='.$payment->id, $langs->trans(
"DeletePayment"), $langs->trans(
"ConfirmDeletePayment"),
'confirm_delete',
'', 0, 2);
129dol_banner_tab($payment,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
131print
'<div class="fichecenter">';
132print
'<div class="underbanner clearboth"></div>';
134print
'<table class="border centpercent">';
137print
'<tr><td>'.$langs->trans(
'Date').
'</td><td>'.
dol_print_date($payment->datep,
'day').
'</td></tr>';
140print
'<tr><td>'.$langs->trans(
'Mode').
'</td><td>'.$langs->trans(
"PaymentType".$payment->type_code).
'</td></tr>';
143print
'<tr><td>'.$langs->trans(
'LoanCapital').
'</td><td>'.
price($payment->amount_capital, 0, $langs, 1, -1, -1,
$conf->currency).
'</td></tr>';
144$loan->fetch($payment->fk_loan);
145print
'<tr><td>'.loanChargeLabel($loan->charge_type, $langs).
'</td><td>'.
price($payment->amount_insurance, 0, $langs, 1, -1, -1,
$conf->currency).
'</td></tr>';
146print
'<tr><td>'.$langs->trans(
'Interest').
'</td><td>'.
price($payment->amount_interest, 0, $langs, 1, -1, -1,
$conf->currency).
'</td></tr>';
149print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td><td>'.nl2br($payment->note_private).
'</td></tr>';
152print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td><td>'.nl2br($payment->note_public).
'</td></tr>';
156 if ($payment->bank_account) {
158 $bankline->fetch($payment->bank_line);
161 print
'<td>'.$langs->trans(
'BankTransactionLine').
'</td>';
163 print $bankline->getNomUrl(1, 0,
'showall');
179$sql =
'SELECT l.rowid as id, l.label, l.paid, l.capital as capital, pl.amount_capital, pl.amount_insurance, pl.amount_interest';
180$sql .=
' FROM '.MAIN_DB_PREFIX.
'payment_loan as pl,'.MAIN_DB_PREFIX.
'loan as l';
181$sql .=
' WHERE pl.fk_loan = l.rowid';
182$sql .=
' AND l.entity = '.((int)
$conf->entity);
183$sql .=
' AND pl.rowid = '.((int) $payment->id);
185dol_syslog(
"loan/payment/card.php", LOG_DEBUG);
186$resql = $db->query($sql);
188 $num = $db->num_rows($resql);
192 print
'<br><table class="noborder centpercent">';
193 print
'<tr class="liste_titre">';
194 print
'<td>'.$langs->trans(
'Loan').
'</td>';
195 print
'<td>'.$langs->trans(
'Label').
'</td>';
197 print
'<td class="center">'.$langs->trans(
'Status').
'</td>';
198 print
'<td class="right">'.$langs->trans(
'PayedByThisPayment').
'</td>';
203 $objp = $db->fetch_object($resql);
205 print
'<tr class="oddeven">';
208 $loan->fetch($objp->id);
209 print $loan->getNomUrl(1);
212 print
'<td>'.$objp->label.
'</td>';
216 print
'<td class="center">'.$loan->getLibStatut(4, $objp->amount_capital).
'</td>';
218 $amount_payed = $objp->amount_capital + $objp->amount_insurance + $objp->amount_interest;
220 print
'<td class="right">'.price($amount_payed).
'</td>';
222 if ($objp->paid == 1) {
225 $total += $objp->amount_capital;
234 dol_print_error($db);
244print
'<div class="tabsAction">';
246if (empty($action) && $user->hasRight(
'loan',
'delete')) {
247 if (!$disable_delete) {
248 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=delete&token='.
newToken(),
'delete', 1, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
250 print dolGetButtonAction($langs->trans(
"CantRemovePaymentWithOneInvoicePaid"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=delete&token='.
newToken(),
'delete', 0);
$id
Support class for third parties, contacts, members, users or resources.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage bank transaction lines.
Class to manage payments of loans.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.