mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix Clean code
This commit is contained in:
parent
3e12a8ab21
commit
f130237e25
|
|
@ -50,6 +50,7 @@ if (!defined('NOREQUIREMENU')) {
|
|||
|
||||
require_once '../main.inc.php';
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
|
@ -128,11 +129,11 @@ if (GETPOST('search_task') != '') {
|
|||
}
|
||||
|
||||
if (GETPOST('search_user') != '') {
|
||||
header("Location: ".DOL_URL_ROOT.'/user/list.php?mode=search&sall='.urlencode(GETPOST('search_user')));
|
||||
header("Location: ".DOL_URL_ROOT.'/user/list.php?search_all='.urlencode(GETPOST('search_user')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_group') != '') {
|
||||
header("Location: ".DOL_URL_ROOT.'/user/group/list.php?mode=search&sall='.urlencode(GETPOST('search_group')));
|
||||
header("Location: ".DOL_URL_ROOT.'/user/group/list.php?search_all='.urlencode(GETPOST('search_group')));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
|||
$optioncss = GETPOST('optioncss', 'aZ09'); // Option for the css output (always '' except when 'print')
|
||||
$mode = GETPOST('mode', 'aZ');
|
||||
|
||||
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
||||
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
||||
$search_group = GETPOST('search_group');
|
||||
|
||||
// Load variable for pagination
|
||||
|
|
@ -152,12 +152,15 @@ if (empty($reshook)) {
|
|||
* View
|
||||
*/
|
||||
|
||||
$help_url="";
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
$title = $langs->trans("UserGroups");
|
||||
$morejs = array();
|
||||
$morecss = array();
|
||||
|
||||
|
||||
// Build and execute select
|
||||
// --------------------------------------------------------------------
|
||||
$sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms as datem, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
|
||||
|
|
@ -230,6 +233,27 @@ foreach ($search as $key => $val) {
|
|||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
// Add $param from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$param .= $hookmanager->resPrint;
|
||||
|
||||
// List of mass actions available
|
||||
$arrayofmassactions = array(
|
||||
//'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
|
||||
//'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
|
||||
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
|
||||
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
||||
);
|
||||
if (!empty($permissiontodelete)) {
|
||||
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
|
||||
}
|
||||
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"].'">'."\n";
|
||||
if ($optioncss != '') {
|
||||
|
|
@ -262,21 +286,43 @@ if ($search_all) {
|
|||
$setupstring .= $key."=".$val.";";
|
||||
}
|
||||
print '<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
|
||||
}
|
||||
|
||||
$moreforfilter = '';
|
||||
|
||||
//$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // 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;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$arrayfields = array();
|
||||
$selectedfields = '';
|
||||
if (!empty($arrayfields)) {
|
||||
$selectedfields = $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";
|
||||
|
||||
// Fields title search
|
||||
// --------------------------------------------------------------------
|
||||
// ...
|
||||
|
||||
$totalarray = array();
|
||||
$totalarray['nbfield'] = 0;
|
||||
|
||||
// Fields title label
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
|
|
@ -298,12 +344,26 @@ print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "g.datec", $p
|
|||
$totalarray['nbfield']++;
|
||||
print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "g.tms", $param, "", '', $sortfield, $sortorder, 'center ');
|
||||
$totalarray['nbfield']++;
|
||||
print_liste_field_titre("", $_SERVER["PHP_SELF"]);
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
/*if (!empty($arrayfields['anotherfield']['checked'])) {
|
||||
print '<th class="liste_titre right">'.$langs->trans("AnotherField").'</th>';
|
||||
$totalarray['nbfield']++;
|
||||
}*/
|
||||
// Action column
|
||||
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
|
||||
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
||||
}
|
||||
$totalarray['nbfield']++; // For the column action
|
||||
print "</tr>\n";
|
||||
|
||||
print '</tr>'."\n";
|
||||
|
||||
|
||||
// Loop on record
|
||||
// --------------------------------------------------------------------
|
||||
$i = 0;
|
||||
$savnbfield = $totalarray['nbfield'];
|
||||
$totalarray = array();
|
||||
|
|
@ -357,17 +417,41 @@ while ($i < $imaxinloop) {
|
|||
print img_picto($langs->trans("GlobalGroup"), 'redstar');
|
||||
}
|
||||
print "</td>";
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
//multicompany
|
||||
if (isModEnabled('multicompany') && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
|
||||
$mc->getInfo($obj->entity);
|
||||
print '<td class="center">'.dol_escape_htmltag($mc->label).'</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
print '<td class="center">'.$obj->nb.'</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
print '<td class="center">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/group/perms.php?id='.$obj->rowid.'">'.$obj->nbpermissions.'</a>';
|
||||
print '</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
print '<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec), "dayhour").'</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
print '<td class="center nowrap">'.dol_print_date($db->jdate($obj->datem), "dayhour").'</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
||||
// Fields from hook
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
|
||||
print '<td class="nowrap center">';
|
||||
|
|
@ -384,17 +468,33 @@ while ($i < $imaxinloop) {
|
|||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
print '</tr>'."\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
print "</form>\n";
|
||||
// Show total line
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
||||
|
||||
// If no record found
|
||||
if ($num == 0) {
|
||||
/*$colspan = 1;
|
||||
foreach ($arrayfields as $key => $val) {
|
||||
if (!empty($val['checked'])) {
|
||||
$colspan++;
|
||||
}
|
||||
}*/
|
||||
$colspan = $savnbfield;
|
||||
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
|
||||
print '</table>'."\n";
|
||||
print '</div>'."\n";
|
||||
|
||||
print '</form>'."\n";
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
|
|||
|
|
@ -542,7 +542,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
|
|||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($sall != '') {
|
||||
$param .= '&sall='.urlencode($sall);
|
||||
$param .= '&search_all='.urlencode($sall);
|
||||
}
|
||||
if ($search_user != '') {
|
||||
$param .= "&search_user=".urlencode($search_user);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user