27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
31 $langs->loadLangs(array(
"loan",
"compta",
"banks",
"bills"));
34 $socid =
GETPOST(
'socid',
'int');
36 $socid = $user->socid;
40 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
41 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
42 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
44 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
47 $offset = $limit * $page;
48 $pageprev = $page - 1;
49 $pagenext = $page + 1;
52 $loan_static =
new Loan($db);
56 $sortfield =
"l.rowid";
62 $search_ref =
GETPOST(
'search_ref',
'int');
63 $search_label =
GETPOST(
'search_label',
'alpha');
64 $search_amount =
GETPOST(
'search_amount',
'alpha');
66 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'loanlist';
67 $optioncss =
GETPOST(
'optioncss',
'alpha');
74 if (
GETPOST(
'cancel',
'alpha')) {
75 $action =
'list'; $massaction =
'';
77 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
81 $parameters = array();
82 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
87 if (empty($reshook)) {
89 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
105 $title = $langs->trans(
'Loans');
107 $sql =
"SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,";
108 $sql .=
" SUM(pl.amount_capital) as alreadypaid";
109 $sql .=
" FROM ".MAIN_DB_PREFIX.
"loan as l LEFT JOIN ".MAIN_DB_PREFIX.
"payment_loan AS pl";
110 $sql .=
" ON l.rowid = pl.fk_loan";
111 $sql .=
" WHERE l.entity = ".$conf->entity;
112 if ($search_amount) {
116 $sql .=
" AND l.rowid = ".((int) $search_ref);
121 $sql .=
" GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
122 $sql .= $db->order($sortfield, $sortorder);
125 $nbtotalofrecords =
'';
126 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
127 $resql = $db->query($sql);
128 $nbtotalofrecords = $db->num_rows(
$resql);
129 if (($page * $limit) > $nbtotalofrecords) {
136 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
137 $num = $nbtotalofrecords;
140 $sql .= $db->plimit($limit + 1, $offset);
143 $resql = $db->query($sql);
149 $num = $db->num_rows(
$resql);
161 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
162 $param .=
'&contextpage='.urlencode($contextpage);
164 if ($limit > 0 && $limit != $conf->liste_limit) {
165 $param .=
'&limit='.urlencode($limit);
168 $param .=
"&search_ref=".urlencode($search_ref);
171 $param .=
"&search_label=".urlencode($search_label);
173 if ($search_amount) {
174 $param .=
"&search_amount=".urlencode($search_amount);
176 if ($optioncss !=
'') {
177 $param .=
'&optioncss='.urlencode($optioncss);
180 $url = DOL_URL_ROOT.
'/loan/card.php?action=create';
181 if (!empty($socid)) {
182 $url .=
'&socid='.$socid;
184 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewLoan'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->loan->write);
186 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
187 if ($optioncss !=
'') {
188 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
190 print
'<input type="hidden" name="token" value="'.newToken().
'">';
191 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
192 print
'<input type="hidden" name="action" value="list">';
193 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
194 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
195 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
197 print_barre_liste($langs->trans(
"Loans"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'money-bill-alt', 0, $newcardbutton,
'', $limit, 0, 0, 1);
201 print
'<div class="div-table-responsive">';
202 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
205 print
'<tr class="liste_titre_filter">';
206 print
'<td class="liste_titre"><input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.
'"></td>';
207 print
'<td class="liste_titre"><input class="flat" size="12" type="text" name="search_label" value="'.$search_label.
'"></td>';
208 print
'<td class="liste_titre right" ><input class="flat" size="8" type="text" name="search_amount" value="'.$search_amount.
'"></td>';
209 print
'<td class="liste_titre"> </td>';
210 print
'<td class="liste_titre"> </td>';
211 print
'<td class="liste_titre"></td>';
212 print
'<td class="liste_titre maxwidthsearch">';
213 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
219 print
'<tr class="liste_titre">';
221 print_liste_field_titre(
"Label", $_SERVER[
"PHP_SELF"],
"l.label",
"", $param,
'', $sortfield, $sortorder,
'left ');
222 print_liste_field_titre(
"LoanCapital", $_SERVER[
"PHP_SELF"],
"l.capital",
"", $param,
'', $sortfield, $sortorder,
'right ');
223 print_liste_field_titre(
"DateStart", $_SERVER[
"PHP_SELF"],
"l.datestart",
"", $param,
'', $sortfield, $sortorder,
'center ');
224 print_liste_field_titre(
"DateEnd", $_SERVER[
"PHP_SELF"],
"l.dateend",
"", $param,
'', $sortfield, $sortorder,
'center ');
225 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"l.paid",
"", $param,
'', $sortfield, $sortorder,
'right ');
234 $totalarray = array();
235 while ($i < ($limit ? min($num, $limit) : $num)) {
236 $obj = $db->fetch_object(
$resql);
241 $loan_static->id = $obj->rowid;
242 $loan_static->ref = $obj->rowid;
243 $loan_static->label = $obj->label;
244 $loan_static->paid = $obj->paid;
246 print
'<tr class="oddeven">';
249 print
'<td>'.$loan_static->getNomUrl(1).
'</td>';
252 print
'<td>'.dol_trunc($obj->label, 42).
'</td>';
255 print
'<td class="right maxwidth100"><span class="amount">'.price($obj->capital).
'</span></td>';
258 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->datestart),
'day').
'</td>';
261 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->dateend),
'day').
'</td>';
263 print
'<td class="right nowrap">';
264 print $loan_static->LibStatut($obj->paid, 5, $obj->alreadypaid);
278 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
281 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
282 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
283 print $hookmanager->resPrint;
285 print
'</table>'.
"\n";
288 print
'</form>'.
"\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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.
dol_now($mode= 'auto')
Return date for now.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
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.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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...
restrictedArea($user, $features, $objectid=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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...