';
+ print '';
+ print '';
+ print '
';
/*
* Payments
@@ -477,14 +501,14 @@ if ($id > 0)
$total_insurance = 0;
$total_interest = 0;
$total_capital = 0;
- echo '
';
+ print '';
print '';
print ''.$langs->trans("RefPayment").' ';
print ''.$langs->trans("Date").' ';
print ''.$langs->trans("Type").' ';
- print ''.$langs->trans("Insurance").' ';
- print ''.$langs->trans("Interest").' ';
- print ''.$langs->trans("LoanCapital").' ';
+ print ''.$langs->trans("Insurance").' ';
+ print ''.$langs->trans("Interest").' ';
+ print ''.$langs->trans("LoanCapital").' ';
print ' ';
$var=True;
@@ -508,13 +532,13 @@ if ($id > 0)
if ($object->paid == 0)
{
- print ''.$langs->trans("AlreadyPaid").' : '.price($totalpaid, 0, $langs, 0, 0, -1, $conf->currency).' ';
- print ''.$langs->trans("AmountExpected").' : '.price($object->capital, 0, $langs, 0, 0, -1, $conf->currency).' ';
+ print ''.$langs->trans("AlreadyPaid").' : '.price($totalpaid, 0, $langs, 0, 0, -1, $conf->currency).' ';
+ print ''.$langs->trans("AmountExpected").' : '.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).' ';
$staytopay = $object->capital - $totalpaid;
print ''.$langs->trans("RemainderToPay").' : ';
- print ''.price($staytopay, 0, $langs, 0, 0, -1, $conf->currency).' ';
+ print ''.price($staytopay, 0, $langs, 0, 0, -1, $conf->currency).' ';
}
print "
";
$db->free($resql);
@@ -523,8 +547,25 @@ if ($id > 0)
{
dol_print_error($db);
}
- print "";
- print "
";
+
+ print '
';
+ print '
';
+ print '';
+
+ print '
';
+
+ dol_fiche_end();
+
+ if ($action == 'edit')
+ {
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
+ print '
';
+ }
+
+ if ($action == 'edit') print "\n";
/*
* Buttons actions
@@ -562,7 +603,7 @@ if ($id > 0)
}
else
{
- // Loan not find
+ // Loan not found
dol_print_error('',$object->error);
}
}
diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php
index 3c89f8b36b0..97d90cb31e7 100644
--- a/htdocs/loan/class/loan.class.php
+++ b/htdocs/loan/class/loan.class.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
@@ -32,6 +32,7 @@ class Loan extends CommonObject
public $element='loan';
public $table='loan';
public $table_element='loan';
+ public $picto = 'bill';
public $rowid;
public $datestart;
@@ -278,6 +279,7 @@ class Loan extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."loan";
$sql.= " SET label='".$this->db->escape($this->label)."',";
+ $sql.= " capital='".price2num($this->db->escape($this->capital))."',";
$sql.= " datestart='".$this->db->idate($this->datestart)."',";
$sql.= " dateend='".$this->db->idate($this->dateend)."',";
$sql.= " fk_user_modif = ".$user->id;
@@ -378,6 +380,12 @@ class Loan extends CommonObject
if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
+ if ($mode == 6)
+ {
+ if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
+ if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
+ if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
+ }
return "Error, mode/status not found";
}
diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php
index 732d8193638..9a245f17762 100644
--- a/htdocs/loan/document.php
+++ b/htdocs/loan/document.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2014-2016 Alexandre Spangaro
*
* 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
@@ -75,17 +75,33 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
$form = new Form($db);
-$help_url='EN:Module_Loan|FR:Module_Emprunt';
-llxHeader("",$langs->trans("Loan"),$help_url);
+$title = $langs->trans("Loan") . ' - ' . $langs->trans("Documents");
+$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
+llxHeader("",$title,$help_url);
if ($object->id)
{
- $alreadypayed=$object->getSumPayment();
+ $totalpaid=$object->getSumPayment();
$head = loan_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans("Loan"), 0, 'bill');
+ $morehtmlref='';
+ // Ref loan
+ $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
+ $morehtmlref.='
';
+
+ $linkback = '' . $langs->trans("BackToList") . ' ';
+
+ $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
+
+ dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
+
+ print '';
+ print '
';
+
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
@@ -97,63 +113,13 @@ if ($object->id)
print '
';
-
- // Ref
- print ''.$langs->trans("Ref").' ';
- print $form->showrefnav($object,'id');
- print " ";
-
- // Label
- if ($action == 'edit')
- {
- print ''.$langs->trans("Label").' ';
- print ' ';
- print ' ';
- }
- else
- {
- print ''.$langs->trans("Label").' '.$object->label.' ';
- }
-
- // Amount
- print ''.$langs->trans("LoanCapital").' '.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).' ';
-
- // Date start
- print "".$langs->trans("DateStart")." ";
- print "";
- if ($action == 'edit')
- {
- print $form->select_date($object->datestart, 'start', 0, 0, 0, 'loan', 1, 0, 1);
- }
- else
- {
- print dol_print_date($object->datestart,"day");
- }
- print " ";
- print " ";
-
- // Date end
- print "".$langs->trans("DateEnd")." ";
- print "";
- if ($action == 'edit')
- {
- print $form->select_date($object->dateend, 'end', 0, 0, 0, 'loan', 1, 0, 1);
- }
- else
- {
- print dol_print_date($object->dateend,"day");
- }
- print " ";
- print " ";
-
- // Status
- print ''.$langs->trans("Status").' '.$object->getLibStatut(4,$alreadypayed).' ';
-
- print ''.$langs->trans("NbOfAttachedFiles").' '.count($filearray).' ';
+ print ''.$langs->trans("NbOfAttachedFiles").' '.count($filearray).' ';
print ''.$langs->trans("TotalSizeOfAttachedFiles").' '.$totalsize.' '.$langs->trans("bytes").' ';
- print '
';
+ print "