diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php
index 921784e4c21..65d9d5da9b1 100644
--- a/htdocs/loan/card.php
+++ b/htdocs/loan/card.php
@@ -76,7 +76,7 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
// Classify paid
- if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write) {
+ if ($action == 'confirm_paid' && $confirm == 'yes' && $user->hasRight('loan', 'write')) {
$object->fetch($id);
$result = $object->setPaid($user);
if ($result > 0) {
@@ -87,7 +87,7 @@ if (empty($reshook)) {
}
// Delete loan
- if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write) {
+ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('loan', 'write')) {
$object->fetch($id);
$result = $object->delete($user);
if ($result > 0) {
@@ -100,12 +100,12 @@ if (empty($reshook)) {
}
// Add loan
- if ($action == 'add' && $user->rights->loan->write) {
+ if ($action == 'add' && $user->hasRight('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'));
+ $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int'));
$capital = price2num(GETPOST('capital'));
- $rate = price2num(GETPOST('rate'));
+ $rate = price2num(GETPOST('rate'));
if (!$capital) {
$error++; $action = 'create';
@@ -168,23 +168,23 @@ if (empty($reshook)) {
header("Location: list.php");
exit();
}
- } elseif ($action == 'update' && $user->rights->loan->write) {
+ } elseif ($action == 'update' && $user->hasRight('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'));
+ $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int'));
+ $capital = price2num(GETPOST('capital'));
if (!$capital) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
$action = 'edit';
} else {
$object->datestart = $datestart;
- $object->dateend = $dateend;
- $object->capital = $capital;
- $object->nbterm = GETPOST("nbterm", 'int');
+ $object->dateend = $dateend;
+ $object->capital = $capital;
+ $object->nbterm = GETPOST("nbterm", 'int');
$object->rate = price2num(GETPOST("rate", 'alpha'));
$object->insurance_amount = price2num(GETPOST('insurance_amount', 'int'));
@@ -225,7 +225,7 @@ if (empty($reshook)) {
}
// Link to a project
- if ($action == 'classin' && $user->rights->loan->write) {
+ if ($action == 'classin' && $user->hasRight('loan', 'write')) {
$object->fetch($id);
$result = $object->setProject($projectid);
if ($result < 0) {
@@ -233,7 +233,7 @@ if (empty($reshook)) {
}
}
- if ($action == 'setlabel' && $user->rights->loan->write) {
+ if ($action == 'setlabel' && $user->hasRight('loan', 'write')) {
$object->fetch($id);
$result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY');
if ($result < 0) {
@@ -350,22 +350,22 @@ if ($action == 'create') {
// Accountancy_account_capital
print '
'.$langs->trans("LoanAccountancyCapitalCode").' ';
print '';
- print $formaccounting->select_account(GETPOST('accountancy_account_capital') ?GETPOST('accountancy_account_capital') : $conf->global->LOAN_ACCOUNTING_ACCOUNT_CAPITAL, 'accountancy_account_capital', 1, '', 1, 1);
+ print $formaccounting->select_account(GETPOST('accountancy_account_capital') ?GETPOST('accountancy_account_capital') : getDolGlobalString('LOAN_ACCOUNTING_ACCOUNT_CAPITAL'), 'accountancy_account_capital', 1, '', 1, 1);
print ' ';
// Accountancy_account_insurance
print ''.$langs->trans("LoanAccountancyInsuranceCode").' ';
print '';
- print $formaccounting->select_account(GETPOST('accountancy_account_insurance') ?GETPOST('accountancy_account_insurance') : $conf->global->LOAN_ACCOUNTING_ACCOUNT_INSURANCE, 'accountancy_account_insurance', 1, '', 1, 1);
+ print $formaccounting->select_account(GETPOST('accountancy_account_insurance') ?GETPOST('accountancy_account_insurance') : getDolGlobalString('LOAN_ACCOUNTING_ACCOUNT_INSURANCE'), 'accountancy_account_insurance', 1, '', 1, 1);
print ' ';
// Accountancy_account_interest
print ''.$langs->trans("LoanAccountancyInterestCode").' ';
print '';
- print $formaccounting->select_account(GETPOST('accountancy_account_interest') ?GETPOST('accountancy_account_interest') : $conf->global->LOAN_ACCOUNTING_ACCOUNT_INTEREST, 'accountancy_account_interest', 1, '', 1, 1);
+ print $formaccounting->select_account(GETPOST('accountancy_account_interest') ?GETPOST('accountancy_account_interest') : getDolGlobalString('LOAN_ACCOUNTING_ACCOUNT_INTEREST'), 'accountancy_account_interest', 1, '', 1, 1);
print ' ';
- } else // For external software
- {
+ } else {
+ // For external software
// Accountancy_account_capital
print ''.$langs->trans("LoanAccountancyCapitalCode").' ';
print ' ';
@@ -426,13 +426,13 @@ if ($id > 0) {
$morehtmlref = '';
// Ref loan
- $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);
+ $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->hasRight('loan', 'write'), 'string', '', 0, 1);
+ $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->hasRight('loan', 'write'), 'string', '', null, null, '', 1);
// Project
if (isModEnabled('project')) {
$langs->loadLangs(array("projects"));
$morehtmlref .= '
'.$langs->trans('Project').' ';
- if ($user->rights->loan->write) {
+ if ($user->hasRight('loan', 'write')) {
if ($action != 'classify') {
$morehtmlref .= '
'.img_edit($langs->transnoentitiesnoconv('SetProject')).' : ';
}
@@ -441,11 +441,11 @@ if ($id > 0) {
$morehtmlref .= '
';
} else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
}
} else {
if (!empty($object->fk_project)) {
@@ -740,17 +740,17 @@ if ($id > 0) {
print '
';
// Edit
- if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write) {
+ if (($object->paid == 0 || $object->paid == 2) && $user->hasRight('loan', 'write')) {
print '
';
}
// 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->hasRight('loan', 'write')) {
print '
';
}
// 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->hasRight('loan', 'write')) {
print '
';
}
diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php
index 54ad6dfb92b..951d430e96f 100644
--- a/htdocs/loan/class/loan.class.php
+++ b/htdocs/loan/class/loan.class.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2015-2018 Frédéric France
+ * Copyright (C) 2015-2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -66,6 +66,9 @@ class Loan extends CommonObject
public $account_capital;
public $account_insurance;
public $account_interest;
+ public $accountancy_account_capital;
+ public $accountancy_account_insurance;
+ public $accountancy_account_interest;
/**
* @var integer|string date_creation
@@ -641,7 +644,6 @@ class Loan extends CommonObject
$this->fk_bank = 1;
$this->label = 'SPECIMEN';
$this->specimen = 1;
- $this->socid = 1;
$this->account_capital = 16;
$this->account_insurance = 616;
$this->account_interest = 518;
diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php
index 50314ce99fc..2618d50c6fd 100644
--- a/htdocs/loan/class/loanschedule.class.php
+++ b/htdocs/loan/class/loanschedule.class.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018-2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php
index fc91fc2f86d..61d763b693e 100644
--- a/htdocs/loan/schedule.php
+++ b/htdocs/loan/schedule.php
@@ -161,11 +161,11 @@ if (!empty($conf->project->enabled)) {
$morehtmlref .= '';
} else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
}
}
} else {