diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a872a4593ba..e3a97fe358e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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). + +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 +### 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). diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index 323516bbbd6..be04beb1d9a 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -1,5 +1,6 @@ + * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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].= ' '.$nbNote.''; + $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; } \ No newline at end of file diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 69aec814413..8654c866969 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -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 + } } } } diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 128f0659c83..9475719732d 100644 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -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 diff --git a/htdocs/install/mysql/tables/llx_loan.sql b/htdocs/install/mysql/tables/llx_loan.sql index bc152099a04..21e9e09d8b7 100644 --- a/htdocs/install/mysql/tables/llx_loan.sql +++ b/htdocs/install/mysql/tables/llx_loan.sql @@ -1,5 +1,6 @@ -- ======================================================================== -- Copyright (C) 2014 Alexandre Spangaro +-- Copyright (C) 2015 Frederic France -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -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; \ No newline at end of file +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_payment_loan.sql b/htdocs/install/mysql/tables/llx_payment_loan.sql index 0fb6b566ca5..4a0ba519c78 100644 --- a/htdocs/install/mysql/tables/llx_payment_loan.sql +++ b/htdocs/install/mysql/tables/llx_payment_loan.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2014 Alexandre Spangaro +-- Copyright (C) 2015 Frederic France -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -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 diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index 4922c0fc0a1..4aba2de625c 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -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=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. +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 down payment = The price of the home multiplied by the percentage down divided by 100 (for 5% down becomes 5/100 or 0.05) +InterestRateDesc=The interest rate = The annual interest percentage divided by 100 +MonthlyFactorDesc=The monthly factor = The result of the following formula +MonthlyInterestRateDesc=The monthly interest rate = The annual interest rate divided by 12 (for the 12 months in a year) +MonthTermDesc=The month term of the loan in months = The number of years you've taken the loan out for times 12 +MonthlyPaymentDesc=The montly payment is figured out using the following formula +AmortizationPaymentDesc=The amortization breaks down how much of your monthly payment goes towards the bank's interest, and how much goes into paying off the principal of your loan. +AmountFinanced=Amount Financed +AmortizationMonthlyPaymentOverYears=Amortization For Monthly Payment: %s over %s years Totalsforyear=Totals for year MonthlyPayment=Monthly Payment LoanCalcDesc=This mortgage calculator can be used to figure out monthly payments of a 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.
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.
+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 diff --git a/htdocs/loan/calc.php b/htdocs/loan/calc.php index 0a5ee21923a..bb6fe9451b6 100644 --- a/htdocs/loan/calc.php +++ b/htdocs/loan/calc.php @@ -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 '
'; @@ -131,33 +132,33 @@ print ''; //print ''; //print ''; print ''; -print ''; +print ''; print ''; print ''; -print ''; +print ''; print '';print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; if (! empty($show_progress)) { - print ''; + print ''; } else { - print ''; + print ''; } print ''; @@ -173,18 +174,18 @@ if ($form_complete && $monthly_payment) print '
'; print '
Purchase & Financing Information'.$langs->trans('PurchaseFinanceInfo').'
Sale Price of Home:'.$langs->trans('SalePriceOfAsset').': '.$langs->trans("Currency".$conf->currency).'
Percentage Down:'.$langs->trans('PercentageDown').':%
Length of Mortgage:'.$langs->trans('LengthOfMortgage').':years
Annual Interest Rate:'.$langs->trans('AnnualInterestRate').':%
Explain Calculations:'.$langs->trans('ExplainCalculations').':Show me the calculations and amortization'.$langs->trans('ShowMeCalculationsAndAmortization').'Show me the calculations and amortization'.$langs->trans('ShowMeCalculationsAndAmortization').'
'; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -203,7 +204,7 @@ if ($form_complete && $monthly_payment) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -243,7 +244,7 @@ if ($form_complete && $monthly_payment) print '
Mortgage Payment Information'.$langs->trans('MortgagePaymentInformation').'
Down Payment:'.$langs->trans('DownPayment').':' . number_format($down_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
Amount Financed:'.$langs->trans('AmountFinanced').':' . number_format($financing_price, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
Monthly Payment:'.$langs->trans('MonthlyPayment').':' . number_format($monthly_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
(Principal & Interest ONLY)
Monthly Payment:'.$langs->trans('MonthlyPayment').':' . number_format(($monthly_payment + $pmi_per_month), "2", ".", ",") . $langs->trans("Currency".$conf->currency) . '
'; print '(Principal & Interest, and PMI)
'; print '
'; -// 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 ''; print ''. $step++ .''; print ''; - echo 'The down payment - = The price of the home multiplied by the percentage down divided by 100 (for 5% down becomes 5/100 or 0.05)

- ' . 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').'

'; + 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 ''; print ''; print ''; print '' . $step++ . ''; print ''; - print 'The interest rate = The annual interest percentage divided by 100

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

'; print $annual_interest_rate . ' = ' . $annual_interest_percent . '% / 100'; print ''; print ''; print ''; print ''; - print 'The monthly factor = The result of the following formula:'; + print $langs->trans('MonthlyFactorDesc') . ':'; print ''; print ''; print ''; print '' . $step++ . ''; print ''; - print 'The monthly interest rate = The annual interest rate divided by 12 (for the 12 months in a year)

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

'; print $monthly_interest_rate . ' = ' . $annual_interest_rate . ' / 12'; print ''; print ''; print ''; print '' . $step++ . ''; print ''; - print 'The month term of the loan in months = The number of years you\'ve taken the loan out for times 12

'; - print $month_term . ' Months = ' . $year_term . ' Years X 12'; + print $langs->trans('MonthTermDesc') . '

'; + print $month_term . ' '. $langs->trans('Months') . ' = ' . $year_term . ' '. $langs->trans('Years') . ' X 12'; print ''; print ''; print ''; print '' . $step++ . ''; print ''; - print 'The montly payment is figured out using the following formula:
'; - print 'Monthly Payment = ' . number_format($financing_price, "2", "", "") . ' * '; + print $langs->trans('MonthlyPaymentDesc') . ':
'; print $langs->trans('MonthlyPayment').' = ' . number_format($financing_price, "2", "", "") . ' * '; print '(1 - ((1 + ' . number_format($monthly_interest_rate, "4", "", "") . ')'; print '-(' . $month_term . '))))'; print '

'; - print 'The amortization 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 ''; print ''; print ''; @@ -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 "

Amortization For Monthly Payment: " . number_format($monthly_payment, "2", ".", ",") . " over " . $year_term . " years
\n"; + print '

'.$langs->trans('AmortizationMonthlyPaymentOverYears', number_format($monthly_payment, "2", ".", ","), $year_term)."
\n"; print ''; @@ -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 ""; print ''; @@ -357,9 +355,9 @@ if ($form_complete && $show_progress) { print ''; print ''; print ''; print ''; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 6a62ffe09ea..8e280b2da75 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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 ''; print '
' . $current_month . '
 '; - print 'You will spend ' . number_format($total_spent_this_year, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . ' on your house in year ' . $current_year . '
'; - print number_format($this_year_interest_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . ' will go towards INTEREST
'; - print number_format($this_year_principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . ' will go towards PRINCIPAL
'; + print $langs->trans('YouWillSpend', number_format($total_spent_this_year, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency), $current_year) . '
'; + print $langs->trans('GoToInterest', number_format($this_year_interest_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency)) . '
'; + print $langs->trans('GoToPrincipal', number_format($this_year_principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency)) . '
'; print '
'; - + // Label print ''; @@ -197,7 +209,7 @@ if ($action == 'create') print $langs->trans("NoBankAccountDefined"); print ''; } - + // Capital print ''; @@ -206,35 +218,44 @@ if ($action == 'create') print ''; - + // Date End print ""; print ''; - + // Number of terms print ''; - + // Rate print ''; - // Note + // Note Private print ''; - print ''; + print ''; print ''; + + // Note Public + print ''; + print ''; + print ''; + print '
'.$langs->trans("Label").'
'.$langs->trans("Capital").'
'.$langs->trans("DateStart").''; print $form->select_date($datestart?$datestart:-1,'start','','','','add',1,1); print '
'.$langs->trans("DateEnd").''; print $form->select_date($dateend?$dateend:-1,'end','','','','add',1,1); print '
'.$langs->trans("Nbterms").'
'.$langs->trans("Rate").' %
'.$langs->trans('Note').''.$langs->trans('NotePrivate').''; - $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 '
'.$langs->trans('NotePublic').''; + $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, 100); + print $doleditor->Create(1); + print '
'; - + print '
'; // Accountancy print ''; - + if ($conf->accounting->enabled) { print ''; @@ -265,7 +286,7 @@ if ($action == 'create') } print '
'.$langs->trans("LoanAccountancyCapitalCode").'
'; - + print '
    '; print '
'; @@ -322,7 +343,7 @@ if ($id > 0) { print ''.$langs->trans("Label").''.$object->label.''; } - + // Capital print ''.$langs->trans("Capital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).''; @@ -351,13 +372,19 @@ if ($id > 0) print dol_print_date($object->dateend,"day"); } print ""; - + // Nbterms print ''.$langs->trans("Nbterms").''.$object->nbterm.''; - + // Rate print ''.$langs->trans("Rate").''.$object->rate.' %'; + // Note Private + print ''.$langs->trans('NotePrivate').''.nl2br($object->note_private).''; + + // Note Public + print ''.$langs->trans('NotePublic').''.nl2br($object->note_public).''; + // Status print ''.$langs->trans("Status").''.$object->getLibStatut(4, $totalpaye).''; @@ -446,7 +473,7 @@ if ($id > 0) } print ""; print ""; - + /* * Buttons actions */ @@ -457,25 +484,25 @@ if ($id > 0) // Edit if ($user->rights->loan->write) { - print "id&action=edit\">".$langs->trans("Modify").""; + print ''.$langs->trans("Modify").''; } // Emit payment if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) { - print "id&action=create\">".$langs->trans("DoPayment").""; + print ''.$langs->trans("DoPayment").''; } // Classify 'paid' if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) { - print "id&action=paid\">".$langs->trans("ClassifyPaid").""; + print ''.$langs->trans("ClassifyPaid").''; } // Delete if ($user->rights->loan->delete) { - print "id&action=delete\">".$langs->trans("Delete").""; + print ''.$langs->trans("Delete").''; } print ""; @@ -490,4 +517,4 @@ if ($id > 0) llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 9ab8a690494..cf58bb1d2c4 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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 = ''; - $linkend=''; + $tooltip = '' . $langs->trans("ShowLoan") . ''; + if (! empty($this->ref)) + $tooltip .= '
' . $langs->trans('Ref') . ': ' . $this->ref; + if (! empty($this->label)) + $tooltip .= '
' . $langs->trans('Label') . ': ' . $this->label; + $link = ''; + $linkend = ''; - 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; } } -} \ No newline at end of file +} diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index bb94a86d945..41b64bcd865 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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; } } - - diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index 082e5d0d0c2..557d1fa5e00 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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 ""; // Ref - print ''.img_object($langs->trans("ShowLoan"),"label").' '.$obj->rowid.''; + print ''.$loan_static->getLinkUrl(1, 42).''; // Label print ''.dol_trunc($obj->label,42).''; @@ -150,4 +154,4 @@ else } llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php new file mode 100644 index 00000000000..a87cd3870d8 --- /dev/null +++ b/htdocs/loan/note.php @@ -0,0 +1,99 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \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 '
'; + print ''; + + print ''; + + // Ref + print ''; + print ''; + // Name + print ''; + print ''; + + print "
'.$langs->trans('Ref').''; + print $form->showrefnav($object,'id','','','rowid','ref'); + print '
'.$langs->trans("Name").''.$object->label.'
"; + + print '
'; + + $colwidth='25'; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + + dol_fiche_end(); +} + +llxFooter(); +$db->close(); + diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index f75a2244154..eb048ce15a6 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -167,8 +167,11 @@ print ''.$langs->trans('Capital').''.p print ''.$langs->trans('Insurance').''.price($payment->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency).''; print ''.$langs->trans('Interest').''.price($payment->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency).''; -// Note -print ''.$langs->trans('Note').''.nl2br($payment->note).''; +// Note Private +print ''.$langs->trans('NotePrivate').''.nl2br($payment->note_private).''; + +// Note Public +print ''.$langs->trans('NotePublic').''.nl2br($payment->note_public).''; // Bank account if (! empty($conf->banque->enabled)) diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 9a087d60633..52921bc6b18 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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 "
\n"; - if ($mesg) - { - print "
$mesg
"; - } - print ''; print ''; print ''; @@ -236,10 +233,14 @@ if ($_GET["action"] == 'create') print ''."\n"; print ''; - print ''.$langs->trans("Comments").''; - print ''; + print ''.$langs->trans("NotePrivate").''; + print ''; print ''; + print ''; + print ''.$langs->trans("NotePublic").''; + print ''; + print ''; print ''; print '
'; @@ -296,7 +297,7 @@ if ($_GET["action"] == 'create') { print '-'; } - print '
'; + print '
'; if ($sumpaid < $objp->capital) { $namea = "amount_insurance_".$objp->id; @@ -306,7 +307,7 @@ if ($_GET["action"] == 'create') { print '-'; } - print '
'; + print '
'; if ($sumpaid < $objp->capital) { $namei = "amount_interest_".$objp->id;