Fix link
This commit is contained in:
parent
4d3ce7a3d6
commit
7d2d818679
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
|
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -17,16 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/loan/class/paymentloan.class.php
|
* \file htdocs/loan/class/paymentloan.class.php
|
||||||
* \ingroup facture
|
* \ingroup loan
|
||||||
* \brief File of class to manage payment of loans
|
* \brief File of class to manage payment of loans
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||||
|
|
||||||
|
|
||||||
/** \class PaymentLoan
|
/** \class PaymentLoan
|
||||||
* \brief Class to manage payments of loans
|
* \brief Class to manage payments of loans
|
||||||
*/
|
*/
|
||||||
class PaymentLoan extends CommonObject
|
class PaymentLoan extends CommonObject
|
||||||
{
|
{
|
||||||
@ -37,8 +37,8 @@ class PaymentLoan extends CommonObject
|
|||||||
var $datec='';
|
var $datec='';
|
||||||
var $tms='';
|
var $tms='';
|
||||||
var $datep='';
|
var $datep='';
|
||||||
var $amounts=array(); // Array of amounts
|
var $amounts=array(); // Array of amounts
|
||||||
var $amount_capital; // Total amount of payment
|
var $amount_capital; // Total amount of payment
|
||||||
var $amount_insurance;
|
var $amount_insurance;
|
||||||
var $amount_interest;
|
var $amount_interest;
|
||||||
var $fk_typepayment;
|
var $fk_typepayment;
|
||||||
@ -65,8 +65,8 @@ class PaymentLoan extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create payment of loan into database.
|
* Create payment of loan into database.
|
||||||
* Use this->amounts to have list of lines for the payment
|
* Use this->amounts to have list of lines for the payment
|
||||||
*
|
*
|
||||||
* @param User $user User making payment
|
* @param User $user User making payment
|
||||||
* @return int <0 if KO, id of payment if OK
|
* @return int <0 if KO, id of payment if OK
|
||||||
*/
|
*/
|
||||||
@ -76,9 +76,9 @@ class PaymentLoan extends CommonObject
|
|||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if (! $this->datepaid)
|
if (! $this->datepaid)
|
||||||
{
|
{
|
||||||
$this->error='ErrorBadValueForParameter';
|
$this->error='ErrorBadValueForParameter';
|
||||||
@ -98,11 +98,11 @@ class PaymentLoan extends CommonObject
|
|||||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = trim($this->fk_user_creat);
|
if (isset($this->fk_user_creat)) $this->fk_user_creat = trim($this->fk_user_creat);
|
||||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = trim($this->fk_user_modif);
|
if (isset($this->fk_user_modif)) $this->fk_user_modif = trim($this->fk_user_modif);
|
||||||
|
|
||||||
$totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest;
|
$totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest;
|
||||||
$totalamount = price2num($totalamount);
|
$totalamount = price2num($totalamount);
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null
|
if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null
|
||||||
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -127,7 +127,7 @@ class PaymentLoan extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,9 +135,9 @@ class PaymentLoan extends CommonObject
|
|||||||
|
|
||||||
if ($totalamount != 0 && ! $error)
|
if ($totalamount != 0 && ! $error)
|
||||||
{
|
{
|
||||||
$this->amount_capital=$totalamount;
|
$this->amount_capital=$totalamount;
|
||||||
$this->total=$totalamount; // deprecated
|
$this->total=$totalamount; // deprecated
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -168,8 +168,8 @@ class PaymentLoan extends CommonObject
|
|||||||
$sql.= " t.amount_interest,";
|
$sql.= " t.amount_interest,";
|
||||||
$sql.= " t.fk_typepayment,";
|
$sql.= " t.fk_typepayment,";
|
||||||
$sql.= " t.num_payment,";
|
$sql.= " t.num_payment,";
|
||||||
$sql.= " t.note_private,";
|
$sql.= " t.note_private,";
|
||||||
$sql.= " t.note_public,";
|
$sql.= " t.note_public,";
|
||||||
$sql.= " t.fk_bank,";
|
$sql.= " t.fk_bank,";
|
||||||
$sql.= " t.fk_user_creat,";
|
$sql.= " t.fk_user_creat,";
|
||||||
$sql.= " t.fk_user_modif,";
|
$sql.= " t.fk_user_modif,";
|
||||||
@ -327,15 +327,15 @@ class PaymentLoan extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
|
||||||
$sql.= " WHERE type='payment_loan' AND url_id=".$this->id;
|
$sql.= " WHERE type='payment_loan' AND url_id=".$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -381,95 +381,95 @@ class PaymentLoan extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add record into bank for payment with links between this bank record and invoices of payment.
|
* Add record into bank for payment with links between this bank record and invoices of payment.
|
||||||
* All payment properties must have been set first like after a call to create().
|
* All payment properties must have been set first like after a call to create().
|
||||||
*
|
*
|
||||||
* @param User $user Object of user making payment
|
* @param User $user Object of user making payment
|
||||||
* @param int $fk_loan Id of fk_loan to do link with this payment
|
* @param int $fk_loan Id of fk_loan to do link with this payment
|
||||||
* @param string $mode 'payment_loan'
|
* @param string $mode 'payment_loan'
|
||||||
* @param string $label Label to use in bank record
|
* @param string $label Label to use in bank record
|
||||||
* @param int $accountid Id of bank account to do link with
|
* @param int $accountid Id of bank account to do link with
|
||||||
* @param string $emetteur_nom Name of transmitter
|
* @param string $emetteur_nom Name of transmitter
|
||||||
* @param string $emetteur_banque Name of bank
|
* @param string $emetteur_banque Name of bank
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function addPaymentToBank($user, $fk_loan, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
|
function addPaymentToBank($user, $fk_loan, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
if (! empty($conf->banque->enabled))
|
if (! empty($conf->banque->enabled))
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
|
|
||||||
$acc = new Account($this->db);
|
$acc = new Account($this->db);
|
||||||
$acc->fetch($accountid);
|
$acc->fetch($accountid);
|
||||||
|
|
||||||
$total=$this->total;
|
$total=$this->total;
|
||||||
if ($mode == 'payment_loan') $total=-$total;
|
if ($mode == 'payment_loan') $total=-$total;
|
||||||
|
|
||||||
// Insert payment into llx_bank
|
// Insert payment into llx_bank
|
||||||
$bank_line_id = $acc->addline(
|
$bank_line_id = $acc->addline(
|
||||||
$this->datepaid,
|
$this->datepaid,
|
||||||
$this->paymenttype, // Payment mode id or code ("CHQ or VIR for example")
|
$this->paymenttype, // Payment mode id or code ("CHQ or VIR for example")
|
||||||
$label,
|
$label,
|
||||||
$total,
|
$total,
|
||||||
$this->num_payment,
|
$this->num_payment,
|
||||||
'',
|
'',
|
||||||
$user,
|
$user,
|
||||||
$emetteur_nom,
|
$emetteur_nom,
|
||||||
$emetteur_banque
|
$emetteur_banque
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update fk_bank into llx_paiement.
|
// Update fk_bank into llx_paiement.
|
||||||
// We know the payment who generated the account write
|
// We know the payment who generated the account write
|
||||||
if ($bank_line_id > 0)
|
if ($bank_line_id > 0)
|
||||||
{
|
{
|
||||||
$result=$this->update_fk_bank($bank_line_id);
|
$result=$this->update_fk_bank($bank_line_id);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add link 'payment_loan' in bank_url between payment and bank transaction
|
// Add link 'payment_loan' in bank_url between payment and bank transaction
|
||||||
$url='';
|
$url='';
|
||||||
if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/loan/payment/card.php?id=';
|
if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/loan/payment/card.php?id=';
|
||||||
if ($url)
|
if ($url)
|
||||||
{
|
{
|
||||||
$result=$acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode);
|
$result=$acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
|
// Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
|
||||||
if ($mode == 'payment_loan')
|
if ($mode == 'payment_loan')
|
||||||
{
|
{
|
||||||
$result=$acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label?$this->label:''),'loan');
|
$result=$acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label?$this->label:''),'loan');
|
||||||
if ($result <= 0) dol_print_error($this->db);
|
if ($result <= 0) dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$acc->error;
|
$this->error=$acc->error;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -512,7 +512,7 @@ class PaymentLoan extends CommonObject
|
|||||||
|
|
||||||
if (!empty($this->id))
|
if (!empty($this->id))
|
||||||
{
|
{
|
||||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/payment/card.php?id='.$this->id.'">';
|
$link = '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$this->id.'">';
|
||||||
$linkend='</a>';
|
$linkend='</a>';
|
||||||
|
|
||||||
if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$linkend.' ');
|
if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$linkend.' ');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user