From 3627f157d2d208882366ddd7615ed5eb0b2f525c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 1 Oct 2014 07:16:29 +0200 Subject: [PATCH] Add langs & debug --- htdocs/compta/bank/account.php | 24 ++ htdocs/compta/loan/card.php | 25 +- htdocs/compta/loan/class/loan.class.php | 14 +- .../compta/loan/class/paymentloan.class.php | 62 ++-- htdocs/compta/loan/document.php | 4 +- htdocs/compta/loan/index.php | 4 +- htdocs/compta/loan/payment/card.php | 308 ++++++++++++++++++ htdocs/compta/loan/payment/index.html | 0 htdocs/compta/loan/{ => payment}/payment.php | 32 +- htdocs/langs/en_US/admin.lang | 6 + htdocs/langs/en_US/loan.lang | 15 + htdocs/langs/fr_FR/admin.lang | 6 + htdocs/langs/fr_FR/loan.lang | 15 + 13 files changed, 442 insertions(+), 73 deletions(-) create mode 100644 htdocs/compta/loan/payment/card.php create mode 100644 htdocs/compta/loan/payment/index.html rename htdocs/compta/loan/{ => payment}/payment.php (89%) create mode 100644 htdocs/langs/en_US/loan.lang create mode 100644 htdocs/langs/fr_FR/loan.lang diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 14b586c6d80..57329e9e93b 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -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 ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print ''; + } 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']; diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index b3e31324cb0..d2dc5362915 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -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 ''; // Ref - print '"; @@ -360,10 +360,9 @@ if ($id > 0) print ''; print '   '; print ''; - print '\n"; + print ''; + print ''; + } 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 "id&action=create\">".$langs->trans("DoPayment").""; + print "id&action=create\">".$langs->trans("DoPayment").""; } // Classify 'paid' if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) { - print "rowid&action=paid\">".$langs->trans("ClassifyPaid").""; + print "id&action=paid\">".$langs->trans("ClassifyPaid").""; } // Delete diff --git a/htdocs/compta/loan/class/loan.class.php b/htdocs/compta/loan/class/loan.class.php index a0cbf9a8224..07b842b708e 100644 --- a/htdocs/compta/loan/class/loan.class.php +++ b/htdocs/compta/loan/class/loan.class.php @@ -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 = ''; + $link = ''; $linkend=''; 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; } diff --git a/htdocs/compta/loan/class/paymentloan.class.php b/htdocs/compta/loan/class/paymentloan.class.php index c0cdb3cdb85..0a558fc9bf4 100644 --- a/htdocs/compta/loan/class/paymentloan.class.php +++ b/htdocs/compta/loan/class/paymentloan.class.php @@ -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 = ''; - $lienfin=''; + $link = ''; + $linkend=''; - 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; diff --git a/htdocs/compta/loan/document.php b/htdocs/compta/loan/document.php index 022340270ad..b263fa1687d 100644 --- a/htdocs/compta/loan/document.php +++ b/htdocs/compta/loan/document.php @@ -119,7 +119,7 @@ if ($object->id) print ''; // Date start - print ""; + print ""; print ""; // Date end - print ""; + print ""; print "'; diff --git a/htdocs/compta/loan/payment/card.php b/htdocs/compta/loan/payment/card.php new file mode 100644 index 00000000000..d08c5f8ce0f --- /dev/null +++ b/htdocs/compta/loan/payment/card.php @@ -0,0 +1,308 @@ + + * + * 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 . + */ + +/** + * \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 '
'.$langs->trans("Ref").''; + print '
'.$langs->trans("Ref").''; print $form->showrefnav($object,'id'); print "
'.$langs->trans("Capital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'
".$langs->trans("Datestart")."
".$langs->trans("DateStart").""; if ($action == 'edit') { @@ -133,7 +133,7 @@ if ($object->id) print "
".$langs->trans("Dateend")."
".$langs->trans("DateEnd").""; if ($action == 'edit') { diff --git a/htdocs/compta/loan/index.php b/htdocs/compta/loan/index.php index 8bef47ff66e..a4432ba9ced 100644 --- a/htdocs/compta/loan/index.php +++ b/htdocs/compta/loan/index.php @@ -110,9 +110,7 @@ if ($resql) // Ref print ''; - $loan->id=$obj->rowid; - $loan->label=$obj->rowid; - $loan->ref=$obj->rowid; + $loan->id = $obj->id; print $loan->getNameUrl(1,'20'); print '
'; + +// Ref +print ''; +print ''; + +// Date +print ''; + +// Mode +print ''; + +// Number +print ''; + +// Amount +print ''; + +// Note +print ''; + +// Bank account +if (! empty($conf->banque->enabled)) +{ + if ($payment->bank_account) + { + $bankline=new AccountLine($db); + $bankline->fetch($payment->bank_line); + + print ''; + print ''; + print ''; + print ''; + } +} + +print '
'.$langs->trans('Ref').''; +print $form->showrefnav($payment,'id','',1,'rowid','id'); +print '
'.$langs->trans('Date').''.dol_print_date($payment->datep,'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$payment->type_code).'
'.$langs->trans('Number').''.$payment->num_payment.'
'.$langs->trans('Amount').''.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($payment->note).'
'.$langs->trans('BankTransactionLine').''; + print $bankline->getNomUrl(1,0,'showall'); + print '
'; + + +/* + * 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 '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + if ($num > 0) + { + $var=True; + + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $var=!$var; + print ''; + // Ref + print '\n"; + // Label + print ''; + // Expected to pay + print ''; + // Status + print ''; + // Amount payed + print ''; + print "\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 "
'.$langs->trans('Loan').''.$langs->trans('Label').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('PayedByThisPayment').'
'; + $loan->fetch($objp->id); + print $loan->getNameUrl(1); + print "'.$objp->label.''.price($objp->capital).''.$loan->getLibStatut(4,$objp->amount).''.price($objp->amount).'
\n"; + $db->free($resql); +} +else +{ + dol_print_error($db); +} + +print ''; + + +/* + * Boutons Actions + */ +print '
'; + +/* +if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) +{ + if ($user->societe_id == 0 && $payment->statut == 0 && $_GET['action'] == '') + { + if ($user->rights->facture->paiement) + { + print ''.$langs->trans('Valid').''; + } + } +} +*/ + +if ($_GET['action'] == '') +{ + if ($user->rights->loan->delete) + { + if (! $disable_delete) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').''; + } + } +} + +print '
'; + + + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/loan/payment/index.html b/htdocs/compta/loan/payment/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/compta/loan/payment.php b/htdocs/compta/loan/payment/payment.php similarity index 89% rename from htdocs/compta/loan/payment.php rename to htdocs/compta/loan/payment/payment.php index a513ba212cd..ed249d8f246 100644 --- a/htdocs/compta/loan/payment.php +++ b/htdocs/compta/loan/payment/payment.php @@ -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 "".$langs->trans("Loan").""; print ''.$langs->trans("Ref").''.$chid.''; - print ''.$langs->trans("Period")."".dol_print_date($loan->datestart,'day')."\n"; + print ''.$langs->trans("DateStart")."".dol_print_date($loan->datestart,'day')."\n"; print ''.$langs->trans("Label").''.$loan->label."\n"; print ''.$langs->trans("Amount")."".price($loan->capital,0,$outputlangs,1,-1,-1,$conf->currency).''; @@ -222,14 +222,14 @@ if ($_GET["action"] == 'create') print ''; print ''.$langs->trans('AccountToDebit').''; print ''; - $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 ''; // Number print ''.$langs->trans('Number'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print ''; - print ''."\n"; + print ''."\n"; print ''; print ''.$langs->trans("Comments").''; @@ -241,7 +241,7 @@ if ($_GET["action"] == 'create') print '
'; /* - * Autres charges impayees + * Other loan unpaid */ $num = 1; $i = 0; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index fae312ee8e8..7650b14950e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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 diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang new file mode 100644 index 00000000000..6be2f13a101 --- /dev/null +++ b/htdocs/langs/en_US/loan.lang @@ -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 \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 0ea2d9d51f4..d8f1e3b0c16 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -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 diff --git a/htdocs/langs/fr_FR/loan.lang b/htdocs/langs/fr_FR/loan.lang new file mode 100644 index 00000000000..d230f7f0582 --- /dev/null +++ b/htdocs/langs/fr_FR/loan.lang @@ -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 \ No newline at end of file