Look and feel v11

This commit is contained in:
Laurent Destailleur 2020-01-13 13:35:29 +01:00
parent 9c9b73e4d1
commit ccdee44ed1
2 changed files with 85 additions and 27 deletions

View File

@ -36,13 +36,18 @@ if ($user->socid) $socid=$user->socid;
$result = restrictedArea($user, 'loan', '', '', '');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $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;
// Initialize technical objects
$loan_static = new Loan($db);
$extrafields = new ExtraFields($db);
if (!$sortfield) $sortfield = "l.rowid";
if (!$sortorder) $sortorder = "DESC";
@ -53,12 +58,27 @@ $search_amount = GETPOST('search_amount', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search
$optioncss = GETPOST('optioncss', 'alpha');
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
/*
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
$search_ref = "";
$search_label = "";
$search_amount = "";
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$search_ref = "";
$search_label = "";
$search_amount = "";
}
}
@ -66,9 +86,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
* View
*/
$loan_static = new Loan($db);
$now = dol_now();
llxHeader();
//$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
$help_url = '';
$title = $langs->trans('Loans');
$sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,";
$sql .= " SUM(pl.amount_capital) as alreadypayed";
@ -81,25 +103,45 @@ if ($search_label) $sql .= natural_search("l.label", $search_label);
$sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0;
$offset = 0;
}
}
$sql.= $db->plimit($limit+1, $offset);
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
{
$num = $nbtotalofrecords;
}
else
{
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if (!$resql)
{
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
}
// Output page
// --------------------------------------------------------------------
llxHeader('', $title, $help_url);
//print $sql;
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$param='';
@ -116,13 +158,15 @@ if ($resql)
$newcardbutton.= dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/loan/card.php?action=create');
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
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="viewstatut" value="'.$viewstatut.'">';
print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit);
@ -146,6 +190,8 @@ if ($resql)
print '</td>';
print '</tr>';
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "l.rowid", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "l.label", "", $param, '', $sortfield, $sortorder, 'left ');
@ -156,9 +202,15 @@ if ($resql)
print_liste_field_titre('');
print "</tr>\n";
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num))
{
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
$loan_static->id = $obj->rowid;
$loan_static->ref = $obj->rowid;
$loan_static->label = $obj->label;
@ -166,19 +218,19 @@ if ($resql)
print '<tr class="oddeven">';
// Ref
print '<td>'.$loan_static->getNomUrl(1, 42).'</td>';
print '<td>'.$loan_static->getNomUrl(1).'</td>';
// Label
print '<td>'.dol_trunc($obj->label, 42).'</td>';
// Capital
print '<td class="right" width="100">'.price($obj->capital).'</td>';
print '<td class="right maxwidth100">'.price($obj->capital).'</td>';
// Date start
print '<td width="110" class="center">'.dol_print_date($db->jdate($obj->datestart), 'day').'</td>';
print '<td class="center width100">'.dol_print_date($db->jdate($obj->datestart), 'day').'</td>';
// Date end
print '<td width="110" class="center">'.dol_print_date($db->jdate($obj->dateend), 'day').'</td>';
print '<td class="center width100">'.dol_print_date($db->jdate($obj->dateend), 'day').'</td>';
print '<td class="right nowrap">'.$loan_static->LibStatut($obj->paid, 5, $obj->alreadypayed).'</a></td>';
@ -197,9 +249,15 @@ if ($resql)
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
print "</table>";
print '</div>';
print "</form>\n";
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>'."\n";
print '</div>'."\n";
print '</form>'."\n";
$db->free($resql);
}
else

View File

@ -360,7 +360,7 @@ if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';