diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php
index 497de98fa72..66fab1b9279 100644
--- a/htdocs/compta/deplacement/list.php
+++ b/htdocs/compta/deplacement/list.php
@@ -80,7 +80,7 @@ $childids[]=$user->id;
llxHeader();
-$sql = "SELECT s.nom, s.rowid as socid,"; // Ou
+$sql = "SELECT s.nom, d.fk_user, s.rowid as socid,"; // Ou
$sql.= " d.rowid, d.type, d.dated as dd, d.km,"; // Comment
$sql.= " d.fk_statut,";
$sql.= " u.lastname, u.firstname"; // Qui
@@ -91,7 +91,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_
$sql.= " WHERE d.fk_user = u.rowid";
$sql.= " AND d.entity = ".$conf->entity;
if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')';
-if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id;
+if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND (sc.fk_user = " .$user->id." OR d.fk_soc IS NULL) ";
if ($socid) $sql.= " AND s.rowid = ".$socid;
if ($search_ref) $sql.=" AND d.rowid=".$search_ref;
@@ -188,7 +188,7 @@ if ($resql)
print '
'.dol_print_date($db->jdate($obj->dd),'day').' | ';
// User
print '';
- $userstatic->id = $obj->rowid;
+ $userstatic->id = $obj->fk_user;
$userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname;
print $userstatic->getNomUrl(1);
diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php
index 9dbb2a9664b..fa80fe31a2b 100644
--- a/htdocs/core/lib/loan.lib.php
+++ b/htdocs/core/lib/loan.lib.php
@@ -41,15 +41,15 @@ function loan_prepare_head($object)
$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++;
- }
+ 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
diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php
index 116de7c561d..31de81d8b9b 100644
--- a/htdocs/loan/card.php
+++ b/htdocs/loan/card.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2014-2016 Alexandre Spangaro
* Copyright (C) 2015 Frederic France
*
* This program is free software; you can redistribute it and/or modify
@@ -26,6 +26,8 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
$langs->load("compta");
$langs->load("bills");
@@ -104,19 +106,23 @@ if ($action == 'add' && $user->rights->loan->write)
}
else
{
- $object->label = $_POST["label"];
- $object->fk_bank = $_POST["accountid"];
- $object->capital = $_POST["capital"];
- $object->datestart = $datestart;
- $object->dateend = $dateend;
- $object->nbterm = $_POST["nbterm"];
- $object->rate = $_POST["rate"];
- $object->note_private = GETPOST('note_private');
- $object->note_public = GETPOST('note_public');
+ $object->label = $_POST["label"];
+ $object->fk_bank = $_POST["accountid"];
+ $object->capital = $_POST["capital"];
+ $object->datestart = $datestart;
+ $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"];
+ $accountancy_account_capital = GETPOST('accountancy_account_capital');
+ $accountancy_account_insurance = GETPOST('accountancy_account_insurance');
+ $accountancy_account_interest = GETPOST('accountancy_account_interest');
+
+ if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; }
+ if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; }
+ if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; }
$id=$object->create($user);
if ($id <= 0)
@@ -172,6 +178,7 @@ else if ($action == 'update' && $user->rights->loan->write)
*/
$form = new Form($db);
+if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
$help_url='EN:Module_Loan|FR:Module_Emprunt';
llxHeader("",$langs->trans("Loan"),$help_url);
@@ -253,27 +260,50 @@ if ($action == 'create')
print '';
+ print ' ';
+
+ print '';
// Accountancy
- if ($conf->accounting->enabled)
+ if (! empty($conf->accounting->enabled))
{
- print ' ';
-
- print '';
-
+ // Accountancy_account_capital
+ print '| '.$langs->trans("LoanAccountancyCapitalCode").' | ';
+ print '';
+ print $formaccountancy->select_account($object->accountancy_account_capital, 'accountancy_account_capital', 1, '', 0, 1);
+ print ' | ';
+
+ // Accountancy_account_insurance
+ print '| '.$langs->trans("LoanAccountancyInsuranceCode").' | ';
+ print '';
+ print $formaccountancy->select_account($object->accountancy_account_insurance, 'accountancy_account_insurance', 1, '', 0, 1);
+ print ' | ';
+
+ // Accountancy_account_interest
+ print '| '.$langs->trans("LoanAccountancyInterestCode").' | ';
+ print '';
+ print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1);
+ print ' | ';
+ }
+ else // For external software
+ {
+ // Accountancy_account_capital
print '| '.$langs->trans("LoanAccountancyCapitalCode").' | ';
print '';
print ' | ';
-
+
+ // Accountancy_account_insurance
print '| '.$langs->trans("LoanAccountancyInsuranceCode").' | ';
print '';
print ' | ';
-
+
+ // Accountancy_account_interest
print '| '.$langs->trans("LoanAccountancyInterestCode").' | ';
print '';
print ' | ';
print ' ';
}
+ print ' ';
dol_fiche_end();
@@ -375,6 +405,39 @@ if ($id > 0)
// Note Public
print '| '.$langs->trans('NotePublic').' | '.nl2br($object->note_public).' | ';
+ // Accountancy account capital
+ print '| ';
+ print $langs->trans("LoanAccountancyCapitalCode");
+ print ' | ';
+ if (! empty($conf->accounting->enabled)) {
+ print length_accountg($object->account_capital);
+ } else {
+ print $object->account_capital;
+ }
+ print ' | ';
+
+ // Accountancy account insurance
+ print '| ';
+ print $langs->trans("LoanAccountancyInsuranceCode");
+ print ' | ';
+ if (! empty($conf->accounting->enabled)) {
+ print length_accountg($object->account_insurance);
+ } else {
+ print $object->account_insurance;
+ }
+ print ' | ';
+
+ // Accountancy account interest
+ print '| ';
+ print $langs->trans("LoanAccountancyInterestCode");
+ print ' | ';
+ if (! empty($conf->accounting->enabled)) {
+ print length_accountg($object->account_interest);
+ } else {
+ print $object->account_interest;
+ }
+ print ' | ';
+
// Status
print '| '.$langs->trans("Status").' | '.$object->getLibStatut(4, $totalpaye).' | ';
@@ -444,13 +507,11 @@ if ($id > 0)
print ''.price($objp->amount_interest, 0, $langs, 0, 0, -1, $conf->currency)." | \n";
print ''.price($objp->amount_capital, 0, $langs, 0, 0, -1, $conf->currency)." | \n";
print "";
- $total_insurance += $objp->amount_insurance;
- $total_interest += $objp->amount_interest;
$total_capital += $objp->amount_capital;
$i++;
}
- $totalpaid = $total_insurance + $total_interest + $total_capital;
+ $totalpaid = $total_capital;
if ($object->paid == 0)
{
diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php
index 66809b60720..60d4050148a 100644
--- a/htdocs/loan/class/loan.class.php
+++ b/htdocs/loan/class/loan.class.php
@@ -72,7 +72,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_private, l.note_public,";
- $sql.= " l.paid";
+ $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest";
$sql.= " FROM ".MAIN_DB_PREFIX."loan as l";
$sql.= " WHERE l.rowid = ".$id;
@@ -84,17 +84,22 @@ class Loan extends CommonObject
{
$obj = $this->db->fetch_object($resql);
- $this->id = $obj->rowid;
- $this->ref = $obj->rowid;
- $this->datestart = $this->db->jdate($obj->datestart);
- $this->dateend = $this->db->jdate($obj->dateend);
- $this->label = $obj->label;
- $this->capital = $obj->capital;
- $this->nbterm = $obj->nbterm;
- $this->rate = $obj->rate;
- $this->note_private = $obj->note_private;
- $this->note_public = $obj->note_public;
- $this->paid = $obj->paid;
+ $this->id = $obj->rowid;
+ $this->ref = $obj->rowid;
+ $this->datestart = $this->db->jdate($obj->datestart);
+ $this->dateend = $this->db->jdate($obj->dateend);
+ $this->label = $obj->label;
+ $this->capital = $obj->capital;
+ $this->nbterm = $obj->nbterm;
+ $this->rate = $obj->rate;
+ $this->note_private = $obj->note_private;
+ $this->note_public = $obj->note_public;
+ $this->paid = $obj->paid;
+
+ $this->account_capital = $obj->accountancy_account_capital;
+ $this->account_insurance = $obj->accountancy_account_insurance;
+ $this->account_interest = $obj->accountancy_account_interest;
+
return 1;
}
diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php
index e1aa6139678..abf4e9470c1 100644
--- a/htdocs/loan/index.php
+++ b/htdocs/loan/index.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2014 Alexandre Spangaro
* Copyright (C) 2015 Frederic France
* Copyright (C) 2015 Juanjo Menent
- * Copyright (C) 2016 Laurent Destailleur
+ * Copyright (C) 2016 Laurent Destailleur
*
* 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
diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php
index 969d5ecb436..155dacf460b 100644
--- a/htdocs/loan/note.php
+++ b/htdocs/loan/note.php
@@ -56,7 +56,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include,
$form = new Form($db);
-llxHeader('',$langs->trans("LoanArea"),'');
+llxHeader('',$langs->trans("Loan"),'');
if ($id > 0)
{
diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php
index 06061da5c22..e735480e414 100644
--- a/htdocs/loan/payment/payment.php
+++ b/htdocs/loan/payment/payment.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2014-2016 Alexandre Spangaro
* Copyright (C) 2015 Frederic France
*
* This program is free software; you can redistribute it and/or modify
@@ -138,7 +138,7 @@ if ($action == 'add_payment')
}
}
- $_GET["action"]='create';
+ $action = 'create';
}
@@ -152,12 +152,11 @@ $form=new Form($db);
// Form to create loan's payment
-if ($_GET["action"] == 'create')
+if ($action == 'create')
{
$total = $loan->capital;
print load_fiche_titre($langs->trans("DoPayment"));
- print " \n";
print '\n";
}
|