From 5197dc96ea589218bff6f886cc8de645c340c36f Mon Sep 17 00:00:00 2001 From: Thibaud Ajas Date: Tue, 9 May 2017 10:56:39 +0200 Subject: [PATCH] Le nom des matériel s'affiche en rouge sur la liste des matériels et dates sur leur fiche détaillée lorsque la date de garantie est passée. Début de modification d'envoi des mails de façon plus propre. Divers bugfix. --- composer.json | 2 +- composer.lock | 353 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------ database/labinvent_2.1_12-05-16.sql | 40 ++++++++++++++++++++++++++++++++++++++-- database/update/script_sql/db-update-2017-04-25.sql | 2 +- src/Controller/AppController.php | 436 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------- src/Controller/MaterielsController.php | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------- src/Model/Table/CategoriesTable.php | 2 -- src/Model/Table/ConfigurationsTable.php | 1 - src/Model/Table/DocumentsTable.php | 2 -- src/Model/Table/EmpruntsTable.php | 3 +-- src/Model/Table/GroupesMetiersTable.php | 3 --- src/Model/Table/GroupesThematiquesTable.php | 3 --- src/Model/Table/MaterielsTable.php | 25 ++++++++++++++++++++----- src/Model/Table/OrganismesTable.php | 3 --- src/Model/Table/SitesTable.php | 3 --- src/Model/Table/SousCategoriesTable.php | 2 -- src/Model/Table/SuivisTable.php | 2 -- src/Model/Table/SurCategoriesTable.php | 2 -- src/Model/Table/TypeDocumentsTable.php | 3 --- src/Model/Table/TypeSuivisTable.php | 3 --- src/Model/Table/UsersTable.php | 4 +--- src/Template/Categories/index.ctp | 2 +- src/Template/Documents/index.ctp | 2 +- src/Template/Emprunts/index.ctp | 2 +- src/Template/GroupesMetiers/index.ctp | 2 +- src/Template/GroupesThematiques/index.ctp | 2 +- src/Template/Materiels/find.ctp | 359 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/Template/Materiels/index.ctp | 33 ++++++++++++++++++++++++++++++--- src/Template/Materiels/view.ctp | 32 ++++++++++++++++++++++++++------ src/Template/Organismes/index.ctp | 2 +- src/Template/Pages/acls.ctp | 2 +- src/Template/Pages/home.ctp | 2 +- src/Template/Pages/home_install.ctp | 3 +-- src/Template/Pages/tools.ctp | 2 +- src/Template/Pages/tools_cat.ctp | 2 +- src/Template/Pages/tools_menu_cat.ctp | 2 +- src/Template/Pages/tools_menu_sm.ctp | 2 +- src/Template/Pages/tools_sm.ctp | 2 +- src/Template/Sites/index.ctp | 2 +- src/Template/SousCategories/index.ctp | 2 +- src/Template/Suivis/index.ctp | 2 +- src/Template/SurCategories/index.ctp | 2 +- src/Template/TypeDocuments/index.ctp | 2 +- src/Template/TypeSuivis/index.ctp | 2 +- src/Template/Users/index.ctp | 2 +- tests/Fixture/ConfigurationsFixture.php | 1 + tests/TestCase/Controller/MaterielsControllerTest.php | 5 +++-- vendor/webmozart/assert/.composer-auth.json | 7 +++++++ vendor/webmozart/assert/appveyor.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 49 files changed, 992 insertions(+), 516 deletions(-) create mode 100644 vendor/webmozart/assert/.composer-auth.json create mode 100644 vendor/webmozart/assert/appveyor.yml diff --git a/composer.json b/composer.json index 8dcc3fe..f0610cc 100755 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "require-dev": { "psy/psysh": "@stable", "cakephp/bake": "~1.1", - "phpunit/phpunit": "^4.8" + "phpunit/phpunit": "^5.7" }, "suggest": { "phpunit/phpunit": "Allows automated tests to be run without system-wide install.", diff --git a/composer.lock b/composer.lock index 7a48fc5..b277cce 100755 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f3c40c441166c950fe8099531a9d5970", - "content-hash": "5701970d465c36d8bd0d3846ff00efec", + "hash": "89645e7a585f3dc620817a0408eb0ede", + "content-hash": "ab13ce1b88067ed3a8ee3bb1578dac09", "packages": [ { "name": "aura/installer-default", @@ -825,16 +825,16 @@ }, { "name": "symfony/yaml", - "version": "v3.2.7", + "version": "v3.2.8", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621" + "reference": "acec26fcf7f3031e094e910b94b002fa53d4e4d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/62b4cdb99d52cb1ff253c465eb1532a80cebb621", - "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621", + "url": "https://api.github.com/repos/symfony/yaml/zipball/acec26fcf7f3031e094e910b94b002fa53d4e4d6", + "reference": "acec26fcf7f3031e094e910b94b002fa53d4e4d6", "shasum": "" }, "require": { @@ -876,7 +876,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-03-20 09:45:15" + "time": "2017-05-01 14:55:58" } ], "packages-dev": [ @@ -1101,6 +1101,48 @@ "time": "2015-04-20 18:58:01" }, { + "name": "myclabs/deep-copy", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "doctrine/collections": "1.*", + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "homepage": "https://github.com/myclabs/DeepCopy", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2017-04-12 18:52:22" + }, + { "name": "nikic/php-parser", "version": "v2.1.0", "source": { @@ -1362,39 +1404,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.2.4", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^5.6 || ^7.0", + "phpunit/php-file-iterator": "^1.3", + "phpunit/php-text-template": "^1.2", + "phpunit/php-token-stream": "^1.4.2 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0", + "sebastian/environment": "^1.3.2 || ^2.0", + "sebastian/version": "^1.0 || ^2.0" }, "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" + "ext-xdebug": "^2.1.4", + "phpunit/phpunit": "^5.7" }, "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" + "ext-xdebug": "^2.5.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "4.0.x-dev" } }, "autoload": { @@ -1420,7 +1463,7 @@ "testing", "xunit" ], - "time": "2015-10-06 15:47:00" + "time": "2017-04-02 07:44:40" }, { "name": "phpunit/php-file-iterator", @@ -1610,40 +1653,50 @@ }, { "name": "phpunit/phpunit", - "version": "4.8.35", + "version": "5.7.19", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87" + "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/791b1a67c25af50e230f841ee7a9c6eba507dc87", - "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/69c4f49ff376af2692bad9cebd883d17ebaa98a1", + "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1", "shasum": "" }, "require": { "ext-dom": "*", "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "~1.3", + "php": "^5.6 || ^7.0", + "phpspec/prophecy": "^1.6.2", + "phpunit/php-code-coverage": "^4.0.4", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.2.2", + "phpunit/phpunit-mock-objects": "^3.2", + "sebastian/comparator": "^1.2.4", "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", + "sebastian/environment": "^1.3.4 || ^2.0", + "sebastian/exporter": "~2.0", + "sebastian/global-state": "^1.1", + "sebastian/object-enumerator": "~2.0", + "sebastian/resource-operations": "~1.0", + "sebastian/version": "~1.0.3|~2.0", "symfony/yaml": "~2.1|~3.0" }, + "conflict": { + "phpdocumentor/reflection-docblock": "3.0.2" + }, + "require-dev": { + "ext-pdo": "*" + }, "suggest": { + "ext-xdebug": "*", "phpunit/php-invoker": "~1.1" }, "bin": [ @@ -1652,7 +1705,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.8.x-dev" + "dev-master": "5.7.x-dev" } }, "autoload": { @@ -1678,30 +1731,33 @@ "testing", "xunit" ], - "time": "2017-02-06 05:18:07" + "time": "2017-04-03 02:22:27" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", + "version": "3.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" + "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", + "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" + "php": "^5.6 || ^7.0", + "phpunit/php-text-template": "^1.2", + "sebastian/exporter": "^1.2 || ^2.0" + }, + "conflict": { + "phpunit/phpunit": "<5.4.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^5.4" }, "suggest": { "ext-soap": "*" @@ -1709,7 +1765,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "3.2.x-dev" } }, "autoload": { @@ -1734,7 +1790,7 @@ "mock", "xunit" ], - "time": "2015-10-02 06:51:40" + "time": "2016-12-08 20:27:08" }, { "name": "psy/psysh", @@ -1809,6 +1865,51 @@ "time": "2016-03-09 05:03:14" }, { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04 06:30:41" + }, + { "name": "sebastian/comparator", "version": "1.2.4", "source": { @@ -1926,28 +2027,28 @@ }, { "name": "sebastian/environment", - "version": "1.3.8", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" + "phpunit/phpunit": "^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1972,25 +2073,25 @@ "environment", "hhvm" ], - "time": "2016-08-18 05:49:44" + "time": "2016-11-26 07:53:53" }, { "name": "sebastian/exporter", - "version": "1.2.2", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", "shasum": "" }, "require": { "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" + "sebastian/recursion-context": "~2.0" }, "require-dev": { "ext-mbstring": "*", @@ -1999,7 +2100,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -2039,7 +2140,7 @@ "export", "exporter" ], - "time": "2016-06-17 09:04:28" + "time": "2016-11-19 08:54:04" }, { "name": "sebastian/global-state", @@ -2093,17 +2194,63 @@ "time": "2015-10-12 03:26:01" }, { + "name": "sebastian/object-enumerator", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-02-18 15:18:39" + }, + { "name": "sebastian/recursion-context", - "version": "1.0.5", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", "shasum": "" }, "require": { @@ -2115,7 +2262,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -2143,23 +2290,73 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-10-03 07:41:43" + "time": "2016-11-19 07:33:16" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28 20:34:47" }, { "name": "sebastian/version", - "version": "1.0.6", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", "shasum": "" }, + "require": { + "php": ">=5.6" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -2178,7 +2375,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21 13:59:46" + "time": "2016-10-03 07:35:21" }, { "name": "symfony/var-dumper", diff --git a/database/labinvent_2.1_12-05-16.sql b/database/labinvent_2.1_12-05-16.sql index b5f6224..a72bd69 100755 --- a/database/labinvent_2.1_12-05-16.sql +++ b/database/labinvent_2.1_12-05-16.sql @@ -345,7 +345,7 @@ CREATE TABLE IF NOT EXISTS `configurations` ( `hasPrinter` tinyint(1) DEFAULT NULL, `nom_groupe_thematique` varchar(50) DEFAULT 'Groupe thematique', `nom_groupe_metier` varchar(50) DEFAULT 'Groupe metier', - `envoi_mail_management_dev` tinyint(1) DEFAULT NULL, + `envoi_mail_management_dev` tinyint(1) NOT NULL DEFAULT 1, `sender_mail` varchar(500) DEFAULT 'labinvent@irap.omp.eu', `emailGuest1` varchar(45) DEFAULT NULL, `emailGuest2` varchar(45) DEFAULT NULL, @@ -362,6 +362,7 @@ CREATE TABLE IF NOT EXISTS `configurations` ( `numero_labo_sans_annee` tinyint(1) DEFAULT NULL, `date_commande_facultative` tinyint(1) DEFAULT NULL, `taille_max_doc` int (15) DEFAULT '8000000', + `aff_par_defaut` smallint(6) NOT NULL DEFAULT 20, PRIMARY KEY (`id`), UNIQUE KEY `nom_UNIQUE` (`nom`) ); @@ -446,7 +447,42 @@ Insert into type_documents(nom) values ('Certificat de conformité'); Insert into type_documents(nom) values ('Manuel d\'utilisation'); -- Insertion par défaut pour la table configuration -Insert into `configurations`(`nom`, `mode_install`, `mode_debug`, `use_ldap`, `host_ldap`, `port_ldap`, `authentificationType_ldap`, `baseDn_ldap`, `filter_ldap`, `labName`, `labNameShort`, `labPresent`, `labUmr`, `hasPrinter`, `emailGuest1`, `emailGuest2`, `emailGuest3`) values ('default', '1', '0', '0', '', '', 'xxx', '', '', 'LABONAME', 'LABO', 'du ', '', '0', '', '', ''); +Insert into `configurations`( +`nom`, +`mode_install`, +`mode_debug`, +`use_ldap`, +`host_ldap`, +`port_ldap`, +`authentificationType_ldap`, +`baseDn_ldap`, +`filter_ldap`, +`labName`, +`labNameShort`, +`labPresent`, +`labUmr`, +`hasPrinter`, +`emailGuest1`, +`emailGuest2`, +`emailGuest3`) +values ( +'default', +'1', +'0', +'0', +'', +'', +'xxx', +'', +'', +'LABONAME', +'LABO', +'du ', +'', +'0', +'', +'', +''); diff --git a/database/update/script_sql/db-update-2017-04-25.sql b/database/update/script_sql/db-update-2017-04-25.sql index 9116f81..7a5c917 100755 --- a/database/update/script_sql/db-update-2017-04-25.sql +++ b/database/update/script_sql/db-update-2017-04-25.sql @@ -1,3 +1,3 @@ use database; -ALTER TABLE `configurations` ADD `aff_par_default` smallint(6) DEFAULT 20; +ALTER TABLE `configurations` ADD `aff_par_defaut` SMALLINT NOT NULL DEFAULT '20'; diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index dadf9df..a608134 100755 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -180,9 +180,11 @@ class AppController extends Controller $this->set('idGmNa', TableRegistry::get('GroupesMetiers')->find()->where(['nom =' => 'N/A'])->first()['id']); $this->set('idGtNa', TableRegistry::get('GroupesThematiques')->find()->where(['nom =' => 'N/A'])->first()['id']); - $displayElement = function ($nom, $valeur) { + $displayElement = function ($nom, $valeur, $params="") { + $balise = ($params != "") ? '' : ''; + // Ca c'est parce que sinon y'a au moins deux tests qui passent pas, a cause de l'espace dans la balise ... if ($valeur != "") - echo ''.$nom.' '.$valeur.''; + echo ''.$nom.' '.$balise.$valeur.''; }; $this->set('displayElement', $displayElement); @@ -198,39 +200,39 @@ class AppController extends Controller * @param string $message * @param string[] $to */ - public function sendEmailTo($subject, $message, $to = null) { +// public function sendEmailTo($subject, $message, $to = null) { - $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); +// $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); - if ($to != null && !$configuration->test) { +// if ($to != null && !$configuration->test) { - for($i = 0; $i < sizeof($to); $i++) { +// for($i = 0; $i < sizeof($to); $i++) { - if (filter_var($to[$i], FILTER_VALIDATE_EMAIL)) { - $email = new Email(); +// if (filter_var($to[$i], FILTER_VALIDATE_EMAIL)) { +// $email = new Email(); - $etiquetteFrom = explode("@", $configuration->sender_mail); +// $etiquetteFrom = explode("@", $configuration->sender_mail); - if($configuration->envoi_mail_management_dev) { - $email->transport('dev') - ->from([$configuration->sender_mail => $etiquetteFrom[0]]) - ->to($to[$i]) - ->subject("[LabInvent] ".$subject) - ->send($message); - } else { - $email->transport('default') - ->from([$configuration->sender_mail => $etiquetteFrom[0]]) - ->to($to[$i]) - ->subject("[LabInvent] ".$subject) - ->send($message); - } - } +// if($configuration->envoi_mail_management_dev) { +// $email->transport('dev') +// ->from([$configuration->sender_mail => $etiquetteFrom[0]]) +// ->to($to[$i]) +// ->subject("[LabInvent] ".$subject) +// ->send($message); +// } else { +// $email->transport('default') +// ->from([$configuration->sender_mail => $etiquetteFrom[0]]) +// ->to($to[$i]) +// ->subject("[LabInvent] ".$subject) +// ->send($message); +// } +// } - } - } +// } +// } - } +// } /** * Envoi d'un email à la gestion (et aux devs) pour prévenir qu'un matériel a été créé ou modifié @@ -238,163 +240,319 @@ class AppController extends Controller * @param string $subject * @param string $message */ - public function sendEmailToManagementWith($subject, $message) { +// public function sendEmailToManagementWith($subject, $message) { - $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); +// $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); - for($i = 1; $i < 11; $i++) { - $t = 'emailGuest'.$i; - $to = $configuration->$t; +// for($i = 1; $i < 11; $i++) { +// $t = 'emailGuest'.$i; +// $to = $configuration->$t; - if ($to != null && !$configuration->test) { - if (filter_var($to, FILTER_VALIDATE_EMAIL)) { - $email = new Email(); +// if ($to != null && !$configuration->test) { +// if (filter_var($to, FILTER_VALIDATE_EMAIL)) { +// $email = new Email(); - $etiquetteFrom = explode("@", $configuration->sender_mail); +// $etiquetteFrom = explode("@", $configuration->sender_mail); - if($configuration->envoi_mail_management_dev) { - $email->transport('dev') - ->from([$configuration->sender_mail => $etiquetteFrom[0]]) - ->to($to) - ->subject("[LabInvent] ".$subject) - ->send($message); - } else { - $email->transport('default') - ->from([$configuration->sender_mail => $etiquetteFrom[0]]) - ->to($to) - ->subject("[LabInvent] ".$subject) - ->send($message); - } - } +// if($configuration->envoi_mail_management_dev) { +// $email->transport('dev') +// ->from([$configuration->sender_mail => $etiquetteFrom[0]]) +// ->to($to) +// ->subject("[LabInvent] ".$subject) +// ->send($message); +// } else { +// $email->transport('default') +// ->from([$configuration->sender_mail => $etiquetteFrom[0]]) +// ->to($to) +// ->subject("[LabInvent] ".$subject) +// ->send($message); +// } +// } - } - } +// } +// } - } - public function sendEmailToManagement($idObj = null) { +// } - $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); +// public function sendEmailToManagement($idObj = null) { + +// $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); - $userAuth = $this->LdapAuth->user($configuration->authentificationType_ldap)[0]; - $controller = substr($this->request->params['controller'], 0, -1); // materiel - $action = $this->request->params['action']; // add or edit or delete or ... - $userName = $this->LdapAuth->user('sn')[0].' '.$this->LdapAuth->user('givenname')[0]; - $userEmail = $this->LdapAuth->user('mail')[0]; - $role = TableRegistry::get('Users')->find()->where(['username' => $this->LdapAuth->user($configuration->authentificationType_ldap)[0]])->first()['role']; - if($role == null) $role = 'Utilisateur'; +// $userAuth = $this->LdapAuth->user($configuration->authentificationType_ldap)[0]; +// $controller = substr($this->request->params['controller'], 0, -1); // materiel +// $action = $this->request->params['action']; // add or edit or delete or ... +// $userName = $this->LdapAuth->user('sn')[0].' '.$this->LdapAuth->user('givenname')[0]; +// $userEmail = $this->LdapAuth->user('mail')[0]; +// $role = TableRegistry::get('Users')->find()->where(['username' => $this->LdapAuth->user($configuration->authentificationType_ldap)[0]])->first()['role']; +// if($role == null) $role = 'Utilisateur'; - $modelName = $this->modelClass; // 'Materiels' - $id = $idObj; +// $modelName = $this->modelClass; // 'Materiels' +// $id = $idObj; - switch ($action) { - case 'add': - $actionFrench = ['Création d\'un ', 'été créé']; - break; - case 'edit': - $actionFrench = ['Modification d\'un ', 'été modifié']; - break; - case 'delete': - $actionFrench = ['Suppression d\'un ', 'été supprimé']; - break; - case 'statusValidated': - $actionFrench = ['Validation d\'un ', 'été validé']; - break; - case 'statusToBeArchived': - $actionFrench = ['Demande Archivage d\'un ', 'été demandé pour archivage']; - break; - case 'statusArchived': - $actionFrench = ['Archivage d\'un ', 'été archivé']; - break; - case 'setLabelIsPlaced': - $actionFrench = ['Etiquette posé sur un ', 'reçu une étiquette']; - break; - default: - $actionFrench = [$action.' d\'un ', 'été '.$action]; - break; - } - $doneBy = $userName." (".$userEmail.", login=".$userAuth.", profil=".$role.")."; +// switch ($action) { +// case 'add': +// $actionFrench = ['Création d\'un ', 'été créé']; +// break; +// case 'edit': +// $actionFrench = ['Modification d\'un ', 'été modifié']; +// break; +// case 'delete': +// $actionFrench = ['Suppression d\'un ', 'été supprimé']; +// break; +// case 'statusValidated': +// $actionFrench = ['Validation d\'un ', 'été validé']; +// break; +// case 'statusToBeArchived': +// $actionFrench = ['Demande Archivage d\'un ', 'été demandé pour archivage']; +// break; +// case 'statusArchived': +// $actionFrench = ['Archivage d\'un ', 'été archivé']; +// break; +// case 'setLabelIsPlaced': +// $actionFrench = ['Etiquette posé sur un ', 'reçu une étiquette']; +// break; +// default: +// $actionFrench = [$action.' d\'un ', 'été '.$action]; +// break; +// } +// $doneBy = $userName." (".$userEmail.", login=".$userAuth.", profil=".$role.")."; - $subject = $actionFrench[0].$controller; +// $subject = $actionFrench[0].$controller; - if($id != null) { - $entityName = TableRegistry::get($modelName)->find('all')->where(['id =' => $id])->first(); +// if($id != null) { +// $entityName = TableRegistry::get($modelName)->find('all')->where(['id =' => $id])->first(); - if($modelName == 'Materiels') { - $entityName = $entityName['designation']; - } - else if ($modelName == 'Suivis' || $modelName == 'Emprunts') { - $entityName = $entityName['id']; - } - else { - $entityName = $entityName['nom']; - } - } - else { - $entityName = NULL; - } +// if($modelName == 'Materiels') { +// $entityName = $entityName['designation']; +// } +// else if ($modelName == 'Suivis' || $modelName == 'Emprunts') { +// $entityName = $entityName['id']; +// } +// else { +// $entityName = $entityName['nom']; +// } +// } +// else { +// $entityName = NULL; +// } - $message = $this->getArticle().$controller." ".$entityName." (id=".$id.") a ".$actionFrench[1]." par ".$doneBy; +// $message = $this->getArticle().$controller." ".$entityName." (id=".$id.") a ".$actionFrench[1]." par ".$doneBy; - $this->sendEmailToManagementWith($subject, $message); +// $this->sendEmailToManagementWith($subject, $message); - } +// } /** * Envoi d'un email au propriétaire pour prévenir qu'un matériel a été créé * @param string $subject * @param string $message */ - public function sendEmailToCreate($idObj = null) { +// public function sendEmailToCreate($idObj = null) { - $id = $idObj; +// $id = $idObj; + +// $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); +// $materiel = TableRegistry::get('Materiels')->find()->where(['id =' => $id])->first(); + +// $createurName = $this->LdapAuth->user('sn')[0].' '.$this->LdapAuth->user('givenname')[0]; +// $createurEmail = $this->LdapAuth->user('mail')[0]; +// $toEmail = $materiel->email_responsable; + +// $role = TableRegistry::get('Users')->find()->where(['username' => $this->LdapAuth->user($configuration->authentificationType_ldap)[0]])->first()['role']; +// if($role == null) $role = 'Utilisateur'; + +// $subject = 'Ajout d\'un matériel'; +// $message = $createurName.' (email = '.$createurEmail.', role = '.$role.') a ajouté le matériel "'.$materiel->designation.'" ('.$materiel->numero_laboratoire.') et vous a nommé propriétaire de ce matériel.'; + +// if ($toEmail != null && !$configuration->test) { +// if (filter_var($toEmail, FILTER_VALIDATE_EMAIL)) { +// $email = new Email(); + +// $etiquetteFrom = explode("@", $configuration->sender_mail); + +// if($configuration->envoi_mail_management_dev) { +// $email->transport('dev') +// ->from([$configuration->sender_mail => $etiquetteFrom[0]]) +// ->to($toEmail) +// ->subject("[LabInvent] ".$subject) +// ->send($message); +// } else { +// $email->transport('default') +// ->from([$configuration->sender_mail => $etiquetteFrom[0]]) +// ->to($toEmail) +// ->subject("[LabInvent] ".$subject) +// ->send($message); +// } +// } + +// } + +// } + + + static function isLabinventDebugMode() { + return TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first()->mode_debug; + } + function myDebug($arg, $stop=false) { + if ($this->isLabinventDebugMode()) { + Configure::write('debug', true); + debug($arg); + if ($stop) exit; + } + } + + /** + * Envoie un mail avec un sujet, contenant un message à destination d'une liste de mails, selon l'action effectuée. + * @param string $subject -> Sujet du mail + * @param string $msg -> Message à envoyer + * @param array $listMails -> Liste des mails des destinataires + * @param id $idObj -> ID du matériel créé, modifié, supprimé ... + */ + public function sendEmail($subject, $msg, $listMails, $idObj = null) { $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); - $materiel = TableRegistry::get('Materiels')->find()->where(['id =' => $id])->first(); - $createurName = $this->LdapAuth->user('sn')[0].' '.$this->LdapAuth->user('givenname')[0]; - $createurEmail = $this->LdapAuth->user('mail')[0]; - $toEmail = $materiel->email_responsable; + //if(!$configuration['envoi_mail_management_dev']) { + foreach($listMails as $mail){ + $mailInTable = TableRegistry::get('Users')->find()->select('email')->where(['email =' => $mail])->first(); + if ($mailInTable!= null) { // Tous les utilisateurs privilégiés, si le mode LDAP est activé, sinon tout le monde + $roleInTable = TableRegistry::get('Users')->find()->select('role')->where(['email =' => $mail])->first(); + Switch ($roleInTable){ + case 'Super Administrateur': + $this->sendEmailToSuperAdmin($subject, $msg, $mail, $idObj, $configuration); + break; + case 'Administration Plus': + // Role useless, mais il existe dans BD ... + break; + case 'Administration': + $this->sendEmailToManagement($subject, $msg, $mail, $idObj, $configuration); + break; + case 'Responsable': + $this->sendEmailToResponsable($subject, $msg, $mail, $idObj, $configuration); + break; + case 'Utilisateur': + $this->sendEmailToUser($subject, $msg, $mail, $idObj, $configuration); + break; + default : + break; + } + } else { // Si on utilise le LDAP, les seuls utilisateurs qui ne sont pas dans la BD du site sont les utilisateurs normaux + $this->sendEmailToUser($subject, $msg, $mail, $idObj, $configuration); // <-- + } + } + //} - $role = TableRegistry::get('Users')->find()->where(['username' => $this->LdapAuth->user($configuration->authentificationType_ldap)[0]])->first()['role']; - if($role == null) $role = 'Utilisateur'; + } + + private function sendEmailToResponsable($subject, $msg, $mail, $idObj = null, $config) { - $subject = 'Ajout d\'un matériel'; - $message = $createurName.' (email = '.$createurEmail.', role = '.$role.') a ajouté le matériel "'.$materiel->designation.'" ('.$materiel->numero_laboratoire.') et vous a nommé propriétaire de ce matériel.'; + // Rajouter la vérif sur la colone adéquate de la bd - if ($toEmail != null && !$configuration->test) { - if (filter_var($toEmail, FILTER_VALIDATE_EMAIL)) { + if ($mail != null && !$config->test && false) { // flase à remplacer + if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { $email = new Email(); - $etiquetteFrom = explode("@", $configuration->sender_mail); + $etiquetteFrom = explode("@", $config->sender_mail); - if($configuration->envoi_mail_management_dev) { + if($config->envoi_mail_management_dev) { // <-- Si la case est cochée $email->transport('dev') - ->from([$configuration->sender_mail => $etiquetteFrom[0]]) - ->to($toEmail) + ->from([$config->sender_mail => $etiquetteFrom[0]]) + ->to($mail) ->subject("[LabInvent] ".$subject) - ->send($message); - } else { + ->send($msg); + } else { // <-- Si la case n'est pas cochée $email->transport('default') - ->from([$configuration->sender_mail => $etiquetteFrom[0]]) - ->to($toEmail) + ->from([$config->sender_mail => $etiquetteFrom[0]]) + ->to($mail) ->subject("[LabInvent] ".$subject) - ->send($message); + ->send($msg); } } - + } - } + private function sendEmailToUser($subject, $msg, $mail, $idObj = null, $config) { + + // Rajouter la vérif sur la colone adéquate de la bd + var_dump($mail); + if ($mail != null && !$config->test && true) { // flase à remplacer + if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { + $email = new Email(); + + $etiquetteFrom = explode("@", $config->sender_mail); + + if($config->envoi_mail_management_dev) { + $email->transport('dev') + ->from([$config->sender_mail => $etiquetteFrom[0]]) + ->to($mail) + ->subject("[LabInvent] ".$subject) + ->send($msg); + } else { + $email->transport('default') + ->from([$config->sender_mail => $etiquetteFrom[0]]) + ->to($mail) + ->subject("[LabInvent] ".$subject) + ->send($msg); + } + } + + } + } - static function isLabinventDebugMode() { - return TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first()->mode_debug; + private function sendEmailToSuperAdmin($subject, $msg, $mail, $idObj = null, $config) { + + // Rajouter la vérif sur la colone adéquate de la bd + + if ($mail != null && !$config->test && false) { // flase à remplacer + if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { + $email = new Email(); + + $etiquetteFrom = explode("@", $config->sender_mail); + + if($config->envoi_mail_management_dev) { + $email->transport('dev') + ->from([$config->sender_mail => $etiquetteFrom[0]]) + ->to($mail) + ->subject("[LabInvent] ".$subject) + ->send($msg); + } else { + $email->transport('default') + ->from([$config->sender_mail => $etiquetteFrom[0]]) + ->to($mail) + ->subject("[LabInvent] ".$subject) + ->send($msg); + } + } + + } } - function myDebug($arg, $stop=false) { - if ($this->isLabinventDebugMode()) { - Configure::write('debug', true); - debug($arg); - if ($stop) exit; + + private function sendEmailToManagement($subject, $msg, $mail, $idObj = null, $config) { + + // Rajouter la vérif sur la colone adéquate de la bd + + if ($mail != null && !$config->test && false) { // flase à remplacer + if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { + $email = new Email(); + + $etiquetteFrom = explode("@", $config->sender_mail); + + if($config->envoi_mail_management_dev) { + $email->transport('dev') + ->from([$config->sender_mail => $etiquetteFrom[0]]) + ->to($mail) + ->subject("[LabInvent] ".$subject) + ->send($msg); + } else { + $email->transport('default') + ->from([$config->sender_mail => $etiquetteFrom[0]]) + ->to($mail) + ->subject("[LabInvent] ".$subject) + ->send($msg); + } + } + } } diff --git a/src/Controller/MaterielsController.php b/src/Controller/MaterielsController.php index 06a1673..667ce8e 100755 --- a/src/Controller/MaterielsController.php +++ b/src/Controller/MaterielsController.php @@ -2,6 +2,7 @@ namespace App\Controller; use App\Controller\AppController; +use Cake\Core\Configure; use Cake\ORM\TableRegistry; use Cake\Mailer\Email; @@ -171,10 +172,12 @@ class MaterielsController extends AppController */ public function index() { + // Remplacement de $this->passedArgs[0] (deprecated) + // Par $this->request->params['pass'][0] $condition = ''; - if (isset($this->passedArgs[0])) { - $condition = ['Materiels.status =' => $this->passedArgs[0]]; - $this->set('STATUS', $this->passedArgs[0]); + if (isset($this->request->params['pass'][0])) { + $condition = ['Materiels.status =' => $this->request->params['pass'][0]]; + $this->set('STATUS', $this->request->params['pass'][0]); } $GM = $this->request->query('GM'); @@ -282,40 +285,43 @@ class MaterielsController extends AppController if ($this->Materiels->save($materiel)) { $this->Flash->success(__('Le matériel a bien été ajouté.')); - $this->sendEmailToManagement($materiel->id); +// $this->sendEmailToManagement($materiel->id); - if($materiel->nom_createur != $materiel->nom_responsable) { - $this->sendEmailToCreate($materiel->id); - } +// if($materiel->nom_createur != $materiel->nom_responsable) { +// $this->sendEmailToCreate($materiel->id); +// } - $message = $materiel->get('nom_createur').' a ajouté le matériel "'.$materiel->get('designation').'" ('.$materiel->numero_laboratoire.')'; + $msg = $materiel->get('nom_createur').' à ajouté le matériel "'.$materiel->get('designation').'" ('.$materiel->numero_laboratoire.')'; + $subject = 'Ajout de matériel'; + $listMails = []; - //Envoi mail responsable - $mailsResp = TableRegistry::get('Users')->find()->select('email')->where(['role =' => 'Responsable', 'groupes_metier_id =' => $materiel->get('groupes_metier_id')])->orWhere(['role =' => 'Responsable', 'groupe_thematique_id =' => $materiel->get('groupes_thematique_id')])->toArray(); - $mails = []; - for($i = 0; $i < sizeof($mailsResp); $i++) { - $mails[$i] = $mailsResp[$i]['email']; - } - $this->sendEmailTo('Ajout d\'un matériel', $message, $mails); +// //Envoi mail responsable +// $mailsResp = TableRegistry::get('Users')->find()->select('email')->where(['role =' => 'Responsable', 'groupes_metier_id =' => $materiel->get('groupes_metier_id')])->orWhere(['role =' => 'Responsable', 'groupe_thematique_id =' => $materiel->get('groupes_thematique_id')])->toArray(); +// $mails = []; +// for($i = 0; $i < sizeof($mailsResp); $i++) { +// $mails[$i] = $mailsResp[$i]['email']; +// } +// $this->sendEmailTo('Ajout d\'un matériel', $message, $mails); - //Envoi mail administratif - //$mailsResp = TableRegistry::get('Users')->find()->select('email')->where(['role =' => 'Administration Plus'])->orWhere(['role =' => 'Administration'])->toArray(); - $mailsResp = TableRegistry::get('Users')->find()->select('email')->where(['role =' => 'Administration Plus'])->toArray(); - $mails = []; - for($i = 0; $i < sizeof($mailsResp); $i++) { - $mails[$i] = $mailsResp[$i]['email']; - } +// //Envoi mail administratif +// //$mailsResp = TableRegistry::get('Users')->find()->select('email')->where(['role =' => 'Administration Plus'])->orWhere(['role =' => 'Administration'])->toArray(); +// $mailsResp = TableRegistry::get('Users')->find()->select('email')->where(['role =' => 'Administration Plus'])->toArray(); +// $mails = []; +// for($i = 0; $i < sizeof($mailsResp); $i++) { +// $mails[$i] = $mailsResp[$i]['email']; +// } - // Rajout condition d'envoi de mail ou pas - $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); +// // Rajout condition d'envoi de mail ou pas +// $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); - if(!$configuration['envoi_mail_management_dev']){ // Si false, on envoie les mails, sinon on les envoie pas - $this->sendEmailTo('Ajout d\'un matériel', $message, $mails); - } - +// if(!$configuration['envoi_mail_management_dev']){ // Si false, on envoie les mails, sinon on les envoie pas +// $this->sendEmailTo('Ajout d\'un matériel', $message, $mails); +// } + + $this->sendEmail($subject, $msg, $listMails); - //return $this->redirect(['action' => 'view', $materiel->id]); + return $this->redirect(['action' => 'view', $materiel->id]); } else { $this->Flash->error(__('Le matériel n\'a pas pu être ajouté.')); } @@ -339,8 +345,8 @@ class MaterielsController extends AppController $mail_responsable = TableRegistry::get('Users')->find()->select('email')->where(['username =' => $this->LdapAuth->user($this->request->session()->read('authType'))[0]])->first()['email']; - if(isset($this->request->params[0])) { - $cpMateriel = $this->Materiels->get($this->request->params[0]); + if(isset($this->request->params['pass'][0])) { + $cpMateriel = $this->Materiels->get($this->request->params['pass'][0]); $this->set('cpMateriel', $cpMateriel); } @@ -365,11 +371,11 @@ class MaterielsController extends AppController $materiel = $this->Materiels->patchEntity($materiel, $this->request->data); if ($this->Materiels->save($materiel)) { $this->Flash->success(__('Le matériel a bien été édité.')); - $this->sendEmailToManagement($id); - if($materiel->nom_modificateur != $materiel->nom_responsable) { - $message = $materiel->get('nom_modificateur').' a édité le matériel "'.$materiel->get('designation').'" ('.$materiel->numero_laboratoire.')'; - $this->sendEmailTo('Modification d\'un matériel', $message, [$materiel->get('email_responsable')]); - } +// $this->sendEmailToManagement($id); +// if($materiel->nom_modificateur != $materiel->nom_responsable) { +// $message = $materiel->get('nom_modificateur').' a édité le matériel "'.$materiel->get('designation').'" ('.$materiel->numero_laboratoire.')'; +// $this->sendEmailTo('Modification d\'un matériel', $message, [$materiel->get('email_responsable')]); +// } return $this->redirect(['action' => 'view', $id]); } else { $this->Flash->error(__('Le matériel n\'a pas pu être édité.')); @@ -399,7 +405,7 @@ class MaterielsController extends AppController } $mail_responsable = TableRegistry::get('Users')->find()->select('email')->where(['username =' => $this->LdapAuth->user($this->request->session()->read('authType'))[0]])->first()['email']; - //Fonction utilisé dans la vue, déclaré ici pour éviter les problèmes de tests + //Fonction utilisée dans la vue, déclaré ici pour éviter les problèmes de tests $isReadonlyField = function ($fieldName, $myReadonlyFields) { if (! empty ( $myReadonlyFields ) && $myReadonlyFields [0] == '*') { $modifiableFields = $myReadonlyFields; @@ -486,7 +492,7 @@ class MaterielsController extends AppController $materiel = $this->Materiels->get($id); if ($this->Materiels->delete($materiel)) { $this->Flash->success(__('Le matériel a bien été supprimé.')); - $this->sendEmailToManagement($id); +// $this->sendEmailToManagement($id); } else { $this->Flash->error(__('Le matériel n\'a pas pu être supprimé.')); } @@ -514,13 +520,13 @@ class MaterielsController extends AppController $this->Flash->error('Pour valider un matériel, les champs suivants ne doivent pas être vide : Nom propriétaire, Fournisseur, Numéro de commande, Organisme, prix et date de reception'); return $this->redirect(['action' => 'edit', $id]); } - $message = 'Le matériel "'.$materiel->get('designation').'" ('.$materiel->numero_laboratoire.') a été validé.'; - $this->sendEmailTo('Validation d\'un matériel', $message, [$materiel->get('email_responsable')]); +// $message = 'Le matériel "'.$materiel->get('designation').'" ('.$materiel->numero_laboratoire.') a été validé.'; +// $this->sendEmailTo('Validation d\'un matériel', $message, [$materiel->get('email_responsable')]); } if ($this->Materiels->save($materiel, ['checkRules' => false, 'checkExisting' => false])) { $this->Flash->success(__($message)); - $this->sendEmailToManagement($id); +// $this->sendEmailToManagement($id); } else { $this->Flash->error(__('Le statut n\'a pas pu être édité.')); @@ -892,10 +898,10 @@ class MaterielsController extends AppController } - else if (isset($this->passedArgs[0])) { + else if (isset($this->request->params['pass'][0])) { $this->myDebug("OTHER CASE 3"); - $what = $this->passedArgs[0]; + $what = $this->request->params['pass'][0]; if ($what == 'search') { $materiels = $this->request->session()->read("result"); } @@ -1038,7 +1044,7 @@ class MaterielsController extends AppController $this->Flash->success(__('L\'étiquette a bien été éditer.')); // Envoi email seulement si etiquette posée if ($printed) { - $this->sendEmailToManagement($id); +// $this->sendEmailToManagement($id); } } else { diff --git a/src/Model/Table/CategoriesTable.php b/src/Model/Table/CategoriesTable.php index 6feb6c0..f2924c7 100755 --- a/src/Model/Table/CategoriesTable.php +++ b/src/Model/Table/CategoriesTable.php @@ -1,8 +1,6 @@ year-$time->month-$time->day"))->format('Ymd'); // On extrait la date on la formatte en un format comparable de type 20171231 + $timeEntity = new time($entity); + $dateEntity = (new date("$timeEntity->year-$timeEntity->month-$timeEntity->day"))->format('Ymd'); + return ($today >= $dateEntity); + }; + $validator ->integer('id') ->allowEmpty('id', 'create'); @@ -120,12 +128,19 @@ class MaterielsTable extends AppTable $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); if($configuration->date_commande_facultative) { $validator - ->allowEmpty('date_acquisition'); + ->allowEmpty('date_acquisition') + ->add('date_acquisition', 'custom', [ // Ajouté par Thibault Ajas, le 28/04/2017 + 'rule' => $dateValide, + 'message' => 'La date n\'est pas valide' + ]); } else { $validator - ->notEmpty('date_acquisition', 'Ce champ doit être rempli') - ->date('date_acquisition', 'dmy', null); + ->notEmpty('date_acquisition', 'Ce champ doit être rempli') + ->add('date_acquisition', 'custom', [ // Ajouté par Thibault Ajas, le 28/04/2017 + 'rule' => $dateValide, + 'message' => 'La date n\'est pas valide' + ]); } diff --git a/src/Model/Table/OrganismesTable.php b/src/Model/Table/OrganismesTable.php index 7b9d4a5..33c0274 100755 --- a/src/Model/Table/OrganismesTable.php +++ b/src/Model/Table/OrganismesTable.php @@ -1,9 +1,6 @@ Liste des catégories'; ?> - +
diff --git a/src/Template/Documents/index.ctp b/src/Template/Documents/index.ctp index af0b397..c81226d 100755 --- a/src/Template/Documents/index.ctp +++ b/src/Template/Documents/index.ctp @@ -1,7 +1,7 @@
Liste des documents'; ?> -
+
diff --git a/src/Template/Emprunts/index.ctp b/src/Template/Emprunts/index.ctp index b50ece7..7eb28b0 100755 --- a/src/Template/Emprunts/index.ctp +++ b/src/Template/Emprunts/index.ctp @@ -1,7 +1,7 @@
Liste des emprunts ('.$nbEmprunts.')'; ?> -
+
diff --git a/src/Template/GroupesMetiers/index.ctp b/src/Template/GroupesMetiers/index.ctp index 4c116e0..0d4e2a5 100755 --- a/src/Template/GroupesMetiers/index.ctp +++ b/src/Template/GroupesMetiers/index.ctp @@ -1,7 +1,7 @@
Liste des '.$configuration->nom_groupe_metier.''; ?> -
+
diff --git a/src/Template/GroupesThematiques/index.ctp b/src/Template/GroupesThematiques/index.ctp index 9279fb1..b003714 100755 --- a/src/Template/GroupesThematiques/index.ctp +++ b/src/Template/GroupesThematiques/index.ctp @@ -1,7 +1,7 @@
Liste des '.$configuration->nom_groupe_thematique.'s'; ?> -
+
diff --git a/src/Template/Materiels/find.ctp b/src/Template/Materiels/find.ctp index 3ad78e1..c151815 100644 --- a/src/Template/Materiels/find.ctp +++ b/src/Template/Materiels/find.ctp @@ -3,23 +3,23 @@

Recherche de matériel

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

Filtres

-
> '' - ]; - - - // 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 - ]); - - $options = [ - 'CREATED' => 'Créé', - 'VALIDATED' => 'Validé', - 'TOBEARCHIVED' => 'À archiver', - ]; - if(in_array($role, ['Administration', 'Administration Plus', 'Super Administrateur'])) { - $options['ARCHIVED'] = 'Archivé'; - } - // STATUT - echo $this->Form->input ( 's_status', [ - 'label' => 'Statut', - 'empty' => 'Tous', - $selected, - 'options' => $options, - 'style' => 'width: 200px' - ]); - - // Groupe metier et thematique - echo $this->Form->input ( 's_groupes_metier_id', [ - 'label' => $configuration->nom_groupe_metier, - 'empty' => 'Tous', - $selected, - 'options' => $s_groupes_metiers, - 'style' => 'width: 200px' - ]); - echo $this->Form->input ( 's_groupes_thematique_id', [ - 'label' => $configuration->nom_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' => 'Nom du propriétaire' - ]); - 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 à']); + + // 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 + ]); + + $options = [ + 'CREATED' => 'Créé', + 'VALIDATED' => 'Validé', + 'TOBEARCHIVED' => 'À archiver', + ]; + if(in_array($role, ['Administration', 'Administration Plus', 'Super Administrateur'])) { + $options['ARCHIVED'] = 'Archivé'; + } + // STATUT + echo $this->Form->input ( 's_status', [ + 'label' => 'Statut', + 'empty' => 'Tous', + $selected, + 'options' => $options, + 'style' => 'width: 200px' + ]); + + // Groupe metier et thematique + echo $this->Form->input ( 's_groupes_metier_id', [ + 'label' => $configuration->nom_groupe_metier, + 'empty' => 'Tous', + $selected, + 'options' => $s_groupes_metiers, + 'style' => 'width: 200px' + ]); + echo $this->Form->input ( 's_groupes_thematique_id', [ + 'label' => $configuration->nom_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)' + ]); - // CHAMP DE RECHERCHE GENERIQUE - echo $this->Form->input ( 's_all', ['label' => 'TOUS LES CHAMPS' ]); + //ORGANISME + $orgas = $s_organismes; + echo $this->Form->input ( 's_organisme_id', [ + 'label' => 'Organisme', + 'empty' => 'Toutes', + 'style' => 'width: 200px', + 'options' => $orgas + ]); - // -------Bouton recherche Bas--------- - echo $this->Form->submit('Rechercher', ['style' => 'width: 20%']); - echo '


'; - ?> + echo $this->Form->input ( 's_nom_responsable', [ + 'label' => 'Nom du propriétaire' + ]); + 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 '


'; + ?>

@@ -206,7 +207,7 @@ if ($r) { $this->request->session()->write("resultTri", $_results); ?> -

+
diff --git a/src/Template/Materiels/index.ctp b/src/Template/Materiels/index.ctp index b766687..0bb175e 100755 --- a/src/Template/Materiels/index.ctp +++ b/src/Template/Materiels/index.ctp @@ -1,3 +1,9 @@ + + +
Liste des matériels ('.$nbMateriels.')'; ?> @@ -114,7 +120,7 @@ if (isset ( $STATUS )) { } ?> -
+
'; }?> @@ -131,7 +137,26 @@ if (isset ( $STATUS )) { + + year-$time->month-$time->day"); // On extrait la date pour la vérification de fin de garantie + $today = $today->format('Ydm'); // On formatte la date initialement en 31-12-2000 (par exemple) en un format qui pourra etre comparé : 20001231 + ?> + + + date_fin_garantie !== NULL) { + $timeFin = new time($materiel->date_fin_garantie); + $dateFin = new date("$timeFin->year-$timeFin->month-$timeFin->day"); + $dateFin = $dateFin->format('Ydm'); + } + if($materiel->date_fin_garantie !== NULL) $styleLien = ($today >= $dateFin) ? 'style="color: #FF0000"' : '' ; else $styleLien = ''; + // Fin ajout - Utilisation de la variable $styleLien ligne 213 + ?> + '.$this->Form->checkbox($materiel->id, ['style' => 'margin: 3px','id' => $materiel->id]).'' ; @@ -188,7 +213,7 @@ if (isset ( $STATUS )) { } ?> - + @@ -294,7 +319,9 @@ if (isset ( $STATUS )) { 'singularHumanName' => 'Matériel' ]) ?> - + + +
has('designation') ? $this->Html->link($materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $materiel->id]) : '' ?>has('designation') ? $this->Html->link($materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $materiel->id],[$styleLien]) : '' ?> numero_laboratoire) ?> has('category') ? h($materiel->category->nom) : '' ?> has('organisme') ? h($materiel->organisme->nom) : '' ?>