*/
$displaySearchField = function($params, $searchfor, $html, $form) {
/*
echo $html->link('Chercher', [
'action' => 'index',
'?' => $params
], [
'title' => 'Tous',
'style' => 'margin-right: 5px',
'escape' => false
]);
echo "
";
*/
//echo $this->Form->create('Materiel', ['url' => '/materiels/find']);
/*
echo $this->Form->create('Materiel', ['action' => 'index', '?'=>$params]);
echo '
';
echo "Afficher les matériels : ";
echo '';
echo '';
$b_all = $b_cre = $b_tbo = $b_val = $b_tba = $b_arc = '';
$SELECTED = '';
//if (isset($SELECTED_STATUS)) {
if ($SELECTED_STATUS) {
if ($SELECTED_STATUS == 'CREATED')
$b_cre = $SELECTED;
elseif ($SELECTED_STATUS == 'TOBEORDERED')
$b_tbo = $SELECTED;
elseif ($SELECTED_STATUS == 'VALIDATED')
$b_val = $SELECTED;
elseif ($SELECTED_STATUS == 'TOBEARCHIVED')
$b_tba = $SELECTED;
elseif ($SELECTED_STATUS == 'ARCHIVED')
$b_arc = $SELECTED;
} else $b_all = $SELECTED;
//debug($params);
/*
* Affichage des boutons de filtrage par statut (en haut de la page)
*/
$statuses = [
'TOUS' => [$b_all, 'TOUS', 'Tous les matériels', 5],
'CREATED' => [$b_cre, 'À VALIDER', 'Seulement les matériels créés (à valider)', 5]
];
if ($HAS_ORDER_BUTTON) $statuses['TOBEORDERED'] = [$b_tbo, 'EN COMMANDE', 'Seulement les matériels commandés (à valider)', 5];
$statuses['VALIDATED'] = [$b_val, 'VALIDÉS', "Seulement les matériels validés", 5];
$statuses['TOBEARCHIVED'] = [$b_tba, 'À SORTIR', "Seulement les matériels à archiver", 5];
$statuses['ARCHIVED'] = [$b_arc, 'ARCHIVÉS', "Seulement les matériels sortis de l'inventaire", 0];
// https://book.cakephp.org/3/en/views/helpers/html.html#creating-links
foreach ($statuses as $status=>$status_params) {
$i=-1;
if ($status=='TOUS') {
$status=null;
$color = 'black';
}
else
$color = $statuses_color[$status];
echo $html->link($status_params[++$i].' '.$status_params[++$i], [
//'action' => 'index',
//'CREATED',
//'?' => ['height' => 400, 'width' => 500]
//'?' => $params + ['status'=>'CREATED']
'?' => array_merge($params, ['status'=>$status])
//'?' => null
//[$args],
//"http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
], [
'title' => $status_params[++$i],
//'style' => 'margin-right: 5px',
'style' => 'color:'.$color.' ; margin-right: '.$status_params[++$i].'px',
'escape' => false
]);
}
echo '';
// ACTIONS : buttons "Tout selectionner", "Tout decocher"
// - show only with "A valider" and "A sortir"
if ($SELECTED_STATUS && $nbMateriels>0) {
echo $html->link(' Tout cocher', '#all', [
'onclick' => 'selectAll()',
'title' => 'Sélectionner tout les matériels',
'style' => ': 400px; margin-right: 50px',
'escape' => false
]);
echo $html->link(' Tout décocher', '#none', [
'onclick' => 'selectNone()',
'title' => 'Sélectionner aucun matériel',
'style' => 'margin-right: 50px',
'escape' => false
]);
}
echo "
";
}; // displayStatusButtons()
//$displaySelectors = function($form, $request,
$displayFilters = function($form, $request,
$df,
/*
$displayNbLinesSelector,
$displayAgeSelector,
*/
//$f1_func,
//$f1_func,
$f1_name, $f1_label, $f1_options,
//$f2_func, $f2_options,
$f2_name, $f2_label, $f2_options,
//$displayDomaineSelector, $domain_options,
//$displayProjetSelector, $projet_options
$f3_name, $f3_label, $f3_options,
$f4_name, $f4_label, $f4_options
) {
//echo '';
echo '
';
echo '
';
// Filtre 1
echo '';
//$displayNbLinesSelector($form, $request);
//$f1_func($form, $request);
$df($f1_name, $f1_label, $form, $request, $f1_options);
echo ' | ';
// Filtre 2
echo '';
//$displayAgeSelector($form, $request);
//$f2_func($form, $request, $f2_options);
$df($f2_name, $f2_label, $form, $request, $f2_options);
echo ' | ';
// Filtre 3
echo '';
//$displayDomaineSelector($form, $request, $domain_options);
//$df('domain', $form, $request, $domain_options);
$df($f3_name, $f3_label, $form, $request, $f3_options);
echo ' | ';
// Filtre 4
echo '';
//$displayProjetSelector('projet', $form, $request, $projet_options);
//$df('projet', $form, $request, $projet_options);
$df($f4_name, $f4_label, $form, $request, $f4_options);
echo ' | ';
echo '
';
echo '
';
};
/*
$displayNbLinesSelector = function($form, $request, $options) {
//echo '
';
//echo $this->Form->create('materiels', [
// echo $this->Form->create('materiels', ['url' => '/materiels/execActions?page=index']);
//echo $this->Form->control('aff_par_defaut', [
echo $form->control('aff_par_defaut', [
'label' => 'Nombre lignes',
'onchange' => "updateUrlWithSelectedValue('aff-par-defaut', 'aff')",
'options' => $options,
]);
//echo '
';
}; // displayNbLinesSelector()
$age_options = [
'0' => 'Tous',
'5' => 'Récents (5 ans max)',
'10' => '5-10 ans',
'15' => '10-15 ans',
'20' => '15-20 ans',
//'20plus' => '+ 20 ans',
'21' => '+ 20 ans',
//'unknown' => 'inconnu',
'-1' => 'inconnu',
];
$displayAgeSelector = function($form, $request, $options) {
//echo '
';
echo $form->control('age_selector', [
'label' => 'Age',
'onchange' => "updateUrlWithSelectedValue('age-selector', 'age')",
'options' => $options,
'default' => '0',
// Inutile car géré via javascript
//'default' => '5',
]);
//echo '
';
}; // $displayAgeSelector()
$displayDomaineSelector = function($form, $request, $options) {
//echo '
';
echo $form->control('domain_selector', [
'label' => 'Domaine',
'onchange' => "updateUrlWithSelectedValue('domain-selector', 'domain')",
'options' => $options,
// Inutile car géré via javascript
'default' => 0,
]);
//echo '
';
};
$displayProjetSelector = function($form, $request, $options) {
//echo '
';
echo $form->control('projet_selector', [
'label' => 'Projet',
'onchange' => "updateUrlWithSelectedValue('projet-selector', 'projet')",
'options' => $options,
// Inutile car géré via javascript
'default' => 0,
]);
//echo '
';
};
$displayProjetSelector = function($filter_name, // 'projet'
$form, $request, $options
) {
//echo '
';
$html_filter_name = $filter_name.'-selector';
//echo $form->control('projet_selector', [
echo $form->control($filter_name.'_selector', [ // 'projet_selector'
//'label' => 'Projet',
'label' => ucfirst($filter_name), // 'Projet'
//'onchange' => "updateUrlWithSelectedValue('projet-selector', 'projet')",
//'onchange' => "updateUrlWithSelectedValue($filter_name.'-selector', $filter_name)", // ('projet-selector', 'projet')
'onchange' => "updateUrlWithSelectedValue('$html_filter_name', '$filter_name')", // ('projet-selector', 'projet')
'options' => $options,
// Inutile car géré via javascript
'default' => 0,
]);
//echo '
';
};
*/
$displayFilter = function($filter_name, $filter_label,// 'projet'
$form, $request, $options
) {
//echo '
';
$html_filter_name = $filter_name.'-selector';
//echo $form->control('projet_selector', [
echo $form->control($filter_name.'_selector', [ // 'projet_selector'
//'label' => 'Projet',
'label' => $filter_label ? $filter_label : ucfirst($filter_name), // 'Projet'
//'onchange' => "updateUrlWithSelectedValue('projet-selector', 'projet')",
//'onchange' => "updateUrlWithSelectedValue($filter_name.'-selector', $filter_name)", // ('projet-selector', 'projet')
'onchange' => "updateUrlWithSelectedValue('$html_filter_name', '$filter_name')", // ('projet-selector', 'projet')
'options' => $options,
// Inutile car géré via javascript
'default' => 0,
]);
//echo '
';
};
$displayActionButtonsForSelectedOrAllElements = function(
$form,
$SELECTED_STATUS,
$USER_IS_RESPONSABLE, $USER_IS_ADMIN_OR_MORE, $USER_IS_SUPERADMIN,
$displayExportCurrentButton, $params) {
//if (isset($SELECTED_STATUS)) {
if ($SELECTED_STATUS) {
switch ($SELECTED_STATUS) {
case 'CREATED':
$action = 'Valider les';
break;
case 'TOBEORDERED':
$action = "Valider les";
break;
case 'VALIDATED':
$action = "Demander l'archivage des";
break;
case 'TOBEARCHIVED':
$action = "Sortir les";
break;
}
if ($SELECTED_STATUS != 'ARCHIVED') {
//if (! ($role == 'Super Administrateur' && $SELECTED_STATUS == 'TOBEARCHIVED')) {
if (! ($USER_IS_SUPERADMIN && $SELECTED_STATUS=='TOBEARCHIVED') ) {
//echo $this->Form->submit($action . ' matériels cochés', [
// 'name' => 'updateSelectedStatus',
// 'id' => 'updateSelectedStatus',
// 'style' => 'margin: 0px'
//]);
//echo $this->Form->button($action . ' matériels cochés', [ 'class'=>'btn btn-outline-success', 'type'=>'submit', 'name' => 'updateSelectedStatus', 'id' => 'updateSelectedStatus', 'style' => 'margin: 0px']);
echo $form->button($action . ' matériels cochés', [ 'class'=>'btn btn-outline-success', 'type'=>'submit', 'name' => 'updateSelectedStatus', 'id' => 'updateSelectedStatus', 'style' => 'margin: 0px']);
echo "
";
}
}
//echo $this->Form->submit('Exporter la liste des matériels cochés', [
// 'name' => 'export',
// 'id' => 'export',
// 'style' => 'margin: 0px;'
//]);
echo $form->button('Exporter la liste des matériels cochés', ['class'=>'btn btn-outline-success', 'type'=>'submit', 'name' => 'export', 'id' => 'export', 'style' => 'margin: 0px;' ]);
echo "
";
} // if $SELECTED_STATUS
if ($USER_IS_ADMIN_OR_MORE || $USER_IS_RESPONSABLE) {
//echo $this->Form->submit('Exporter la liste complete', [
// 'name' => 'exportAll',
// 'id' => 'exportAll',
// 'style' => 'margin: 0px;'
//]);
$displayExportCurrentButton($params, $this->Html);
echo '
';
echo $form->button('Exporter la liste complète (tous les matériels NON archivés)', ['class'=>'btn btn-outline-success', 'type'=>'submit', 'name' => 'exportAll', 'id' => 'exportAll', 'style' => 'margin: 0px;']);
}
}; // $displayActionButtonsForSelectedOrAllElements()
/*
* Couleurs en fonction du statut du matos
*
*/
$displayLegend = function() {
// CREATED => bleu
// VALIDATED => vert
// TBA => orange
// ARCHIVED => rouge
//echo "
Couleur :
bleu=à valider
; vert=validé ; orange=à sortir ; rouge=archivé (couleur date rouge = fin garantie)";
//echo "
Statut : C(réé)=Matériel à commander ; V(alidé)=Matériel livré ; TBA=à sortir ; A=Archivé ;
";
//echo "
Couleur : bleu=à valider ; vert=validé ; orange=à sortir ; rouge=archivé ; couleur date rouge = fin garantie
";
echo "
Couleur :
orange=créé (à valider) ;
rouge=en commande (à valider) ou à sortir ;
noir=livré (validé) ;"
//rouge=à sortir ;
." bleu=archivé ;
(couleur date : rouge=fin garantie, orange=< 1 an)
";
};
/*
* On récupère les paramètres passés actuellement à l'URL (age, domain, searchfor...)
* afin de les rappeler quand on clique sur les boutons de filtrage
*/
//$args = explode('?',$_SERVER['REQUEST_URI']);
//$args = count($args)==2 ? '?'.$args[1] : null;
$params = $this->request->getParam('?');
if (!$params) $params=[];
// S'il y a des paramètres, supprimer le paramètre 'page' car inapproprié
if ($params) unset($params['page']);
?>
Liste des matériels ('.$nbMateriels.')'; ?>
';
echo $this->Html->link(' Nouveau Matériel', [
'action' => 'add'
], [
'title' => 'Ajouter un matériel',
'escape' => false
]);
echo '';*/
//if ($USER_IS_ADMIN_OR_MORE) $displayExportCurrentButton($SELECTED_STATUS, $params, $nbMateriels, $this->Html);
if ($USER_IS_ADMIN_OR_MORE) $displayStatusButtons($HAS_ORDER_BUTTON, $SELECTED_STATUS, $params, $nbMateriels, $statuses_color, $this->Html);
//
//
//$displaySelectors(
$displayFilters(
$this->Form, $this->request,
$displayFilter,
//$displayNbLinesSelector,
'nblines', 'Lignes par page', $nblines_options,
//$displayAgeSelector, $age_options,
'age', '', $age_options,
//$displayDomaineSelector, $domain_options,
//$displayProjetSelector, $projet_options
'domaine', '', $domaine_options,
'projet', '', $projet_options
);
//$displayNbLinesSelector($this->Form, $this->request);
// Formulaire de RECHERCHE de materiels
// Search field
echo "\n";
echo "\n";
$displaySearchField($params, $searchfor, $this->Html, $this->Form);
echo "\n";
echo "\n";
//
if ($nbMateriels == 0) echo 'Aucun matériel';
else {
//
$this->Form->end();
} // (nbMateriels>0)
?>