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 @@ -
= $this->Paginator->sort('id', 'N°') ?> | -= $this->Paginator->sort('chemin', 'Chemin') ?> | -= $this->Paginator->sort('type_doc', 'Type') ?> | = $this->Paginator->sort('materiel_id', 'Materiel') ?> | = $this->Paginator->sort('suivi_id', 'Suivi') ?> | -= $this->Paginator->sort('materiel_id', 'Numéro Materiel (labo)') ?> | += $this->Paginator->sort('type_doc', 'Type') ?> | = __('') ?> | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
= 'Fichier '.$this->Number->format($document->id) ?> | -= h($document->chemin) ?> | -= h($document->type_doc) ?> | -= $document->has('materiel') ? $this->Html->link($document->materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $document->materiel->id]) : '' ?> | -= $document->has('suivi') ? $this->Html->link('Suivi '.$document->suivi->id, ['controller' => 'Suivis', 'action' => 'view', $document->suivi->id]) : '' ?> | -= $document->has('materiel') ? $document->materiel->numero_laboratoire : '' ?> | += $this->Html->link('Fichier '.$this->Number->format($document->id), ['action' => 'view', $document->id]) ?> | + + materiel_id)) { ?> += $this->Html->link($materiel->find()->where(['id =' => $document->materiel_id])->first()['designation'], ['controller' => 'Materiels', 'action' => 'view', $document->materiel_id]) ?> | ++ + | + | = $this->Html->link('Suivi '.$document->suivi_id, ['controller' => 'Suivis', 'action' => 'view', $document->suivi_id]) ?> | + += h($document->type_doc) ?> |
= $this->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 |