|
@@ -31,14 +31,16 @@ require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
|
|
|
// Load translation files required by the page
|
|
|
$langs->loadLangs(array("banks", "bills", "compta", "loan"));
|
|
|
|
|
|
+$massaction = GETPOST('massaction', 'alpha');
|
|
|
+
|
|
|
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
|
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
|
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
|
|
-$massaction = GETPOST('massaction', 'alpha');
|
|
|
-if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
|
|
+if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
|
|
|
+ // If $page is not defined, or '' or -1 or if we click on clear filters
|
|
|
$page = 0;
|
|
|
-} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
|
|
+}
|
|
|
$offset = $limit * $page;
|
|
|
$pageprev = $page - 1;
|
|
|
$pagenext = $page + 1;
|
|
@@ -72,12 +74,14 @@ if ($user->socid) {
|
|
|
}
|
|
|
$result = restrictedArea($user, 'loan', '', '', '');
|
|
|
|
|
|
+
|
|
|
/*
|
|
|
* Actions
|
|
|
*/
|
|
|
|
|
|
if (GETPOST('cancel', 'alpha')) {
|
|
|
- $action = 'list'; $massaction = '';
|
|
|
+ $action = 'list';
|
|
|
+ $massaction = '';
|
|
|
}
|
|
|
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
|
|
$massaction = '';
|
|
@@ -113,6 +117,8 @@ llxHeader('', $title, $help_url);
|
|
|
|
|
|
$arrayofselected = is_array($toselect) ? $toselect : array();
|
|
|
|
|
|
+// Build and execute select
|
|
|
+// --------------------------------------------------------------------
|
|
|
$sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,";
|
|
|
$sql .= " SUM(pl.amount_capital) as alreadypaid";
|
|
|
|
|
@@ -139,7 +145,6 @@ $nbtotalofrecords = '';
|
|
|
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
|
|
|
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
|
|
$sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
|
|
|
- $sqlforcount = preg_replace('/'.preg_quote($linktopl, '/').'/', '', $sqlforcount);
|
|
|
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
|
|
|
$resql = $db->query($sqlforcount);
|
|
|
if ($resql) {
|
|
@@ -149,7 +154,7 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
|
|
|
dol_print_error($db);
|
|
|
}
|
|
|
|
|
|
- if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
|
|
+ if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
|
|
|
$page = 0;
|
|
|
$offset = 0;
|
|
|
}
|
|
@@ -171,6 +176,17 @@ if (!$resql) {
|
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+// Direct jump if only one record found
|
|
|
+if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
|
|
|
+ $obj = $db->fetch_object($resql);
|
|
|
+ $id = $obj->rowid;
|
|
|
+ header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.((int) $id));
|
|
|
+ exit;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
// Output page
|
|
|
// --------------------------------------------------------------------
|
|
|
if ($resql) {
|
|
@@ -209,6 +225,8 @@ if ($resql) {
|
|
|
$newcardbutton .= dolGetButtonTitleSeparator();
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
|
|
|
|
|
|
+ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
|
|
+
|
|
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
|
|
if ($optioncss != '') {
|
|
|
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
@@ -218,22 +236,50 @@ if ($resql) {
|
|
|
print '<input type="hidden" name="action" value="list">';
|
|
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
|
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
|
|
+ print '<input type="hidden" name="page" value="'.$page.'">';
|
|
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
|
|
+ print '<input type="hidden" name="page_y" value="">';
|
|
|
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
|
|
|
|
|
+ $newcardbutton = '';
|
|
|
+ $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'));
|
|
|
+ $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'));
|
|
|
+ $newcardbutton .= dolGetButtonTitleSeparator();
|
|
|
+ $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/loan/card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
|
|
|
|
|
|
- print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'money-bill-alt', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
|
|
+ print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'money-bill-alt', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
|
|
|
|
|
- $moreforfilter = '';
|
|
|
+ $parameters = array();
|
|
|
+ $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
+ if (empty($reshook)) {
|
|
|
+ $moreforfilter .= $hookmanager->resPrint;
|
|
|
+ } else {
|
|
|
+ $moreforfilter = $hookmanager->resPrint;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($moreforfilter)) {
|
|
|
+ print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
|
|
+ print $moreforfilter;
|
|
|
+ $parameters = array();
|
|
|
+ $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
+ print $hookmanager->resPrint;
|
|
|
+ print '</div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
|
|
+ $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
|
|
|
+ $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
|
|
|
|
|
print '<div class="div-table-responsive">';
|
|
|
- print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
|
|
+ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
|
|
|
|
|
- // Filters lines
|
|
|
+ // Fields title search
|
|
|
+ // --------------------------------------------------------------------
|
|
|
print '<tr class="liste_titre_filter">';
|
|
|
+ // Action column
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
|
|
- print '<td class="liste_titre maxwidthsearch">';
|
|
|
- $searchpicto = $form->showFilterAndCheckAddButtons();
|
|
|
+ print '<td class="liste_titre center maxwidthsearch">';
|
|
|
+ $searchpicto = $form->showFilterButtons('left');
|
|
|
print $searchpicto;
|
|
|
print '</td>';
|
|
|
}
|
|
@@ -256,14 +302,14 @@ if ($resql) {
|
|
|
// No filter: Status
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
|
|
|
- // Filter: Buttons
|
|
|
+ // Action column
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
|
|
- print '<td class="liste_titre maxwidthsearch">';
|
|
|
- $searchpicto = $form->showFilterAndCheckAddButtons();
|
|
|
+ print '<td class="liste_titre center maxwidthsearch">';
|
|
|
+ $searchpicto = $form->showFilterButtons();
|
|
|
print $searchpicto;
|
|
|
print '</td>';
|
|
|
}
|
|
|
- print '</tr>';
|
|
|
+ print '</tr>'."\n";
|
|
|
|
|
|
$totalarray = array();
|
|
|
$totalarray['nbfield'] = 0;
|
|
@@ -271,6 +317,7 @@ if ($resql) {
|
|
|
// Fields title label
|
|
|
// --------------------------------------------------------------------
|
|
|
print '<tr class="liste_titre">';
|
|
|
+ // Action column
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
|
|
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
|
|
|
$totalarray['nbfield']++;
|
|
@@ -293,13 +340,13 @@ if ($resql) {
|
|
|
}
|
|
|
print "</tr>\n";
|
|
|
|
|
|
- print "</tr>\n";
|
|
|
|
|
|
// Loop on record
|
|
|
// --------------------------------------------------------------------
|
|
|
$i = 0;
|
|
|
$savnbfield = $totalarray['nbfield'];
|
|
|
$totalarray = array();
|
|
|
+ $totalarray['nbfield'] = 0;
|
|
|
$imaxinloop = ($limit ? min($num, $limit) : $num);
|
|
|
while ($i < $imaxinloop) {
|
|
|
$obj = $db->fetch_object($resql);
|
|
@@ -324,13 +371,21 @@ if ($resql) {
|
|
|
$object->capital = $obj->capital;
|
|
|
$object->totalpaid = $obj->paid;
|
|
|
|
|
|
- print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
|
|
|
+ // Output Kanban
|
|
|
+ $selected = -1;
|
|
|
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
|
|
+ $selected = 0;
|
|
|
+ if (in_array($object->id, $arrayofselected)) {
|
|
|
+ $selected = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ print $object->getKanbanView('', array('selected' => $selected));
|
|
|
if ($i == ($imaxinloop - 1)) {
|
|
|
print '</div>';
|
|
|
print '</td></tr>';
|
|
|
}
|
|
|
} else {
|
|
|
- print '<tr class="oddeven">';
|
|
|
+ print '<tr data-rowid="'.$object->id.'" class="oddeven">';
|
|
|
|
|
|
// Action column
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
|
@@ -361,7 +416,7 @@ if ($resql) {
|
|
|
print '<td></td>';
|
|
|
}
|
|
|
|
|
|
- print "</tr>\n";
|
|
|
+ print '</tr>'."\n";
|
|
|
}
|
|
|
$i++;
|
|
|
}
|
|
@@ -374,7 +429,7 @@ if ($resql) {
|
|
|
}
|
|
|
|
|
|
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
|
|
- $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
+ $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
|
print '</table>'."\n";
|