diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang
index 98a7fb4ed93..449afa5afbd 100644
--- a/htdocs/langs/en_US/loan.lang
+++ b/htdocs/langs/en_US/loan.lang
@@ -13,10 +13,11 @@ LoanAccountancyInsuranceCode=Accountancy code insurance
LoanAccountancyInterestCode=Accountancy code interest
LoanPayment=Loan payment
ConfirmDeleteLoan=Confirm deleting this loan
+LoanDeleted=Loan Deleted Successfully
ConfirmPayLoan=Confirm classify paid this loan
-ErrorLoanCapital=Loan amount has to be numeric and greater than zero.
-ErrorLoanLength=Loan length has to be numeric and greater than zero.
-ErrorLoanInterest=Annual interest has to be numeric and greater than zero.
+ErrorLoanCapital=Loan amount has to be numeric and greater than zero.
+ErrorLoanLength=Loan length has to be numeric and greater than zero.
+ErrorLoanInterest=Annual interest has to be numeric and greater than zero.
# Calc
LoanCalc=Bank Loans Calculator
PurchaseFinanceInfo=Purchase & Financing Information
diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php
index 90b17d6e408..cd222ea4365 100644
--- a/htdocs/loan/card.php
+++ b/htdocs/loan/card.php
@@ -61,6 +61,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes')
$result=$object->delete($user);
if ($result > 0)
{
+ setEventMessage($langs->trans('LoanDeleted'));
header("Location: index.php");
exit;
}
@@ -129,7 +130,7 @@ else if ($action == 'update' && $user->rights->loan->write)
if (! $cancel)
{
$result = $object->fetch($id);
-
+
if ($object->fetch($id))
{
$object->label = GETPOST("label");
@@ -475,25 +476,25 @@ if ($id > 0)
// Edit
if ($user->rights->loan->write)
{
- print "id&action=edit\">".$langs->trans("Modify")."";
+ print ''.$langs->trans("Modify").'';
}
// Emit payment
if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write)
{
- print "id&action=create\">".$langs->trans("DoPayment")."";
+ print ''.$langs->trans("DoPayment").'';
}
// Classify 'paid'
if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write)
{
- print "id&action=paid\">".$langs->trans("ClassifyPaid")."";
+ print ''.$langs->trans("ClassifyPaid").'';
}
// Delete
if ($user->rights->loan->delete)
{
- print "id&action=delete\">".$langs->trans("Delete")."";
+ print ''.$langs->trans("Delete").'';
}
print "";
diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php
index 65379f6011d..41b64bcd865 100644
--- a/htdocs/loan/class/paymentloan.class.php
+++ b/htdocs/loan/class/paymentloan.class.php
@@ -119,7 +119,7 @@ class PaymentLoan extends CommonObject
$sql.= " VALUES (".$this->chid.", '".$this->db->idate($now)."',";
$sql.= " '".$this->db->idate($this->datepaid)."',";
$sql.= " ".$totalamount.",";
- $sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_private)."', ".$this->db->escape($this->note_public)."', ".$user->id.",";
+ $sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_private)."', '".$this->db->escape($this->note_public)."', ".$user->id.",";
$sql.= " 0)";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@@ -130,6 +130,7 @@ class PaymentLoan extends CommonObject
}
else
{
+ $this->error=$this->db->lasterror();
$error++;
}
diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php
index 924fa698364..557d1fa5e00 100644
--- a/htdocs/loan/index.php
+++ b/htdocs/loan/index.php
@@ -31,7 +31,7 @@ $langs->load("banks");
$langs->load("bills");
// Security check
-$socid = isset($_GET["socid"])?$_GET["socid"]:'';
+$socid = GETPOST('socid', int);
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'loan', '', '', '');
diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php
index e57ce652fa4..1d503649c60 100644
--- a/htdocs/loan/payment/payment.php
+++ b/htdocs/loan/payment/payment.php
@@ -56,21 +56,21 @@ if ($action == 'add_payment')
exit;
}
- $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
+ $datepaid = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (! $_POST["paymenttype"] > 0)
{
- $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")), 'errors');
$error++;
}
if ($datepaid == '')
{
- $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date"));
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")), 'errors');
$error++;
}
if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0)
{
- $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit"));
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit")), 'errors');
$error++;
}
@@ -90,8 +90,8 @@ if ($action == 'add_payment')
if (count($amounts) <= 0)
{
+ setEventMessage($langs->trans('ErrorNoPaymentDefined'), 'errors');
$error++;
- $errmsg='ErrorNoPaymentDefined';
}
if (! $error)
@@ -103,11 +103,11 @@ if ($action == 'add_payment')
$payment->chid = $chid;
$payment->datepaid = $datepaid;
$payment->amounts = $amounts; // Tableau de montant
- $payment->amount_capital = $_POST["amount_capital"];
- $payment->amount_insurance = $_POST["amount_insurance"];
- $payment->amount_interest = $_POST["amount_interest"];
- $payment->paymenttype = $_POST["paymenttype"];
- $payment->num_payment = $_POST["num_payment"];
+ $payment->amount_capital = GETPOST('amount_capital');
+ $payment->amount_insurance = GETPOST('amount_insurance');
+ $payment->amount_interest = GETPOST('amount_interest');
+ $payment->paymenttype = GETPOST('paymenttype');
+ $payment->num_payment = GETPOST('num_payment');
$payment->note_private = GETPOST('note_private');
$payment->note_public = GETPOST('note_public');
@@ -116,17 +116,17 @@ if ($action == 'add_payment')
$paymentid = $payment->create($user);
if ($paymentid < 0)
{
- $errmsg=$payment->error;
+ setEventMessage($payment->error, 'errors');
$error++;
}
}
if (! $error)
{
- $result=$payment->addPaymentToBank($user,'payment_loan','(LoanPayment)',$_POST['accountid'],'','');
+ $result=$payment->addPaymentToBank($user, 'payment_loan', '(LoanPayment)', GETPOST('accountid', 'int'), '', '');
if (! $result > 0)
{
- $errmsg=$payment->error;
+ setEventMessage($payment->error, 'errors');
$error++;
}
}