28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
32$langs->loadLangs(array(
"loan",
"compta",
"banks",
"bills"));
35$socid =
GETPOST(
'socid',
'int');
37 $socid = $user->socid;
41$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
42$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
43$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
44$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
45$massaction =
GETPOST(
'massaction',
'alpha');
46if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
49$offset = $limit * $page;
54$loan_static =
new Loan($db);
58 $sortfield =
"l.rowid";
64$search_ref =
GETPOST(
'search_ref',
'int');
65$search_label =
GETPOST(
'search_label',
'alpha');
66$search_amount =
GETPOST(
'search_amount',
'alpha');
68$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'loanlist';
69$optioncss =
GETPOST(
'optioncss',
'alpha');
70$mode =
GETPOST(
'mode',
'alpha');
77if (
GETPOST(
'cancel',
'alpha')) {
78 $action =
'list'; $massaction =
'';
80if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
85$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
92 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
108$title = $langs->trans(
'Loans');
110$sql =
"SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,";
111$sql .=
" SUM(pl.amount_capital) as alreadypaid";
115$sql .=
" FROM ".MAIN_DB_PREFIX.
"loan as l";
116$linktopl =
" LEFT JOIN ".MAIN_DB_PREFIX.
"payment_loan AS pl ON l.rowid = pl.fk_loan";
119$sql .=
" WHERE l.entity = ".$conf->entity;
124 $sql .=
" AND l.rowid = ".((int) $search_ref);
129$sql .=
" GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
132$nbtotalofrecords =
'';
135 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
136 $sqlforcount = preg_replace(
'/'.preg_quote($linktopl,
'/').
'/',
'', $sqlforcount);
137 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
138 $resql = $db->query($sqlforcount);
140 $objforcount = $db->fetch_object($resql);
141 $nbtotalofrecords = $objforcount->nbtotalofrecords;
146 if (($page * $limit) > $nbtotalofrecords) {
152$arrayfields = array();
155$sql .= $db->order($sortfield, $sortorder);
157 $sql .= $db->plimit($limit + 1, $offset);
160$resql = $db->query($sql);
166$num = $db->num_rows($resql);
178 $param .=
'&mode='.urlencode($mode);
180 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
181 $param .=
'&contextpage='.urlencode($contextpage);
183 if ($limit > 0 && $limit != $conf->liste_limit) {
184 $param .=
'&limit='.((int) $limit);
187 $param .=
"&search_ref=".urlencode($search_ref);
190 $param .=
"&search_label=".urlencode($search_label);
192 if ($search_amount) {
193 $param .=
"&search_amount=".urlencode($search_amount);
195 if ($optioncss !=
'') {
196 $param .=
'&optioncss='.urlencode($optioncss);
199 $url = DOL_URL_ROOT.
'/loan/card.php?action=create';
200 if (!empty($socid)) {
201 $url .=
'&socid='.$socid;
204 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss'=>
'reposition'));
205 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss'=>
'reposition'));
206 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewLoan'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->loan->write);
208 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
209 if ($optioncss !=
'') {
210 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
212 print
'<input type="hidden" name="token" value="'.newToken().
'">';
213 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
214 print
'<input type="hidden" name="action" value="list">';
215 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
216 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
217 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
218 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
221 print_barre_liste($langs->trans(
"Loans"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'money-bill-alt', 0, $newcardbutton,
'', $limit, 0, 0, 1);
225 print
'<div class="div-table-responsive">';
226 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
229 print
'<tr class="liste_titre_filter">';
231 print
'<td class="liste_titre maxwidthsearch">';
232 $searchpicto = $form->showFilterAndCheckAddButtons();
236 print
'<td class="liste_titre"><input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.
'"></td>';
237 print
'<td class="liste_titre"><input class="flat" size="12" type="text" name="search_label" value="'.$search_label.
'"></td>';
238 print
'<td class="liste_titre right" ><input class="flat" size="8" type="text" name="search_amount" value="'.$search_amount.
'"></td>';
239 print
'<td class="liste_titre"> </td>';
240 print
'<td class="liste_titre"> </td>';
241 print
'<td class="liste_titre"></td>';
243 print
'<td class="liste_titre maxwidthsearch">';
244 $searchpicto = $form->showFilterAndCheckAddButtons();
250 $totalarray = array();
251 $totalarray[
'nbfield'] = 0;
255 print
'<tr class="liste_titre">';
258 $totalarray[
'nbfield']++;
261 $totalarray[
'nbfield']++;
262 print_liste_field_titre(
"Label", $_SERVER[
"PHP_SELF"],
"l.label",
"", $param,
'', $sortfield, $sortorder,
'left ');
263 $totalarray[
'nbfield']++;
264 print_liste_field_titre(
"LoanCapital", $_SERVER[
"PHP_SELF"],
"l.capital",
"", $param,
'', $sortfield, $sortorder,
'right ');
265 $totalarray[
'nbfield']++;
266 print_liste_field_titre(
"DateStart", $_SERVER[
"PHP_SELF"],
"l.datestart",
"", $param,
'', $sortfield, $sortorder,
'center ');
267 $totalarray[
'nbfield']++;
268 print_liste_field_titre(
"DateEnd", $_SERVER[
"PHP_SELF"],
"l.dateend",
"", $param,
'', $sortfield, $sortorder,
'center ');
269 $totalarray[
'nbfield']++;
270 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"l.paid",
"", $param,
'', $sortfield, $sortorder,
'right ');
271 $totalarray[
'nbfield']++;
274 $totalarray[
'nbfield']++;
283 $savnbfield = $totalarray[
'nbfield'];
284 $totalarray = array();
285 $imaxinloop = ($limit ? min($num, $limit) : $num);
286 while ($i < $imaxinloop) {
287 $obj = $db->fetch_object($resql);
292 $loan_static->id = $obj->rowid;
293 $loan_static->ref = $obj->rowid;
294 $loan_static->label = $obj->label;
295 $loan_static->paid = $obj->paid;
298 if ($mode ==
'kanban') {
300 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
301 print
'<div class="box-flex-container kanban">';
304 $loan_static->datestart= $obj->datestart;
305 $loan_static->dateend = $obj->dateend;
306 $loan_static->capital = $obj->capital;
307 $loan_static->totalpaid = $obj->paid;
309 print $loan_static->getKanbanView(
'', array(
'selected' => in_array($loan_static->id, $arrayofselected)));
310 if ($i == ($imaxinloop - 1)) {
315 print
'<tr class="oddeven">';
323 print
'<td>'.$loan_static->getNomUrl(1).
'</td>';
326 print
'<td>'.dol_trunc($obj->label, 42).
'</td>';
329 print
'<td class="right maxwidth100"><span class="amount">'.price($obj->capital).
'</span></td>';
332 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->datestart),
'day').
'</td>';
335 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->dateend),
'day').
'</td>';
337 print
'<td class="right nowrap">';
338 print $loan_static->LibStatut($obj->paid, 5, $obj->alreadypaid);
355 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
358 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
359 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
360 print $hookmanager->resPrint;
362 print
'</table>'.
"\n";
365 print
'</form>'.
"\n";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.