28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
32 $langs->loadLangs(array(
"banks",
"bills",
"compta",
"loan"));
35 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
36 $massaction =
GETPOST(
'massaction',
'alpha');
38 $confirm =
GETPOST(
'confirm',
'alpha');
39 $cancel =
GETPOST(
'cancel',
'alpha');
40 $toselect =
GETPOST(
'toselect',
'array');
41 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
42 $backtopage =
GETPOST(
'backtopage',
'alpha');
43 $optioncss =
GETPOST(
'optioncss',
'aZ');
47 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
48 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
50 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
54 $offset = $limit * $page;
55 $pageprev = $page - 1;
56 $pagenext = $page + 1;
61 $diroutputmassaction = $conf->loan->dir_output.
'/temp/massgeneration/'.$user->id;
62 $hookmanager->initHooks(array($contextpage));
65 $extrafields->fetch_name_optionals_label(
$object->table_element);
68 $search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
72 $sortfield =
"l.rowid";
79 $arrayfields = array();
80 foreach (
$object->fields as $key => $val) {
82 if (!empty($val[
'visible'])) {
83 $visible = (int)
dol_eval($val[
'visible'], 1);
84 $arrayfields[
't.'.$key] = array(
85 'label'=>$val[
'label'],
86 'checked'=>(($visible < 0) ? 0 : 1),
87 'enabled'=>(abs($visible) != 3 && (
int)
dol_eval($val[
'enabled'], 1)),
88 'position'=>$val[
'position'],
89 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
94 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
100 $search_ref =
GETPOST(
'search_ref',
'alpha');
101 $search_label =
GETPOST(
'search_label',
'alpha');
102 $search_amount =
GETPOST(
'search_amount',
'alpha');
104 $permissiontoadd = $user->hasRight(
'loan',
'write');
109 $socid = $user->socid;
118 if (
GETPOST(
'cancel',
'alpha')) {
122 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
126 $parameters = array();
127 $reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
132 if (empty($reshook)) {
134 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
145 $form =
new Form($db);
148 $help_url=
"EN:Module_Loan|FR:Module_Emprunt";
150 $title = $langs->trans(
'Loans');
155 $sql =
"SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,";
156 $sql .=
" SUM(pl.amount_capital) as alreadypaid";
160 $sql .=
" FROM ".MAIN_DB_PREFIX.
"loan as l";
161 $linktopl =
" LEFT JOIN ".MAIN_DB_PREFIX.
"payment_loan AS pl ON l.rowid = pl.fk_loan";
164 $sql .=
" WHERE l.entity = ".$conf->entity;
165 if ($search_amount) {
169 $sql .=
" AND l.rowid = ".((int) $search_ref);
174 $sql .=
" GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
177 $nbtotalofrecords =
'';
180 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
181 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
182 $resql = $db->query($sqlforcount);
184 $objforcount = $db->fetch_object($resql);
185 $nbtotalofrecords = $objforcount->nbtotalofrecords;
190 if (($page * $limit) > $nbtotalofrecords) {
198 $sql .= $db->order($sortfield, $sortorder);
200 $sql .= $db->plimit($limit + 1, $offset);
203 $resql = $db->query(
$sql);
209 $num = $db->num_rows($resql);
214 if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
215 $obj = $db->fetch_object($resql);
217 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((
int) $id));
227 $arrayofselected = is_array($toselect) ? $toselect : array();
231 $param .=
'&mode='.urlencode($mode);
233 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
234 $param .=
'&contextpage='.urlencode($contextpage);
236 if ($limit > 0 && $limit != $conf->liste_limit) {
237 $param .=
'&limit='.((int) $limit);
239 if ($optioncss !=
'') {
240 $param .=
'&optioncss='.urlencode($optioncss);
243 $param .=
"&search_ref=".urlencode($search_ref);
246 $param .=
"&search_label=".urlencode($search_label);
248 if ($search_amount) {
249 $param .=
"&search_amount=".urlencode($search_amount);
252 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
254 $parameters = array(
'param' => &$param);
255 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters,
$object, $action);
256 $param .= $hookmanager->resPrint;
259 $arrayofmassactions = array();
260 if (!empty($permissiontodelete)) {
261 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
263 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
264 $arrayofmassactions = array();
266 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
269 $url = DOL_URL_ROOT.
'/loan/card.php?action=create';
270 if (!empty($socid)) {
271 $url .=
'&socid='.$socid;
274 $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'));
275 $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'));
277 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewLoan'),
'',
'fa fa-plus-circle', $url,
'', $permissiontoadd);
279 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
281 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
282 if ($optioncss !=
'') {
283 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
285 print
'<input type="hidden" name="token" value="'.newToken().
'">';
286 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
287 print
'<input type="hidden" name="action" value="list">';
288 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
289 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
290 print
'<input type="hidden" name="page" value="'.$page.
'">';
291 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
292 print
'<input type="hidden" name="page_y" value="">';
293 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
296 $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'));
297 $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'));
299 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle',
dol_buildpath(
'/loan/card.php', 1).
'?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
301 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'money-bill-alt', 0, $newcardbutton,
'', $limit, 0, 0, 1);
305 $parameters = array();
306 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters,
$object, $action);
307 if (empty($reshook)) {
308 $moreforfilter .= $hookmanager->resPrint;
310 $moreforfilter = $hookmanager->resPrint;
313 if (!empty($moreforfilter)) {
314 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
315 print $moreforfilter;
316 $parameters = array();
317 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters,
$object, $action);
318 print $hookmanager->resPrint;
322 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
323 $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
324 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
325 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
327 print
'<div class="div-table-responsive">';
328 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
332 print
'<tr class="liste_titre_filter">';
335 print
'<td class="liste_titre center maxwidthsearch">';
336 $searchpicto = $form->showFilterButtons(
'left');
342 print
'<td class="liste_titre"><input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.
'"></td>';
345 print
'<td class="liste_titre"><input class="flat" size="12" type="text" name="search_label" value="'.$search_label.
'"></td>';
348 print
'<td class="liste_titre right" ><input class="flat" size="8" type="text" name="search_amount" value="'.$search_amount.
'"></td>';
351 print
'<td class="liste_titre"> </td>';
354 print
'<td class="liste_titre"> </td>';
357 print
'<td class="liste_titre"></td>';
361 print
'<td class="liste_titre center maxwidthsearch">';
362 $searchpicto = $form->showFilterButtons();
368 $totalarray = array();
369 $totalarray[
'nbfield'] = 0;
373 print
'<tr class="liste_titre">';
377 $totalarray[
'nbfield']++;
380 $totalarray[
'nbfield']++;
381 print_liste_field_titre(
"Label", $_SERVER[
"PHP_SELF"],
"l.label",
"", $param,
'', $sortfield, $sortorder,
'left ');
382 $totalarray[
'nbfield']++;
383 print_liste_field_titre(
"LoanCapital", $_SERVER[
"PHP_SELF"],
"l.capital",
"", $param,
'', $sortfield, $sortorder,
'right ');
384 $totalarray[
'nbfield']++;
385 print_liste_field_titre(
"DateStart", $_SERVER[
"PHP_SELF"],
"l.datestart",
"", $param,
'', $sortfield, $sortorder,
'center ');
386 $totalarray[
'nbfield']++;
387 print_liste_field_titre(
"DateEnd", $_SERVER[
"PHP_SELF"],
"l.dateend",
"", $param,
'', $sortfield, $sortorder,
'center ');
388 $totalarray[
'nbfield']++;
389 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"l.paid",
"", $param,
'', $sortfield, $sortorder,
'right ');
390 $totalarray[
'nbfield']++;
393 $totalarray[
'nbfield']++;
401 $savnbfield = $totalarray[
'nbfield'];
402 $totalarray = array();
403 $totalarray[
'nbfield'] = 0;
404 $imaxinloop = ($limit ? min($num, $limit) : $num);
405 while ($i < $imaxinloop) {
406 $obj = $db->fetch_object($resql);
417 if ($mode ==
'kanban') {
419 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
420 print
'<div class="box-flex-container kanban">';
423 $object->datestart= $obj->datestart;
424 $object->dateend = $obj->dateend;
425 $object->capital = $obj->capital;
426 $object->totalpaid = $obj->paid;
430 if ($massactionbutton || $massaction) {
432 if (in_array(
$object->id, $arrayofselected)) {
436 print
$object->getKanbanView(
'', array(
'selected' => $selected));
437 if ($i == ($imaxinloop - 1)) {
444 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
452 print
'<td>'.$object->getNomUrl(1).
'</td>';
455 print
'<td>'.dol_trunc($obj->label, 42).
'</td>';
458 print
'<td class="right maxwidth100"><span class="amount">'.price($obj->capital).
'</span></td>';
461 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->datestart),
'day').
'</td>';
464 print
'<td class="center width100">'.dol_print_date($db->jdate($obj->dateend),
'day').
'</td>';
466 print
'<td class="right nowrap">';
467 print
$object->LibStatut($obj->paid, 5, $obj->alreadypaid);
484 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
489 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
490 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters,
$object, $action);
491 print $hookmanager->resPrint;
493 print
'</table>'.
"\n";
496 print
'</form>'.
"\n";
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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 a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
print_barre_liste($title, $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.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.