28 require
'../main.inc.php';
29 require_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');
45 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
48 $offset = $limit * $page;
49 $pageprev = $page - 1;
50 $pagenext = $page + 1;
53 $loan_static =
new Loan($db);
57 $sortfield =
"l.rowid";
63 $search_ref =
GETPOST(
'search_ref',
'int');
64 $search_label =
GETPOST(
'search_label',
'alpha');
65 $search_amount =
GETPOST(
'search_amount',
'alpha');
67 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'loanlist';
68 $optioncss =
GETPOST(
'optioncss',
'alpha');
75 if (
GETPOST(
'cancel',
'alpha')) {
76 $action =
'list'; $massaction =
'';
78 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
82 $parameters = array();
83 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
88 if (empty($reshook)) {
90 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
106 $title = $langs->trans(
'Loans');
108 $sql =
"SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,";
109 $sql .=
" SUM(pl.amount_capital) as alreadypaid";
113 $sql .=
" FROM ".MAIN_DB_PREFIX.
"loan as l";
114 $linktopl =
" LEFT JOIN ".MAIN_DB_PREFIX.
"payment_loan AS pl ON l.rowid = pl.fk_loan";
117 $sql .=
" WHERE l.entity = ".$conf->entity;
118 if ($search_amount) {
122 $sql .=
" AND l.rowid = ".((int) $search_ref);
127 $sql .=
" GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
131 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
133 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
134 $sqlforcount = preg_replace(
'/'.preg_quote($linktopl,
'/').
'/',
'', $sqlforcount);
135 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
136 $resql = $db->query($sqlforcount);
138 $objforcount = $db->fetch_object(
$resql);
152 $sql .= $db->order($sortfield, $sortorder);
154 $sql .= $db->plimit($limit + 1, $offset);
157 $resql = $db->query($sql);
163 $num = $db->num_rows(
$resql);
174 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
175 $param .=
'&contextpage='.urlencode($contextpage);
177 if ($limit > 0 && $limit != $conf->liste_limit) {
178 $param .=
'&limit='.urlencode($limit);
181 $param .=
"&search_ref=".urlencode($search_ref);
184 $param .=
"&search_label=".urlencode($search_label);
186 if ($search_amount) {
187 $param .=
"&search_amount=".urlencode($search_amount);
189 if ($optioncss !=
'') {
190 $param .=
'&optioncss='.urlencode($optioncss);
193 $url = DOL_URL_ROOT.
'/loan/card.php?action=create';
194 if (!empty($socid)) {
195 $url .=
'&socid='.$socid;
197 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewLoan'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->loan->write);
199 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
200 if ($optioncss !=
'') {
201 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
203 print
'<input type="hidden" name="token" value="'.newToken().
'">';
204 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
205 print
'<input type="hidden" name="action" value="list">';
206 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
207 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
208 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
210 print_barre_liste($langs->trans(
"Loans"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'money-bill-alt', 0, $newcardbutton,
'', $limit, 0, 0, 1);
214 print
'<div class="div-table-responsive">';
215 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
218 print
'<tr class="liste_titre_filter">';
219 print
'<td class="liste_titre"><input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.
'"></td>';
220 print
'<td class="liste_titre"><input class="flat" size="12" type="text" name="search_label" value="'.$search_label.
'"></td>';
221 print
'<td class="liste_titre right" ><input class="flat" size="8" type="text" name="search_amount" value="'.$search_amount.
'"></td>';
222 print
'<td class="liste_titre"> </td>';
223 print
'<td class="liste_titre"> </td>';
224 print
'<td class="liste_titre"></td>';
225 print
'<td class="liste_titre maxwidthsearch">';
226 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
232 print
'<tr class="liste_titre">';
234 print_liste_field_titre(
"Label", $_SERVER[
"PHP_SELF"],
"l.label",
"", $param,
'', $sortfield, $sortorder,
'left ');
235 print_liste_field_titre(
"LoanCapital", $_SERVER[
"PHP_SELF"],
"l.capital",
"", $param,
'', $sortfield, $sortorder,
'right ');
236 print_liste_field_titre(
"DateStart", $_SERVER[
"PHP_SELF"],
"l.datestart",
"", $param,
'', $sortfield, $sortorder,
'center ');
237 print_liste_field_titre(
"DateEnd", $_SERVER[
"PHP_SELF"],
"l.dateend",
"", $param,
'', $sortfield, $sortorder,
'center ');
238 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"l.paid",
"", $param,
'', $sortfield, $sortorder,
'right ');
247 $totalarray = array();
248 while ($i < ($limit ? min($num, $limit) : $num)) {
249 $obj = $db->fetch_object(
$resql);
254 $loan_static->id = $obj->rowid;
255 $loan_static->ref = $obj->rowid;
256 $loan_static->label = $obj->label;
257 $loan_static->paid = $obj->paid;
259 print
'<tr class="oddeven">';
262 print
'<td>'.$loan_static->getNomUrl(1).
'</td>';
265 print
'<td>'.dol_trunc($obj->label, 42).
'</td>';
268 print
'<td class="right maxwidth100"><span class="amount">'.price($obj->capital).
'</span></td>';
271 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->datestart),
'day').
'</td>';
274 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->dateend),
'day').
'</td>';
276 print
'<td class="right nowrap">';
277 print $loan_static->LibStatut($obj->paid, 5, $obj->alreadypaid);
291 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
294 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
295 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
296 print $hookmanager->resPrint;
298 print
'</table>'.
"\n";
301 print
'</form>'.
"\n";
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_now($mode='auto')
Return date for now.
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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
$nbtotalofrecords
Count total nb of records.
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.