Skip to content
Permalink
Browse files

Look and feel v11

  • Loading branch information
eldy committed Jan 13, 2020
1 parent 9c9b73e commit ccdee44ed130c67f10b7be13998c7a99e94db6e6
Showing with 85 additions and 27 deletions.
  1. +84 −26 htdocs/loan/list.php
  2. +1 −1 htdocs/modulebuilder/template/myobject_list.php
@@ -36,13 +36,18 @@
$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,22 +58,39 @@
$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 = "";
}
}


/*
* 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 @@
$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 @@
$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 @@
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,29 +202,35 @@
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;

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 @@
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
@@ -360,7 +360,7 @@ function init_myfunc()
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">';

0 comments on commit ccdee44

Please sign in to comment.
You can’t perform that action at this time.