Merge pull request #8821 from aspangaro/8.0-b26

Fix Loan : Move to Loadlangs / Remove oldcode (calc) / Presentation / Small problems
This commit is contained in:
Laurent Destailleur 2018-05-25 10:36:46 +02:00 committed by GitHub
commit 02803f9284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 267 additions and 667 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016-2018 Alexandre Spangaro <aspangaro@zendsi.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

View File

@ -1,12 +1,12 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017 Frédéric France <frederic.france@netlogic.fr>
*
* 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 '<br>';
$i = 0;
print '<div class="div-table-responsive">';
print '<div class="div-table-responsive">';
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td></td>";
@ -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';

View File

@ -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&amp;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

View File

@ -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 <b>down payment</b> = The price of the home multiplied by the percentage down divided by 100 (for 5% down becomes 5/100 or 0.05)
InterestRateDesc=The <b>interest rate</b> = The annual interest percentage divided by 100
MonthlyFactorDesc=The <b>monthly factor</b> = The result of the following formula
MonthlyInterestRateDesc=The <b>monthly interest rate</b> = The annual interest rate divided by 12 (for the 12 months in a year)
MonthTermDesc=The <b>month term</b> 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 <a href="#amortization">amortization</a> 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: <b>%s</b> over %s years
Totalsforyear=Totals for year
MonthlyPayment=Monthly Payment
LoanCalcDesc=This <b>mortgage calculator</b> 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.<br> 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.<br>
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

View File

@ -1,393 +0,0 @@
<?php
/* Copyright (C) 2002 David Tufts <http://dave.imarc.net>
* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* 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/>.
*/
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 <b>Sale Price of Home</b>";
}
if ((float) $sale_price <= 0) {
$errors[] = "You must enter a <b>Length of Mortgage</b>";
}
if ((float) $annual_interest_percent <= 0) {
$errors[] = "You must enter an <b>Annual Interest Rate</b>";
}
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 '<form method="GET" name="information" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="form_complete" value="1"><br>';
dol_fiche_head('');
print '<table class="noborder centpercent">';
//print '<tr>';
//print '<td align="right"><img src="/images/clear.gif" width="225" height="1" border="0" alt=""></td>';
//print '<td align="smalltext" width="100%"><img src="/images/clear.gif" width="250" height="1" border="0" alt=""></td>';
//print '</tr>';
print '<tr>';
print '<td align="center" colspan="2"><b>'.$langs->trans('PurchaseFinanceInfo').'</b></td>';
print '</tr>';
print '<tr>';
print '<td align="right">'.$langs->trans('SalePriceOfAsset').':</td>';
print '<td><input type="text" size="10" name="sale_price" value="'.$sale_price.'"> '.$langs->trans("Currency".$conf->currency).'</td>';print '</tr>';
print '<tr>';
print '<td align="right">'.$langs->trans('PercentageDown').':</td>';
print '<td><input type="text" size="5" name="down_percent" value="'.$down_percent.'">%</td>';
print '</tr>';
print '<tr>';
print '<td align="right">'.$langs->trans('LengthOfMortgage').':</td>';
print '<td><input type="text" size="3" name="year_term" value="'.$year_term.'"> '.$langs->trans("years").'</td>';
print '</tr>';
print '<tr>';
print '<td align="right">'.$langs->trans('AnnualInterestRate').':</td>';
print '<td><input type="text" size="5" name="annual_interest_percent" value="'.$annual_interest_percent.'">%</td>';
print '</tr>';
print '<tr>';
print '<td align="right">'.$langs->trans('ExplainCalculations').':</td>';
if (! empty($show_progress))
{
print '<td><input type="checkbox" name="show_progress" value="1" checked>'.$langs->trans('ShowMeCalculationsAndAmortization').'</td>';
}
else
{
print '<td><input type="checkbox" name="show_progress" value="1">'.$langs->trans('ShowMeCalculationsAndAmortization').'</td>';
}
print '</tr>';
print '</table>';
dol_fiche_end();
print '<center><input class="button" type="submit" value="'.$langs->trans("Calculate").'"> &nbsp; &nbsp; ';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
// 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 '<br>';
print '<table cellpadding="2" cellspacing="0" border="0" width="100%">';
print '<tr valign="top">';
print '<td align="center" colspan="2" bgcolor="#000000"><font color="#ffffff"><b>'.$langs->trans('MortgagePaymentInformation').'</b></font></td>';
print '</tr>';
print '<tr valign="top" bgcolor="#eeeeee">';
print '<td align="right">'.$langs->trans('DownPayment').':</td>';
print '<td><b>' . number_format($down_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</b></td>';
print '</tr>';
print '<tr valign="top" bgcolor="#eeeeee">';
print '<td align="right">'.$langs->trans('AmountFinanced').':</td>';
print '<td><b>' . number_format($financing_price, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</b></td>';
print '</tr>';
print '<tr valign="top" bgcolor="#cccccc">';
print '<td align="right">'.$langs->trans('MonthlyPayment').':</td>';
print '<td><b>' . number_format($monthly_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</b><br><font>(Principal &amp; Interest ONLY)</font></td>';
print '</tr>';
if ($down_percent < 20)
{
$pmi_per_month = 55 * ($financing_price / 100000);
/*print '<tr valign="top" bgcolor="#FFFFCC">';
print '<td align="right">&nbsp;</td>';
print '<td>';
print '<br>';
echo 'Since you are putting LESS than 20% down, you will need to pay PMI
(<a href="http://www.google.com/search?hl=en&q=private+mortgage+insurance">Private Mortgage Insurance</a>), 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 '</td>';
print '</tr>';*/
print '<tr valign="top" bgcolor="#FFFF99">';
print '<td align="right">'.$langs->trans('MonthlyPayment').':</td>';
print '<td><b>' . number_format(($monthly_payment + $pmi_per_month), "2", ".", ",") . $langs->trans("Currency".$conf->currency) . '</b><br><font>';
print '(Principal &amp; Interest, and PMI)</td>';
print '</tr>';
}
/*print '<tr valign="top" bgcolor="#CCCCFF">';
print '<td align="right">&nbsp;</td>';
print '<td>';
print '<br>';*/
$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 '<br><br>';
//print "Let's say that your property's <i>assessed value</i> 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 '</td>';
print '</tr>';
*/
print '<tr valign="top" bgcolor="#9999FF">';
print '<td align="right">TOTAL Monthly Payment:</td>';
print '<td><b>' . number_format(($monthly_payment + $pmi_per_month + $residential_monthly_tax), "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</b><br><font>';
print '(including '.$pmi_text.')</font></td>';
print '</tr>';
}
print '</table>';
print '</form>';
// This prints the calculation progress and
// the instructions of HOW everything is figured
// out
if ($form_complete && $show_progress) {
$step = 1;
print '<br><br>';
print '<table cellpadding="5" cellspacing="0" border="1" width="100%">';
print '<tr valign="top">';
print '<td><b>'. $step++ .'</b></td>';
print '<td>';
print $langs->trans('DownPaymentDesc').'<br><br>';
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 '</td>';
print '</tr>';
print '<tr valign="top">';
print '<td><b>' . $step++ . '</b></td>';
print '<td>';
print $langs->trans('InterestRateDesc') . '<br><br>';
print $annual_interest_rate . ' = ' . $annual_interest_percent . '% / 100';
print '</td>';
print '</tr>';
print '<tr valign="top" bgcolor="#cccccc">';
print '<td colspan="2">';
print $langs->trans('MonthlyFactorDesc') . ':';
print '</td>';
print '</tr>';
print '<tr valign="top">';
print '<td><b>' . $step++ . '</b></td>';
print '<td>';
print $langs->trans('MonthlyInterestRateDesc') . '<br><br>';
print $monthly_interest_rate . ' = ' . $annual_interest_rate . ' / 12';
print '</td>';
print '</tr>';
print '<tr valign="top">';
print '<td><b>' . $step++ . '</b></td>';
print '<td>';
print $langs->trans('MonthTermDesc') . '<br><br>';
print $month_term . ' '. $langs->trans('Months') . ' = ' . $year_term . ' '. $langs->trans('Years') . ' X 12';
print '</td>';
print '</tr>';
print '<tr valign="top">';
print '<td><b>' . $step++ . '</b></td>';
print '<td>';
print $langs->trans('MonthlyPaymentDesc') . ':<br>';
print $langs->trans('MonthlyPayment').' = ' . number_format($financing_price, "2", "", "") . ' * ';
print '(1 - ((1 + ' . number_format($monthly_interest_rate, "4", "", "") . ')';
print '<sup>-(' . $month_term . ')</sup>)))';
print '<br><br>';
print $langs->trans('AmortizationPaymentDesc');
print '</td>';
print '</tr>';
print '</table>';
print '<br>';
// 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 '<br><br><a name="amortization"></a>'.$langs->trans('AmortizationMonthlyPaymentOverYears', number_format($monthly_payment, "2", ".", ","), $year_term)."<br>\n";
print '<table class="noborder" width="100%">';
// This LEGEND will get reprinted every 12 months
$legend = '<tr class="liste_titre">';
$legend.= '<td class="liste_titre" align="center">' . $langs->trans("Month") . '</td>';
$legend.= '<td class="liste_titre" align="center">' . $langs->trans("Interest") . '</td>';
$legend.= '<td class="liste_titre" align="center">' . $langs->trans("LoanCapital") . '</td>';
$legend.= '<td class="liste_titre" align="center">' . $langs->trans("Position") . '</td>';
$legend.= '</tr>';
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 '<tr class="oddeven">';
print '<td align="right">' . $current_month . '</td>';
print '<td align="right">' . number_format($interest_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</td>';
print '<td align="right">' . number_format($principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</td>';
print '<td align="right">' . number_format($remaining_balance, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</td>';
print '</tr>';
($current_month % 12) ? ($show_legend = false) : ($show_legend = true);
if ($show_legend) {
print '<tr>';
print '<td colspan="4"><b>' . $langs->trans("Totalsforyear") . ' ' . $current_year . '</td>';
print '</tr>';
$total_spent_this_year = $this_year_interest_paid + $this_year_principal_paid;
print '<tr>';
print '<td>&nbsp;</td>';
print '<td colspan="3">';
print $langs->trans('YouWillSpend', number_format($total_spent_this_year, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency), $current_year) . '<br>';
print $langs->trans('GoToInterest', number_format($this_year_interest_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency)) . '<br>';
print $langs->trans('GoToPrincipal', number_format($this_year_principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency)) . '<br>';
print '</td>';
print '</tr>';
print '<tr>';
print '<td colspan="4">&nbsp;<br></td>';
print '</tr>';
$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 "</table>\n";
}
llxFooter();
$db->close();

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro@zendsi.com>
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
@ -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 '<tr><td>'.$langs->trans("Project").'</td><td>';
@ -444,7 +442,7 @@ if ($id > 0)
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$langs->loadLangs(array("projects"));
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->loan->write)
{
@ -699,8 +697,8 @@ if ($id > 0)
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Insurance").'</td>';
print '<td align="right">'.$langs->trans("Interest").'</td>';
print '<td align="right">'.$langs->trans("LoanCapital").'</td>';
print '</tr>';
print '<td align="right">'.$langs->trans("LoanCapital").'</td>';
print '</tr>';
while ($i < $num)
{
@ -710,9 +708,9 @@ if ($id > 0)
print '<td><a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
print "<td>".$objp->paiement_type.' '.$objp->num_payment."</td>\n";
print '<td align="right">'.price($objp->amount_insurance, 0, $langs, 0, 0, -1, $conf->currency)."</td>\n";
print '<td align="right">'.price($objp->amount_interest, 0, $langs, 0, 0, -1, $conf->currency)."</td>\n";
print '<td align="right">'.price($objp->amount_capital, 0, $langs, 0, 0, -1, $conf->currency)."</td>\n";
print '<td align="right">'.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."</td>\n";
print '<td align="right">'.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."</td>\n";
print '<td align="right">'.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency)."</td>\n";
print "</tr>";
$total_capital += $objp->amount_capital;
$i++;
@ -770,7 +768,7 @@ if ($id > 0)
print '<div class="tabsAction">';
// Edit
if ($user->rights->loan->write)
if ($object->paid == 0 && $user->rights->loan->write)
{
print '<a href="javascript:popEcheancier()" class="butAction">'.$langs->trans('CreateCalcSchedule').'</a>';
@ -790,7 +788,7 @@ if ($id > 0)
}
// Delete
if ($user->rights->loan->delete)
if ($object->paid == 0 && $user->rights->loan->delete)
{
print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* 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)
{

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* 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 = '<a href="'.DOL_URL_ROOT.'/compta/payment/card.php?id='.$this->id.'">';
$link = '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$this->id.'">';
$linkend='</a>';
if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$linkend.' ');

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2017 Franck Moreau <franck.moreau@theobald.com>
/* Copyright (C) 2017 Franck Moreau <franck.moreau@theobald.com>
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@zendsi.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
@ -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 '</th>';
print '</tr>';
print '<tr class="liste_titre">';
Print '<th width="10%" align="center">'.$langs->trans("DueDate").'</th>';
Print '<th width="10%" align="center">'.$langs->trans("Term").'</th>';
Print '<th width="10%" align="center">'.$langs->trans("Date").'</th>';
Print '<th width="10%" align="center">'.$langs->trans("Amount").'</th>';
Print '<th width="20%" align="center">'.$langs->trans("InterestAmount").'</th>';
Print '<th width="40%" align="center">'.$langs->trans("Remain");
Print '<th width="40%" align="center">'.$langs->trans("CapitalRemain");
print ' ('.price2num($object->capital).')';
print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">';
print '</th>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
*
* 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');

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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.="&amp;search_ref=".urlencode($search_ref);
if ($search_label) $param.="&amp;search_label=".urlencode($search_user);
if ($search_amount) $param.="&amp;search_amount=".urlencode($search_amount_ht);
if ($optioncss != '') $param.='&amp;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.="&amp;search_ref=".urlencode($search_ref);
if ($search_label) $param.="&amp;search_label=".urlencode($search_user);
if ($search_amount) $param.="&amp;search_amount=".urlencode($search_amount_ht);
if ($optioncss != '') $param.='&amp;optioncss='.urlencode($optioncss);
$newcardbutton='';
if ($user->rights->loan->write)
{
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/loan/card.php?action=create">'.$langs->trans('NewLoan');
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
}
$newcardbutton='';
if ($user->rights->loan->write)
{
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/loan/card.php?action=create">'.$langs->trans('NewLoan');
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit);
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// Filters lines
print '<tr class="liste_titre_filter">';
@ -144,6 +141,7 @@ if ($resql)
print '<td class="liste_titre"><input class="flat" size="12" type="text" name="search_label" value="'.$search_label.'"></td>';
print '<td class="liste_titre" align="right" ><input class="flat" size="8" type="text" name="search_amount" value="'.$search_amount.'"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre"></td>';
print '<td align="right" class="liste_titre">';
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
@ -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 "</tr>\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 '<tr class="oddeven">';
@ -182,23 +181,26 @@ if ($resql)
// Date start
print '<td width="110" align="center">'.dol_print_date($db->jdate($obj->datestart), 'day').'</td>';
// Date end
print '<td width="110" align="center">'.dol_print_date($db->jdate($obj->dateend), 'day').'</td>';
print '<td align="right" class="nowrap">'.$loan_static->LibStatut($obj->paid,5,$obj->alreadypayed).'</a></td>';
print '<td></td>';
print "</tr>\n";
print "</tr>\n";
$i++;
}
print "</table>";
print '</div>';
print "</form>\n";
$db->free($resql);
print "</table>";
print '</div>';
print "</form>\n";
$db->free($resql);
}
else
{
dol_print_error($db);
dol_print_error($db);
}
llxFooter();

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
*
* 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');

View File

@ -4,8 +4,8 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
*
* 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 .= '<br>' . $langs->trans('Project') . ' : ';
if ($user->rights->loan->write) {
//if ($action != 'classify')

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.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
@ -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 '<tr><td>'.$langs->trans('NotePublic').'</td><td>'.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 '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td>';
print $bankline->getNomUrl(1,0,'showall');
print '</td>';
print '</tr>';
}
print '</td>';
print '</tr>';
}
}
print '</table>';
@ -213,7 +210,7 @@ if ($resql)
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="right">'.$langs->trans('ExpectedToPay').'</td>';
print '<td align="center">'.$langs->trans('Status').'</td>';
print '<td align="right">'.$langs->trans('PayedByThisPayment').'</td>';
print "</tr>\n";
@ -233,11 +230,13 @@ if ($resql)
// Label
print '<td>'.$objp->label.'</td>';
// Expected to pay
print '<td align="right">'.price($objp->capital).'</td>';
// print '<td align="right">'.price($objp->capital).'</td>';
// Status
print '<td align="center">'.$loan->getLibStatut(4,$objp->amount_capital).'</td>';
// Amount payed
print '<td align="right">'.price($objp->amount_capital).'</td>';
$amount_payed = $objp->amount_capital + $objp->amount_insurance + $objp->amount_interest;
print '<td align="right">'.price($amount_payed).'</td>';
print "</tr>\n";
if ($objp->paid == 1) // If at least one invoice is paid, disable delete
{

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* 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');