Merge remote-tracking branch 'Upstream/develop' into develop-ReviewAssoc
This commit is contained in:
commit
a92f68a5ed
@ -3,28 +3,30 @@ How to contribute to Dolibarr
|
||||
|
||||
Bug reports and feature requests
|
||||
--------------------------------
|
||||
Issues are tracked at [Doliforge](https://doliforge.org/projects/dolibarr)
|
||||
** NEW **
|
||||
|
||||
*You need to create an account before being able to use the "Bugs & Tasks" feature.*
|
||||
Issues are now managed on [GitHub](https://github.com/Dolibarr/dolibarr/Issues).
|
||||
|
||||
1. Use the search engine to check if nobody's already reported your problem.
|
||||
2. Choose the right section. (Bugs or Task and Feature Request).
|
||||
3. Report with as much detail as possible (Use screenshots or even screencasts whenever possible).
|
||||
1. Please [use the search engine](https://help.github.com/articles/searching-issues) to check if nobody's already reported your problem.
|
||||
2. [Create an issue](https://help.github.com/articles/creating-an-issue). Choose an appropriate title. Prepend appropriately with Bug or Feature Request.
|
||||
3. Report with as much detail as possible ([Use screenshots or even screencasts whenever possible](https://help.github.com/articles/issue-attachments)).
|
||||
|
||||
Code
|
||||
----
|
||||
We're still figuring out how to migrate old issues to GitHub. In the meantime, they are still available at [Doliforge](https://doliforge.org/projects/dolibarr).
|
||||
|
||||
<a name=code></a>Code
|
||||
---------------------
|
||||
|
||||
### Basic workflow
|
||||
|
||||
1. Fork the [GitHub repository](https://github.com/Dolibarr/dolibarr).
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo) the [GitHub repository](https://github.com/Dolibarr/dolibarr).
|
||||
2. Clone your fork.
|
||||
3. Choose a branch(See the Branches section below).
|
||||
3. Choose a branch(See the [Branches](#branches) section below).
|
||||
4. Commit and push your changes.
|
||||
5. Make a pull request.
|
||||
5. [Make a pull request](https://help.github.com/articles/creating-a-pull-request).
|
||||
|
||||
### Branches
|
||||
### <a name=branches></a>Branches
|
||||
|
||||
Unless you're fixing a bug, all pull request should be made against the *develop* branch.
|
||||
Unless you're fixing a bug, all pull requests should be made against the *develop* branch.
|
||||
|
||||
If you're fixing a bug, it is preferred that you cook your fix and pull request it
|
||||
against the oldest version affected that's still supported.
|
||||
@ -69,7 +71,7 @@ Where KEYWORD is one of:
|
||||
|
||||
Translations
|
||||
------------
|
||||
en_US and delta languages (i.e: fr_XX) are maintained in the repository. See Code section above.
|
||||
The source language (en_US) is maintained in the repository. See the [Code](#code) section above.
|
||||
|
||||
All other translations are managed online at [Transifex](https://www.transifex.com/projects/p/dolibarr).
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@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
|
||||
@ -32,35 +33,45 @@ function loan_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$tab = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Card');
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
$head[$tab][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id;
|
||||
$head[$tab][1] = $langs->trans('Card');
|
||||
$head[$tab][2] = 'card';
|
||||
$tab++;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
|
||||
$head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id;
|
||||
$head[$tab][1] = $langs->trans("Notes");
|
||||
if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
$head[$tab][2] = 'note';
|
||||
$tab++;
|
||||
}
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'loan');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $tab,'loan');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
$head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id;
|
||||
$head[$tab][1] = $langs->trans("Documents");
|
||||
if($nbFiles > 0) $head[$tab][1].= ' ('.$nbFiles.')';
|
||||
$head[$tab][2] = 'documents';
|
||||
$tab++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
$head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id;
|
||||
$head[$tab][1] = $langs->trans("Info");
|
||||
$head[$tab][2] = 'info';
|
||||
$tab++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'loan','remove');
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$tab,'loan','remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@ -111,15 +111,22 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=
|
||||
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
|
||||
}
|
||||
|
||||
if ($passok && ! empty($conf->multicompany->enabled)) // We must check entity
|
||||
// We must check entity
|
||||
if ($passok)
|
||||
{
|
||||
global $mc;
|
||||
|
||||
$ret=$mc->checkRight($obj->rowid, $entitytotest);
|
||||
if ($ret < 0)
|
||||
{
|
||||
dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '".$entitytotest."' not allowed for user '".$obj->rowid."'");
|
||||
$login=''; // force authentication failure
|
||||
if (!isset($mc)) {
|
||||
//Global not available, disable $conf->multicompany->enabled for safety
|
||||
$conf->multicompany->enabled = false;
|
||||
}
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$ret = $mc->checkRight($obj->rowid, $entitytotest);
|
||||
if ($ret < 0) {
|
||||
dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'");
|
||||
$login = ''; // force authentication failure
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,8 @@ create table llx_loan
|
||||
dateend date,
|
||||
nbterm real,
|
||||
rate double NOT NULL,
|
||||
note text,
|
||||
note_private text,
|
||||
note_public text,
|
||||
capital_position real default 0,
|
||||
date_position date,
|
||||
paid smallint default 0 NOT NULL,
|
||||
@ -56,7 +57,8 @@ create table llx_payment_loan
|
||||
amount_interest real DEFAULT 0,
|
||||
fk_typepayment integer NOT NULL,
|
||||
num_payment varchar(50),
|
||||
note text,
|
||||
note_private text,
|
||||
note_public text,
|
||||
fk_bank integer NOT NULL,
|
||||
fk_user_creat integer,
|
||||
fk_user_modif integer
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ========================================================================
|
||||
-- Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@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
|
||||
@ -32,7 +33,8 @@ create table llx_loan
|
||||
nbterm real,
|
||||
rate double NOT NULL,
|
||||
|
||||
note text,
|
||||
note_private text,
|
||||
note_public text,
|
||||
|
||||
capital_position real default 0, -- If not a new loan, just have the position of capital
|
||||
date_position date,
|
||||
@ -46,4 +48,4 @@ create table llx_loan
|
||||
fk_user_author integer DEFAULT NULL,
|
||||
fk_user_modif integer DEFAULT NULL,
|
||||
active tinyint DEFAULT 1 NOT NULL
|
||||
)ENGINE=innodb;
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@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
|
||||
@ -28,7 +29,8 @@ create table llx_payment_loan
|
||||
amount_interest real DEFAULT 0,
|
||||
fk_typepayment integer NOT NULL,
|
||||
num_payment varchar(50),
|
||||
note text,
|
||||
note_private text,
|
||||
note_public text,
|
||||
fk_bank integer NOT NULL,
|
||||
fk_user_creat integer, -- creation user
|
||||
fk_user_modif integer -- last modification user
|
||||
|
||||
@ -13,14 +13,38 @@ LoanAccountancyInsuranceCode=Accountancy code insurance
|
||||
LoanAccountancyInterestCode=Accountancy code interest
|
||||
LoanPayment=Loan payment
|
||||
ConfirmDeleteLoan=Confirm deleting this loan
|
||||
ConfirmPayLoan=Confirm classify paid this loan
|
||||
ErrorLoanCapital=<font color=red>Loan amount</font> has to be numeric and greater than zero.
|
||||
ErrorLoanLength=<font color=red>Loan length</font> has to be numeric and greater than zero.
|
||||
ErrorLoanInterest=<font color=red>Annual interest</font> has to be numeric and greater than zero.
|
||||
LoanDeleted=Loan Deleted Successfully
|
||||
ConfirmPayLoan=Confirm classify paid this loan
|
||||
LoanPaid=Loan Paid
|
||||
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.
|
||||
# Calc
|
||||
LoanCalc=Bank Loans Calculator
|
||||
PurchaseFinanceInfo=Purchase & Financing Information
|
||||
SalePriceOfAsset=Sale Price of Asset
|
||||
PercentageDown=Percentage Down
|
||||
LengthOfMortgage=Length of Mortgage
|
||||
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 home mortgage loan, based on the home's sale price, the term of the loan desired, buyer's down payment percentage, and the loan's interest rate.<br> This calculator factors in 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 on your house in year %s
|
||||
# Admin
|
||||
ConfigLoan=Configuration of the module loan
|
||||
LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default
|
||||
|
||||
@ -56,13 +56,13 @@ if (isset($_REQUEST['form_complete'])) {
|
||||
$show_progress = (isset($_REQUEST['show_progress'])) ? $_REQUEST['show_progress'] : false;
|
||||
$form_complete = $_REQUEST['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;
|
||||
@ -71,7 +71,7 @@ function get_interest_factor($year_term, $monthly_interest_rate) {
|
||||
$denominator *= $base_rate;
|
||||
}
|
||||
return $factor;
|
||||
}
|
||||
}
|
||||
|
||||
// If the form is complete, we'll start the math
|
||||
if ($form_complete) {
|
||||
@ -109,18 +109,19 @@ if ($form_complete) {
|
||||
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_fiche_titre($langs->trans("LoanCalc"));
|
||||
print $langs->trans('LoanCalcDesc');
|
||||
|
||||
print '<form method="GET" name="information" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
@ -131,33 +132,33 @@ print '<table cellpadding="2" cellspacing="0" border="0" width="100%">';
|
||||
//print '<td align="smalltext" width="100%"><img src="/images/clear.gif" width="250" height="1" border="0" alt=""></td>';
|
||||
//print '</tr>';
|
||||
print '<tr bgcolor="#cccccc">';
|
||||
print '<td align="center" colspan="2"><b>Purchase & Financing Information</b></td>';
|
||||
print '<td align="center" colspan="2"><b>'.$langs->trans('PurchaseFinanceInfo').'</b></td>';
|
||||
print '</tr>';
|
||||
print '<tr bgcolor="#eeeeee">';
|
||||
print '<td align="right">Sale Price of Home:</td>';
|
||||
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 bgcolor="#eeeeee">';
|
||||
print '<td align="right">Percentage Down:</td>';
|
||||
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 bgcolor="#eeeeee">';
|
||||
print '<td align="right">Length of Mortgage:</td>';
|
||||
print '<td align="right">'.$langs->trans('LengthOfMortgage').':</td>';
|
||||
print '<td><input type="text" size="3" name="year_term" value="'.$year_term.'">years</td>';
|
||||
print '</tr>';
|
||||
print '<tr bgcolor="#eeeeee">';
|
||||
print '<td align="right">Annual Interest Rate:</td>';
|
||||
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 bgcolor="#eeeeee">';
|
||||
print '<td align="right">Explain Calculations:</td>';
|
||||
print '<td align="right">'.$langs->trans('ExplainCalculations').':</td>';
|
||||
|
||||
if (! empty($show_progress))
|
||||
{
|
||||
print '<td><input type="checkbox" name="show_progress" value="1" checked>Show me the calculations and amortization</td>';
|
||||
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">Show me the calculations and amortization</td>';
|
||||
print '<td><input type="checkbox" name="show_progress" value="1">'.$langs->trans('ShowMeCalculationsAndAmortization').'</td>';
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
@ -173,18 +174,18 @@ 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>Mortgage Payment Information</b></font></td>';
|
||||
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">Down Payment:</td>';
|
||||
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">Amount Financed:</td>';
|
||||
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">Monthly Payment:</td>';
|
||||
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 & Interest ONLY)</font></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -203,7 +204,7 @@ if ($form_complete && $monthly_payment)
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '<tr valign="top" bgcolor="#FFFF99">';
|
||||
print '<td align="right">Monthly Payment:</td>';
|
||||
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 & Interest, and PMI)</td>';
|
||||
print '</tr>';
|
||||
@ -243,7 +244,7 @@ if ($form_complete && $monthly_payment)
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
// This prints the calculation progress and
|
||||
// This prints the calculation progress and
|
||||
// the instructions of HOW everything is figured
|
||||
// out
|
||||
if ($form_complete && $show_progress) {
|
||||
@ -254,49 +255,46 @@ if ($form_complete && $show_progress) {
|
||||
print '<tr valign="top">';
|
||||
print '<td><b>'. $step++ .'</b></td>';
|
||||
print '<td>';
|
||||
echo '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)<br><br>
|
||||
' . number_format($down_payment,"2",".",",") . ' ' . $langs->trans("Currency".$conf->currency) . ' = '.number_format($sale_price,"2",".",",") . ' ' . $langs->trans("Currency".$conf->currency) . ' X
|
||||
('.$down_percent.' / 100)';
|
||||
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 'The <b>interest rate</b> = The annual interest percentage divided by 100<br><br>';
|
||||
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 'The <b>monthly factor</b> = The result of the following formula:';
|
||||
print $langs->trans('MonthlyFactorDesc') . ':';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '<tr valign="top">';
|
||||
print '<td><b>' . $step++ . '</b></td>';
|
||||
print '<td>';
|
||||
print 'The <b>monthly interest rate</b> = The annual interest rate divided by 12 (for the 12 months in a year)<br><br>';
|
||||
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 'The <b>month term</b> of the loan in months = The number of years you\'ve taken the loan out for times 12<br><br>';
|
||||
print $month_term . ' Months = ' . $year_term . ' Years X 12';
|
||||
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 'The montly payment is figured out using the following formula:<br>';
|
||||
print 'Monthly Payment = ' . number_format($financing_price, "2", "", "") . ' * ';
|
||||
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 'The <a href="#amortization">amortization</a> breaks down how much of your monthly payment goes towards the bank\'s interest,';
|
||||
print 'and how much goes into paying off the principal of your loan.';
|
||||
print $langs->trans('AmortizationPaymentDesc');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
@ -313,7 +311,7 @@ if ($form_complete && $show_progress) {
|
||||
$denom = pow((1 + $monthly_interest_rate), $power);
|
||||
$monthly_payment = $principal * ($monthly_interest_rate / (1 - $denom));
|
||||
|
||||
print "<br><br><a name=\"amortization\"></a>Amortization For Monthly Payment: <b>" . number_format($monthly_payment, "2", ".", ",") . "</b> over " . $year_term . " years<br>\n";
|
||||
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%">';
|
||||
|
||||
@ -327,17 +325,17 @@ if ($form_complete && $show_progress) {
|
||||
|
||||
print $legend;
|
||||
|
||||
// Loop through and get the current month's payments for
|
||||
// the length of the loan
|
||||
// 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 ".$bc[$var].">";
|
||||
print '<td align="right">' . $current_month . '</td>';
|
||||
@ -357,9 +355,9 @@ if ($form_complete && $show_progress) {
|
||||
print '<tr>';
|
||||
print '<td> </td>';
|
||||
print '<td colspan="3">';
|
||||
print 'You will spend ' . number_format($total_spent_this_year, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . ' on your house in year ' . $current_year . '<br>';
|
||||
print number_format($this_year_interest_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . ' will go towards INTEREST<br>';
|
||||
print number_format($this_year_principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . ' will go towards PRINCIPAL<br>';
|
||||
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>';
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@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
|
||||
@ -51,6 +52,14 @@ if ($action == 'confirm_paid' && $confirm == 'yes')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->set_paid($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessage($langs->trans('LoanPaid'));
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($loan->error, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Delete loan
|
||||
@ -60,6 +69,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes')
|
||||
$result=$object->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessage($langs->trans('LoanDeleted'));
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
@ -101,10 +111,12 @@ if ($action == 'add' && $user->rights->loan->write)
|
||||
$object->dateend = $dateend;
|
||||
$object->nbterm = $_POST["nbterm"];
|
||||
$object->rate = $_POST["rate"];
|
||||
|
||||
$object->note_private = GETPOST('note_private');
|
||||
$object->note_public = GETPOST('note_public');
|
||||
|
||||
$object->account_capital = $_POST["accountancy_account_capital"];
|
||||
$object->account_insurance = $_POST["accountancy_account_insurance"];
|
||||
$object->account_interest = $_POST["accountancy_account_interest"];
|
||||
$object->account_interest = $_POST["accountancy_account_interest"];
|
||||
|
||||
$id=$object->create($user);
|
||||
if ($id <= 0)
|
||||
@ -126,7 +138,7 @@ else if ($action == 'update' && $user->rights->loan->write)
|
||||
if (! $cancel)
|
||||
{
|
||||
$result = $object->fetch($id);
|
||||
|
||||
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$object->label = GETPOST("label");
|
||||
@ -135,7 +147,7 @@ else if ($action == 'update' && $user->rights->loan->write)
|
||||
$object->nbterm = GETPOST("nbterm");
|
||||
$object->rate = GETPOST("rate");
|
||||
}
|
||||
|
||||
|
||||
$result = $object->update($user);
|
||||
|
||||
if ($result > 0)
|
||||
@ -180,7 +192,7 @@ if ($action == 'create')
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
|
||||
// Label
|
||||
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("Label").'</td><td colspan="3"><input name="label" size="40" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'"></td></tr>';
|
||||
|
||||
@ -197,7 +209,7 @@ if ($action == 'create')
|
||||
print $langs->trans("NoBankAccountDefined");
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Capital
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Capital").'</td><td><input name="capital" size="10" value="' . GETPOST("capital") . '"></td></tr>';
|
||||
|
||||
@ -206,35 +218,44 @@ if ($action == 'create')
|
||||
print '<td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
|
||||
print $form->select_date($datestart?$datestart:-1,'start','','','','add',1,1);
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Date End
|
||||
print "<tr>";
|
||||
print '<td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
|
||||
print $form->select_date($dateend?$dateend:-1,'end','','','','add',1,1);
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Number of terms
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Nbterms").'</td><td><input name="nbterm" size="5" value="' . GETPOST('nbterm') . '"></td></tr>';
|
||||
|
||||
|
||||
// Rate
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Rate").'</td><td><input name="rate" size="5" value="' . GETPOST("rate") . '"> %</td></tr>';
|
||||
|
||||
// Note
|
||||
// Note Private
|
||||
print '<tr>';
|
||||
print '<td class="border" valign="top">'.$langs->trans('Note').'</td>';
|
||||
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
|
||||
print '<td valign="top" colspan="2">';
|
||||
|
||||
$doleditor = new DolEditor('note', GETPOST('note', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, 100);
|
||||
$doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, 100);
|
||||
print $doleditor->Create(1);
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// Note Public
|
||||
print '<tr>';
|
||||
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
|
||||
print '<td valign="top" colspan="2">';
|
||||
$doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, 100);
|
||||
print $doleditor->Create(1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Accountancy
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
|
||||
if ($conf->accounting->enabled)
|
||||
{
|
||||
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
|
||||
@ -265,7 +286,7 @@ if ($action == 'create')
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '<br><center><input class="button" type="submit" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
||||
|
||||
@ -322,7 +343,7 @@ if ($id > 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->label.'</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Capital
|
||||
print '<tr><td>'.$langs->trans("Capital").'</td><td>'.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
@ -351,13 +372,19 @@ if ($id > 0)
|
||||
print dol_print_date($object->dateend,"day");
|
||||
}
|
||||
print "</td></tr>";
|
||||
|
||||
|
||||
// Nbterms
|
||||
print '<tr><td>'.$langs->trans("Nbterms").'</td><td>'.$object->nbterm.'</td></tr>';
|
||||
|
||||
|
||||
// Rate
|
||||
print '<tr><td>'.$langs->trans("Rate").'</td><td>'.$object->rate.' %</td></tr>';
|
||||
|
||||
// Note Private
|
||||
print '<tr><td>'.$langs->trans('NotePrivate').'</td><td>'.nl2br($object->note_private).'</td></tr>';
|
||||
|
||||
// Note Public
|
||||
print '<tr><td>'.$langs->trans('NotePublic').'</td><td>'.nl2br($object->note_public).'</td></tr>';
|
||||
|
||||
// Status
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>';
|
||||
|
||||
@ -446,7 +473,7 @@ if ($id > 0)
|
||||
}
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
|
||||
/*
|
||||
* Buttons actions
|
||||
*/
|
||||
@ -457,25 +484,25 @@ if ($id > 0)
|
||||
// Edit
|
||||
if ($user->rights->loan->write)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/loan/card.php?id=$object->id&action=edit\">".$langs->trans("Modify")."</a>";
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>';
|
||||
}
|
||||
|
||||
// Emit payment
|
||||
if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/loan/payment/payment.php?id=$object->id&action=create\">".$langs->trans("DoPayment")."</a>";
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans("DoPayment").'</a>';
|
||||
}
|
||||
|
||||
// Classify 'paid'
|
||||
if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/loan/card.php?id=$object->id&action=paid\">".$langs->trans("ClassifyPaid")."</a>";
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=paid">'.$langs->trans("ClassifyPaid").'</a>';
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($user->rights->loan->delete)
|
||||
{
|
||||
print "<a class=\"butActionDelete\" href=\"".DOL_URL_ROOT."/loan/card.php?id=$object->id&action=delete\">".$langs->trans("Delete")."</a>";
|
||||
print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
@ -490,4 +517,4 @@ if ($id > 0)
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
$db->close();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@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
|
||||
@ -41,7 +42,8 @@ class Loan extends CommonObject
|
||||
var $capital;
|
||||
var $nbterm;
|
||||
var $rate;
|
||||
var $note;
|
||||
var $note_private;
|
||||
var $note_public;
|
||||
var $paid;
|
||||
var $account_capital;
|
||||
var $account_insurance;
|
||||
@ -73,7 +75,7 @@ class Loan extends CommonObject
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
$sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note,";
|
||||
$sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public,";
|
||||
$sql.= " l.paid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."loan as l";
|
||||
$sql.= " WHERE l.rowid = ".$id;
|
||||
@ -93,9 +95,10 @@ class Loan extends CommonObject
|
||||
$this->label = $obj->label;
|
||||
$this->capital = $obj->capital;
|
||||
$this->nbterm = $obj->nbterm;
|
||||
$this->rate = $obj->rate;
|
||||
$this->note = $obj->note;
|
||||
$this->paid = $obj->paid;
|
||||
$this->rate = $obj->rate;
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->paid = $obj->paid;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -129,7 +132,8 @@ class Loan extends CommonObject
|
||||
|
||||
// clean parameters
|
||||
$newcapital=price2num($this->capital,'MT');
|
||||
if (isset($this->note)) $this->note = trim($this->note);
|
||||
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
|
||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
||||
if (isset($this->account_capital)) $this->account_capital = trim($this->account_capital);
|
||||
if (isset($this->account_insurance)) $this->account_insurance = trim($this->account_insurance);
|
||||
if (isset($this->account_interest)) $this->account_interest = trim($this->account_interest);
|
||||
@ -151,7 +155,7 @@ class Loan extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public";
|
||||
$sql.= " ,accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity";
|
||||
$sql.= " ,datec, fk_user_author)";
|
||||
$sql.= " VALUES ('".$this->db->escape($this->label)."',";
|
||||
@ -161,7 +165,8 @@ class Loan extends CommonObject
|
||||
$sql.= " '".$this->db->idate($this->dateend)."',";
|
||||
$sql.= " '".$this->db->escape($this->nbterm)."',";
|
||||
$sql.= " '".$this->db->escape($this->rate)."',";
|
||||
$sql.= " '".$this->db->escape($this->note)."',";
|
||||
$sql.= " '".$this->db->escape($this->note_private)."',";
|
||||
$sql.= " '".$this->db->escape($this->note_public)."',";
|
||||
$sql.= " '".$this->db->escape($this->account_capital)."',";
|
||||
$sql.= " '".$this->db->escape($this->account_insurance)."',";
|
||||
$sql.= " '".$this->db->escape($this->account_interest)."',";
|
||||
@ -390,12 +395,18 @@ class Loan extends CommonObject
|
||||
|
||||
$result='';
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$this->id.'">';
|
||||
$linkend='</a>';
|
||||
$tooltip = '<u>' . $langs->trans("ShowLoan") . '</u>';
|
||||
if (! empty($this->ref))
|
||||
$tooltip .= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||
if (! empty($this->label))
|
||||
$tooltip .= '<br><b>' . $langs->trans('Label') . ':</b> ' . $this->label;
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$this->id.'"';
|
||||
$linkclose = '" title="'.str_replace('\n', '', dol_escape_htmltag($tooltip, 1)).'" class="classfortooltip">';
|
||||
$linkend = '</a>';
|
||||
|
||||
if ($withpicto) $result.=($link.img_object($langs->trans("ShowLoan").': '.$this->label,'bill').$linkend.' ');
|
||||
if ($withpicto) $result.=($link.$linkclose.img_object($langs->trans("ShowLoan").': '.$this->label,'bill', 'class="classfortooltip"').$linkend.' ');
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend;
|
||||
if ($withpicto != 2) $result.=$link.$linkclose.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -484,4 +495,4 @@ class Loan extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@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
|
||||
@ -45,7 +46,8 @@ class PaymentLoan extends CommonObject
|
||||
var $amount_interest;
|
||||
var $fk_typepayment;
|
||||
var $num_payment;
|
||||
var $note;
|
||||
var $note_private;
|
||||
var $note_public;
|
||||
var $fk_bank;
|
||||
var $fk_user_creat;
|
||||
var $fk_user_modif;
|
||||
@ -89,7 +91,8 @@ class PaymentLoan extends CommonObject
|
||||
if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest);
|
||||
if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment);
|
||||
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
|
||||
if (isset($this->note)) $this->note = trim($this->note);
|
||||
if (isset($this->note_private)) $this->note = trim($this->note_private);
|
||||
if (isset($this->note_public)) $this->note = trim($this->note_public);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank);
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = trim($this->fk_user_creat);
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = trim($this->fk_user_modif);
|
||||
@ -112,11 +115,11 @@ class PaymentLoan extends CommonObject
|
||||
if ($totalamount != 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_loan (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,";
|
||||
$sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)";
|
||||
$sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',";
|
||||
$sql.= " fk_typepayment, num_payment, note_private, note_public, fk_user_creat, fk_bank)";
|
||||
$sql.= " VALUES (".$this->chid.", '".$this->db->idate($now)."',";
|
||||
$sql.= " '".$this->db->idate($this->datepaid)."',";
|
||||
$sql.= " ".$totalamount.",";
|
||||
$sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.",";
|
||||
$sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_private)."', '".$this->db->escape($this->note_public)."', ".$user->id.",";
|
||||
$sql.= " 0)";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
@ -127,6 +130,7 @@ class PaymentLoan extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -167,7 +171,8 @@ class PaymentLoan extends CommonObject
|
||||
$sql.= " t.amount_interest,";
|
||||
$sql.= " t.fk_typepayment,";
|
||||
$sql.= " t.num_payment,";
|
||||
$sql.= " t.note,";
|
||||
$sql.= " t.note_private,";
|
||||
$sql.= " t.note_public,";
|
||||
$sql.= " t.fk_bank,";
|
||||
$sql.= " t.fk_user_creat,";
|
||||
$sql.= " t.fk_user_modif,";
|
||||
@ -197,7 +202,8 @@ class PaymentLoan extends CommonObject
|
||||
$this->amount_interest = $obj->amount_interest;
|
||||
$this->fk_typepayment = $obj->fk_typepayment;
|
||||
$this->num_payment = $obj->num_payment;
|
||||
$this->note = $obj->note;
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->fk_bank = $obj->fk_bank;
|
||||
$this->fk_user_creat = $obj->fk_user_creat;
|
||||
$this->fk_user_modif = $obj->fk_user_modif;
|
||||
@ -239,7 +245,8 @@ class PaymentLoan extends CommonObject
|
||||
if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest);
|
||||
if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment);
|
||||
if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment);
|
||||
if (isset($this->note)) $this->note=trim($this->note);
|
||||
if (isset($this->note_private)) $this->note=trim($this->note_private);
|
||||
if (isset($this->note_public)) $this->note=trim($this->note_public);
|
||||
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
|
||||
@ -259,7 +266,8 @@ class PaymentLoan extends CommonObject
|
||||
$sql.= " amount_interest=".(isset($this->amount_interest)?$this->amount_interest:"null").",";
|
||||
$sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").",";
|
||||
$sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").",";
|
||||
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
|
||||
$sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").",";
|
||||
$sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").",";
|
||||
$sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").",";
|
||||
$sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").",";
|
||||
$sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null")."";
|
||||
@ -522,5 +530,3 @@ class PaymentLoan extends CommonObject
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@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
|
||||
@ -30,7 +31,7 @@ $langs->load("banks");
|
||||
$langs->load("bills");
|
||||
|
||||
// Security check
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
$socid = GETPOST('socid', int);
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'loan', '', '', '');
|
||||
|
||||
@ -117,12 +118,15 @@ 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;
|
||||
|
||||
$var = !$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
|
||||
// Ref
|
||||
print '<td><a href="card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowLoan"),"label").' '.$obj->rowid.'</a></td>';
|
||||
print '<td>'.$loan_static->getLinkUrl(1, 42).'</td>';
|
||||
|
||||
// Label
|
||||
print '<td>'.dol_trunc($obj->label,42).'</td>';
|
||||
@ -150,4 +154,4 @@ else
|
||||
}
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
$db->close();
|
||||
|
||||
99
htdocs/loan/note.php
Normal file
99
htdocs/loan/note.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* 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>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/loan/note.php
|
||||
* \brief Tab for notes on loan
|
||||
* \ingroup loan
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once(DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php');
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
|
||||
|
||||
$action = GETPOST('action');
|
||||
|
||||
$langs->load('loan');
|
||||
|
||||
// Security check
|
||||
$id = GETPOST('id','int');
|
||||
$result = restrictedArea($user, 'loan', $id, '&loan');
|
||||
|
||||
$object = new Loan($db);
|
||||
if ($id > 0) $object->fetch($id);
|
||||
|
||||
$permissionnote=$user->rights->loan->read; // Used by the include of actions_setnotes.inc.php
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader('',$langs->trans("LoanArea").' - '.$langs->trans("Notes"),'');
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
|
||||
$head = loan_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'note', $langs->trans("Loan"),0,'loan');
|
||||
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans('Ref').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->showrefnav($object,'id','','','rowid','ref');
|
||||
print '</td></tr>';
|
||||
// Name
|
||||
print '<tr><td width="20%">'.$langs->trans("Name").'</td>';
|
||||
print '<td colspan="3">'.$object->label.'</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br>';
|
||||
|
||||
$colwidth='25';
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -167,8 +167,11 @@ print '<tr><td valign="top">'.$langs->trans('Capital').'</td><td colspan="3">'.p
|
||||
print '<tr><td valign="top">'.$langs->trans('Insurance').'</td><td colspan="3">'.price($payment->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans('Interest').'</td><td colspan="3">'.price($payment->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
|
||||
// Note
|
||||
print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($payment->note).'</td></tr>';
|
||||
// Note Private
|
||||
print '<tr><td valign="top">'.$langs->trans('NotePrivate').'</td><td colspan="3">'.nl2br($payment->note_private).'</td></tr>';
|
||||
|
||||
// Note Public
|
||||
print '<tr><td valign="top">'.$langs->trans('NotePublic').'</td><td colspan="3">'.nl2br($payment->note_public).'</td></tr>';
|
||||
|
||||
// Bank account
|
||||
if (! empty($conf->banque->enabled))
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@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
|
||||
@ -55,21 +56,21 @@ if ($action == 'add_payment')
|
||||
exit;
|
||||
}
|
||||
|
||||
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
$datepaid = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||
|
||||
if (! $_POST["paymenttype"] > 0)
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")), 'errors');
|
||||
$error++;
|
||||
}
|
||||
if ($datepaid == '')
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date"));
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")), 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0)
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit"));
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit")), 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -89,8 +90,8 @@ if ($action == 'add_payment')
|
||||
|
||||
if (count($amounts) <= 0)
|
||||
{
|
||||
setEventMessage($langs->trans('ErrorNoPaymentDefined'), 'errors');
|
||||
$error++;
|
||||
$errmsg='ErrorNoPaymentDefined';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
@ -102,29 +103,30 @@ if ($action == 'add_payment')
|
||||
$payment->chid = $chid;
|
||||
$payment->datepaid = $datepaid;
|
||||
$payment->amounts = $amounts; // Tableau de montant
|
||||
$payment->amount_capital = $_POST["amount_capital"];
|
||||
$payment->amount_insurance = $_POST["amount_insurance"];
|
||||
$payment->amount_interest = $_POST["amount_interest"];
|
||||
$payment->paymenttype = $_POST["paymenttype"];
|
||||
$payment->num_payment = $_POST["num_payment"];
|
||||
$payment->note = $_POST["note"];
|
||||
$payment->amount_capital = GETPOST('amount_capital');
|
||||
$payment->amount_insurance = GETPOST('amount_insurance');
|
||||
$payment->amount_interest = GETPOST('amount_interest');
|
||||
$payment->paymenttype = GETPOST('paymenttype');
|
||||
$payment->num_payment = GETPOST('num_payment');
|
||||
$payment->note_private = GETPOST('note_private');
|
||||
$payment->note_public = GETPOST('note_public');
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$paymentid = $payment->create($user);
|
||||
if ($paymentid < 0)
|
||||
{
|
||||
$errmsg=$payment->error;
|
||||
setEventMessage($payment->error, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result=$payment->addPaymentToBank($user,'payment_loan','(LoanPayment)',$_POST['accountid'],'','');
|
||||
$result=$payment->addPaymentToBank($user, 'payment_loan', '(LoanPayment)', GETPOST('accountid', 'int'), '', '');
|
||||
if (! $result > 0)
|
||||
{
|
||||
$errmsg=$payment->error;
|
||||
setEventMessage($payment->error, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -168,11 +170,6 @@ if ($_GET["action"] == 'create')
|
||||
print_fiche_titre($langs->trans("DoPayment"));
|
||||
print "<br>\n";
|
||||
|
||||
if ($mesg)
|
||||
{
|
||||
print "<div class=\"error\">$mesg</div>";
|
||||
}
|
||||
|
||||
print '<form name="add_payment" action="'.$_SERVER['PHP_SELF'].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$chid.'">';
|
||||
@ -236,10 +233,14 @@ if ($_GET["action"] == 'create')
|
||||
print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment').'"></td></tr>'."\n";
|
||||
|
||||
print '<tr>';
|
||||
print '<td valign="top">'.$langs->trans("Comments").'</td>';
|
||||
print '<td valign="top" colspan="2"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '<td valign="top">'.$langs->trans("NotePrivate").'</td>';
|
||||
print '<td valign="top" colspan="2"><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td valign="top">'.$langs->trans("NotePublic").'</td>';
|
||||
print '<td valign="top" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
@ -296,7 +297,7 @@ if ($_GET["action"] == 'create')
|
||||
{
|
||||
print '-';
|
||||
}
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
if ($sumpaid < $objp->capital)
|
||||
{
|
||||
$namea = "amount_insurance_".$objp->id;
|
||||
@ -306,7 +307,7 @@ if ($_GET["action"] == 'create')
|
||||
{
|
||||
print '-';
|
||||
}
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
if ($sumpaid < $objp->capital)
|
||||
{
|
||||
$namei = "amount_interest_".$objp->id;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user