diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 8de7209ef93..ba79f9ee78e 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2016 Alexandre Spangaro +/* Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2016-2018 Alexandre Spangaro * * 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 diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index be299471708..3bb98e42727 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -1,12 +1,12 @@ - * Copyright (C) 2007-2010 Jean Heimburger - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2014 Olivier Geffroy +/* Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2017 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -24,9 +24,9 @@ */ /** - * \file htdocs/accountancy/journal/bankjournal.php - * \ingroup Advanced accountancy - * \brief Page with bank journal + * \file htdocs/accountancy/journal/bankjournal.php + * \ingroup Advanced accountancy + * \brief Page with bank journal */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; @@ -53,8 +53,10 @@ require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT . '/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT . '/loan/class/paymentloan.class.php'; -$langs->loadLangs(array("companies","other","compta","banks",'bills','donations',"accountancy","trips","salaries","hrm")); +$langs->loadLangs(array("companies","other","compta","banks","bills","donations","loan","accountancy","trips","salaries","hrm")); // Multi journal $id_journal = GETPOST('id_journal', 'int'); @@ -143,6 +145,7 @@ $paymentvatstatic = new TVA($db); $paymentsalstatic = new PaymentSalary($db); $paymentexpensereportstatic = new PaymentExpenseReport($db); $paymentvariousstatic = new PaymentVarious($db); +$paymentloanstatic = new PaymentLoan($db); // Get code of finance journal $accountingjournalstatic = new AccountingJournal($db); @@ -254,7 +257,7 @@ if ($result) { // Now loop on each link of record in bank. foreach ($links as $key => $val) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary', 'payment_various'))) + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_loan', 'payment_salary', 'payment_various'))) { // So we excluded 'company' and 'user' here. We want only payment lines @@ -358,6 +361,13 @@ if ($result) { $paymentvariousstatic->fetch($paymentvariousstatic->id); $account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word $tabtp[$obj->rowid][$account_various] += $obj->amount; + } else if ($links[$key]['type'] == 'payment_loan') { + $paymentloanstatic->id = $links[$key]['url_id']; + $paymentloanstatic->ref = $links[$key]['url_id']; + $paymentloanstatic->fk_loan = $links[$key]['url_id']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentloanstatic->getNomUrl(2); + $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; + //$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount; } else if ($links[$key]['type'] == 'banktransfert') { $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer"); $tabtp[$obj->rowid][$account_transfer] += $obj->amount; @@ -548,6 +558,11 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_loan') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; } else if ($tabtype[$key] == 'payment_various') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; @@ -713,8 +728,8 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print '"' . $langs->trans("LedgerAccount") . '"' . $sep; print '"' . $langs->trans("SubledgerAccount") . '"' . $sep; print '"' . $langs->trans("Label"). '"' . $sep; - print '"' . $langs->trans("Amount") . '"' . $sep; - print '"' . $langs->trans("Amount") . '"' . $sep; + print '"' . $langs->trans("Debit") . '"' . $sep; + print '"' . $langs->trans("Credit") . '"' . $sep; print '"' . $langs->trans("Journal") . '"' . $sep; print '"' . $langs->trans("Note") . '"' . $sep; print "\n"; @@ -822,6 +837,7 @@ if (empty($action) || $action == 'view') { $expensereportstatic = new ExpenseReport($db); $vatstatic = new Tva($db); $donationstatic = new Don($db); + $loanstatic = new Loan($db); $salarystatic = new PaymentSalary($db); $variousstatic = new PaymentVarious($db); @@ -893,7 +909,7 @@ if (empty($action) || $action == 'view') { print '
'; $i = 0; - print '
'; + print '
'; print ""; print ""; print ""; @@ -1119,6 +1135,9 @@ function getSourceDocRef($val, $typerecord) if ($ref == '(ExpenseReportPayment)') { $ref = $langs->trans('Employee'); } + if ($ref == '(LoanPayment)') { + $ref = $langs->trans('Loan'); + } if ($ref == '(payment_salary)') { $ref = $langs->trans('Employee'); } @@ -1173,6 +1192,13 @@ function getSourceDocRef($val, $typerecord) $sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; $ref = $langs->trans("Donation"); } + elseif ($typerecord == 'payment_loan') + { + $sqlmid = 'SELECT l.rowid as ref'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_loan as l"; + $sqlmid .= " WHERE l.rowid=" . $val["paymentloanid"]; + $ref = $langs->trans("LoanPayment"); + } elseif ($typerecord == 'payment_various') { $sqlmid = 'SELECT v.rowid as ref'; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 2fa2b8a7822..448d3d4870c 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -943,7 +943,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/loan/index.php?leftmenu=tax_loan&mainmenu=billing",$langs->trans("Loans"),1,$user->rights->loan->read, '', $mainmenu, 'tax_loan'); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/loan/card.php?leftmenu=tax_loan&action=create",$langs->trans("NewLoan"),2,$user->rights->loan->write); //if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/loan/payment/list.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read); - if (($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) && ! empty($conf->global->LOAN_SHOW_CALCULATOR)) $newmenu->add("/loan/calc.php?leftmenu=tax_loan",$langs->trans("Calculator"),2,$user->rights->loan->calc); } // Various payment diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index 9aae3869cc3..534dee08867 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -10,6 +10,7 @@ LoanCapital=Capital Insurance=Insurance Interest=Interest Nbterms=Number of terms +Term=Term LoanAccountancyCapitalCode=Accounting account capital LoanAccountancyInsuranceCode=Accounting account insurance LoanAccountancyInterestCode=Accounting account interest @@ -17,39 +18,14 @@ ConfirmDeleteLoan=Confirm deleting this loan LoanDeleted=Loan Deleted Successfully ConfirmPayLoan=Confirm classify paid this loan LoanPaid=Loan Paid -# Calc -LoanCalc=Bank Loans Calculator -PurchaseFinanceInfo=Purchase & Financing Information -SalePriceOfAsset=Sale Price of Asset -PercentageDown=Percentage Down -LengthOfMortgage=Duration of loan -AnnualInterestRate=Annual Interest Rate -ExplainCalculations=Explain Calculations -ShowMeCalculationsAndAmortization=Show me the calculations and amortization -MortgagePaymentInformation=Mortgage Payment Information -DownPayment=Down Payment -DownPaymentDesc=The down payment = The price of the home multiplied by the percentage down divided by 100 (for 5% down becomes 5/100 or 0.05) -InterestRateDesc=The interest rate = The annual interest percentage divided by 100 -MonthlyFactorDesc=The monthly factor = The result of the following formula -MonthlyInterestRateDesc=The monthly interest rate = The annual interest rate divided by 12 (for the 12 months in a year) -MonthTermDesc=The month term of the loan in months = The number of years you've taken the loan out for times 12 -MonthlyPaymentDesc=The montly payment is figured out using the following formula -AmortizationPaymentDesc=The amortization breaks down how much of your monthly payment goes towards the bank's interest, and how much goes into paying off the principal of your loan. -AmountFinanced=Amount Financed -AmortizationMonthlyPaymentOverYears=Amortization For Monthly Payment: %s over %s years -Totalsforyear=Totals for year -MonthlyPayment=Monthly Payment -LoanCalcDesc=This mortgage calculator can be used to figure out monthly payments of a loaning, based on the amount borrowed, the term of the loan desired and the interest rate.
This calculator includes also PMI (Private Mortgage Insurance) for loans where less than 20%% is put as a down payment. Also taken into consideration are the town property taxes, and their effect on the total monthly mortgage payment.
-GoToInterest=%s will go towards INTEREST -GoToPrincipal=%s will go towards PRINCIPAL -YouWillSpend=You will spend %s in year %s ListLoanAssociatedProject=List of loan associated with the project AddLoan=Create loan +FinancialCommitment=Financial commitment +InterestAmount=Interest +CapitalRemain=Capital remain # Admin ConfigLoan=Configuration of the module loan LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accounting account capital by default LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accounting account interest by default LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Accounting account insurance by default -FinancialCommitment=Financial commitment CreateCalcSchedule=Edit financial commitment -InterestAmount=Interest amount diff --git a/htdocs/loan/calc.php b/htdocs/loan/calc.php deleted file mode 100644 index fedf26e6a36..00000000000 --- a/htdocs/loan/calc.php +++ /dev/null @@ -1,393 +0,0 @@ - - * Copyright (C) 2014 Alexandre Spangaro - * Copyright (C) 2015 Frederic France - * - * 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 . - */ - -require '../main.inc.php'; - -$langs->load("loan"); - -/* --------------------------------------------------- * - * Set Form DEFAULT values - * --------------------------------------------------- */ -$default_sale_price = "150000"; -$default_annual_interest_percent = 7.0; -$default_year_term = 30; -$default_down_percent = 10; -$default_show_progress = true; - -/* --------------------------------------------------- * - * Initialize Variables - * --------------------------------------------------- */ -$sale_price = 0; -$annual_interest_percent = 0; -$year_term = 0; -$down_percent = 0; -$this_year_interest_paid = 0; -$this_year_principal_paid = 0; -$form_complete = false; -$show_progress = false; -$monthly_payment = false; -$show_progress = false; -$error = false; - -/* --------------------------------------------------- * - * Set the USER INPUT values - * --------------------------------------------------- */ -if (isset($_REQUEST['form_complete'])) { - $sale_price = GETPOST('sale_price'); - $annual_interest_percent = GETPOST('annual_interest_percent'); - $year_term = GETPOST('year_term'); - $down_percent = GETPOST('down_percent'); - $show_progress = (isset($_REQUEST['show_progress'])) ? GETPOST('show_progress') : false; - $form_complete = GETPOST('form_complete'); -} - -// This function does the actual mortgage calculations -// by plotting a PVIFA (Present Value Interest Factor of Annuity) -// table... -function get_interest_factor($year_term, $monthly_interest_rate) { - global $base_rate; - - $factor = 0; - $base_rate = 1 + $monthly_interest_rate; - $denominator = $base_rate; - for ($i=0; $i < ($year_term * 12); $i++) { - $factor += (1 / $denominator); - $denominator *= $base_rate; - } - return $factor; -} - -// If the form is complete, we'll start the math -if ($form_complete) { - // We'll set all the numeric values to JUST - // numbers - this will delete any dollars signs, - // commas, spaces, and letters, without invalidating - // the value of the number - $sale_price = preg_replace( "[^0-9.]", "", $sale_price); - $annual_interest_percent = preg_replace( "[^0-9.]", "", $annual_interest_percent); - $year_term = preg_replace( "[^0-9.]", "", $year_term); - $down_percent = preg_replace( "[^0-9.]", "", $down_percent); - - if ((float) $year_term <= 0) { - $errors[] = "You must enter a Sale Price of Home"; - } - if ((float) $sale_price <= 0) { - $errors[] = "You must enter a Length of Mortgage"; - } - if ((float) $annual_interest_percent <= 0) { - $errors[] = "You must enter an Annual Interest Rate"; - } - if (!$errors) { - $month_term = $year_term * 12; - $down_payment = $sale_price * ($down_percent / 100); - $annual_interest_rate = $annual_interest_percent / 100; - $monthly_interest_rate = $annual_interest_rate / 12; - $financing_price = $sale_price - $down_payment; - $monthly_factor = get_interest_factor($year_term, $monthly_interest_rate); - $monthly_payment = $financing_price / $monthly_factor; - } -} else { - if (!$sale_price) { $sale_price = $default_sale_price; } - if (!$annual_interest_percent) { $annual_interest_percent = $default_annual_interest_percent; } - if (!$year_term) { $year_term = $default_year_term; } - if (!$down_percent) { $down_percent = $default_down_percent; } - if (!$show_progress) { $show_progress = $default_show_progress; } -} - -if (! empty($errors)) { - setEventMessages('', $errors, 'errors'); - $form_complete = false; -} - - - -/* - * View - */ - -llxHeader(); - -print load_fiche_titre($langs->trans("LoanCalc"), '', 'title_accountancy.png'); - -print $langs->trans('LoanCalcDesc'); - -print '
'; -print '
'; - -dol_fiche_head(''); - -print '
'; -//print ''; -//print ''; -//print ''; -//print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print '';print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -if (! empty($show_progress)) -{ - print ''; -} -else -{ - print ''; -} - -print ''; -print '
'.$langs->trans('PurchaseFinanceInfo').'
'.$langs->trans('SalePriceOfAsset').': '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('PercentageDown').':%
'.$langs->trans('LengthOfMortgage').': '.$langs->trans("years").'
'.$langs->trans('AnnualInterestRate').':%
'.$langs->trans('ExplainCalculations').':'.$langs->trans('ShowMeCalculationsAndAmortization').''.$langs->trans('ShowMeCalculationsAndAmortization').'
'; - -dol_fiche_end(); - -print '
    '; -print '
'; - -// If the form has already been calculated, the $down_payment -// and $monthly_payment variables will be figured out, so we can show them in this table -if ($form_complete && $monthly_payment) -{ - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - if ($down_percent < 20) - { - $pmi_per_month = 55 * ($financing_price / 100000); - - /*print ''; - print ''; - print ''; - print '';*/ - print ''; - print ''; - print ''; - print ''; - } - - /*print ''; - print ''; - print ''; - print ''; - */ - - print ''; - print ''; - print ''; - print ''; -} - -print '
'.$langs->trans('MortgagePaymentInformation').'
'.$langs->trans('DownPayment').':' . number_format($down_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
'.$langs->trans('AmountFinanced').':' . number_format($financing_price, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
'.$langs->trans('MonthlyPayment').':' . number_format($monthly_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
(Principal & Interest ONLY)
 '; - print '
'; - echo 'Since you are putting LESS than 20% down, you will need to pay PMI - (Private Mortgage Insurance), which tends - to be about $55 per month for every $100,000 financed (until you have paid off 20% of your loan). This could add - '."\$" . number_format($pmi_per_month, "2", ".", ",").' to your monthly payment.'; - print '
'.$langs->trans('MonthlyPayment').':' . number_format(($monthly_payment + $pmi_per_month), "2", ".", ",") . $langs->trans("Currency".$conf->currency) . '
'; - print '(Principal & Interest, and PMI)
 '; - print '
';*/ - - $assessed_price = ($sale_price * .85); - $residential_yearly_tax = ($assessed_price / 1000) * 14; - $residential_monthly_tax = $residential_yearly_tax / 12; - - if ($pmi_per_month) - { - $pmi_text = "PMI"; - } - /*echo "Residential (or Property) Taxes are a little harder to figure out... In Massachusetts, the average resedential tax rate seems - to be around $14 per year for every $1,000 of your property's assessed value.";*/ - //print '

'; - //print "Let's say that your property's assessed value is 85% of what you actually paid for it - "; - /*print number_format($assessed_price, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . 'This would mean that your yearly residential taxes will be around'; - print number_format($residential_yearly_tax, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency); - print 'This could add ' . number_format($residential_monthly_tax, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . 'to your monthly payment'; - print '
TOTAL Monthly Payment:' . number_format(($monthly_payment + $pmi_per_month + $residential_monthly_tax), "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
'; - print '(including '.$pmi_text.')
'; -print ''; - -// This prints the calculation progress and -// the instructions of HOW everything is figured -// out -if ($form_complete && $show_progress) { - $step = 1; - - print '

'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'. $step++ .''; - print $langs->trans('DownPaymentDesc').'

'; - print number_format($down_payment,"2",".",",") . ' ' . $langs->trans("Currency".$conf->currency) . ' = '; - print number_format($sale_price,"2",".",",") . ' ' . $langs->trans("Currency".$conf->currency) . ' X (' . $down_percent . ' / 100)'; - print '
' . $step++ . ''; - print $langs->trans('InterestRateDesc') . '

'; - print $annual_interest_rate . ' = ' . $annual_interest_percent . '% / 100'; - print '
'; - print $langs->trans('MonthlyFactorDesc') . ':'; - print '
' . $step++ . ''; - print $langs->trans('MonthlyInterestRateDesc') . '

'; - print $monthly_interest_rate . ' = ' . $annual_interest_rate . ' / 12'; - print '
' . $step++ . ''; - print $langs->trans('MonthTermDesc') . '

'; - print $month_term . ' '. $langs->trans('Months') . ' = ' . $year_term . ' '. $langs->trans('Years') . ' X 12'; - print '
' . $step++ . ''; - print $langs->trans('MonthlyPaymentDesc') . ':
'; - print $langs->trans('MonthlyPayment').' = ' . number_format($financing_price, "2", "", "") . ' * '; - print '(1 - ((1 + ' . number_format($monthly_interest_rate, "4", "", "") . ')'; - print '-(' . $month_term . '))))'; - print '

'; - print $langs->trans('AmortizationPaymentDesc'); - print '
'; - print '
'; - - - // Set some base variables - $principal = $financing_price; - $current_month = 1; - $current_year = 1; - - // This basically, re-figures out the monthly payment, again. - $power = -($month_term); - $denom = pow((1 + $monthly_interest_rate), $power); - $monthly_payment = $principal * ($monthly_interest_rate / (1 - $denom)); - - print '

'.$langs->trans('AmortizationMonthlyPaymentOverYears', number_format($monthly_payment, "2", ".", ","), $year_term)."
\n"; - - print ''; - - // This LEGEND will get reprinted every 12 months - $legend = ''; - $legend.= ''; - $legend.= ''; - $legend.= ''; - $legend.= ''; - $legend.= ''; - - print $legend; - - // Loop through and get the current month's payments for - // the length of the loan - while ($current_month <= $month_term) - { - $interest_paid = $principal * $monthly_interest_rate; - $principal_paid = $monthly_payment - $interest_paid; - $remaining_balance = $principal - $principal_paid; - - $this_year_interest_paid = $this_year_interest_paid + $interest_paid; - $this_year_principal_paid = $this_year_principal_paid + $principal_paid; - - $var = !$var; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - ($current_month % 12) ? ($show_legend = false) : ($show_legend = true); - - if ($show_legend) { - print ''; - print ''; - print ''; - - $total_spent_this_year = $this_year_interest_paid + $this_year_principal_paid; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - - $current_year++; - $this_year_interest_paid = 0; - $this_year_principal_paid = 0; - - if (($current_month + 6) < $month_term) - { - echo $legend; - } - } - $principal = $remaining_balance; - $current_month++; - } - print "
' . $langs->trans("Month") . '' . $langs->trans("Interest") . '' . $langs->trans("LoanCapital") . '' . $langs->trans("Position") . '
' . $current_month . '' . number_format($interest_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '' . number_format($principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '' . number_format($remaining_balance, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
' . $langs->trans("Totalsforyear") . ' ' . $current_year . '
 '; - print $langs->trans('YouWillSpend', number_format($total_spent_this_year, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency), $current_year) . '
'; - print $langs->trans('GoToInterest', number_format($this_year_interest_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency)) . '
'; - print $langs->trans('GoToPrincipal', number_format($this_year_principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency)) . '
'; - print '
 
\n"; -} - -llxFooter(); - -$db->close(); diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 53cf9e7cb82..42c8cc57a4a 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Frederic France * Copyright (C) 2017 Laurent Destailleur * @@ -32,9 +32,7 @@ if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accoun require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -$langs->load("compta"); -$langs->load("bills"); -$langs->load("loan"); +$langs->loadLangs(array("compta","bills","loan")); $id=GETPOST('id','int'); $action=GETPOST('action','aZ09'); @@ -308,7 +306,7 @@ if ($action == 'create') $formproject=new FormProjets($db); // Projet associe - $langs->load("projects"); + $langs->loadLangs(array("projects")); print ''.$langs->trans("Project").''; @@ -444,7 +442,7 @@ if ($id > 0) // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); + $langs->loadLangs(array("projects")); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->loan->write) { @@ -699,8 +697,8 @@ if ($id > 0) print ''.$langs->trans("Type").''; print ''.$langs->trans("Insurance").''; print ''.$langs->trans("Interest").''; - print ''.$langs->trans("LoanCapital").''; - print ''; + print ''.$langs->trans("LoanCapital").''; + print ''; while ($i < $num) { @@ -710,9 +708,9 @@ if ($id > 0) print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; print "".$objp->paiement_type.' '.$objp->num_payment."\n"; - print ''.price($objp->amount_insurance, 0, $langs, 0, 0, -1, $conf->currency)."\n"; - print ''.price($objp->amount_interest, 0, $langs, 0, 0, -1, $conf->currency)."\n"; - print ''.price($objp->amount_capital, 0, $langs, 0, 0, -1, $conf->currency)."\n"; + print ''.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."\n"; + print ''.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."\n"; + print ''.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency)."\n"; print ""; $total_capital += $objp->amount_capital; $i++; @@ -770,7 +768,7 @@ if ($id > 0) print '
'; // Edit - if ($user->rights->loan->write) + if ($object->paid == 0 && $user->rights->loan->write) { print ''.$langs->trans('CreateCalcSchedule').''; @@ -790,7 +788,7 @@ if ($id > 0) } // Delete - if ($user->rights->loan->delete) + if ($object->paid == 0 && $user->rights->loan->delete) { print ''.$langs->trans("Delete").''; } diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 1de0e908c97..7843694585f 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify @@ -344,7 +344,7 @@ class Loan extends CommonObject $this->error=$this->db->lasterror(); return -1; } - } + } /** * Return label of loan status (unpaid, paid) @@ -369,8 +369,7 @@ class Loan extends CommonObject function LibStatut($statut,$mode=0,$alreadypaid=-1) { global $langs; - $langs->load('customers'); - $langs->load('bills'); + $langs->loadLangs(array("customers","bills")); if ($mode == 0) { diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 022cf050f11..595aead109e 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify @@ -17,16 +17,16 @@ */ /** - * \file htdocs/loan/class/paymentloan.class.php - * \ingroup facture - * \brief File of class to manage payment of loans + * \file htdocs/loan/class/paymentloan.class.php + * \ingroup loan + * \brief File of class to manage payment of loans */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -/** \class PaymentLoan - * \brief Class to manage payments of loans +/** \class PaymentLoan + * \brief Class to manage payments of loans */ class PaymentLoan extends CommonObject { @@ -37,8 +37,8 @@ class PaymentLoan extends CommonObject var $datec=''; var $tms=''; var $datep=''; - var $amounts=array(); // Array of amounts - var $amount_capital; // Total amount of payment + var $amounts=array(); // Array of amounts + var $amount_capital; // Total amount of payment var $amount_insurance; var $amount_interest; var $fk_typepayment; @@ -65,8 +65,8 @@ class PaymentLoan extends CommonObject /** * 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 * @return int <0 if KO, id of payment if OK */ @@ -76,9 +76,9 @@ class PaymentLoan extends CommonObject $error=0; - $now=dol_now(); + $now=dol_now(); - // Validate parameters + // Validate parameters if (! $this->datepaid) { $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_modif)) $this->fk_user_modif = trim($this->fk_user_modif); - $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest; - $totalamount = price2num($totalamount); + $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest; + $totalamount = price2num($totalamount); - // Check parameters - if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null + // Check parameters + if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null $this->db->begin(); @@ -127,7 +127,7 @@ class PaymentLoan extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error=$this->db->lasterror(); $error++; } @@ -135,9 +135,9 @@ class PaymentLoan extends CommonObject if ($totalamount != 0 && ! $error) { - $this->amount_capital=$totalamount; - $this->total=$totalamount; // deprecated - $this->db->commit(); + $this->amount_capital=$totalamount; + $this->total=$totalamount; // deprecated + $this->db->commit(); return $this->id; } else @@ -168,8 +168,8 @@ class PaymentLoan extends CommonObject $sql.= " t.amount_interest,"; $sql.= " t.fk_typepayment,"; $sql.= " t.num_payment,"; - $sql.= " t.note_private,"; - $sql.= " t.note_public,"; + $sql.= " t.note_private,"; + $sql.= " t.note_public,"; $sql.= " t.fk_bank,"; $sql.= " t.fk_user_creat,"; $sql.= " t.fk_user_modif,"; @@ -327,15 +327,15 @@ class PaymentLoan extends CommonObject $this->db->begin(); - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql.= " WHERE type='payment_loan' AND url_id=".$this->id; + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; + $sql.= " WHERE type='payment_loan' AND url_id=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } 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. - * All payment properties must have been set first like after a call to create(). - * - * @param User $user Object of user making payment - * @param int $fk_loan Id of fk_loan to do link with this payment - * @param string $mode 'payment_loan' - * @param string $label Label to use in bank record - * @param int $accountid Id of bank account to do link with - * @param string $emetteur_nom Name of transmitter - * @param string $emetteur_banque Name of bank - * @return int <0 if KO, >0 if OK - */ - function addPaymentToBank($user, $fk_loan, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) - { - global $conf; + /** + * 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(). + * + * @param User $user Object of user making payment + * @param int $fk_loan Id of fk_loan to do link with this payment + * @param string $mode 'payment_loan' + * @param string $label Label to use in bank record + * @param int $accountid Id of bank account to do link with + * @param string $emetteur_nom Name of transmitter + * @param string $emetteur_banque Name of bank + * @return int <0 if KO, >0 if OK + */ + function addPaymentToBank($user, $fk_loan, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + { + global $conf; - $error=0; + $error=0; - if (! empty($conf->banque->enabled)) - { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if (! empty($conf->banque->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acc = new Account($this->db); - $acc->fetch($accountid); + $acc = new Account($this->db); + $acc->fetch($accountid); - $total=$this->total; - if ($mode == 'payment_loan') $total=-$total; + $total=$this->total; + if ($mode == 'payment_loan') $total=-$total; - // Insert payment into llx_bank - $bank_line_id = $acc->addline( - $this->datepaid, - $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") - $label, - $total, - $this->num_payment, - '', - $user, - $emetteur_nom, - $emetteur_banque - ); + // Insert payment into llx_bank + $bank_line_id = $acc->addline( + $this->datepaid, + $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") + $label, + $total, + $this->num_payment, + '', + $user, + $emetteur_nom, + $emetteur_banque + ); - // 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); - if ($result <= 0) - { - $error++; - dol_print_error($this->db); - } + // 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); + if ($result <= 0) + { + $error++; + dol_print_error($this->db); + } - // Add link 'payment_loan' in bank_url between payment and bank transaction - $url=''; - if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/loan/payment/card.php?id='; - if ($url) - { - $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode); - if ($result <= 0) - { - $error++; - dol_print_error($this->db); - } - } + // Add link 'payment_loan' in bank_url between payment and bank transaction + $url=''; + if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/loan/payment/card.php?id='; + if ($url) + { + $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode); + if ($result <= 0) + { + $error++; + dol_print_error($this->db); + } + } - // Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment) - 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'); - if ($result <= 0) dol_print_error($this->db); - } - } - else - { - $this->error=$acc->error; - $error++; - } - } + // Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment) + 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'); + if ($result <= 0) dol_print_error($this->db); + } + } + else + { + $this->error=$acc->error; + $error++; + } + } - if (! $error) - { - return 1; - } - else - { - return -1; - } - } + if (! $error) + { + return 1; + } + else + { + return -1; + } + } /** @@ -512,7 +512,7 @@ class PaymentLoan extends CommonObject if (!empty($this->id)) { - $link = ''; + $link = ''; $linkend=''; if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$linkend.' '); diff --git a/htdocs/loan/createschedule.php b/htdocs/loan/createschedule.php index 0ecc0038835..0983fb15a05 100644 --- a/htdocs/loan/createschedule.php +++ b/htdocs/loan/createschedule.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2017 Franck Moreau + * Copyright (C) 2018 Alexandre Spangaro * * 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 @@ -16,9 +17,9 @@ */ /** - * \file htdocs/loan/createecheancier.php - * \ingroup loan - * \brief Schedule card + * \file htdocs/loan/createschedule.php + * \ingroup loan + * \brief Schedule card */ require '../main.inc.php'; @@ -33,7 +34,7 @@ $action = GETPOST('action','aZ09'); $object = new Loan($db); $object->fetch($loanid); -$langs->load('loan'); +$langs->loadLangs(array("loan")); if ($action == 'createecheancier') { @@ -147,11 +148,11 @@ print ''; print ''; print ''; -Print ''.$langs->trans("DueDate").''; +Print ''.$langs->trans("Term").''; Print ''.$langs->trans("Date").''; Print ''.$langs->trans("Amount").''; Print ''.$langs->trans("InterestAmount").''; -Print ''.$langs->trans("Remain"); +Print ''.$langs->trans("CapitalRemain"); print ' ('.price2num($object->capital).')'; print ''; print ''; diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index 54333029689..b6504d0a776 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -1,6 +1,6 @@ - * Copyright (C) 2017 Ferran Marcet +/* Copyright (C) 2014-2018 Alexandre Spangaro + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -32,11 +32,7 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; } -$langs->load("other"); -$langs->load("companies"); -$langs->load("compta"); -$langs->load("bills"); -$langs->load("loan"); +$langs->loadLangs(array("other","companies","compta","bills","loan")); $id = GETPOST('id','int'); $action = GETPOST('action','aZ09'); diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index 7a6bee5d79f..c48e9b50ac1 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Frederic France - * Copyright (C) 2015 Juanjo Menent - * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2016 Laurent Destailleur * * 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 @@ -19,18 +19,15 @@ */ /** - * \file htdocs/loan/index.php - * \ingroup loan - * \brief Page to list all loans + * \file htdocs/loan/index.php + * \ingroup loan + * \brief Page to list all loans */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; -$langs->load("loan"); -$langs->load("compta"); -$langs->load("banks"); -$langs->load("bills"); +$langs->loadLangs(array("loan","compta","banks","bills")); // Security check $socid = GETPOST('socid', 'int'); @@ -57,7 +54,7 @@ $optioncss = GETPOST('optioncss','alpha'); // Purge search criteria if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { - $search_ref=""; + $search_ref=""; $search_label=""; $search_amount=""; } @@ -71,7 +68,7 @@ $loan_static = new Loan($db); llxHeader(); -$sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend,"; +$sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,"; $sql.= " SUM(pl.amount_capital) as alreadypayed"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl"; $sql.= " ON l.rowid = pl.fk_loan"; @@ -80,8 +77,8 @@ if ($search_amount) $sql.= natural_search("l.capital", $search_amount, 1); if ($search_ref) $sql.= " AND l.rowid = ".$db->escape($search_ref); if ($search_label) $sql.= natural_search("l.label", $search_label); if ($filtre) { - $filtre=str_replace(":","=",$filtre); - $sql .= " AND ".$filtre; + $filtre=str_replace(":","=",$filtre); + $sql .= " AND ".$filtre; } $sql.= " GROUP BY l.rowid, l.label, l.capital, l.datestart, l.dateend"; $sql.= $db->order($sortfield,$sortorder); @@ -89,13 +86,13 @@ $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); @@ -108,35 +105,35 @@ if ($resql) $i = 0; $var=true; - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_label) $param.="&search_label=".urlencode($search_user); - if ($search_amount) $param.="&search_amount=".urlencode($search_amount_ht); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_ref) $param.="&search_ref=".urlencode($search_ref); + if ($search_label) $param.="&search_label=".urlencode($search_user); + if ($search_amount) $param.="&search_amount=".urlencode($search_amount_ht); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - $newcardbutton=''; - if ($user->rights->loan->write) - { - $newcardbutton=''.$langs->trans('NewLoan'); - $newcardbutton.= ''; - $newcardbutton.= ''; - } + $newcardbutton=''; + if ($user->rights->loan->write) + { + $newcardbutton=''.$langs->trans('NewLoan'); + $newcardbutton.= ''; + $newcardbutton.= ''; + } - print '
'."\n"; - if ($optioncss != '') print ''; + print ''."\n"; + if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; // Filters lines print ''; @@ -144,6 +141,7 @@ if ($resql) print ''; print ''; print ''; + print ''; print ''; print '\n"; @@ -163,9 +162,9 @@ if ($resql) while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - $loan_static->id = $obj->rowid; - $loan_static->ref = $obj->rowid; - $loan_static->label = $obj->label; + $loan_static->id = $obj->rowid; + $loan_static->ref = $obj->rowid; + $loan_static->label = $obj->label; $var = !$var; print ''; @@ -182,23 +181,26 @@ if ($resql) // Date start print ''; + // Date end + print ''; + print ''; print ''; - print "\n"; + print "\n"; $i++; } - print "
  '; print ''; @@ -156,6 +154,7 @@ if ($resql) print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"l.label","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre("LoanCapital",$_SERVER["PHP_SELF"],"l.capital","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("DateStart",$_SERVER["PHP_SELF"],"l.datestart","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre("DateEnd",$_SERVER["PHP_SELF"],"l.dateend","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"l.paid","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); print "
'.dol_print_date($db->jdate($obj->datestart), 'day').''.dol_print_date($db->jdate($obj->dateend), 'day').''.$loan_static->LibStatut($obj->paid,5,$obj->alreadypayed).'
"; - print '
'; - print "
\n"; - $db->free($resql); + print ""; + print '
'; + print "\n"; + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } llxFooter(); diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index ea7237cdd34..d94bedbf9fb 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -1,6 +1,6 @@ - * Copyright (C) 2017 Ferran Marcet +/* Copyright (C) 2014-2018 Alexandre Spangaro + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -30,9 +30,7 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; } -$langs->load("compta"); -$langs->load("bills"); -$langs->load("loan"); +$langs->loadLangs(array("compta","bills","loan")); $id=GETPOST('id','int'); $action=GETPOST('action','aZ09'); diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 8f64036f819..9e5fedc423b 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -4,8 +4,8 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Frederic France - * Copyright (C) 2016 Alexandre Spangaro - * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2016-2018 Alexandre Spangaro + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -36,7 +36,7 @@ if (! empty($conf->projet->enabled)) { $action = GETPOST('action','aZ09'); -$langs->load('loan'); +$langs->loadLangs(array("loan")); // Security check $id = GETPOST('id','int'); @@ -82,7 +82,7 @@ if ($id > 0) $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); + $langs->loadLangs(array("projects")); $morehtmlref .= '
' . $langs->trans('Project') . ' : '; if ($user->rights->loan->write) { //if ($action != 'classify') diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index 47efb9c8cde..2f6fbe8f202 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2018 Alexandre Spangaro * * 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 @@ -16,9 +16,9 @@ */ /** - * \file htdocs/loan/payment/card.php - * \ingroup loan - * \brief Payment's card of loan + * \file htdocs/loan/payment/card.php + * \ingroup loan + * \brief Payment's card of loan */ require '../../main.inc.php'; @@ -26,10 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.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'); +$langs->loadLangs(array("bills","banks","companies","loan")); // Security check $id=GETPOST("id",'int'); @@ -59,14 +56,14 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del $result = $payment->delete($user); if ($result > 0) { - $db->commit(); - header("Location: ".DOL_URL_ROOT."/loan/index.php"); - exit; + $db->commit(); + header("Location: ".DOL_URL_ROOT."/loan/index.php"); + exit; } else { setEventMessages($payment->error, $payment->errors, 'errors'); - $db->rollback(); + $db->rollback(); } } @@ -173,18 +170,18 @@ print ''.$langs->trans('NotePublic').''.nl2br($payment->note_pu // Bank account if (! empty($conf->banque->enabled)) { - if ($payment->bank_account) - { - $bankline=new AccountLine($db); - $bankline->fetch($payment->bank_line); + if ($payment->bank_account) + { + $bankline=new AccountLine($db); + $bankline->fetch($payment->bank_line); - print ''; - print ''.$langs->trans('BankTransactionLine').''; + print ''; + print ''.$langs->trans('BankTransactionLine').''; print ''; print $bankline->getNomUrl(1,0,'showall'); - print ''; - print ''; - } + print ''; + print ''; + } } print ''; @@ -213,7 +210,7 @@ if ($resql) print ''; print ''.$langs->trans('Loan').''; print ''.$langs->trans('Label').''; - print ''.$langs->trans('ExpectedToPay').''; + // print ''.$langs->trans('ExpectedToPay').''; print ''.$langs->trans('Status').''; print ''.$langs->trans('PayedByThisPayment').''; print "\n"; @@ -233,11 +230,13 @@ if ($resql) // Label print ''.$objp->label.''; // Expected to pay - print ''.price($objp->capital).''; + // print ''.price($objp->capital).''; // Status print ''.$loan->getLibStatut(4,$objp->amount_capital).''; // Amount payed - print ''.price($objp->amount_capital).''; + $amount_payed = $objp->amount_capital + $objp->amount_insurance + $objp->amount_interest; + + print ''.price($amount_payed).''; print "\n"; if ($objp->paid == 1) // If at least one invoice is paid, disable delete { diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 8faac08fb60..ee83bf17f00 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify @@ -27,8 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -$langs->load("bills"); -$langs->load("loan"); +$langs->loadLangs(array("bills","loan")); $chid=GETPOST('id','int'); $action=GETPOST('action','aZ09');