Add langs & debug
This commit is contained in:
parent
50c5b20d81
commit
3627f157d2
@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
@ -44,6 +45,7 @@ $langs->load("banks");
|
||||
$langs->load("categories");
|
||||
$langs->load("bills");
|
||||
$langs->load("companies");
|
||||
$langs->load("loan");
|
||||
|
||||
$id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int'));
|
||||
$ref = GETPOST('ref','alpha');
|
||||
@ -148,6 +150,7 @@ llxHeader();
|
||||
$societestatic=new Societe($db);
|
||||
$userstatic=new User($db);
|
||||
$chargestatic=new ChargeSociales($db);
|
||||
$loanstatic=new Loan($db);
|
||||
$memberstatic=new Adherent($db);
|
||||
$paymentstatic=new Paiement($db);
|
||||
$paymentsupplierstatic=new PaiementFourn($db);
|
||||
@ -606,6 +609,12 @@ if ($id > 0 || ! empty($ref))
|
||||
$paymentsalstatic->ref=$links[$key]['url_id'];
|
||||
print ' '.$paymentsalstatic->getNomUrl(2);
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_loan')
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
|
||||
print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
|
||||
print '</a>';
|
||||
}
|
||||
elseif ($links[$key]['type']=='banktransfert')
|
||||
{
|
||||
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
|
||||
@ -705,6 +714,21 @@ if ($id > 0 || ! empty($ref))
|
||||
$chargestatic->ref=$chargestatic->lib;
|
||||
print $chargestatic->getNomUrl(1,16);
|
||||
}
|
||||
else if ($links[$key]['type']=='loan')
|
||||
{
|
||||
$loanstatic->id=$links[$key]['url_id'];
|
||||
if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg))
|
||||
{
|
||||
if ($reg[1]=='loan') $reg[1]='Loan';
|
||||
$loanstatic->label=$langs->trans($reg[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$loanstatic->label=$links[$key]['label'];
|
||||
}
|
||||
$loanstatic->ref=$loanstatic->label;
|
||||
print $loanstatic->getNameUrl(1,16);
|
||||
}
|
||||
else if ($links[$key]['type']=='member')
|
||||
{
|
||||
$memberstatic->id=$links[$key]['url_id'];
|
||||
|
||||
@ -116,16 +116,16 @@ if ($action == 'add' && $user->rights->loan->write)
|
||||
|
||||
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->loan->write)
|
||||
{
|
||||
$dateech=dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]);
|
||||
$dateperiod=dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]);
|
||||
if (! $dateech)
|
||||
$datestart=dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]);
|
||||
$dateend=dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]);
|
||||
if (! $datestart)
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors');
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors');
|
||||
$action = 'edit';
|
||||
}
|
||||
elseif (! $dateperiod)
|
||||
elseif (! $dateend)
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors');
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateEnd")), 'errors');
|
||||
$action = 'edit';
|
||||
}
|
||||
else
|
||||
@ -298,7 +298,7 @@ if ($id > 0)
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="2">';
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $form->showrefnav($object,'id');
|
||||
print "</td></tr>";
|
||||
|
||||
@ -360,10 +360,9 @@ if ($id > 0)
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div';
|
||||
}
|
||||
|
||||
if ($action == 'edit') print "</form>\n";
|
||||
print '</div>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
@ -450,13 +449,13 @@ if ($id > 0)
|
||||
// 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."/compta/loan/payment.php?id=$object->id&action=create\">".$langs->trans("DoPayment")."</a>";
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/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."/compta/loan/card.php?id=$object->rowid&action=paid\">".$langs->trans("ClassifyPaid")."</a>";
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/loan/card.php?id=$object->id&action=paid\">".$langs->trans("ClassifyPaid")."</a>";
|
||||
}
|
||||
|
||||
// Delete
|
||||
|
||||
@ -87,7 +87,7 @@ class Loan extends CommonObject
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->datestart = $this->db->jdate($obj->datestart);
|
||||
$this->dateend = $this->db->jdate($obj->dateend);
|
||||
$this->label = $obj->label;
|
||||
@ -114,7 +114,7 @@ class Loan extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Create a social contribution into database
|
||||
* Create a loan into database
|
||||
*
|
||||
* @param User $user User making creation
|
||||
* @return int <0 if KO, id if OK
|
||||
@ -201,10 +201,10 @@ class Loan extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Get bank transaction lines for this social contributions
|
||||
// Get bank transaction lines for this loan
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
$account=new Account($this->db);
|
||||
$lines_url=$account->get_url('',$this->id,'sc');
|
||||
$lines_url=$account->get_url('',$this->id,'loan');
|
||||
|
||||
// Delete bank urls
|
||||
foreach ($lines_url as $line_url)
|
||||
@ -385,14 +385,12 @@ class Loan extends CommonObject
|
||||
|
||||
$result='';
|
||||
|
||||
if (empty($this->ref)) $this->ref=$this->label;
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/loan/card.php?id='.$this->rowid.'">';
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/loan/card.php?id='.$this->id.'">';
|
||||
$linkend='</a>';
|
||||
|
||||
if ($withpicto) $result.=($link.img_object($langs->trans("ShowLoan").': '.$this->label,'bill').$linkend.' ');
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend;
|
||||
if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
|
||||
|
||||
/** \class PaymentSocialContribution
|
||||
* \brief Class to manage payments of social contributions
|
||||
/** \class PaymentLoan
|
||||
* \brief Class to manage payments of loans
|
||||
*/
|
||||
class PaymentLoan extends CommonObject
|
||||
{
|
||||
@ -41,8 +41,8 @@ class PaymentLoan extends CommonObject
|
||||
var $datep='';
|
||||
var $amount; // Total amount of payment
|
||||
var $amounts=array(); // Array of amounts
|
||||
var $fk_typepaiement;
|
||||
var $num_paiement;
|
||||
var $fk_typepayment;
|
||||
var $num_payment;
|
||||
var $note;
|
||||
var $fk_bank;
|
||||
var $fk_user_creat;
|
||||
@ -59,7 +59,7 @@ class PaymentLoan extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Create payment of social contribution into database.
|
||||
* Create payment of loan into database.
|
||||
* Use this->amounts to have list of lines for the payment
|
||||
*
|
||||
* @param User $user User making payment
|
||||
@ -81,14 +81,14 @@ class PaymentLoan extends CommonObject
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan);
|
||||
if (isset($this->amount)) $this->amount=trim($this->amount);
|
||||
if (isset($this->fk_typepayment)) $this->fk_typepaiement=trim($this->fk_typepayment);
|
||||
if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment);
|
||||
if (isset($this->note)) $this->note=trim($this->note);
|
||||
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
|
||||
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_loan)) $this->fk_loan = trim($this->fk_loan);
|
||||
if (isset($this->amount)) $this->amount = trim($this->amount);
|
||||
if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment);
|
||||
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
|
||||
if (isset($this->note)) $this->note = trim($this->note);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank);
|
||||
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);
|
||||
|
||||
$totalamount = 0;
|
||||
foreach ($this->amounts as $key => $value) // How payment is dispatch
|
||||
@ -390,7 +390,7 @@ class PaymentLoan extends CommonObject
|
||||
$acc->fetch($accountid);
|
||||
|
||||
$total=$this->total;
|
||||
if ($mode == 'payment_sc') $total=-$total;
|
||||
if ($mode == 'payment_loan') $total=-$total;
|
||||
|
||||
// Insert payment into llx_bank
|
||||
$bank_line_id = $acc->addline(
|
||||
@ -405,8 +405,8 @@ class PaymentLoan extends CommonObject
|
||||
$emetteur_banque
|
||||
);
|
||||
|
||||
// Mise a jour fk_bank dans llx_paiement.
|
||||
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||
// Update fk_bank into llx_paiement.
|
||||
// We know the payment who generated the account write
|
||||
if ($bank_line_id > 0)
|
||||
{
|
||||
$result=$this->update_fk_bank($bank_line_id);
|
||||
@ -416,7 +416,7 @@ class PaymentLoan extends CommonObject
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
// Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
|
||||
// Add link 'payment_loan' in bank_url between payment and bank transaction
|
||||
$url='';
|
||||
if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/compta/loan/payment/card.php?id=';
|
||||
if ($url)
|
||||
@ -433,11 +433,11 @@ class PaymentLoan extends CommonObject
|
||||
$linkaddedforthirdparty=array();
|
||||
foreach ($this->amounts as $key => $value)
|
||||
{
|
||||
if ($mode == 'payment_sc')
|
||||
if ($mode == 'payment_loan')
|
||||
{
|
||||
$socialcontrib = new ChargeSociales($this->db);
|
||||
$socialcontrib->fetch($key);
|
||||
$result=$acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''),'sc');
|
||||
$loan = new Loan($this->db);
|
||||
$loan->fetch($key);
|
||||
$result=$acc->add_url_line($bank_line_id, $loan->id, DOL_URL_ROOT.'/compta/loan/card.php?id=', $loan->type_libelle.(($loan->lib && $loan->lib!=$loan->type_libelle)?' ('.$loan->lib.')':''),'loan');
|
||||
if ($result <= 0) dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
@ -461,14 +461,14 @@ class PaymentLoan extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee
|
||||
* Update link between loan's payment and the line generate in llx_bank
|
||||
*
|
||||
* @param int $id_bank Id if bank
|
||||
* @return int >0 if OK, <=0 if KO
|
||||
*/
|
||||
function update_fk_bank($id_bank)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id;
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -484,11 +484,11 @@ class PaymentLoan extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie nom clicable (avec eventuellement le picto)
|
||||
* Return clicable name (with eventually a picto)
|
||||
*
|
||||
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
||||
* @param int $maxlen Longueur max libelle
|
||||
* @return string Chaine avec URL
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=No picto
|
||||
* @param int $maxlen Max length label
|
||||
* @return string Chaine with URL
|
||||
*/
|
||||
function getNameUrl($withpicto=0,$maxlen=0)
|
||||
{
|
||||
@ -500,12 +500,12 @@ class PaymentLoan extends CommonObject
|
||||
|
||||
if (!empty($this->id))
|
||||
{
|
||||
$lien = '<a href="'.DOL_URL_ROOT.'/compta/payment/card.php?id='.$this->id.'">';
|
||||
$lienfin='</a>';
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/payment/card.php?id='.$this->id.'">';
|
||||
$linkend='</a>';
|
||||
|
||||
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$lienfin.' ');
|
||||
if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$linkend.' ');
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
if ($withpicto != 2) $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin;
|
||||
if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
@ -119,7 +119,7 @@ if ($object->id)
|
||||
print '<tr><td>'.$langs->trans("Capital").'</td><td>'.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
// Date start
|
||||
print "<tr><td>".$langs->trans("Datestart")."</td>";
|
||||
print "<tr><td>".$langs->trans("DateStart")."</td>";
|
||||
print "<td>";
|
||||
if ($action == 'edit')
|
||||
{
|
||||
@ -133,7 +133,7 @@ if ($object->id)
|
||||
print "</tr>";
|
||||
|
||||
// Date end
|
||||
print "<tr><td>".$langs->trans("Dateend")."</td>";
|
||||
print "<tr><td>".$langs->trans("DateEnd")."</td>";
|
||||
print "<td>";
|
||||
if ($action == 'edit')
|
||||
{
|
||||
|
||||
@ -110,9 +110,7 @@ if ($resql)
|
||||
|
||||
// Ref
|
||||
print '<td width="60">';
|
||||
$loan->id=$obj->rowid;
|
||||
$loan->label=$obj->rowid;
|
||||
$loan->ref=$obj->rowid;
|
||||
$loan->id = $obj->id;
|
||||
print $loan->getNameUrl(1,'20');
|
||||
print '</td>';
|
||||
|
||||
|
||||
308
htdocs/compta/loan/payment/card.php
Normal file
308
htdocs/compta/loan/payment/card.php
Normal file
@ -0,0 +1,308 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/loan/payment/card.php
|
||||
* \ingroup loan
|
||||
* \brief Payment's card of loan
|
||||
*/
|
||||
|
||||
require '../../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/paymentloan.class.php';
|
||||
// require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
// require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
|
||||
if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$langs->load('bills');
|
||||
$langs->load('banks');
|
||||
$langs->load('companies');
|
||||
$langs->load('loan');
|
||||
|
||||
// Security check
|
||||
$id=GETPOST("id");
|
||||
$action=GETPOST("action");
|
||||
$confirm=GETPOST('confirm');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
// TODO ajouter regle pour restreindre acces paiement
|
||||
//$result = restrictedArea($user, 'facture', $id,'');
|
||||
|
||||
$payment = new PaymentLoan($db);
|
||||
if ($id > 0)
|
||||
{
|
||||
$result=$payment->fetch($id);
|
||||
if (! $result) dol_print_error($db,'Failed to get payment id '.$id);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// Delete payment
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result = $payment->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
header("Location: ".DOL_URL_ROOT."/compta/loan/index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($payment->error, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
// Create payment
|
||||
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->loan->write)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result=$payment->valide();
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$factures=array(); // TODO Get all id of invoices linked to this payment
|
||||
foreach($factures as $id)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($id);
|
||||
|
||||
$outputlangs = $langs;
|
||||
if (! empty($_REQUEST['lang_id']))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$fac->generateDocument($fac->modelpdf, $outputlangs);
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: card.php?id='.$payment->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($payment->error);
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$loan = new Loan($db);
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/loan/payment/card.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), 0, 'payment');
|
||||
|
||||
/*
|
||||
* Confirm deletion of the payment
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirm validation of the payment
|
||||
*/
|
||||
if ($action == 'valide')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
print $form->formconfirm('card.php?id='.$payment->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td valign="top" width="140">'.$langs->trans('Ref').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->showrefnav($payment,'id','',1,'rowid','id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td valign="top" width="120">'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($payment->datep,'day').'</td></tr>';
|
||||
|
||||
// Mode
|
||||
print '<tr><td valign="top">'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$payment->type_code).'</td></tr>';
|
||||
|
||||
// Number
|
||||
print '<tr><td valign="top">'.$langs->trans('Number').'</td><td colspan="3">'.$payment->num_payment.'</td></tr>';
|
||||
|
||||
// Amount
|
||||
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
|
||||
// Note
|
||||
print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($payment->note).'</td></tr>';
|
||||
|
||||
// Bank account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
if ($payment->bank_account)
|
||||
{
|
||||
$bankline=new AccountLine($db);
|
||||
$bankline->fetch($payment->bank_line);
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $bankline->getNomUrl(1,0,'showall');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
/*
|
||||
* List of loans payed
|
||||
*/
|
||||
|
||||
$disable_delete = 0;
|
||||
$sql = 'SELECT l.rowid as id, l.label, l.paid, l.capital as capital, pl.amount';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl,'.MAIN_DB_PREFIX.'loan as l';
|
||||
$sql.= ' WHERE pl.fk_loan = l.rowid';
|
||||
$sql.= ' AND l.entity = '.$conf->entity;
|
||||
$sql.= ' AND pl.rowid = '.$payment->id;
|
||||
|
||||
dol_syslog("compta/loan/payment/card.php", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Loan').'</td>';
|
||||
print '<td>'.$langs->trans('Label').'</td>';
|
||||
print '<td align="right">'.$langs->trans('ExpectedToPay').'</td>';
|
||||
print '<td align="center">'.$langs->trans('Status').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PayedByThisPayment').'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
// Ref
|
||||
print '<td>';
|
||||
$loan->fetch($objp->id);
|
||||
print $loan->getNameUrl(1);
|
||||
print "</td>\n";
|
||||
// Label
|
||||
print '<td>'.$objp->label.'</td>';
|
||||
// Expected to pay
|
||||
print '<td align="right">'.price($objp->capital).'</td>';
|
||||
// Status
|
||||
print '<td align="center">'.$loan->getLibStatut(4,$objp->amount).'</td>';
|
||||
// Amount payed
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
print "</tr>\n";
|
||||
if ($objp->paye == 1) // If at least one invoice is paid, disable delete
|
||||
{
|
||||
$disable_delete = 1;
|
||||
}
|
||||
$total = $total + $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$var=!$var;
|
||||
|
||||
print "</table>\n";
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
/*
|
||||
* Boutons Actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
/*
|
||||
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
|
||||
{
|
||||
if ($user->societe_id == 0 && $payment->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
if ($user->rights->facture->paiement)
|
||||
{
|
||||
print '<a class="butAction" href="card.php?id='.$_GET['id'].'&facid='.$objp->facid.'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ($_GET['action'] == '')
|
||||
{
|
||||
if ($user->rights->loan->delete)
|
||||
{
|
||||
if (! $disable_delete)
|
||||
{
|
||||
print '<a class="butActionDelete" href="card.php?id='.$_GET['id'].'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
0
htdocs/compta/loan/payment/index.html
Normal file
0
htdocs/compta/loan/payment/index.html
Normal file
@ -21,12 +21,13 @@
|
||||
* \brief Page to add payment of a loan
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require '../../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/paymentloan.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$langs->load("bills");
|
||||
$langs->load("loan");
|
||||
|
||||
$chid=GETPOST("id");
|
||||
$action=GETPOST('action');
|
||||
@ -42,7 +43,6 @@ if ($user->societe_id > 0)
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'add_payment')
|
||||
{
|
||||
$error=0;
|
||||
@ -97,30 +97,30 @@ if ($action == 'add_payment')
|
||||
$db->begin();
|
||||
|
||||
// Create a line of payments
|
||||
$paiement = new PaymentSocialContribution($db);
|
||||
$paiement->chid = $chid;
|
||||
$paiement->datepaid = $datepaid;
|
||||
$paiement->amounts = $amounts; // Tableau de montant
|
||||
$paiement->paymenttype = $_POST["paymenttype"];
|
||||
$paiement->num_payment = $_POST["num_payment"];
|
||||
$paiement->note = $_POST["note"];
|
||||
$payment = new PaymentLoan($db);
|
||||
$payment->chid = $chid;
|
||||
$payment->datepaid = $datepaid;
|
||||
$payment->amounts = $amounts; // Tableau de montant
|
||||
$payment->paymenttype = $_POST["paymenttype"];
|
||||
$payment->num_payment = $_POST["num_payment"];
|
||||
$payment->note = $_POST["note"];
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$paymentid = $payment->create($user);
|
||||
if ($paymentid < 0)
|
||||
{
|
||||
$errmsg=$paiement->error;
|
||||
$errmsg=$payment->error;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result=$paiement->addPaymentToBank($user,'payment_sc','(SocialContributionPayment)',$_POST['accountid'],'','');
|
||||
$result=$payment->addPaymentToBank($user,'payment_loan','(LoanPayment)',$_POST['accountid'],'','');
|
||||
if (! $result > 0)
|
||||
{
|
||||
$errmsg=$paiement->error;
|
||||
$errmsg=$payment->error;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -180,7 +180,7 @@ if ($_GET["action"] == 'create')
|
||||
print "<tr class=\"liste_titre\"><td colspan=\"3\">".$langs->trans("Loan")."</td>";
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/compta/loan/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Period")."</td><td colspan=\"2\">".dol_print_date($loan->datestart,'day')."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("DateStart")."</td><td colspan=\"2\">".dol_print_date($loan->datestart,'day')."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$loan->label."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Amount")."</td><td colspan=\"2\">".price($loan->capital,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
@ -222,14 +222,14 @@ if ($_GET["action"] == 'create')
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
|
||||
print '<td colspan="2">';
|
||||
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '',1); // Show opend bank account list
|
||||
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$loan->accountid, "accountid", 0, '',1); // Show opend bank account list
|
||||
print '</td></tr>';
|
||||
|
||||
// Number
|
||||
print '<tr><td>'.$langs->trans('Number');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td colspan="2"><input name="num_paiement" type="text" value="'.GETPOST('num_paiement').'"></td></tr>'."\n";
|
||||
print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment').'"></td></tr>'."\n";
|
||||
|
||||
print '<tr>';
|
||||
print '<td valign="top">'.$langs->trans("Comments").'</td>';
|
||||
@ -241,7 +241,7 @@ if ($_GET["action"] == 'create')
|
||||
print '<br>';
|
||||
|
||||
/*
|
||||
* Autres charges impayees
|
||||
* Other loan unpaid
|
||||
*/
|
||||
$num = 1;
|
||||
$i = 0;
|
||||
@ -483,6 +483,8 @@ Module500Name=Special expenses (tax, social contributions, dividends)
|
||||
Module500Desc=Management of special expenses like taxes, social contribution, dividends and salaries
|
||||
Module510Name=Salaries
|
||||
Module510Desc=Management of employees salaries and payments
|
||||
Module520Name=Loan
|
||||
Module520Desc=Management of loans
|
||||
Module600Name=Notifications
|
||||
Module600Desc=Send notifications by email on some Dolibarr business events to third party contacts
|
||||
Module700Name=Donations
|
||||
@ -696,6 +698,10 @@ Permission510=Read Salaries
|
||||
Permission512=Create/modify salaries
|
||||
Permission514=Delete salaries
|
||||
Permission517=Export salaries
|
||||
Permission520=Read Loans
|
||||
Permission522=Create/modify loans
|
||||
Permission524=Delete loans
|
||||
Permission527=Export loans
|
||||
Permission531=Read services
|
||||
Permission532=Create/modify services
|
||||
Permission534=Delete services
|
||||
|
||||
15
htdocs/langs/en_US/loan.lang
Normal file
15
htdocs/langs/en_US/loan.lang
Normal file
@ -0,0 +1,15 @@
|
||||
# Dolibarr language file - Source file is en_US - loan
|
||||
Loan=Loan
|
||||
Loans=Loans
|
||||
NewLoan=New Loan
|
||||
ShowLoan=Show Loan
|
||||
PaymentLoan=Loan payment
|
||||
Capital=Capital
|
||||
Nbterms=Number of terms
|
||||
LoanAccountancyCapitalCode=Accountancy code capital
|
||||
LoanAccountancyInsuranceCode=Accountancy code insurance
|
||||
LoanAccountancyInterestCode=Accountancy code interest
|
||||
ConfigLoan=Configuration of the module loan
|
||||
LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default
|
||||
LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accountancy code interest by default
|
||||
LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Accountancy code insurance by default
|
||||
@ -482,6 +482,8 @@ Module500Name=Dépenses spéciales (taxes, charges, dividendes)
|
||||
Module500Desc=Gestion des dépenses spéciales comme les taxes, charges sociales et dividendes
|
||||
Module510Name=Salaires
|
||||
Module510Desc=Gestion des paiements des salaires des employés
|
||||
Module520Name=Emprunts
|
||||
Module520Desc=Suivi des emprunts
|
||||
Module600Name=Notifications
|
||||
Module600Desc=Envoi de notifications (par email) aux contacts de tiers sur certains événements métiers
|
||||
Module700Name=Dons
|
||||
@ -695,6 +697,10 @@ Permission510=Consulter les salaires
|
||||
Permission512=Créer/modifier les salaires
|
||||
Permission514=Supprimer les salaires
|
||||
Permission517=Exporter les salaires
|
||||
Permission520=Consulter les emprunts
|
||||
Permission522=Créer/modifier les emprunts
|
||||
Permission524=Supprimer les emprunts
|
||||
Permission527=Exporter les emprunts
|
||||
Permission531=Consulter les services
|
||||
Permission532=Créer/modifier les services
|
||||
Permission534=Supprimer les services
|
||||
|
||||
15
htdocs/langs/fr_FR/loan.lang
Normal file
15
htdocs/langs/fr_FR/loan.lang
Normal file
@ -0,0 +1,15 @@
|
||||
# Dolibarr language file - Source file is en_US - loan
|
||||
Loan=Emprunt
|
||||
Loans=Emprunts
|
||||
NewLoan=Nouvel emprunt
|
||||
ShowLoan=Voir emprunt
|
||||
PaymentLoan=Règlement d'emprunt
|
||||
Capital=Capital
|
||||
Nbterms=Nombre d'échéances
|
||||
LoanAccountancyCapitalCode=Compte comptable capital
|
||||
LoanAccountancyInsuranceCode=Compte comptable assurance
|
||||
LoanAccountancyInterestCode=Compte comptable intérêts
|
||||
ConfigLoan=Configuration du module emprunt
|
||||
LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Compte comptable capital par défaut
|
||||
LOAN_ACCOUNTING_ACCOUNT_INTEREST=Compte comptable intérêts par défaut
|
||||
LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Compte comptable assurance par défaut
|
||||
Loading…
Reference in New Issue
Block a user