Skip to content

Commit

Permalink
#1612 [Control] add: default filter for pwa source control list
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jan 5, 2024
1 parent 4de9ea0 commit 67122e1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
11 changes: 7 additions & 4 deletions core/tpl/digiquali_control_list.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,15 @@
if (GETPOSTISSET('id')) {
print '<input type="hidden" name="id" value="'.GETPOST('id','int').'">';
}

$fromurl = '';
if (!empty($fromtype)) {
$fromurl = '&fromtype='.$fromtype.'&fromid='.$fromid;
$fromurl = '&fromtype=' . $fromtype . '&fromid=' . $fromid;
}
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/digiquali/view/control/control_card.php', 1).'?action=create'.$fromurl, '', $permissiontoadd);

print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
$newCardButton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/digiquali/view/control/control_card.php', 1) . '?action=create&source=' . $source . $fromurl, '', $permissiontoadd);

print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newCardButton, '', $limit, 0, 0, 1);

if ($massaction == 'prearchive') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('ConfirmMassArchive'), $langs->trans('ConfirmMassArchivingQuestion', count($toselect)), 'archive', null, '', 0, 200, 500, 1);
Expand All @@ -237,7 +240,7 @@
$moreforfilter = '';

// Filter on categories
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && $source != 'pwa') {
$formcategory = new FormCategory($db);
$moreforfilter .= $formcategory->getFilterBox('control', $search_category_array);
}
Expand Down
40 changes: 25 additions & 15 deletions view/control/control_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$fromtype = GETPOST('fromtype', 'alpha'); // element type
$fromid = GETPOST('fromid', 'int'); //element id
$source = GETPOST('source', 'alpha'); // source PWA

// Load variable for pagination
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
Expand Down Expand Up @@ -188,20 +189,26 @@
}

// Definition of array of fields for columns
$arrayfields = array();
$arrayfields['t.days_remaining_before_next_control'] = [
'label' => 'DaysBeforeNextControl',
'checked' => $source == 'pwa' ? 0 : 1,
'enabled' => 1,
//'arrayofkeyval' => ['', '< 30', '< 60', '<90'],
'position' => 66
];
foreach ($object->fields as $key => $val) {
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) {
$visible = (int) dol_eval($val['visible'], 1);
$arrayfields['t.'.$key] = array(
'label'=>$val['label'],
'checked'=>(($visible < 0) ? 0 : 1),
'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
'position'=>$val['position'],
'help'=>$val['help'],
'css' => $val['css']
);
}
// If $val['visible'] == 0, then we never show the field
if (!empty($val['visible'])) {
$visible = (int) dol_eval($val['visible'], 1);
$arrayfields['t.' . $key] = [
'label' => $val['label'],
'checked' => (($visible < 0 || ($val['showinpwa'] == 0 && $source == 'pwa')) ? 0 : 1),
'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1)),
'position'=> $val['position'],
'help' => $val['help'],
'css' => $val['css']
];
}
}

// Extra fields
Expand Down Expand Up @@ -316,6 +323,11 @@
$help_url = '';
$title = $langs->trans("ControlList");

if ($source == 'pwa') {
$conf->dol_hide_topmenu = 1;
$conf->dol_hide_leftmenu = 1;
}

saturne_header(0,'', $title, $help_url);
if (!empty($fromtype)) {
print saturne_get_fiche_head($objectLinked, 'control', $langs->trans("Control"));
Expand Down Expand Up @@ -359,8 +371,6 @@
print '</div>';
}

$newcardbutton = dolGetButtonTitle($langs->trans('NewControl'), '', 'fa fa-plus-circle', dol_buildpath('/digiquali/view/control/control_card.php', 1).'?action=create', '', $permissiontoadd);

include_once '../../core/tpl/digiquali_control_list.tpl.php';

// End of page
Expand Down

0 comments on commit 67122e1

Please sign in to comment.