From 4fd23929311c4e01bb2ab6507b13b78cd69dba01 Mon Sep 17 00:00:00 2001 From: Alexandre Cases Date: Tue, 7 Jun 2016 15:29:41 +0200 Subject: [PATCH] Version: 2.5.0 --- README-LABINVENT.md | 12 +++++++----- database/labinvent_2.1_12-05-16.sql | 7 ++++--- database/update/db-update-2016-06-07.sql | 16 ++++++++++++++++ database/update/update_Donnees_IAS_Labinvent2.sql | 6 ++++-- database/update/update_Donnees_IRAP_Labinvent2.sql | 17 +++++++++++++++++ src/Controller/AppController.php | 2 +- src/Controller/DocumentsController.php | 51 ++++++++++++++++++++++++++++++++++++++------------- src/Model/Entity/Document.php | 1 + src/Model/Table/DocumentsTable.php | 13 +++++++++++-- src/Template/Documents/add.ctp | 25 ++++++++++++++++++++----- src/Template/Documents/edit.ctp | 24 +++++++++++++++++++----- src/Template/Documents/index.ctp | 26 ++++++++++++++------------ src/Template/Documents/view.ctp | 24 +++++++++++++++--------- src/Template/Materiels/view.ctp | 20 ++++++++++---------- src/Template/Suivis/view.ctp | 13 ++++++++++++- tests/Fixture/DocumentsFixture.php | 8 +++++--- 16 files changed, 194 insertions(+), 71 deletions(-) create mode 100755 database/update/db-update-2016-06-07.sql diff --git a/README-LABINVENT.md b/README-LABINVENT.md index d97f6ce..26da12c 100755 --- a/README-LABINVENT.md +++ b/README-LABINVENT.md @@ -50,14 +50,16 @@ Logiciel testé et validé sur les configurations suivantes : VERSION ACTUELLE -Date: 07/06/2016 (Version 2.4 finale) -Version: 2.4.2.25 +Date: 07/06/2016 +Version: 2.5.0 -Implémentation des ACL (droits) - Version Final +!!! MAJ BD !!! +Modification table documents (mise en place vue) -Demande (terminée): https://projects.irap.omp.eu/issues/3579 +Demande (en cours): https://projects.irap.omp.eu/issues/3716 + https://projects.irap.omp.eu/issues/3762 -Version majeure en cours (2.4): https://projects.irap.omp.eu/versions/107 +Version majeure en cours (2.5): https://projects.irap.omp.eu/versions/99 ROADMAP: https://projects.irap.omp.eu/projects/labinvent/roadmap diff --git a/database/labinvent_2.1_12-05-16.sql b/database/labinvent_2.1_12-05-16.sql index 2f49394..8c1578a 100755 --- a/database/labinvent_2.1_12-05-16.sql +++ b/database/labinvent_2.1_12-05-16.sql @@ -72,9 +72,10 @@ DROP TABLE IF EXISTS `documents`; CREATE TABLE IF NOT EXISTS `documents` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type_doc` varchar(20) DEFAULT NULL, - `chemin` varchar(60) DEFAULT NULL, - `materiel_id` int(11) NOT NULL, - `suivi_id` int(11) NOT NULL, + `description` varchar(100) DEFAULT NULL, + `chemin` varchar(100) DEFAULT NULL, + `materiel_id` int(11) DEFAULT NULL, + `suivi_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_documents_materiel_id` (`materiel_id`), KEY `fk_documents_suivi_id` (`suivi_id`) diff --git a/database/update/db-update-2016-06-07.sql b/database/update/db-update-2016-06-07.sql new file mode 100755 index 0000000..fc1ece1 --- /dev/null +++ b/database/update/db-update-2016-06-07.sql @@ -0,0 +1,16 @@ +DROP TABLE IF EXISTS `documents`; +CREATE TABLE IF NOT EXISTS `documents` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `type_doc` varchar(20) DEFAULT NULL, + `description` varchar(100) DEFAULT NULL, + `chemin` varchar(100) DEFAULT NULL, + `materiel_id` int(11) DEFAULT NULL, + `suivi_id` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `fk_documents_materiel_id` (`materiel_id`), + KEY `fk_documents_suivi_id` (`suivi_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +ALTER TABLE `documents` + ADD CONSTRAINT `fk_documents_materiel_id` FOREIGN KEY (`materiel_id`) REFERENCES `materiels` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + ADD CONSTRAINT `fk_documents_suivi_id` FOREIGN KEY (`suivi_id`) REFERENCES `suivis` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; diff --git a/database/update/update_Donnees_IAS_Labinvent2.sql b/database/update/update_Donnees_IAS_Labinvent2.sql index c568a73..fb8267f 100644 --- a/database/update/update_Donnees_IAS_Labinvent2.sql +++ b/database/update/update_Donnees_IAS_Labinvent2.sql @@ -120,8 +120,10 @@ CREATE TABLE IF NOT EXISTS `documents` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type_doc` varchar(20) DEFAULT NULL, `chemin` varchar(60) DEFAULT NULL, - `materiel_id` int(11) NOT NULL, - `suivi_id` int(11) NOT NULL, + `description` varchar(100) DEFAULT NULL, + `chemin` varchar(100) DEFAULT NULL, + `materiel_id` int(11) DEFAULT NULL, + `suivi_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_documents_materiel_id` (`materiel_id`), KEY `fk_documents_suivi_id` (`suivi_id`) diff --git a/database/update/update_Donnees_IRAP_Labinvent2.sql b/database/update/update_Donnees_IRAP_Labinvent2.sql index 29abb68..d85797f 100644 --- a/database/update/update_Donnees_IRAP_Labinvent2.sql +++ b/database/update/update_Donnees_IRAP_Labinvent2.sql @@ -115,4 +115,21 @@ ALTER TABLE `suivis` DROP `type_intervention`; Alter table `suivis` Add `type_frequence` VARCHAR(30) DEFAULT NULL; +DROP TABLE IF EXISTS `documents`; +CREATE TABLE IF NOT EXISTS `documents` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `type_doc` varchar(20) DEFAULT NULL, + `description` varchar(100) DEFAULT NULL, + `chemin` varchar(100) DEFAULT NULL, + `materiel_id` int(11) DEFAULT NULL, + `suivi_id` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `fk_documents_materiel_id` (`materiel_id`), + KEY `fk_documents_suivi_id` (`suivi_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +ALTER TABLE `documents` + ADD CONSTRAINT `fk_documents_materiel_id` FOREIGN KEY (`materiel_id`) REFERENCES `materiels` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + ADD CONSTRAINT `fk_documents_suivi_id` FOREIGN KEY (`suivi_id`) REFERENCES `suivis` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; + COMMIT; diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 3750801..c81c69e 100755 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -187,7 +187,7 @@ class AppController extends Controller //$configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); //$to = $configuration->emailGuest2; - $to = "labinvent2@gmail.co"; + $to = "labinvent2gmail.co"; if (filter_var($to, FILTER_VALIDATE_EMAIL)) { $email = new Email(); diff --git a/src/Controller/DocumentsController.php b/src/Controller/DocumentsController.php index 97bacc7..803fa52 100755 --- a/src/Controller/DocumentsController.php +++ b/src/Controller/DocumentsController.php @@ -42,12 +42,11 @@ class DocumentsController extends AppController */ public function index() { - $this->paginate = [ - 'contain' => ['Materiels', 'Suivis'] - ]; $documents = $this->paginate($this->Documents); - $this->set(compact('documents')); + $materiel = $this->Documents->Materiels; + + $this->set(compact('documents', 'materiel')); $this->set('_serialize', ['documents']); } @@ -60,10 +59,18 @@ class DocumentsController extends AppController */ public function view($id = null) { - $document = $this->Documents->get($id, [ - 'contain' => ['Materiels', 'Suivis'] - ]); + $document = $this->Documents->get($id); + $materiel = $this->Documents->Materiels->find()->where(['id =' => $document->materiel_id])->first(); + + if($materiel != null) { + $this->set('materiel', $materiel); + } + else { + $suivi = $this->Documents->Suivis->find()->where(['id =' => $document->suivi_id])->first(); + $this->set('suivi', $suivi); + } + $this->set('document', $document); $this->set('_serialize', ['document']); } @@ -85,9 +92,18 @@ class DocumentsController extends AppController $this->Flash->error(__('Le fichier n\'a pas pu être ajouté.')); } } - $materiels = $this->Documents->Materiels->find('list', ['limit' => 200]); - $suivis = $this->Documents->Suivis->find('list', ['limit' => 200]); - $this->set(compact('document', 'materiels', 'suivis')); + + if(isset($this->passedArgs[1]) && $this->passedArgs[1] == 'mat') { + $materiel = $this->Documents->Materiels->find('list', [ 'keyField' => 'id', 'valueField' => 'numero_laboratoire'])->where(['id =' => $this->passedArgs[0]]); + $this->set('materiel', $materiel); + } + else { + $suivi = $this->Documents->Suivis->find('list', [ 'keyField' => 'id', 'valueField' => 'id'])->where(['id =' => $this->passedArgs[0]]); + $this->set('suivi', $suivi); + } + + + $this->set(compact('document')); $this->set('_serialize', ['document']); } @@ -112,9 +128,18 @@ class DocumentsController extends AppController $this->Flash->error(__('Le fichier n\'a pas pu être édité.')); } } - $materiels = $this->Documents->Materiels->find('list', ['limit' => 200]); - $suivis = $this->Documents->Suivis->find('list', ['limit' => 200]); - $this->set(compact('document', 'materiels', 'suivis')); + + $materiel = $this->Documents->Materiels->find('list', [ 'keyField' => 'id', 'valueField' => 'numero_laboratoire'])->where(['id =' => $document->materiel_id]); + if($materiel->count() > 0) { + $this->set('materiel', $materiel); + } + else { + $suivi = $this->Documents->Suivis->find('list', [ 'keyField' => 'id', 'valueField' => 'id'])->where(['id =' => $document->suivi_id]); + $this->set('suivi', $suivi); + } + + + $this->set(compact('document')); $this->set('_serialize', ['document']); } diff --git a/src/Model/Entity/Document.php b/src/Model/Entity/Document.php index ac3f2d0..71455b7 100755 --- a/src/Model/Entity/Document.php +++ b/src/Model/Entity/Document.php @@ -9,6 +9,7 @@ use Cake\ORM\Entity; * @property int $id * @property string $type_doc * @property string $chemin + * @property string $description * @property int $materiel_id * @property \App\Model\Entity\Materiel $materiel * @property int $suivi_id diff --git a/src/Model/Table/DocumentsTable.php b/src/Model/Table/DocumentsTable.php index 9477040..6a45db5 100755 --- a/src/Model/Table/DocumentsTable.php +++ b/src/Model/Table/DocumentsTable.php @@ -57,6 +57,15 @@ class DocumentsTable extends AppTable $validator ->allowEmpty('chemin'); + + $validator + ->allowEmpty('description'); + + $validator + ->allowEmpty('materiel_id'); + + $validator + ->allowEmpty('suivi_id'); return $validator; } @@ -67,11 +76,11 @@ class DocumentsTable extends AppTable * * @param \Cake\ORM\RulesChecker $rules The rules object to be modified. * @return \Cake\ORM\RulesChecker - */ + * public function buildRules(RulesChecker $rules) { $rules->add($rules->existsIn(['materiel_id'], 'Materiels')); $rules->add($rules->existsIn(['suivi_id'], 'Suivis')); return $rules; - } + }*/ } diff --git a/src/Template/Documents/add.ctp b/src/Template/Documents/add.ctp index 91c01aa..e49f782 100755 --- a/src/Template/Documents/add.ctp +++ b/src/Template/Documents/add.ctp @@ -1,15 +1,30 @@ -
+
Form->create($document) ?>
- +

Lier un document

Form->input('materiel_id', ['label' => 'N° materiel labo', 'options' => $materiel, 'default' => $this->passedArgs[0], 'readonly' => TRUE]); + } + else if(isset($suivi)) { + echo $this->Form->input('suivi_id', ['label' => 'N° suivi', 'options' => $suivi, 'default' => $this->passedArgs[0], 'readonly' => TRUE]); + } + echo $this->Form->input('type_doc'); + echo $this->Form->input('description'); echo $this->Form->input('chemin'); - echo $this->Form->input('materiel_id', ['options' => $materiels]); - echo $this->Form->input('suivi_id', ['options' => $suivis]); + + ?>
- Form->button(__('Submit')) ?> + Form->submit(__('Valider')) ?> Form->end() ?>
+ +
+ element('menu'); + echo $this->element('menu_form', [ 'pluralHumanName' => 'Documents' ]); + ?> +
diff --git a/src/Template/Documents/edit.ctp b/src/Template/Documents/edit.ctp index 0f77944..10a6bc3 100755 --- a/src/Template/Documents/edit.ctp +++ b/src/Template/Documents/edit.ctp @@ -1,15 +1,29 @@ -
+
Form->create($document) ?>
- +

Editer document

Form->input('materiel_id', ['label' => 'N° materiel labo', 'options' => $materiel, 'readonly' => TRUE]); + } + else if(isset($suivi)) { + echo $this->Form->input('suivi_id', ['label' => 'N° suivi', 'options' => $suivi, 'readonly' => TRUE]); + } + echo $this->Form->input('type_doc'); + echo $this->Form->input('description'); echo $this->Form->input('chemin'); - echo $this->Form->input('materiel_id', ['options' => $materiels]); - echo $this->Form->input('suivi_id', ['options' => $suivis]); + ?>
- Form->button(__('Submit')) ?> + Form->submit(__('Valider')) ?> Form->end() ?>
+ +
+ element('menu'); + echo $this->element('menu_form', [ 'pluralHumanName' => 'Documents' ]); + ?> +
\ No newline at end of file diff --git a/src/Template/Documents/index.ctp b/src/Template/Documents/index.ctp index 87ff89e..6d995fc 100755 --- a/src/Template/Documents/index.ctp +++ b/src/Template/Documents/index.ctp @@ -1,27 +1,29 @@
- Liste des fichiers'; ?> + Liste des documents'; ?> - - - + - - - - - - + + + materiel_id)) { ?> + + + + + + +
Paginator->sort('id', 'N°') ?>Paginator->sort('chemin', 'Chemin') ?>Paginator->sort('type_doc', 'Type') ?> Paginator->sort('materiel_id', 'Materiel') ?> Paginator->sort('suivi_id', 'Suivi') ?>Paginator->sort('materiel_id', 'Numéro Materiel (labo)') ?>Paginator->sort('type_doc', 'Type') ?>
Number->format($document->id) ?>chemin) ?>type_doc) ?>has('materiel') ? $this->Html->link($document->materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $document->materiel->id]) : '' ?>has('suivi') ? $this->Html->link('Suivi '.$document->suivi->id, ['controller' => 'Suivis', 'action' => 'view', $document->suivi->id]) : '' ?>has('materiel') ? $document->materiel->numero_laboratoire : '' ?>Html->link('Fichier '.$this->Number->format($document->id), ['action' => 'view', $document->id]) ?>Html->link($materiel->find()->where(['id =' => $document->materiel_id])->first()['designation'], ['controller' => 'Materiels', 'action' => 'view', $document->materiel_id]) ?>Html->link('Suivi '.$document->suivi_id, ['controller' => 'Suivis', 'action' => 'view', $document->suivi_id]) ?>type_doc) ?> Html->link(__(''), ['action' => 'view', $document->id], ['title' => 'Visualiser', 'style' => 'margin: 0 2px', 'escape' => false ]) ?> @@ -46,6 +48,6 @@
element('menu') ?> element('menu_index', - [ 'pluralHumanName' => 'Fichiers', - 'singularHumanName' => 'Fichier' ]) ?> + [ 'pluralHumanName' => 'Documents', + 'singularHumanName' => 'DOcument' ]) ?>
\ No newline at end of file diff --git a/src/Template/Documents/view.ctp b/src/Template/Documents/view.ctp index 3c04387..51132a3 100755 --- a/src/Template/Documents/view.ctp +++ b/src/Template/Documents/view.ctp @@ -1,28 +1,34 @@
-

Détail fichier

+

Détail document

Html->link(__(' Editer ce fichier'), + echo $this->Html->link(__(' Editer ce document'), ['action' => 'edit', $document->id], ['escape' => false,'onclick' => 'return true;'] ); - echo $this->Form->postLink(__(' Supprimer ce fichier'), + echo $this->Form->postLink(__(' Supprimer ce document'), ['action' => 'delete', $document->id], ['style'=>'margin-left: 110px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $document->id)] ); + if(isset($materiel)) { + $displayElement(__('Materiel'), $this->Html->link($materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $materiel->id])); + } + else if(isset($suivi)) { + $displayElement(__('Suivi'), $this->Html->link('Suivi '.$suivi->id, ['controller' => 'Suivis', 'action' => 'view', $suivi->id])); + } + $displayElement(__('N°'), 'Fichier '.$this->Number->format($document->id)); - $displayElement(__('Chemin'), h($document->chemin)); $displayElement(__('Type'), h($document->type_doc)); - $displayElement(__('Materiel'), $document->has('materiel') ? $this->Html->link($document->materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $document->materiel->id]) : ''); - $displayElement(__('Suivi'), 'Suivi '.$document->has('suivi') ? $this->Html->link('Suivi '.$document->suivi->id, ['controller' => 'Suivis', 'action' => 'view', $document->suivi->id]) : '' ); - $displayElement(__('Numéro interne (labo)'), $document->has('materiel') ? h($document->materiel->numero_laboratoire) : ''); + $displayElement(__('Description'), h($document->chemin)); + $displayElement(__('Chemin'), h($document->chemin)); + ?> @@ -33,7 +39,7 @@
element('menu') ?> element('menu_view', - [ 'pluralHumanName' => 'Fichiers', - 'singularHumanName' => 'Fichier', + [ 'pluralHumanName' => 'Documents', + 'singularHumanName' => 'Document', 'lien' => $document->id ]) ?>
\ No newline at end of file diff --git a/src/Template/Materiels/view.ctp b/src/Template/Materiels/view.ctp index c970aa1..b87cb7a 100755 --- a/src/Template/Materiels/view.ctp +++ b/src/Template/Materiels/view.ctp @@ -62,18 +62,18 @@ ); // End link - /*echo $this->Html->link(' Lier un Doc.', - ['controller' => 'documents', - 'action' => 'add', - 'mat' => $materiel->id, - ], - ['title' => 'Attacher un Doc. à ce matériel', - 'style' => 'margin-right: 10px', - 'escape' => false - ] - );*/ + } + echo $this->Html->link(' Lier un Doc.', + ['controller' => 'documents', + 'action' => 'add', + $materiel->id, 'mat'], + ['title' => 'Attacher un Doc. à ce matériel', + 'style' => 'margin-right: 10px', + 'escape' => false] + ); + if(in_array($role, ['Administration', 'Administration Plus', 'Super Administrateur'])) { if (($materiel->status == 'VALIDATED') || ($materiel->status == 'CREATED')) { echo $this->Html->link(' Doc. admission', diff --git a/src/Template/Suivis/view.ctp b/src/Template/Suivis/view.ctp index 5d785d3..3ae8612 100755 --- a/src/Template/Suivis/view.ctp +++ b/src/Template/Suivis/view.ctp @@ -13,10 +13,21 @@ ); echo $this->Form->postLink(__(' Supprimer ce suivi'), ['action' => 'delete', $suivi->id], - ['style'=>'margin-left: 140px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $suivi->id)] + ['style'=>'margin-left: 100px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $suivi->id)] + ); + + echo $this->Html->link(' Lier un Doc.', + ['controller' => 'documents', + 'action' => 'add', + $suivi->id], + ['title' => 'Attacher un Doc. à ce suivi', + 'style' => 'margin-left: 100px', + 'escape' => false] ); } + + $displayElement(__('Materiel'), $suivi->has('materiel') ? $this->Html->link($suivi->materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $suivi->materiel->id]) : ''); $displayElement(__('Numéro interne (labo)'), $suivi->has('materiel') ? h($suivi->materiel->numero_laboratoire) : ''); $displayElement(__('Date Intervention'), h($suivi->date_controle)); diff --git a/tests/Fixture/DocumentsFixture.php b/tests/Fixture/DocumentsFixture.php index 06d4004..87ebf6a 100755 --- a/tests/Fixture/DocumentsFixture.php +++ b/tests/Fixture/DocumentsFixture.php @@ -19,9 +19,10 @@ class DocumentsFixture extends TestFixture public $fields = [ 'id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], 'type_doc' => ['type' => 'string', 'length' => 20, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], - 'chemin' => ['type' => 'string', 'length' => 60, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], - 'materiel_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], - 'suivi_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'description' => ['type' => 'string', 'length' => 100, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], + 'chemin' => ['type' => 'string', 'length' => 100, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], + 'materiel_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'suivi_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], '_indexes' => [ 'fk_documents_materiel_id' => ['type' => 'index', 'columns' => ['materiel_id'], 'length' => []], 'fk_documents_suivi_id' => ['type' => 'index', 'columns' => ['suivi_id'], 'length' => []], @@ -46,6 +47,7 @@ class DocumentsFixture extends TestFixture public $records = [ [ 'id' => 1, + 'description' => 'dsfdssdf', 'type_doc' => 'Lorem ipsum dolor ', 'chemin' => 'Lorem ipsum dolor sit amet', 'materiel_id' => 3, -- libgit2 0.21.2