From 3ab8435bee8536ef1c0017dd9cb516bdc44afa25 Mon Sep 17 00:00:00 2001 From: Alexandre Cases Date: Thu, 23 Jun 2016 10:39:21 +0200 Subject: [PATCH] Version: 2.4.6.4 --- README-LABINVENT.md | 15 +++++++++------ config/app.default.php | 28 ++++++++++++++-------------- database/labinvent_2.1_12-05-16.sql | 2 +- database/update/db-update-2016-06-22.sh | 18 ++++++++++++++++++ database/update/script_sql/db-update-2016-06-22.sql | 3 +++ database/update/update_Donnees_IAS_Labinvent2.sql | 2 +- src/Controller/AppController.php | 8 +++++--- src/Controller/SuivisController.php | 24 ++++++++++++++++++++++++ src/Model/Entity/Configuration.php | 2 +- src/Model/Table/AppTable.php | 4 +++- src/Model/Table/ConfigurationsTable.php | 10 +++++----- src/Template/Configurations/edit.ctp | 2 +- src/Template/Configurations/view.ctp | 2 +- src/Template/Layout/default.ctp | 6 +++--- src/Template/Suivis/add.ctp | 39 +++++++++++++++++++++++++++++++++++++-- src/Template/Suivis/edit.ctp | 39 +++++++++++++++++++++++++++++++++++++-- src/Template/Suivis/get_next_date.ctp | 3 +++ tests/Fixture/ConfigurationsFixture.php | 4 ++-- 18 files changed, 168 insertions(+), 43 deletions(-) create mode 100755 database/update/db-update-2016-06-22.sh create mode 100755 database/update/script_sql/db-update-2016-06-22.sql create mode 100755 src/Template/Suivis/get_next_date.ctp diff --git a/README-LABINVENT.md b/README-LABINVENT.md index 05e1464..17feab8 100755 --- a/README-LABINVENT.md +++ b/README-LABINVENT.md @@ -50,13 +50,14 @@ Logiciel testé et validé sur les configurations suivantes : VERSION ACTUELLE -Date: 21/06/2016 -Version: 2.4.6.3 +Date: 23/06/2016 +Version: 2.4.6.4 -Materiels (date_archivage) + materiel (fonctionnent responsable si gmétier OU gthématique) +!!! Se placer dans ./database/update et exécuter le script database/update/db-update-2016-06-22.sh !!! -Demande (terminé) : https://projects.irap.omp.eu/issues/3803 - https://projects.irap.omp.eu/issues/3808 +calcul date suivi + ajout sender configurations + +Demande (terminé) : https://projects.irap.omp.eu/issues/3805 Version majeure en cours (2.4): https://projects.irap.omp.eu/versions/107 @@ -92,7 +93,9 @@ Liste complète des évolutions: https://gitlab.irap.omp.eu/epallier/labinvent/c MODIFICATIONS STRUCTURELLES A FAIRE MANUELLEMENT APRES LA MISE A JOUR (git pull) -20/06/16 (v2.4.6.0) Exécuter le script database/update/db-update-2016-06-20.sh +23/06/16 (v2.4.6.4) Se placer dans ./database/update et exécuter le script database/update/db-update-2016-06-22.sh + +20/06/16 (v2.4.6.0) Se placer dans ./database/update et exécuter le script database/update/db-update-2016-06-20.sh 17/06/16 (v2.4.4.4) (Exceptionnel) Exécuter les lignes suivantes (à la racine) : cp -p config/app.php ../config/app.php.ORIG diff --git a/config/app.default.php b/config/app.default.php index 6842ccb..50e6d7d 100755 --- a/config/app.default.php +++ b/config/app.default.php @@ -188,20 +188,20 @@ return [ 'tls' => null, 'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null), ], - 'dev' => [ - 'className' => 'Smtp', - 'host' => 'ssl://smtp.gmail.com', - 'port' => 465, - 'username' => 'labinvent2@gmail.com', - 'password' => 'cakephp3', - 'context' => [ - 'ssl' => [ - 'verify_peer' => false, - 'verify_peer_name' => false, - 'allow_self_signed' => true - ] - ] - ], + 'dev' => [ + 'className' => 'Smtp', + 'host' => 'ssl://smtp.gmail.com', + 'port' => 465, + 'username' => 'xxxxxxxxxxxxxxxxxxxxx', + 'password' => 'xxxxxxxxxxxxxxxxxxxxx', + 'context' => [ + 'ssl' => [ + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed' => true + ] + ] + ], ], /** diff --git a/database/labinvent_2.1_12-05-16.sql b/database/labinvent_2.1_12-05-16.sql index 9905f7b..933dc37 100755 --- a/database/labinvent_2.1_12-05-16.sql +++ b/database/labinvent_2.1_12-05-16.sql @@ -335,7 +335,7 @@ CREATE TABLE IF NOT EXISTS `configurations` ( `nom_groupe_thematique` varchar(50) DEFAULT 'Groupe thematique', `nom_groupe_metier` varchar(50) DEFAULT 'Groupe metier', `envoi_mail_management_dev` tinyint(1) DEFAULT NULL, - `from_mail` varchar(200) DEFAULT 'localhost.com', + `sender_mail` varchar(500) DEFAULT 'labinvent@irap.omp.eu', `emailGuest1` varchar(45) DEFAULT NULL, `emailGuest2` varchar(45) DEFAULT NULL, `emailGuest3` varchar(45) DEFAULT NULL, diff --git a/database/update/db-update-2016-06-22.sh b/database/update/db-update-2016-06-22.sh new file mode 100755 index 0000000..0a35d28 --- /dev/null +++ b/database/update/db-update-2016-06-22.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +username=$(grep "/\*d\*/'username'" ../../config/app.php | cut -d"'" -f4) +password=$(grep "/\*d\*/'password'" ../../config/app.php | cut -d"'" -f4) +database=$(grep "/\*d\*/'database'" ../../config/app.php | cut -d"'" -f4) +host=$(grep "/\*d\*/'host'" ../../config/app.php | cut -d"'" -f4) + +cp -p ./script_sql/db-update-2016-06-22.sql ./script_sql/db-update-2016-06-22-build.sql + +sed -e "s/database/$database/" -i ./script_sql/db-update-2016-06-22-build.sql +mysql --user=$username --password=$password -h $host < ./script_sql/db-update-2016-06-22-build.sql + +sudo rm ../../tmp/cache/models/* +sudo rm ../../tmp/cache/persistent/* + +sudo chmod -R 777 ../../tmp +sudo chmod -R 777 ../../vendor +sudo chmod -R 777 ../../webroot diff --git a/database/update/script_sql/db-update-2016-06-22.sql b/database/update/script_sql/db-update-2016-06-22.sql new file mode 100755 index 0000000..a3f05d7 --- /dev/null +++ b/database/update/script_sql/db-update-2016-06-22.sql @@ -0,0 +1,3 @@ +ALTER TABLE `configurations` DROP `from_mail`; + +ALTER TABLE `configurations` ADD `sender_mail` varchar(500) DEFAULT 'labinvent@irap.omp.eu'; diff --git a/database/update/update_Donnees_IAS_Labinvent2.sql b/database/update/update_Donnees_IAS_Labinvent2.sql index e57e761..4b74a19 100644 --- a/database/update/update_Donnees_IAS_Labinvent2.sql +++ b/database/update/update_Donnees_IAS_Labinvent2.sql @@ -183,7 +183,7 @@ CREATE TABLE IF NOT EXISTS `configurations` ( `nom_groupe_thematique` varchar(50) DEFAULT 'Groupe thematique', `nom_groupe_metier` varchar(50) DEFAULT 'Groupe metier', `envoi_mail_management_dev` tinyint(1) DEFAULT NULL, - `from_mail` varchar(200) DEFAULT 'localhost.com', + `sender_mail` varchar(500) DEFAULT 'labinvent@irap.omp.eu', `emailGuest1` varchar(45) DEFAULT NULL, `emailGuest2` varchar(45) DEFAULT NULL, `emailGuest3` varchar(45) DEFAULT NULL, diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index c35b6bd..4f30e6c 100755 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -80,7 +80,7 @@ class AppController extends Controller if($role == 'Super Administrateur') return true; //Pour tout le monde - if (in_array($action, ['index', 'find', 'view', 'creer', 'add'])) return true; + if (in_array($action, ['index', 'find', 'view', 'creer', 'add', 'getNextDate'])) return true; // Par défaut refuser @@ -211,15 +211,17 @@ class AppController extends Controller if (filter_var($to, FILTER_VALIDATE_EMAIL)) { $email = new Email(); + $etiquetteFrom = explode("@", $configuration->sender_mail); + if($configuration->envoi_mail_management_dev) { $email->transport('dev') - ->from(["labinvent2@".$configuration->from_mail => "Labinvent2"]) + ->from([$configuration->sender_mail => $etiquetteFrom[0]]) ->to($to) ->subject("[LabInvent] ".$subject) ->send($message); } else { $email->transport('default') - ->from(["labinvent2@".$configuration->from_mail => "Labinvent2"]) + ->from([$configuration->sender_mail => $etiquetteFrom[0]]) ->to($to) ->subject("[LabInvent] ".$subject) ->send($message); diff --git a/src/Controller/SuivisController.php b/src/Controller/SuivisController.php index d9447ab..5404e3b 100755 --- a/src/Controller/SuivisController.php +++ b/src/Controller/SuivisController.php @@ -256,5 +256,29 @@ class SuivisController extends AppController } } + // called from Javascript (Ajax) + public function getNextDate($date, $frequence, $typeFrequence) { + $date_next = date_create_from_format('d-m-Y', $date); + + switch($typeFrequence) { + case "Jours": + date_add($date_next, date_interval_create_from_date_string($frequence.' days')); + break; + case "Semaines": + date_add($date_next, date_interval_create_from_date_string((7*$frequence).' days')); + break; + case "Mois": + date_add($date_next, date_interval_create_from_date_string($frequence.' months')); + break; + case "Ans": + date_add($date_next, date_interval_create_from_date_string($frequence.' years')); + break; + } + + $this->set ('date', date_format($date_next, 'd-m-Y')); + + + $this->viewBuilder()->layout = 'ajax'; + } } diff --git a/src/Model/Entity/Configuration.php b/src/Model/Entity/Configuration.php index c6bed9f..a4ec9ad 100644 --- a/src/Model/Entity/Configuration.php +++ b/src/Model/Entity/Configuration.php @@ -24,7 +24,7 @@ use Cake\ORM\Entity; * @property string $nom_groupe_thematique * @property string $nom_groupe_metier * @property bool $envoi_mail_management_dev - * @property string $from_mail + * @property string $sender_mail * @property string $emailGuest1 * @property string $emailGuest2 * @property string $emailGuest3 diff --git a/src/Model/Table/AppTable.php b/src/Model/Table/AppTable.php index e34d65d..f0de810 100644 --- a/src/Model/Table/AppTable.php +++ b/src/Model/Table/AppTable.php @@ -23,7 +23,9 @@ class AppTable extends Table return (bool) preg_match('/^['.$this->string.'?%!:,&*><\-\+\="\''.']*$/', $check); } - + public function check_mail2($check) { + return (bool) filter_var($check, FILTER_VALIDATE_EMAIL); + } } diff --git a/src/Model/Table/ConfigurationsTable.php b/src/Model/Table/ConfigurationsTable.php index 22f0652..f221ba8 100644 --- a/src/Model/Table/ConfigurationsTable.php +++ b/src/Model/Table/ConfigurationsTable.php @@ -11,7 +11,7 @@ use Cake\Validation\Validator; * Configurations Model * */ -class ConfigurationsTable extends Table +class ConfigurationsTable extends AppTable { /** @@ -99,12 +99,12 @@ class ConfigurationsTable extends Table ->allowEmpty('envoi_mail_management_dev'); $validator - ->notEmpty('from_mail'); - - + ->notEmpty('sender_mail') + ->add('sender_mail', 'valid', ['rule' => 'check_mail2', 'message' => 'Le champ doit être une adresse email.', 'provider' => 'table']); + $validator ->allowEmpty('emailGuest1'); - + $validator ->allowEmpty('emailGuest2'); diff --git a/src/Template/Configurations/edit.ctp b/src/Template/Configurations/edit.ctp index e9af166..1a054b8 100644 --- a/src/Template/Configurations/edit.ctp +++ b/src/Template/Configurations/edit.ctp @@ -23,7 +23,7 @@ echo $this->Form->input('envoi_mail_management_dev', ['label' => 'Ne pas envoyer les mails de management en local']); - echo $this->Form->input('from_mail', ['label' => 'Attribut "from" ']); + echo $this->Form->input('sender_mail', ['label' => 'Attribut "sender" (mail)']); echo $this->Form->input('emailGuest1', ['label' => 'Mail guest 1']); echo $this->Form->input('emailGuest2', ['label' => 'Mail guest 2']); echo $this->Form->input('emailGuest3', ['label' => 'Mail guest 3']); diff --git a/src/Template/Configurations/view.ctp b/src/Template/Configurations/view.ctp index c103ac6..c1c333b 100644 --- a/src/Template/Configurations/view.ctp +++ b/src/Template/Configurations/view.ctp @@ -54,7 +54,7 @@ $displayElement(__('Seuil (prix) Matériel administratif'), h($configuration->prix_inventaire_administratif)); $displayElement(__('Envoi des mails de management en local'), $local); - $displayElement(__('Attribut "from"'), h($configuration->from_mail)); + $displayElement(__('Attribut "sender" (mail)'), h($configuration->sender_mail)); $displayElement(__('Mail guest 1'), h($configuration->emailGuest1)); $displayElement(__('Mail guest 2'), h($configuration->emailGuest2)); $displayElement(__('Mail guest 3'), h($configuration->emailGuest3)); diff --git a/src/Template/Layout/default.ctp b/src/Template/Layout/default.ctp index afd3894..c6e9f73 100755 --- a/src/Template/Layout/default.ctp +++ b/src/Template/Layout/default.ctp @@ -12,7 +12,7 @@ * @since 0.10.0 * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -$cakeDescription = 'Labinvent 2.0'; +$cakeDescription = 'Labinvent 2'; ?> @@ -80,7 +80,7 @@ $cakeDescription = 'Labinvent 2.0';

Merci de communiquer remarques et bugs à LABINVENT-MAILING-LIST + href="mailto:inventirap@irap.omp.eu">LABINVENT-MAILING-LIST

- VERSION 2.4.6.3 (21/06/2016) + VERSION 2.4.6.4 (22/06/2016) diff --git a/src/Template/Suivis/add.ctp b/src/Template/Suivis/add.ctp index 6fbe86c..f2df6f4 100755 --- a/src/Template/Suivis/add.ctp +++ b/src/Template/Suivis/add.ctp @@ -38,7 +38,8 @@ echo $this->Form->input ('type_frequence', [ 'label' => false, 'templates' => ['inputContainer' => '
{{content}}
'], - 'options' => ['/ Jours' => '/ Jours', '/ Semaines' => '/ Semaines', '/ Mois' => '/ Mois', '/ Ans' => '/ Ans'] + 'options' => ['/ Jours' => '/ Jours', '/ Semaines' => '/ Semaines', '/ Mois' => '/ Mois', '/ Ans' => '/ Ans'], + 'default' => '/ Mois' ]); echo ''; @@ -67,4 +68,38 @@ echo $this->element('menu'); echo $this->element('menu_form', [ 'pluralHumanName' => 'Suivis' ]); ?> - \ No newline at end of file + + + diff --git a/src/Template/Suivis/edit.ctp b/src/Template/Suivis/edit.ctp index 27b1be5..e3a1475 100755 --- a/src/Template/Suivis/edit.ctp +++ b/src/Template/Suivis/edit.ctp @@ -44,7 +44,8 @@ echo $this->Form->input ('type_frequence', [ 'label' => false, 'templates' => ['inputContainer' => '
{{content}}
'], - 'options' => ['/ Jours' => '/ Jours', '/ Semaines' => '/ Semaines', '/ Mois' => '/ Mois', '/ Ans' => '/ Ans'] + 'options' => ['/ Jours' => '/ Jours', '/ Semaines' => '/ Semaines', '/ Mois' => '/ Mois', '/ Ans' => '/ Ans'], + 'default' => '/ Mois' ]); echo ''; @@ -73,4 +74,38 @@ echo $this->element('menu'); echo $this->element('menu_form', [ 'pluralHumanName' => 'Suivis' ]); ?> - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/Template/Suivis/get_next_date.ctp b/src/Template/Suivis/get_next_date.ctp new file mode 100755 index 0000000..2ff7e70 --- /dev/null +++ b/src/Template/Suivis/get_next_date.ctp @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/tests/Fixture/ConfigurationsFixture.php b/tests/Fixture/ConfigurationsFixture.php index b53018b..af51b51 100644 --- a/tests/Fixture/ConfigurationsFixture.php +++ b/tests/Fixture/ConfigurationsFixture.php @@ -35,7 +35,7 @@ class ConfigurationsFixture extends TestFixture 'nom_groupe_thematique' => ['type' => 'string', 'length' => 45, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], 'nom_groupe_metier' => ['type' => 'string', 'length' => 45, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], 'envoi_mail_management_dev' => ['type' => 'boolean', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null], - 'from_mail' => ['type' => 'string', 'length' => 200, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], + 'sender_mail' => ['type' => 'string', 'length' => 500, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], 'emailGuest1' => ['type' => 'string', 'length' => 45, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], 'emailGuest2' => ['type' => 'string', 'length' => 45, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], 'emailGuest3' => ['type' => 'string', 'length' => 45, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], @@ -84,7 +84,7 @@ class ConfigurationsFixture extends TestFixture 'nom_groupe_thematique' => 'Lorem ipsum dolor sit amet', 'nom_groupe_metier' => 'Lorem ipsum dolor sit amet', 'envoi_mail_management_dev' => 1, - 'from_mail' => '@localhost.com', + 'sender_mail' => 'ezarear@localhost.com', 'emailGuest1' => 'Lorem ipsum dolor sit amet', 'emailGuest2' => 'Lorem ipsum dolor sit amet', 'emailGuest3' => 'Lorem ipsum dolor sit amet', -- libgit2 0.21.2