From a97b5772f968ce7f0e2913866110bdba6d77f260 Mon Sep 17 00:00:00 2001 From: Alexandre Cases Date: Sun, 8 May 2016 16:29:00 +0200 Subject: [PATCH] Migration fonctionnalités, bugfixes (voir détail) --- src/Controller/MaterielsController.php | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------- src/Model/Table/MaterielsTable.php | 30 ++++++++++++++++++++++++++++++ src/Template/Element/menu.ctp | 2 +- src/Template/Emprunts/index.ctp | 2 +- src/Template/Layout/default.ctp | 2 +- src/Template/Materiels/add.ctp | 19 +++++++++++++++++-- src/Template/Materiels/edit.ctp | 19 +++++++++++++++++-- src/Template/Materiels/find.ctp | 328 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/Template/Materiels/index.ctp | 37 +++++++++++++++++++++++++++++++------ src/Template/Suivis/index.ctp | 2 +- 10 files changed, 614 insertions(+), 30 deletions(-) diff --git a/src/Controller/MaterielsController.php b/src/Controller/MaterielsController.php index a0fb7c9..a251eeb 100755 --- a/src/Controller/MaterielsController.php +++ b/src/Controller/MaterielsController.php @@ -65,13 +65,14 @@ class MaterielsController extends AppController $this->Flash->error(__('Le matériel n\'a pas pu être ajouté.')); } } - $surCategories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $sousCategories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $groupesThematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $groupesMetiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $sites = $this->Materiels->Sites->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); + + $surCategories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SurCategories.nom']); + $categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Categories.nom']); + $sousCategories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SousCategories.nom']); + $groupesThematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesThematiques.nom']); + $groupesMetiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesMetiers.nom']); + $organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Organismes.nom']); + $sites = $this->Materiels->Sites->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Sites.nom']); $utilisateurs = TableRegistry::get('Users')->find('list', [ 'keyField' => 'nom', 'valueField' => 'nom']); @@ -102,13 +103,13 @@ class MaterielsController extends AppController $this->Flash->error(__('Le matériel n\'a pas pu être édité.')); } } - $surCategories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $sousCategories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $groupesThematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $groupesMetiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); - $sites = $this->Materiels->Sites->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); + $surCategories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SurCategories.nom']); + $categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Categories.nom']); + $sousCategories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SousCategories.nom']); + $groupesThematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesThematiques.nom']); + $groupesMetiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesMetiers.nom']); + $organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Organismes.nom']); + $sites = $this->Materiels->Sites->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Sites.nom']); $utilisateurs = TableRegistry::get('Users')->find('list', [ 'keyField' => 'nom', 'valueField' => 'nom']); @@ -143,14 +144,186 @@ class MaterielsController extends AppController return $this->redirect(['action' => 'index']); } + private function statusSetTo($newStatus, $message, $id = null, $from = 'index') { + $materiel = $this->Materiels->get($id)->set('status', $newStatus); + + if ($this->Materiels->save($materiel)) { + $this->Flash->success(__($message)); + } + + return $this->redirect(['action'=>$from, $id]); + } + + public function statusValidated($id = null, $from = 'index') { + $this->statusSetTo('VALIDATED', 'Le matériel a bien été validé', $id, $from); + } + public function statusToBeArchived($id = null, $from = 'index') { + $this->statusSetTo('TOBEARCHIVED', 'La sortie d\'inventaire a bien été demandée', $id, $from); + } + public function statusArchived($id = null, $from = 'index') { + $this->statusSetTo('ARCHIVED', 'Le matériel a bien été sorti de l\'inventaire', $id, $from); + } + + private function getConditionForField($fieldName) { + $searchFieldName = 's_' . $fieldName; + if ( isset($this->request->data[$searchFieldName]) && ($this->request->data[$searchFieldName] != '')) return ["Materiels.$fieldName LIKE" => '%'.$this->request->data[$searchFieldName].'%']; + return NULL; + } + + private function getConditionForFieldNumber($fieldName) { + $searchFieldName = 's_' . $fieldName; + if ( isset($this->request->data[$searchFieldName]) && ($this->request->data[$searchFieldName] != '')) return ["Materiels.$fieldName =" => $this->request->data[$searchFieldName]]; + return NULL; + } + public function find() { + + $s_sur_categories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SurCategories.nom']); + $s_categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Categories.nom']); + $s_sous_categories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SousCategories.nom']); + $s_groupes_thematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesThematiques.nom']); + $s_groupes_metiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesMetiers.nom']); + $s_organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Organismes.nom']); + + $this->set(compact('s_sur_categories', 's_categories', 's_sous_categories', 's_groupes_thematiques', 's_groupes_metiers', 's_organismes')); + + // some data POSTED (au moins le champ de recherche generale) ? + if ( isset($this->request->data['s_all']) || isset($this->request->data['s_all_2']) || isset($this->request->data['designation'])) { + $generalFieldConditions = NULL; + // if general field set (s_all), then set general request for it + if (isset($this->request->data['s_all'])) { + $all = $this->request->data['s_all']; + $generalFieldConditions = ['OR' => [ + 'Materiels.designation LIKE' => '%'.$all.'%', + 'Materiels.numero_laboratoire LIKE' => '%'.$all.'%', + 'Materiels.numero_inventaire_organisme LIKE' => '%'.$all.'%', + 'Materiels.numero_inventaire_old LIKE' => '%'.$all.'%', + 'Materiels.numero_commande LIKE' => '%'.$all.'%', + 'Materiels.description LIKE' => '%'.$all.'%', + 'Materiels.fournisseur LIKE' => '%'.$all.'%', + 'Materiels.nom_responsable LIKE' => '%'.$all.'%', + 'Materiels.email_responsable LIKE' => '%'.$all.'%', + 'Materiels.code_comptable LIKE' => '%'.$all.'%', + 'Materiels.numero_serie LIKE' => '%'.$all.'%', + 'Materiels.date_acquisition LIKE' => '%'.$all.'%', + 'Materiels.date_reception LIKE' => '%'.$all.'%', + ]]; + } + if (isset($this->request->data['s_all_2'])) { + $all = $this->request->data['s_all_2']; + $generalFieldConditions = ['OR' => [ + 'Materiels.designation LIKE' => '%'.$all.'%', + 'Materiels.numero_laboratoire LIKE' => '%'.$all.'%', + 'Materiels.numero_inventaire_organisme LIKE' => '%'.$all.'%', + 'Materiels.numero_inventaire_old LIKE' => '%'.$all.'%', + 'Materiels.numero_commande LIKE' => '%'.$all.'%', + 'Materiels.description LIKE' => '%'.$all.'%', + 'Materiels.fournisseur LIKE' => '%'.$all.'%', + 'Materiels.nom_responsable LIKE' => '%'.$all.'%', + 'Materiels.email_responsable LIKE' => '%'.$all.'%', + 'Materiels.code_comptable LIKE' => '%'.$all.'%', + 'Materiels.numero_serie LIKE' => '%'.$all.'%', + 'Materiels.date_acquisition LIKE' => '%'.$all.'%', + 'Materiels.date_reception LIKE' => '%'.$all.'%', + ]]; + } + $specificFieldsConditions = NULL; + // au moins un champ specifique rempli ? + if ( isset($this->request->data['s_designation']) ) { + // Materiel type + $matostype = $this->request->data['s_matostype']; + $matostypeRequest = NULL; + + switch ($matostype) { + // Administratif + case 'A': + $matostypeRequest['Materiels.materiel_administratif ='] = '1'; + break; + // Technique + case 'T': + $matostypeRequest['Materiels.materiel_technique ='] = '1'; + break; + // Admin et Tech + case 'AT': + $matostypeRequest['Materiels.materiel_administratif ='] = '1'; + $matostypeRequest['Materiels.materiel_technique ='] = '1'; + break; + // Admin ONLY + case 'AO': + $matostypeRequest['Materiels.materiel_administratif ='] = '1'; + $matostypeRequest['Materiels.materiel_technique ='] = '0'; + break; + // Tech ONLY + case 'TO': + $matostypeRequest['Materiels.materiel_administratif ='] = '0'; + $matostypeRequest['Materiels.materiel_technique ='] = '1'; + break; + } + + $periode_acquisitionRequest = NULL; + if ($this->request->data['s_periode_acquisition1'] != '') + $periode_acquisitionRequest['Materiels.date_acquisition >='] = $this->request->data['s_periode_acquisition1']; + if ($this->request->data['s_periode_acquisition2'] != '') + $periode_acquisitionRequest['Materiels.date_acquisition <='] = $this->request->data['s_periode_acquisition2']; + $montantRequest = []; + if ($this->request->data['s_prix_ht_inf'] != '') + $montantRequest['Materiels.prix_ht <='] = $this->request->data['s_prix_ht_inf']; + if ($this->request->data['s_prix_ht_sup'] != '') + $montantRequest['Materiels.prix_ht >='] = $this->request->data['s_prix_ht_sup']; + + $specificFieldsConditions = [ + 'Materiels.designation LIKE' => '%'.$this->request->data['s_designation'].'%', + 'Materiels.numero_laboratoire LIKE' => '%'.$this->request->data['s_numero_laboratoire'].'%', + $this->getConditionForField('numero_commande'), + 'Materiels.date_acquisition LIKE' => '%'.$this->request->data['s_date_acquisition'].'%', + $periode_acquisitionRequest, + $this->getConditionForFieldNumber('prix_ht'), + $montantRequest, + $this->getConditionForFieldNumber('sur_categorie_id'), + $this->getConditionForFieldNumber('categorie_id'), + $this->getConditionForFieldNumber('sous_categorie_id'), + $this->getConditionForField('nom_responsable'), + $this->getConditionForField('numero_inventaire_organisme'), + $this->getConditionForField('numero_inventaire_old'), + $this->getConditionForFieldNumber('groupes_metier_id'), + $this->getConditionForFieldNumber('groupes_thematique_id'), + $this->getConditionForField('status'), + $this->getConditionForFieldNumber('organisme_id'), + $matostypeRequest, + ]; + } + + // CONSTRUCTION DE LA REQUETE SQL COMPLETE = $specificFieldsConditions OR $generalFieldConditions (mais entre chaque champ, c'est un AND) + // by default, no sort + $order = []; + + if (isset($this->passedArgs[0]) && isset($this->passedArgs[1])) { + $order = $this->passedArgs[0]; + $order .= ' '.$this->passedArgs[1]; + } + + if (isset($this->request->data['s_all_2']) && $this->request->data['s_all_2'] != '') { + $conditions = $generalFieldConditions; + } + else if (isset($this->request->data['s_all']) && $this->request->data['s_all'] != '') { + $conditions = $generalFieldConditions; + } + else { + $conditions = $specificFieldsConditions; + } + + $lastResults = $this->Materiels->find('all', ['limit' => 1000, 'order' => $order, 'conditions' => $conditions])->toArray(); + + $this->set('_results', $lastResults); + + } // end if() } public function export() { } - + /** * Activate install mode * diff --git a/src/Model/Table/MaterielsTable.php b/src/Model/Table/MaterielsTable.php index 19bc43f..ddb52ee 100755 --- a/src/Model/Table/MaterielsTable.php +++ b/src/Model/Table/MaterielsTable.php @@ -6,6 +6,7 @@ use Cake\ORM\Query; use Cake\ORM\RulesChecker; use Cake\ORM\Table; use Cake\Validation\Validator; +use Cake\ORM\TableRegistry; /** * Materiels Model @@ -243,4 +244,33 @@ class MaterielsTable extends AppTable $rules->add($rules->existsIn(['site_id'], 'Sites')); return $rules; } + + + public function beforeSave($event, $entity, $options) + { + if(!empty($entity->get('nom_responsable')) && empty($entity->get('nom_responsable'))){ + $entity->set('nom_responsable', $entity->get('nom_ancien_responsable')); + } + + // numero_laboratoire generator (QC changed this in Jan 2015) + if (empty($entity->get('numero_laboratoire')) && !empty($entity->get('date_acquisition'))) { + $year = substr($entity->get('date_acquisition'), 6, 4); + $labName = 'IRAP'; + + $num = TableRegistry::get('Materiels')->find('all', [ + 'fields' => ['numero_laboratoire'], + 'conditions' => ['Materiels.numero_laboratoire LIKE' => $labName.'-'.$year.'%'], + 'order' => ['Materiels.numero_laboratoire DESC'] + ])->first()['numero_laboratoire']; + + $newId = substr($num, -4)+1; + $labNumber = $labName.'-'.$year.'-'.sprintf("%04d", $newId); + + $entity->set('numero_laboratoire', $labNumber); + } + + return true; + } + + } diff --git a/src/Template/Element/menu.ctp b/src/Template/Element/menu.ctp index 41bfc14..6837559 100755 --- a/src/Template/Element/menu.ctp +++ b/src/Template/Element/menu.ctp @@ -34,6 +34,6 @@ Form->create('Materiel', ['url' => '/materiels/find']); - echo ''; + echo ''; echo $this->Form->end(); ?> \ No newline at end of file diff --git a/src/Template/Emprunts/index.ctp b/src/Template/Emprunts/index.ctp index b5c90c9..0674ceb 100755 --- a/src/Template/Emprunts/index.ctp +++ b/src/Template/Emprunts/index.ctp @@ -19,7 +19,7 @@ - Number->format($emprunt->id) ?> + Html->link('Emprunt '.$this->Number->format($emprunt->id), ['action' => 'view', $emprunt->id])?> has('materiel') ? $this->Html->link($emprunt->materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $emprunt->materiel->id]) : '' ?> has('materiel') ? h($emprunt->materiel->numero_laboratoire) : '' ?> emprunt_interne) == '1') { echo 'Interne'; } else { echo 'Externe'; } ?> diff --git a/src/Template/Layout/default.ctp b/src/Template/Layout/default.ctp index eebd453..541aa21 100755 --- a/src/Template/Layout/default.ctp +++ b/src/Template/Layout/default.ctp @@ -93,7 +93,7 @@ $cakeDescription = 'Labinvent 2.0'; - VERSION 2.0.2.2 (06/05/2016) + VERSION 2.0.3.1 (08/05/2016) diff --git a/src/Template/Materiels/add.ctp b/src/Template/Materiels/add.ctp index b1dbe15..2f17de9 100755 --- a/src/Template/Materiels/add.ctp +++ b/src/Template/Materiels/add.ctp @@ -7,9 +7,24 @@ Form->input('designation', ['label' => 'Désignation']); + echo $this->Form->input('sur_categorie_id', ['label' => 'Domaine', 'options' => $surCategories, 'empty' => 'Choisir un domaine']); - echo $this->Form->input('categorie_id', ['label' => 'Catégorie', 'options' => $categories, 'empty' => 'Choisir une catégorie']); - echo $this->Form->input('sous_categorie_id', ['label' => 'Sous-catégorie', 'options' => $sousCategories, 'empty' => 'Choisir une sous-catégorie']); + + // if a domaine is selected, reduce the categories list to this domaine + $categs = $categories; + if (isset ( $this->request->data['sur_categorie_id'] ) && ($this->request->data['sur_categorie_id'] != '')) { + $categs = $categs->where(['sur_categorie_id =' => $this->request->data['sur_categorie_id']]); + } + echo $this->Form->input('categorie_id', ['label' => 'Catégorie', 'options' => $categs, 'empty' => 'Choisir une catégorie']); + + // by default, list is empty + $souscategs = []; + // if a categ is selected, update sous-categs list for this categ (only) + if (isset ( $this->request->data['categorie_id'] ) && ($this->request->data['categorie_id'] != '')) { + $souscategs = $sousCategories; + $souscategs = $souscategs->where(['categorie_id' => $this->request->data['categorie_id']]); + } + echo $this->Form->input('sous_categorie_id', ['label' => 'Sous-catégorie', 'options' => $souscategs, 'empty' => 'Choisir une sous-catégorie']); echo $this->Form->input('materiel_technique', ['label' => 'Technique']); echo $this->Form->input('materiel_administratif', ['label' => 'Inventoriable (>800€)']); diff --git a/src/Template/Materiels/edit.ctp b/src/Template/Materiels/edit.ctp index 59e0ab0..68809d6 100755 --- a/src/Template/Materiels/edit.ctp +++ b/src/Template/Materiels/edit.ctp @@ -69,15 +69,30 @@ if (IS_VALIDATED) 'disabled' => isReadonlyField ( 'sur_categorie_id', $myReadonlyFields ) ]); + + $categs = $categories; + // if a domaine is selected, reduce the categories list to this domaine + if (isset ( $this->request->data['sur_categorie_id'] ) && ($this->request->data['sur_categorie_id'] != '')) { + $categs = $categs->where(['sur_categorie_id =' => $this->request->data['sur_categorie_id']]); + } echo $this->Form->input('categorie_id', [ 'label' => 'Catégorie', - 'options' => $categories, + 'options' => $categs, 'empty' => 'Choisir une catégorie', 'disabled' => isReadonlyField('categorie_id', $myReadonlyFields) ]); + + // SOUS-CATEGORIES + // by default, list is empty + $souscategs = []; + // if a categ is selected, update sous-categs list for this categ (only) + if (isset ( $this->request->data['categorie_id'] ) && ($this->request->data['categorie_id'] != '')) { + $souscategs = $sousCategories; + $souscategs = $souscategs->where(['categorie_id' => $this->request->data['categorie_id']]); + } echo $this->Form->input('sous_categorie_id', [ 'label' => 'Sous-catégorie', - 'options' => $sousCategories, + 'options' => $souscategs, 'empty' => 'Choisir une sous-catégorie', 'disabled' => isReadonlyField('sous_categorie_id', $myReadonlyFields) ]); diff --git a/src/Template/Materiels/find.ctp b/src/Template/Materiels/find.ctp index edef030..a82497a 100644 --- a/src/Template/Materiels/find.ctp +++ b/src/Template/Materiels/find.ctp @@ -1,4 +1,329 @@ +
+

+ Recherche de matériel +

+'; + echo $this->Html->link ( ' Exporter la liste', [ + 'controller' => 'Materiels', + 'action' => 'export', + 'what' => 'search' + ], [ + 'title' => 'Editer le résultat de la recherche', + 'style' => 'margin-right: 15px', + 'escape' => false + ]); + echo '
'; +} +?> + +

+ + style="font-size: 14px;" id="i_filter"> Filtres +

+ +
> '' + ]; + function getSortLinkForColumnTitle($label, $fieldName) { + return " + + "; + } + + // FORMULAIRE DE RECHERCHE + echo $this->Form->create(); + + // -------Bouton recherche Haut--------- + echo $this->Form->submit ( 'Rechercher', ['style' => 'width: 20%']); + + // Designation + echo $this->Form->input ( 's_designation', ['label' => 'Désignation']); + + // Matériel administratif et/ou technique + $typeOptions = []; + echo $this->Form->input ( 's_matostype', [ + 'label' => 'Type', + 'empty' => 'Tous', + 'options' => [ + 'A' => 'Administratif', + 'T' => 'Technique', + 'AT' => 'Administratif et Technique', + 'AO' => 'Administratif seulement', + 'TO' => 'Technique seulement' + ], + 'style' => 'width: 280px' + ]); + + // DOMAINE + echo $this->Form->input ( 's_sur_categorie_id', [ + 'label' => 'Domaine', + 'empty' => 'Tous', + $selected, + 'options' => $s_sur_categories, + 'style' => 'width: 200px' + ]); + + // CATEGORIES + // by default, ALL categs + $categs = $s_categories; + + // if a domaine is selected, reduce the categories list to this domaine + if (isset ( $this->request->data['s_sur_categorie_id'] ) && ($this->request->data['s_sur_categorie_id'] != '')) { + $categs = $categs->where(['sur_categorie_id =' => $this->request->data['s_sur_categorie_id']]); + } + + echo $this->Form->input ( 's_categorie_id', [ + 'label' => 'Catégorie', + 'empty' => 'Toutes', + 'style' => 'width: 200px', + 'options' => $categs + ]); + + // SOUS-CATEGORIES + // by default, list is empty + $souscategs = []; + // if a categ is selected, update sous-categs list for this categ (only) + if (isset ( $this->request->data['s_categorie_id'] ) && ($this->request->data['s_categorie_id'] != '')) { + $souscategs = $s_sous_categories; + $souscategs = $souscategs->where(['categorie_id' => $this->request->data['s_categorie_id']]); + } + + echo $this->Form->input ( 's_sous_categorie_id', [ + 'label' => 'Sous-catégorie', + 'empty' => 'Toutes', + 'style' => 'width: 200px', + 'options' => $souscategs + ]); + + + // STATUT + echo $this->Form->input ( 's_status', [ + 'label' => 'Statut', + 'empty' => 'Tous', + $selected, + 'options' => [ + 'CREATED' => 'Créé', + 'VALIDATED' => 'Validé', + 'TOBEARCHIVED' => 'À archiver', + 'ARCHIVED' => 'Archivé' + ], + 'style' => 'width: 200px' + ]); + + // Groupe metier et thematique + echo $this->Form->input ( 's_groupes_metier_id', [ + 'label' => 'Groupe Métier', + 'empty' => 'Tous', + $selected, + 'options' => $s_groupes_metiers, + 'style' => 'width: 200px' + ]); + echo $this->Form->input ( 's_groupes_thematique_id', [ + 'label' => 'Groupe Thematique', + 'empty' => 'Tous', + $selected, + 'options' => $s_groupes_thematiques, + 'style' => 'width: 200px' + ]); + + // Autres champs + echo $this->Form->input ( 's_numero_commande', [ + 'label' => 'N° BC' + ]); + echo $this->Form->input ( 's_numero_laboratoire', [ + 'label' => 'N° interne (labo)' + ]); + + //ORGANISME + $orgas = $s_organismes; + echo $this->Form->input ( 's_organisme_id', [ + 'label' => 'Organisme', + 'empty' => 'Toutes', + 'style' => 'width: 200px', + 'options' => $orgas + ]); + + echo $this->Form->input ( 's_nom_responsable', [ + 'label' => 'Responsable' + ]); + echo $this->Form->input ( 's_numero_inventaire_organisme', [ + 'label' => 'N° inventaire organisme' + ]); + echo $this->Form->input ( 's_numero_inventaire_old', [ + 'label' => 'N° inventaire (ancien)' + ]); + + // Date acquisition + echo "DATE d'achat:"; + echo $this->Form->input ( 's_date_acquisition', [ + 'placeholder' => 'Cliquez pour selectionner une date', + 'label' => '- Date exacte', + 'class' => 'datepicker' + ]); + echo $this->Form->input ( 's_periode_acquisition1', [ + 'placeholder' => 'Cliquez pour selectionner une date', + 'label' => '- Date Début', + 'class' => 'datepicker' + ]); + echo $this->Form->input ( 's_periode_acquisition2', [ + 'placeholder' => 'Cliquez pour selectionner une date', + 'label' => '- Date Fin', + 'class' => 'datepicker' + ]); + + echo "MONTANT :"; + echo $this->Form->input ( 's_prix_ht', ['label' => '- Montant exact']); + echo $this->Form->input ( 's_prix_ht_sup', ['label' => '- Montant sup. ou égal à']); + echo $this->Form->input ( 's_prix_ht_inf', ['label' => '- Montant inf. ou égal à']); + + // CHAMP DE RECHERCHE GENERIQUE + echo $this->Form->input ( 's_all', ['label' => 'TOUS LES CHAMPS' ]); + + // -------Bouton recherche Bas--------- + echo $this->Form->submit('Rechercher', ['style' => 'width: 20%']); + echo '


'; + ?> +
+ +

+ + style="font-size: 14px;" id="i_result"> Résultats +

+
> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + /* + * ACTION 'edit' + */ + echo ''; + + echo ''; + + /* + * ACTION 'delete' + */ + // Seul un materiel CREATED peut être supprimer + if ($material->status == 'CREATED') { + echo ''; + } + + echo ''; + endforeach; + echo ''; + echo '
'; + echo $this->Html->link ( h($material->designation), [ + 'action' => 'view', + $material->id + ], ['title' => 'Détails']); + echo ''; + echo $material->numero_laboratoire; + echo ''; + echo $this->Html->link ( $material->nom, [ + 'controller' => 'categories', + 'action' => 'view', + $material->id + ]); + echo ''; + echo $material->nom_responsable; + echo ''; + echo $material->status; + echo ''; + echo date ( "d-m-Y", strtotime ( $material->date_acquisition )); + echo ''; + + echo $this->Html->link('', + ['action' => 'edit', $material->id], + ['title' => 'Éditer', 'style' => 'margin: 0 2px', 'escape' => false] + ); + echo ''; + + if(h($material->status) == 'CREATED') { + echo $this->Form->postLink('', + ['action' => 'statusValidated', $material->id], + ['title' => 'Valider', 'style' => 'margin: 0 2px', 'escape' => false, + 'confirm' => __('Êtes-vous sur de vouloir validé # {0}?', $material->designation)]); + } + else if ($material->status == 'VALIDATED' && $material->nom_responsable == $username) { + echo $this->Form->postLink('', + ['action' => 'statusToBeArchived', $material->id], + ['title' => 'Demander la sortie de l\'inventaire', 'style' => 'margin: 0 2px', 'escape' => false, + 'confirm' => __('Êtes-vous sur de vouloir faire une demande d\'archive # {0}?', $material->designation)]); + + } + else if (h($material->status) == 'VALIDATED'){ + echo $this->Form->postLink('', + ['action' => 'statusArchived', $material->id], + ['title' => 'Sortir de l\'inventaire', 'style' => 'margin: 0 2px', 'escape' => false, + 'confirm' => __('Êtes-vous sur de vouloir archivé # {0}?', $material->designation)]); + } + echo ''; + echo $this->Form->postLink(__(''), + ['action' => 'delete', $material->id], + ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $material->id)] + ); + echo '
'; + + } else { + echo 'Aucun résultats pour cette recherche.'; + } + ?> +
+ + Form->end(); + ?> + @@ -6,4 +331,5 @@
element('menu') ?> -
\ No newline at end of file + + diff --git a/src/Template/Materiels/index.ctp b/src/Template/Materiels/index.ctp index 232c908..213caee 100755 --- a/src/Template/Materiels/index.ctp +++ b/src/Template/Materiels/index.ctp @@ -13,6 +13,8 @@ Paginator->sort('date_acquisition', 'Date Achat') ?> Paginator->sort('etiquette', 'Et') ?> + + @@ -30,14 +32,37 @@ Html->link(__(''), ['action' => 'edit', $materiel->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]) ?> - + + bouton valider/archivé - //$this->Html->link(__(''), ['action' => 'view', $materiel->id], ['title' => 'Visualiser', 'style' => 'margin: 0 2px', 'escape' => false ]) - - //A implementer --> bouton suppression caché si matériel validé + if(h($materiel->status) == 'CREATED') { + echo $this->Form->postLink('', + ['action' => 'statusValidated', $materiel->id], + ['title' => 'Valider', 'style' => 'margin: 0 2px', 'escape' => false, + 'confirm' => __('Êtes-vous sur de vouloir validé # {0}?', $materiel->designation)]); + } + else if (h($materiel->status) == 'VALIDATED' && h($materiel->nom_responsable) == $username) { + echo $this->Form->postLink('', + ['action' => 'statusToBeArchived', $materiel->id], + ['title' => 'Demander la sortie de l\'inventaire', 'style' => 'margin: 0 2px', 'escape' => false, + 'confirm' => __('Êtes-vous sur de vouloir faire une demande d\'archive # {0}?', $materiel->designation)]); + + } + else if (h($materiel->status) == 'VALIDATED'){ + echo $this->Form->postLink('', + ['action' => 'statusArchived', $materiel->id], + ['title' => 'Sortir de l\'inventaire', 'style' => 'margin: 0 2px', 'escape' => false, + 'confirm' => __('Êtes-vous sur de vouloir archivé # {0}?', $materiel->designation)]); + } + ?> - Form->postLink(__(''), ['action' => 'delete', $materiel->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $materiel->id)]) ?> + + + status) == 'CREATED') { + echo $this->Form->postLink(__(''), ['action' => 'delete', $materiel->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $materiel->designation)]); + } + ?> diff --git a/src/Template/Suivis/index.ctp b/src/Template/Suivis/index.ctp index e60c1ec..2311839 100755 --- a/src/Template/Suivis/index.ctp +++ b/src/Template/Suivis/index.ctp @@ -16,7 +16,7 @@ - Number->format($suivi->id) ?> + Html->link('Suivi '.$this->Number->format($suivi->id), ['action' => 'view', $suivi->id])?> has('materiel') ? $this->Html->link($suivi->materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $suivi->materiel->id]) : '' ?> has('materiel') ? h($suivi->materiel->numero_laboratoire) : '' ?> date_controle) ?> -- libgit2 0.21.2