|
@@ -28,8 +28,12 @@ require '../main.inc.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
|
|
-if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
|
|
-if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
|
|
+if (!empty($conf->accounting->enabled)) {
|
|
|
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
|
|
+}
|
|
|
+if (!empty($conf->accounting->enabled)) {
|
|
|
+ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
|
|
+}
|
|
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
|
|
|
|
@@ -45,7 +49,9 @@ $projectid = GETPOST('projectid', 'int');
|
|
|
|
|
|
// Security check
|
|
|
$socid = GETPOST('socid', 'int');
|
|
|
-if ($user->socid) $socid = $user->socid;
|
|
|
+if ($user->socid) {
|
|
|
+ $socid = $user->socid;
|
|
|
+}
|
|
|
$result = restrictedArea($user, 'loan', $id, '', '');
|
|
|
|
|
|
$object = new Loan($db);
|
|
@@ -60,16 +66,15 @@ $error = 0;
|
|
|
*/
|
|
|
|
|
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
|
|
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
-if (empty($reshook))
|
|
|
-{
|
|
|
+if ($reshook < 0) {
|
|
|
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
+}
|
|
|
+if (empty($reshook)) {
|
|
|
// Classify paid
|
|
|
- if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write)
|
|
|
- {
|
|
|
+ if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write) {
|
|
|
$object->fetch($id);
|
|
|
$result = $object->setPaid($user);
|
|
|
- if ($result > 0)
|
|
|
- {
|
|
|
+ if ($result > 0) {
|
|
|
setEventMessages($langs->trans('LoanPaid'), null, 'mesgs');
|
|
|
} else {
|
|
|
setEventMessages($loan->error, null, 'errors');
|
|
@@ -77,12 +82,10 @@ if (empty($reshook))
|
|
|
}
|
|
|
|
|
|
// Delete loan
|
|
|
- if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write)
|
|
|
- {
|
|
|
+ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write) {
|
|
|
$object->fetch($id);
|
|
|
$result = $object->delete($user);
|
|
|
- if ($result > 0)
|
|
|
- {
|
|
|
+ if ($result > 0) {
|
|
|
setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs');
|
|
|
header("Location: list.php");
|
|
|
exit;
|
|
@@ -92,44 +95,37 @@ if (empty($reshook))
|
|
|
}
|
|
|
|
|
|
// Add loan
|
|
|
- if ($action == 'add' && $user->rights->loan->write)
|
|
|
- {
|
|
|
- if (!$cancel)
|
|
|
- {
|
|
|
+ if ($action == 'add' && $user->rights->loan->write) {
|
|
|
+ if (!$cancel) {
|
|
|
$datestart = dol_mktime(12, 0, 0, GETPOST('startmonth', 'int'), GETPOST('startday', 'int'), GETPOST('startyear', 'int'));
|
|
|
$dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int'));
|
|
|
$capital = price2num(GETPOST('capital'));
|
|
|
$rate = GETPOST('rate');
|
|
|
|
|
|
- if (!$capital)
|
|
|
- {
|
|
|
+ if (!$capital) {
|
|
|
$error++; $action = 'create';
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
|
|
|
}
|
|
|
- if (!$datestart)
|
|
|
- {
|
|
|
+ if (!$datestart) {
|
|
|
$error++; $action = 'create';
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors');
|
|
|
}
|
|
|
- if (!$dateend)
|
|
|
- {
|
|
|
+ if (!$dateend) {
|
|
|
$error++; $action = 'create';
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors');
|
|
|
}
|
|
|
- if ($rate == '')
|
|
|
- {
|
|
|
+ if ($rate == '') {
|
|
|
$error++; $action = 'create';
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rate")), null, 'errors');
|
|
|
}
|
|
|
|
|
|
- if (!$error)
|
|
|
- {
|
|
|
+ if (!$error) {
|
|
|
$object->label = GETPOST('label');
|
|
|
- $object->fk_bank = GETPOST('accountid');
|
|
|
- $object->capital = $capital;
|
|
|
+ $object->fk_bank = GETPOST('accountid');
|
|
|
+ $object->capital = $capital;
|
|
|
$object->datestart = $datestart;
|
|
|
- $object->dateend = $dateend;
|
|
|
- $object->nbterm = GETPOST('nbterm');
|
|
|
+ $object->dateend = $dateend;
|
|
|
+ $object->nbterm = GETPOST('nbterm');
|
|
|
$object->rate = $rate;
|
|
|
$object->note_private = GETPOST('note_private', 'restricthtml');
|
|
|
$object->note_public = GETPOST('note_public', 'restricthtml');
|
|
@@ -140,13 +136,24 @@ if (empty($reshook))
|
|
|
$accountancy_account_insurance = GETPOST('accountancy_account_insurance');
|
|
|
$accountancy_account_interest = GETPOST('accountancy_account_interest');
|
|
|
|
|
|
- if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; }
|
|
|
- if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; }
|
|
|
- if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; }
|
|
|
+ if ($accountancy_account_capital <= 0) {
|
|
|
+ $object->account_capital = '';
|
|
|
+ } else {
|
|
|
+ $object->account_capital = $accountancy_account_capital;
|
|
|
+ }
|
|
|
+ if ($accountancy_account_insurance <= 0) {
|
|
|
+ $object->account_insurance = '';
|
|
|
+ } else {
|
|
|
+ $object->account_insurance = $accountancy_account_insurance;
|
|
|
+ }
|
|
|
+ if ($accountancy_account_interest <= 0) {
|
|
|
+ $object->account_interest = '';
|
|
|
+ } else {
|
|
|
+ $object->account_interest = $accountancy_account_interest;
|
|
|
+ }
|
|
|
|
|
|
$id = $object->create($user);
|
|
|
- if ($id <= 0)
|
|
|
- {
|
|
|
+ if ($id <= 0) {
|
|
|
$error++;
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
|
|
$action = 'create';
|
|
@@ -156,21 +163,16 @@ if (empty($reshook))
|
|
|
header("Location: list.php");
|
|
|
exit();
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // Update record
|
|
|
- elseif ($action == 'update' && $user->rights->loan->write)
|
|
|
- {
|
|
|
- if (!$cancel)
|
|
|
- {
|
|
|
+ } elseif ($action == 'update' && $user->rights->loan->write) {
|
|
|
+ // Update record
|
|
|
+ if (!$cancel) {
|
|
|
$result = $object->fetch($id);
|
|
|
|
|
|
$datestart = dol_mktime(12, 0, 0, GETPOST('startmonth', 'int'), GETPOST('startday', 'int'), GETPOST('startyear', 'int'));
|
|
|
$dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int'));
|
|
|
$capital = price2num(GETPOST('capital'));
|
|
|
|
|
|
- if (!$capital)
|
|
|
- {
|
|
|
+ if (!$capital) {
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
|
|
|
$action = 'edit';
|
|
|
} else {
|
|
@@ -185,15 +187,26 @@ if (empty($reshook))
|
|
|
$accountancy_account_insurance = GETPOST('accountancy_account_insurance');
|
|
|
$accountancy_account_interest = GETPOST('accountancy_account_interest');
|
|
|
|
|
|
- if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; }
|
|
|
- if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; }
|
|
|
- if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; }
|
|
|
+ if ($accountancy_account_capital <= 0) {
|
|
|
+ $object->account_capital = '';
|
|
|
+ } else {
|
|
|
+ $object->account_capital = $accountancy_account_capital;
|
|
|
+ }
|
|
|
+ if ($accountancy_account_insurance <= 0) {
|
|
|
+ $object->account_insurance = '';
|
|
|
+ } else {
|
|
|
+ $object->account_insurance = $accountancy_account_insurance;
|
|
|
+ }
|
|
|
+ if ($accountancy_account_interest <= 0) {
|
|
|
+ $object->account_interest = '';
|
|
|
+ } else {
|
|
|
+ $object->account_interest = $accountancy_account_interest;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$result = $object->update($user);
|
|
|
|
|
|
- if ($result > 0)
|
|
|
- {
|
|
|
+ if ($result > 0) {
|
|
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
|
|
exit;
|
|
|
} else {
|
|
@@ -207,20 +220,20 @@ if (empty($reshook))
|
|
|
}
|
|
|
|
|
|
// Link to a project
|
|
|
- if ($action == 'classin' && $user->rights->loan->write)
|
|
|
- {
|
|
|
+ if ($action == 'classin' && $user->rights->loan->write) {
|
|
|
$object->fetch($id);
|
|
|
$result = $object->setProject($projectid);
|
|
|
- if ($result < 0)
|
|
|
+ if ($result < 0) {
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if ($action == 'setlabel' && $user->rights->loan->write)
|
|
|
- {
|
|
|
+ if ($action == 'setlabel' && $user->rights->loan->write) {
|
|
|
$object->fetch($id);
|
|
|
$result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY');
|
|
|
- if ($result < 0)
|
|
|
- setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ if ($result < 0) {
|
|
|
+ setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -231,7 +244,9 @@ if (empty($reshook))
|
|
|
|
|
|
$form = new Form($db);
|
|
|
$formproject = new FormProjets($db);
|
|
|
-if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
|
|
+if (!empty($conf->accounting->enabled)) {
|
|
|
+ $formaccounting = new FormAccounting($db);
|
|
|
+}
|
|
|
|
|
|
$title = $langs->trans("Loan").' - '.$langs->trans("Card");
|
|
|
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
|
|
@@ -239,8 +254,7 @@ llxHeader("", $title, $help_url);
|
|
|
|
|
|
|
|
|
// Create mode
|
|
|
-if ($action == 'create')
|
|
|
-{
|
|
|
+if ($action == 'create') {
|
|
|
//WYSIWYG Editor
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
|
|
|
|
@@ -260,8 +274,7 @@ if ($action == 'create')
|
|
|
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth300" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'" autofocus="autofocus"></td></tr>';
|
|
|
|
|
|
// Bank account
|
|
|
- if (!empty($conf->banque->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->banque->enabled)) {
|
|
|
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
|
|
|
$form->select_comptes(GETPOST("accountid"), "accountid", 0, "courant=1", 1); // Show list of bank account with courant
|
|
|
print '</td></tr>';
|
|
@@ -296,8 +309,7 @@ if ($action == 'create')
|
|
|
print '<tr><td>'.$langs->trans("Insurance").'</td><td><input name="insurance_amount" size="10" value="'.dol_escape_htmltag(GETPOST("insurance_amount")).'" placeholder="'.$langs->trans('Amount').'"></td></tr>';
|
|
|
|
|
|
// Project
|
|
|
- if (!empty($conf->projet->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->projet->enabled)) {
|
|
|
$formproject = new FormProjets($db);
|
|
|
|
|
|
// Projet associe
|
|
@@ -329,8 +341,7 @@ if ($action == 'create')
|
|
|
print '</td></tr>';
|
|
|
|
|
|
// Accountancy
|
|
|
- if (!empty($conf->accounting->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->accounting->enabled)) {
|
|
|
// Accountancy_account_capital
|
|
|
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
|
|
|
print '<td>';
|
|
@@ -379,32 +390,27 @@ if ($action == 'create')
|
|
|
}
|
|
|
|
|
|
// View
|
|
|
-if ($id > 0)
|
|
|
-{
|
|
|
+if ($id > 0) {
|
|
|
$object = new Loan($db);
|
|
|
$result = $object->fetch($id);
|
|
|
|
|
|
- if ($result > 0)
|
|
|
- {
|
|
|
+ if ($result > 0) {
|
|
|
$head = loan_prepare_head($object);
|
|
|
|
|
|
$totalpaid = $object->getSumPayment();
|
|
|
|
|
|
// Confirm for loan
|
|
|
- if ($action == 'paid')
|
|
|
- {
|
|
|
+ if ($action == 'paid') {
|
|
|
$text = $langs->trans('ConfirmPayLoan');
|
|
|
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayLoan'), $text, "confirm_paid", '', '', 2);
|
|
|
}
|
|
|
|
|
|
- if ($action == 'delete')
|
|
|
- {
|
|
|
+ if ($action == 'delete') {
|
|
|
$text = $langs->trans('ConfirmDeleteLoan');
|
|
|
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteLoan'), $text, 'confirm_delete', '', '', 2);
|
|
|
}
|
|
|
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
|
print '<input type="hidden" name="action" value="update">';
|
|
@@ -422,14 +428,13 @@ if ($id > 0)
|
|
|
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
|
|
|
$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
|
|
|
// Project
|
|
|
- if (!empty($conf->projet->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->projet->enabled)) {
|
|
|
$langs->loadLangs(array("projects"));
|
|
|
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
|
|
- if ($user->rights->loan->write)
|
|
|
- {
|
|
|
- if ($action != 'classify')
|
|
|
+ if ($user->rights->loan->write) {
|
|
|
+ if ($action != 'classify') {
|
|
|
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
|
|
+ }
|
|
|
if ($action == 'classify') {
|
|
|
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
|
|
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
|
@@ -466,8 +471,7 @@ if ($id > 0)
|
|
|
print '<table class="border centpercent tableforfield">';
|
|
|
|
|
|
// Capital
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print '<tr><td class="fieldrequired titlefield">'.$langs->trans("LoanCapital").'</td><td>';
|
|
|
print '<input name="capital" size="10" value="'.$object->capital.'"></td></tr>';
|
|
|
print '</td></tr>';
|
|
@@ -476,8 +480,7 @@ if ($id > 0)
|
|
|
}
|
|
|
|
|
|
// Insurance
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print '<tr><td class="titlefield">'.$langs->trans("Insurance").'</td><td>';
|
|
|
print '<input name="insurance_amount" size="10" value="'.$object->insurance_amount.'"></td></tr>';
|
|
|
print '</td></tr>';
|
|
@@ -488,8 +491,7 @@ if ($id > 0)
|
|
|
// Date start
|
|
|
print '<tr><td>'.$langs->trans("DateStart")."</td>";
|
|
|
print "<td>";
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print $form->selectDate($object->datestart, 'start', 0, 0, 0, 'update', 1, 0);
|
|
|
} else {
|
|
|
print dol_print_date($object->datestart, "day");
|
|
@@ -499,8 +501,7 @@ if ($id > 0)
|
|
|
// Date end
|
|
|
print '<tr><td>'.$langs->trans("DateEnd")."</td>";
|
|
|
print "<td>";
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print $form->selectDate($object->dateend, 'end', 0, 0, 0, 'update', 1, 0);
|
|
|
} else {
|
|
|
print dol_print_date($object->dateend, "day");
|
|
@@ -510,8 +511,7 @@ if ($id > 0)
|
|
|
// Nbterms
|
|
|
print '<tr><td>'.$langs->trans("Nbterms").'</td>';
|
|
|
print '<td>';
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print '<input name="nbterm" size="4" value="'.$object->nbterm.'">';
|
|
|
} else {
|
|
|
print $object->nbterm;
|
|
@@ -521,8 +521,7 @@ if ($id > 0)
|
|
|
// Rate
|
|
|
print '<tr><td>'.$langs->trans("Rate").'</td>';
|
|
|
print '<td>';
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print '<input name="rate" size="4" value="'.$object->rate.'">%';
|
|
|
} else {
|
|
|
print price($object->rate).'%';
|
|
@@ -531,14 +530,12 @@ if ($id > 0)
|
|
|
|
|
|
// Accountancy account capital
|
|
|
print '<tr>';
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print '<td class="nowrap fieldrequired">';
|
|
|
print $langs->trans("LoanAccountancyCapitalCode");
|
|
|
print '</td><td>';
|
|
|
|
|
|
- if (!empty($conf->accounting->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->accounting->enabled)) {
|
|
|
print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 1, 1);
|
|
|
} else {
|
|
|
print '<input name="accountancy_account_capital" size="16" value="'.$object->account_capital.'">';
|
|
@@ -549,8 +546,7 @@ if ($id > 0)
|
|
|
print $langs->trans("LoanAccountancyCapitalCode");
|
|
|
print '</td><td>';
|
|
|
|
|
|
- if (!empty($conf->accounting->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->accounting->enabled)) {
|
|
|
$accountingaccount = new AccountingAccount($db);
|
|
|
$accountingaccount->fetch('', $object->account_capital, 1);
|
|
|
|
|
@@ -565,14 +561,12 @@ if ($id > 0)
|
|
|
|
|
|
// Accountancy account insurance
|
|
|
print '<tr>';
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print '<td class="nowrap fieldrequired">';
|
|
|
print $langs->trans("LoanAccountancyInsuranceCode");
|
|
|
print '</td><td>';
|
|
|
|
|
|
- if (!empty($conf->accounting->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->accounting->enabled)) {
|
|
|
print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 1, 1);
|
|
|
} else {
|
|
|
print '<input name="accountancy_account_insurance" size="16" value="'.$object->account_insurance.'">';
|
|
@@ -583,8 +577,7 @@ if ($id > 0)
|
|
|
print $langs->trans("LoanAccountancyInsuranceCode");
|
|
|
print '</td><td>';
|
|
|
|
|
|
- if (!empty($conf->accounting->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->accounting->enabled)) {
|
|
|
$accountingaccount = new AccountingAccount($db);
|
|
|
$accountingaccount->fetch('', $object->account_insurance, 1);
|
|
|
|
|
@@ -599,14 +592,12 @@ if ($id > 0)
|
|
|
|
|
|
// Accountancy account interest
|
|
|
print '<tr>';
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print '<td class="nowrap fieldrequired">';
|
|
|
print $langs->trans("LoanAccountancyInterestCode");
|
|
|
print '</td><td>';
|
|
|
|
|
|
- if (!empty($conf->accounting->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->accounting->enabled)) {
|
|
|
print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 1, 1);
|
|
|
} else {
|
|
|
print '<input name="accountancy_account_interest" size="16" value="'.$object->account_interest.'">';
|
|
@@ -617,8 +608,7 @@ if ($id > 0)
|
|
|
print $langs->trans("LoanAccountancyInterestCode");
|
|
|
print '</td><td>';
|
|
|
|
|
|
- if (!empty($conf->accounting->enabled))
|
|
|
- {
|
|
|
+ if (!empty($conf->accounting->enabled)) {
|
|
|
$accountingaccount = new AccountingAccount($db);
|
|
|
$accountingaccount->fetch('', $object->account_interest, 1);
|
|
|
|
|
@@ -653,8 +643,7 @@ if ($id > 0)
|
|
|
|
|
|
//print $sql;
|
|
|
$resql = $db->query($sql);
|
|
|
- if ($resql)
|
|
|
- {
|
|
|
+ if ($resql) {
|
|
|
$num = $db->num_rows($resql);
|
|
|
$i = 0;
|
|
|
$total_insurance = 0;
|
|
@@ -672,8 +661,7 @@ if ($id > 0)
|
|
|
print '<td class="right">'.$langs->trans("LoanCapital").'</td>';
|
|
|
print '</tr>';
|
|
|
|
|
|
- while ($i < $num)
|
|
|
- {
|
|
|
+ while ($i < $num) {
|
|
|
$objp = $db->fetch_object($resql);
|
|
|
|
|
|
print '<tr class="oddeven">';
|
|
@@ -690,8 +678,7 @@ if ($id > 0)
|
|
|
|
|
|
$totalpaid = $total_capital;
|
|
|
|
|
|
- if ($object->paid == 0 || $object->paid == 2)
|
|
|
- {
|
|
|
+ if ($object->paid == 0 || $object->paid == 2) {
|
|
|
print '<tr><td colspan="5" class="right">'.$langs->trans("AlreadyPaid").' :</td><td class="nowrap right">'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'</td></tr>';
|
|
|
print '<tr><td colspan="5" class="right">'.$langs->trans("AmountExpected").' :</td><td class="nowrap right">'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
|
|
|
|
@@ -718,8 +705,7 @@ if ($id > 0)
|
|
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
|
|
- if ($action == 'edit')
|
|
|
- {
|
|
|
+ if ($action == 'edit') {
|
|
|
print '<div class="center">';
|
|
|
print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
|
|
|
print ' ';
|
|
@@ -732,34 +718,28 @@ if ($id > 0)
|
|
|
/*
|
|
|
* Buttons actions
|
|
|
*/
|
|
|
- if ($action != 'edit')
|
|
|
- {
|
|
|
+ if ($action != 'edit') {
|
|
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
- if (empty($reshook))
|
|
|
- {
|
|
|
+ if (empty($reshook)) {
|
|
|
print '<div class="tabsAction">';
|
|
|
|
|
|
// Edit
|
|
|
- if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write)
|
|
|
- {
|
|
|
+ if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write) {
|
|
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>';
|
|
|
}
|
|
|
|
|
|
// Emit payment
|
|
|
- if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write)
|
|
|
- {
|
|
|
+ if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) {
|
|
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans("DoPayment").'</a></div>';
|
|
|
}
|
|
|
|
|
|
// Classify 'paid'
|
|
|
- if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write)
|
|
|
- {
|
|
|
+ if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write) {
|
|
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=paid&token='.newToken().'">'.$langs->trans("ClassifyPaid").'</a></div>';
|
|
|
}
|
|
|
|
|
|
// Delete
|
|
|
- if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete)
|
|
|
- {
|
|
|
+ if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete) {
|
|
|
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
|
|
|
}
|
|
|
|