From 7fa2b6b3ebea20771d330ed97a5c339d2cdf2e2a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 6 Oct 2014 05:34:45 +0200 Subject: [PATCH] Update --- htdocs/compta/loan/calculator.php | 223 ------------------------ htdocs/compta/loan/calculator.tpl | 150 ---------------- htdocs/compta/loan/card.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 1 - htdocs/langs/en_US/loan.lang | 4 +- htdocs/langs/fr_FR/loan.lang | 4 +- 6 files changed, 5 insertions(+), 379 deletions(-) delete mode 100644 htdocs/compta/loan/calculator.php delete mode 100644 htdocs/compta/loan/calculator.tpl diff --git a/htdocs/compta/loan/calculator.php b/htdocs/compta/loan/calculator.php deleted file mode 100644 index 562ce2c27d5..00000000000 --- a/htdocs/compta/loan/calculator.php +++ /dev/null @@ -1,223 +0,0 @@ - - * - * 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/calculator.php - * \ingroup loan - * \brief Calculator for loan - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; - -$langs->load("loan"); -$langs->load("compta"); -$langs->load("banks"); -$langs->load("bills"); - -// Security check -$socid = isset($GETPOST["socid"])?$GETPOST["socid"]:''; -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'loan', '', '', ''); - -$action=GETPOST("action"); - -/* Defining Variables */ -$periods = array( - 52 => $langs->trans("Weekly"), - 26 => $langs->trans("Bi-weekly"), - 12 => $langs->trans("Monthly"), - 6 => $langs->trans("Bi-monthly"), - 4 => $langs->trans("Quarterly"), - 2 => $langs->trans("Semi-annually"), - 1 => $langs->trans("Annually") - ); - -$loan_capital = isset($GETPOST("loan_capital")) ? $GETPOST("loan_capital") : 0; -$loan_length = isset($GETPOST("loan_length")) ? $GETPOST("loan_length") : 0; -$loan_interest = isset(GETPOST("loan_interest")) ? $GETPOST("loan_interest") : 0; -$pay_periodicity = isset(GETPOST("pay_periodicity")) ? $GETPOST("pay_periodicity") : 12; -$periodicity = $periods[$pay_periodicity]; - -$pay_periods = ''; -foreach($periods as $value => $name) -{ - $selected = ($pay_periodicity == $value) ? 'selected' : ''; -} - -if ($action == 'calculate') -{ - /* Checking Variables */ - $error = 0; - - if(!is_numeric($loan_capital) || $loan_capital <= 0) - { - // $this->error="ErrorLoanCapital"; - return -1; - } - if(!is_numeric($loan_length) || $loan_length <= 0) - { - // $this->error="ErrorLoanLength"; - return -1; - } - if(!is_numeric($loan_interest) or $loan_interest <= 0) - { - // $this->error="ErrorLoanInterest"; - return -1; - } - - /* - * Calculating - */ - if(isset($_GET['action'])) - { - $c_balance = $loan_capital; - $total_periods = $loan_length * $pay_periodicity; - $interest_percent = $loan_interest / 100; - $period_interest = $interest_percent / $pay_periodicity; - $c_period_payment = $loan_capital * ($period_interest / (1 - pow((1 + $period_interest), -($total_periods)))); - $total_paid = number_format($c_period_payment * $total_periods, 2, '.', ' '); - $total_interest = number_format($c_period_payment * $total_periods - $loan_capital, 2, '.', ' '); - $total_principal = number_format($loan_capital, 2, '.', ' '); - - $loan_capital = number_format($loan_capital, 2, '.', ' '); - $loan_interest = number_format($loan_interest, 2, '.', ' '); - $period_payment = number_format($c_period_payment, 2, '.', ' '); - - for($period = 1; $period <= $total_periods; $period++) - { - $c_interest = $c_balance * $period_interest; - $c_principal = $c_period_payment - $c_interest; - $c_balance -= $c_principal; - - $interest = number_format($c_interest, 2, '.', ' '); - $principal = number_format($c_principal, 2, '.', ' '); - $balance = number_format($c_balance, 2, '.', ' '); - - $evenrow_row_modifier = ($period % 2) ? '' : 'class=evenrow'; - } - } - else - { - $amortization_table = ''; - $loan_summary = ''; - } -} - -/* - * View - */ - -$help_url='EN:Module_Loan|FR:Module_Emprunt'; -llxHeader("",$langs->trans("Loan"),$help_url); - -print_fiche_titre($langs->trans("CalculatorLoan")); - -print ''; - -print '' . "\n"; -print ''; -print ''; - -// Capital -print ''; - -// Length -print ''; - -// Interest -print ''; - -print '
'.$langs->trans("Capital").'
'.$langs->trans("LengthByYears").'
'.$langs->trans("Interest").' %
'; - -print '
'; - -print ''; - -if ($action == 'calculate') -{ -/* - - - - - - {amortization_table_rows} - - - -
PeriodInterest PaidPrincipal PaidRemaining Balance
Totals:{total_interest}${total_principal}$ 
- - - - - {period} - {interest}$ - {principal}$ - {balance}$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Loan Summary
Loan amount:{loan_amount}$
Loan length:{loan_length} years
Annual interest:{annual_interest}%
Pay periodicity:{periodicity}
{periodicity} payment:{period_payment}$
Total paid:{total_paid}$
Total interest:{total_interest}$
Total periods:{total_periods}
- - */ -} -else -{ - -} - -$db->close(); - -llxFooter(); diff --git a/htdocs/compta/loan/calculator.tpl b/htdocs/compta/loan/calculator.tpl deleted file mode 100644 index 7efbca9924b..00000000000 --- a/htdocs/compta/loan/calculator.tpl +++ /dev/null @@ -1,150 +0,0 @@ - - - - Loan Calculator - - - - - - - - - - -
- {error} - - - - - -
- {loan_summary} - {loan_parameters_form} - - {amortization_table} -
-
- - - -
- - - - - - - - - - -
Loan Parameters
- - - - - - - - - - - - - - - - - - - - -
Loan amount: $
Loan length: years
Annual interest: %
Pay periodicity: - -
-
Powered by PC Calculators
-
- - - - - - - - - - - - {amortization_table_rows} - - - -
PeriodInterest PaidPrincipal PaidRemaining Balance
Totals:{total_interest}${total_principal}$ 
- - - - - {period} - {interest}$ - {principal}$ - {balance}$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Loan Summary
Loan amount:{loan_amount}$
Loan length:{loan_length} years
Annual interest:{annual_interest}%
Pay periodicity:{periodicity}
{periodicity} payment:{period_payment}$
Total paid:{total_paid}$
Total interest:{total_interest}$
Total periods:{total_periods}
- - - - - - diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index c97ca6d84b0..e49aee1b61f 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -297,7 +297,7 @@ if ($id > 0) if ($action == 'edit') { - print "
id&action=update\" method=\"post\">"; + print 'id&action=update" method="POST">'; print ''; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 86e74cfcc5f..1e4f1197cb0 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -834,7 +834,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/loan/index.php?leftmenu=tax_loan&mainmenu=accountancy",$langs->trans("Loans"),1,$user->rights->loan->read, '', $mainmenu, 'tax_loan'); if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/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("/compta/loan/index.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read); - if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/calculator.php?leftmenu=tax_loan",$langs->trans("Calculator"),2,$user->rights->loan->read); } // Social contributions diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index 37523b7408b..10fb0249f6d 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -9,8 +9,8 @@ Nbterms=Number of terms LoanAccountancyCapitalCode=Accountancy code capital LoanAccountancyInsuranceCode=Accountancy code insurance LoanAccountancyInterestCode=Accountancy code interest -Calculator=Simulator -CalculatorLoan=Loan simulator +ConfirmDeleteLoan=Confirm deleting this loan +ConfirmPayLoan=Confirm classify paid this loan ErrorLoanCapital=Loan amount has to be numeric and greater than zero. ErrorLoanLength=Loan length has to be numeric and greater than zero. ErrorLoanInterest=Annual interest has to be numeric and greater than zero. diff --git a/htdocs/langs/fr_FR/loan.lang b/htdocs/langs/fr_FR/loan.lang index c699388e0c0..1e54f90e2be 100644 --- a/htdocs/langs/fr_FR/loan.lang +++ b/htdocs/langs/fr_FR/loan.lang @@ -9,8 +9,8 @@ Nbterms=Nombre d'échéances LoanAccountancyCapitalCode=Compte comptable capital LoanAccountancyInsuranceCode=Compte comptable assurance LoanAccountancyInterestCode=Compte comptable intérêts -Calculator=Simulateur -CalculatorLoan=Simulateur d'emprunt +ConfirmDeleteLoan=Confirmation de supression de cet emprunt +ConfirmPayLoan=Confirmation que cet emprunt est classé comme payé ErrorLoanCapital=Le capital de l'emprunt doit être au format numérique et supérieur à zéro. ErrorLoanLength=La durée de l'emprunt doit être au format numérique et supérieur à zéro. ErrorLoanInterest=Les intérêts d'emprunt doivent être au format numérique et supérieur à zéro.