Note private and Note public for loan

This commit is contained in:
frederic34 2015-03-27 17:13:52 +01:00
parent f6df1d6380
commit 82b8fe6b7d
8 changed files with 91 additions and 54 deletions

View File

@ -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

View File

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

View File

@ -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

View File

@ -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
@ -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 '<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 +200,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 +209,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 +277,7 @@ if ($action == 'create')
}
print '</table>';
print '<br><center><input class="button" type="submit" value="'.$langs->trans("Save").'"> &nbsp; &nbsp; ';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
@ -322,7 +334,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,10 +363,10 @@ 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>';
@ -446,7 +458,7 @@ if ($id > 0)
}
print "</td></tr>";
print "</table>";
/*
* Buttons actions
*/
@ -490,4 +502,4 @@ if ($id > 0)
llxFooter();
$db->close();
$db->close();

View File

@ -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)."',";
@ -484,4 +489,4 @@ class Loan extends CommonObject
return -1;
}
}
}
}

View File

@ -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);
@ -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;
}
}

View File

@ -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))

View File

@ -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
@ -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 '<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 +302,7 @@ if ($_GET["action"] == 'create')
{
print '-';
}
print '<br>';
print '<br>';
if ($sumpaid < $objp->capital)
{
$namea = "amount_insurance_".$objp->id;
@ -306,7 +312,7 @@ if ($_GET["action"] == 'create')
{
print '-';
}
print '<br>';
print '<br>';
if ($sumpaid < $objp->capital)
{
$namei = "amount_interest_".$objp->id;