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');
35 if ($user->socid) $socid = $user->socid;
38 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
39 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
40 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
42 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) { $page = 0; }
43 $offset = $limit * $page;
44 $pageprev = $page - 1;
45 $pagenext = $page + 1;
48 $loan_static =
new Loan($db);
51 if (!$sortfield) $sortfield =
"l.rowid";
52 if (!$sortorder) $sortorder =
"DESC";
54 $search_ref =
GETPOST(
'search_ref',
'int');
55 $search_label =
GETPOST(
'search_label',
'alpha');
56 $search_amount =
GETPOST(
'search_amount',
'alpha');
58 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'loanlist';
59 $optioncss =
GETPOST(
'optioncss',
'alpha');
66 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
67 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
69 $parameters = array();
70 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
71 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
76 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
93 $title = $langs->trans(
'Loans');
95 $sql =
"SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,";
96 $sql .=
" SUM(pl.amount_capital) as alreadypaid";
97 $sql .=
" FROM ".MAIN_DB_PREFIX.
"loan as l LEFT JOIN ".MAIN_DB_PREFIX.
"payment_loan AS pl";
98 $sql .=
" ON l.rowid = pl.fk_loan";
99 $sql .=
" WHERE l.entity = ".$conf->entity;
100 if ($search_amount) $sql .=
natural_search(
"l.capital", $search_amount, 1);
101 if ($search_ref) $sql .=
" AND l.rowid = ".$db->escape($search_ref);
102 if ($search_label) $sql .=
natural_search(
"l.label", $search_label);
103 $sql .=
" GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
104 $sql .= $db->order($sortfield, $sortorder);
107 $nbtotalofrecords =
'';
108 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
110 $resql = $db->query($sql);
111 $nbtotalofrecords = $db->num_rows(
$resql);
112 if (($page * $limit) > $nbtotalofrecords)
120 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
122 $num = $nbtotalofrecords;
124 if ($limit) $sql .= $db->plimit($limit + 1, $offset);
126 $resql = $db->query($sql);
133 $num = $db->num_rows(
$resql);
146 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
147 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
148 if ($search_ref) $param .=
"&search_ref=".urlencode($search_ref);
149 if ($search_label) $param .=
"&search_label=".urlencode($search_label);
150 if ($search_amount) $param .=
"&search_amount=".urlencode($search_amount);
151 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
153 $url = DOL_URL_ROOT.
'/loan/card.php?action=create';
154 if (!empty($socid)) $url .=
'&socid='.$socid;
155 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewLoan'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->loan->write);
157 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
158 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
159 print '<input type="hidden" name="token" value="'.newToken().
'">';
160 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
161 print '<input type="hidden" name="action" value="list">';
162 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
163 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
164 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
166 print_barre_liste($langs->trans(
"Loans"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'money-bill-alt', 0, $newcardbutton,
'', $limit, 0, 0, 1);
170 print '<div class="div-table-responsive">';
171 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
174 print '<tr class="liste_titre_filter">';
175 print
'<td class="liste_titre"><input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.
'"></td>';
176 print
'<td class="liste_titre"><input class="flat" size="12" type="text" name="search_label" value="'.$search_label.
'"></td>';
177 print
'<td class="liste_titre right" ><input class="flat" size="8" type="text" name="search_amount" value="'.$search_amount.
'"></td>';
178 print
'<td class="liste_titre"> </td>';
179 print
'<td class="liste_titre"> </td>';
180 print
'<td class="liste_titre"></td>';
181 print
'<td class="liste_titre maxwidthsearch">';
182 $searchpicto = $form->showFilterAndCheckAddButtons(0);
188 print
'<tr class="liste_titre">';
190 print_liste_field_titre(
"Label", $_SERVER[
"PHP_SELF"],
"l.label",
"", $param,
'', $sortfield, $sortorder,
'left ');
191 print_liste_field_titre(
"LoanCapital", $_SERVER[
"PHP_SELF"],
"l.capital",
"", $param,
'', $sortfield, $sortorder,
'right ');
192 print_liste_field_titre(
"DateStart", $_SERVER[
"PHP_SELF"],
"l.datestart",
"", $param,
'', $sortfield, $sortorder,
'center ');
193 print_liste_field_titre(
"DateEnd", $_SERVER[
"PHP_SELF"],
"l.dateend",
"", $param,
'', $sortfield, $sortorder,
'center ');
194 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"l.paid",
"", $param,
'', $sortfield, $sortorder,
'right ');
203 $totalarray = array();
204 while ($i < ($limit ? min($num, $limit) : $num))
206 $obj = $db->fetch_object(
$resql);
207 if (empty($obj))
break;
209 $loan_static->id = $obj->rowid;
210 $loan_static->ref = $obj->rowid;
211 $loan_static->label = $obj->label;
212 $loan_static->paid = $obj->paid;
214 print
'<tr class="oddeven">';
217 print
'<td>'.$loan_static->getNomUrl(1).
'</td>';
220 print
'<td>'.dol_trunc($obj->label, 42).
'</td>';
223 print
'<td class="right maxwidth100">'.price($obj->capital).
'</td>';
226 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->datestart),
'day').
'</td>';
229 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->dateend),
'day').
'</td>';
231 print
'<td class="right nowrap">';
232 print $loan_static->LibStatut($obj->paid, 5, $obj->alreadypaid);
247 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
250 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
251 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
252 print $hookmanager->resPrint;
254 print
'</table>'.
"\n";
257 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.
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.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $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...