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 34974d3ebd4..bf0fb5dcdbd 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/loan/card.php b/htdocs/loan/card.php index 6a62ffe09ea..89b8459ef7a 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 @@ -101,10 +102,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) @@ -135,7 +138,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 +183,7 @@ if ($action == 'create') print ''; print ''; - + // Label print ''; @@ -197,7 +200,7 @@ if ($action == 'create') print $langs->trans("NoBankAccountDefined"); print ''; } - + // Capital print ''; @@ -206,35 +209,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 +277,7 @@ if ($action == 'create') } print '
'.$langs->trans("LoanAccountancyCapitalCode").'
'; - + print '
    '; print '
'; @@ -322,7 +334,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,10 +363,10 @@ 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.' %'; @@ -446,7 +458,7 @@ if ($id > 0) } print ""; print ""; - + /* * Buttons actions */ @@ -490,4 +502,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..1cdc99633cd 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)."',"; @@ -484,4 +489,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..65379f6011d 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); @@ -167,7 +170,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 +201,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 +244,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 +265,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 +529,3 @@ class PaymentLoan extends CommonObject return $result; } } - - 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..c3dd2658051 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 @@ -107,7 +108,8 @@ if ($action == 'add_payment') $payment->amount_interest = $_POST["amount_interest"]; $payment->paymenttype = $_POST["paymenttype"]; $payment->num_payment = $_POST["num_payment"]; - $payment->note = $_POST["note"]; + $payment->note_private = GETPOST('note_private'); + $payment->note_public = GETPOST('public'); if (! $error) { @@ -236,10 +238,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 +302,7 @@ if ($_GET["action"] == 'create') { print '-'; } - print '
'; + print '
'; if ($sumpaid < $objp->capital) { $namea = "amount_insurance_".$objp->id; @@ -306,7 +312,7 @@ if ($_GET["action"] == 'create') { print '-'; } - print '
'; + print '
'; if ($sumpaid < $objp->capital) { $namei = "amount_interest_".$objp->id;