28require
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
39$langs->loadLangs(array(
"banks",
"bills",
"compta",
"loan"));
41$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
43$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
44$massaction =
GETPOST(
'massaction',
'alpha');
46$confirm =
GETPOST(
'confirm',
'alpha');
47$cancel =
GETPOST(
'cancel',
'alpha');
48$toselect =
GETPOST(
'toselect',
'array:int');
49$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
50$backtopage =
GETPOST(
'backtopage',
'alpha');
51$optioncss =
GETPOST(
'optioncss',
'aZ');
55$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
58if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
62$offset = $limit * $page;
69$diroutputmassaction =
$conf->loan->dir_output.
'/temp/massgeneration/'.$user->id;
70$hookmanager->initHooks(array($contextpage));
73$extrafields->fetch_name_optionals_label(
$object->table_element);
76$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
80 $sortfield =
"l.rowid";
87$arrayfields = array();
88foreach (
$object->fields as $key => $val) {
90 if (!empty($val[
'visible'])) {
91 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
92 $arrayfields[
't.'.$key] = array(
93 'label'=>$val[
'label'],
94 'checked'=>(($visible < 0) ? 0 : 1),
95 'enabled'=>(abs($visible) != 3 && (bool)
dol_eval((
string) $val[
'enabled'], 1)),
96 'position'=>$val[
'position'],
97 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
102include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
108$search_ref =
GETPOST(
'search_ref',
'alpha');
109$search_label =
GETPOST(
'search_label',
'alpha');
110$search_amount =
GETPOST(
'search_amount',
'alpha');
112$permissiontoadd = $user->hasRight(
'loan',
'write');
117 $socid = $user->socid;
126if (
GETPOST(
'cancel',
'alpha')) {
130if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
134$parameters = array();
135$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
140if (empty($reshook)) {
142 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
156$title = $langs->trans(
'Loans');
157$help_url =
"EN:Module_Loan|FR:Module_Emprunt";
161$sql =
"SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,";
162$sql .=
" SUM(pl.amount_capital) as alreadypaid";
166$sql .=
" FROM ".MAIN_DB_PREFIX.
"loan as l";
167$linktopl =
" LEFT JOIN ".MAIN_DB_PREFIX.
"payment_loan AS pl ON l.rowid = pl.fk_loan";
170$sql .=
" WHERE l.entity = ".$conf->entity;
175 $sql .=
" AND l.rowid = ".((int) $search_ref);
180$sql .=
" GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
183$nbtotalofrecords =
'';
186 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
187 $sqlforcount = preg_replace(
'/'.preg_quote($linktopl,
'/').
'/',
'', $sqlforcount);
188 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
189 $resql =
$db->query($sqlforcount);
191 $objforcount =
$db->fetch_object($resql);
192 $nbtotalofrecords = $objforcount->nbtotalofrecords;
197 if (($page * $limit) > (
int) $nbtotalofrecords) {
205$sql .=
$db->order($sortfield, $sortorder);
207 $sql .=
$db->plimit($limit + 1, $offset);
210$resql =
$db->query($sql);
216$num =
$db->num_rows($resql);
221if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
222 $obj =
$db->fetch_object($resql);
232llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-loan page-list');
234$arrayofselected = is_array($toselect) ? $toselect : array();
238 $param .=
'&mode='.urlencode($mode);
240if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
241 $param .=
'&contextpage='.urlencode($contextpage);
243if ($limit > 0 && $limit !=
$conf->liste_limit) {
244 $param .=
'&limit='.((int) $limit);
246if ($optioncss !=
'') {
247 $param .=
'&optioncss='.urlencode($optioncss);
250 $param .=
"&search_ref=".urlencode($search_ref);
253 $param .=
"&search_label=".urlencode($search_label);
256 $param .=
"&search_amount=".urlencode($search_amount);
259include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
261$parameters = array(
'param' => &$param);
262$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
263$param .= $hookmanager->resPrint;
266$arrayofmassactions = array();
267if (!empty($permissiontodelete)) {
268 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
270if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
271 $arrayofmassactions = array();
273$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
276$url = DOL_URL_ROOT.
'/loan/card.php?action=create';
278 $url .=
'&socid='.$socid;
281$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'));
282$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'));
283$newcardbutton .= dolGetButtonTitleSeparator();
284$newcardbutton .= dolGetButtonTitle($langs->trans(
'NewLoan'),
'',
'fa fa-plus-circle', $url,
'', $permissiontoadd);
286$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
288print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
289if ($optioncss !=
'') {
290 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
292print
'<input type="hidden" name="token" value="'.newToken().
'">';
293print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
294print
'<input type="hidden" name="action" value="list">';
295print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
296print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
297print
'<input type="hidden" name="page" value="'.$page.
'">';
298print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
299print
'<input type="hidden" name="page_y" value="">';
300print
'<input type="hidden" name="mode" value="'.$mode.
'">';
303$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'));
304$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'));
305$newcardbutton .= dolGetButtonTitleSeparator();
306$newcardbutton .= dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle',
dol_buildpath(
'/loan/card.php', 1).
'?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
308print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'money-bill-alt', 0, $newcardbutton,
'', $limit, 0, 0, 1);
312$parameters = array();
313$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
314if (empty($reshook)) {
315 $moreforfilter .= $hookmanager->resPrint;
317 $moreforfilter = $hookmanager->resPrint;
320if (!empty($moreforfilter)) {
321 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
322 print $moreforfilter;
326$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
327$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
328$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
329$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
331print
'<div class="div-table-responsive">';
332print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
336print
'<tr class="liste_titre_filter">';
338if (
$conf->main_checkbox_left_column) {
339 print
'<td class="liste_titre center maxwidthsearch">';
340 $searchpicto = $form->showFilterButtons(
'left');
346print
'<td class="liste_titre"><input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.
'"></td>';
349print
'<td class="liste_titre"><input class="flat" size="12" type="text" name="search_label" value="'.$search_label.
'"></td>';
352print
'<td class="liste_titre right" ><input class="flat" size="8" type="text" name="search_amount" value="'.$search_amount.
'"></td>';
355print
'<td class="liste_titre"> </td>';
358print
'<td class="liste_titre"> </td>';
361print
'<td class="liste_titre"></td>';
364if (!
$conf->main_checkbox_left_column) {
365 print
'<td class="liste_titre center maxwidthsearch">';
366 $searchpicto = $form->showFilterButtons();
377print
'<tr class="liste_titre">';
379if (
$conf->main_checkbox_left_column) {
385print_liste_field_titre(
"Label", $_SERVER[
"PHP_SELF"],
"l.label",
"", $param,
'', $sortfield, $sortorder,
'left ');
387print_liste_field_titre(
"LoanCapital", $_SERVER[
"PHP_SELF"],
"l.capital",
"", $param,
'', $sortfield, $sortorder,
'right ');
389print_liste_field_titre(
"DateStart", $_SERVER[
"PHP_SELF"],
"l.datestart",
"", $param,
'', $sortfield, $sortorder,
'center ');
391print_liste_field_titre(
"DateEnd", $_SERVER[
"PHP_SELF"],
"l.dateend",
"", $param,
'', $sortfield, $sortorder,
'center ');
393print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"l.paid",
"", $param,
'', $sortfield, $sortorder,
'center ');
395if (!
$conf->main_checkbox_left_column) {
408$imaxinloop = ($limit ? min($num, $limit) : $num);
409while ($i < $imaxinloop) {
410 $obj =
$db->fetch_object($resql);
419 $object->datestart=
$db->jdate($obj->datestart);
422 if ($mode ==
'kanban') {
424 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
425 print
'<div class="box-flex-container kanban">';
428 $object->capital = $obj->capital;
429 $object->totalpaid = $obj->paid;
433 if ($massactionbutton || $massaction) {
435 if (in_array(
$object->id, $arrayofselected)) {
439 print
$object->getKanbanView(
'', array(
'selected' => $selected));
440 if ($i == ($imaxinloop - 1)) {
447 print
'<tr data-rowid="'.$object->id.
'" class="oddeven row-with-select">';
450 if (
$conf->main_checkbox_left_column) {
455 print
'<td>'.$object->getNomUrl(1).
'</td>';
458 print
'<td>'.dol_trunc($obj->label, 42).
'</td>';
461 print
'<td class="right maxwidth100"><span class="amount">'.price($obj->capital).
'</span></td>';
464 print
'<td class="center width100">'.dol_print_date(
$db->jdate($obj->datestart),
'day').
'</td>';
467 print
'<td class="center width100">'.dol_print_date(
$db->jdate($obj->dateend),
'day').
'</td>';
469 print
'<td class="center nowrap">';
470 print
$object->LibStatut($obj->paid, 5, $obj->alreadypaid);
474 if (!
$conf->main_checkbox_left_column) {
487 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
492$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
493$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
494print $hookmanager->resPrint;
496print
'</table>'.
"\n";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.