Small correction but unable to make loan payment
This commit is contained in:
parent
7282a6faf2
commit
af92174ae2
@ -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=<font color=red>Loan amount</font> has to be numeric and greater than zero.
|
||||
ErrorLoanLength=<font color=red>Loan length</font> has to be numeric and greater than zero.
|
||||
ErrorLoanInterest=<font color=red>Annual interest</font> 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
|
||||
|
||||
@ -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 "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/loan/card.php?id=$object->id&action=edit\">".$langs->trans("Modify")."</a>";
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>';
|
||||
}
|
||||
|
||||
// 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 "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/loan/payment/payment.php?id=$object->id&action=create\">".$langs->trans("DoPayment")."</a>";
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans("DoPayment").'</a>';
|
||||
}
|
||||
|
||||
// Classify 'paid'
|
||||
if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/loan/card.php?id=$object->id&action=paid\">".$langs->trans("ClassifyPaid")."</a>";
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=paid">'.$langs->trans("ClassifyPaid").'</a>';
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($user->rights->loan->delete)
|
||||
{
|
||||
print "<a class=\"butActionDelete\" href=\"".DOL_URL_ROOT."/loan/card.php?id=$object->id&action=delete\">".$langs->trans("Delete")."</a>";
|
||||
print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
|
||||
|
||||
@ -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', '', '', '');
|
||||
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user