From ddff76950ee9aad15f76233825f68d03e19dfdec Mon Sep 17 00:00:00 2001 From: cangreen Date: Fri, 10 Apr 2020 11:26:17 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D0=B5=D1=89=D0=B5=20=D0=BE=D0=B4=D0=BD=D1=83=20=D1=82=D0=B0?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D1=86=D1=83=20=D0=94=D0=9E=D0=9B=D0=96=D0=9D?= =?UTF-8?q?=D0=9E=D0=A1=D0=A2=D0=98,=20=D1=82=D0=B0=D0=BC=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D1=81=D1=83=D1=82=D0=B8=20=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=98=D0=94=20=D0=B8=20=D0=94=D0=9E=D0=9B=D0=96?= =?UTF-8?q?=D0=9D=D0=9E=D0=A1=D0=A2=D0=AC=20=D0=B4=D0=BE=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=20=D0=92=20=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BE=D1=87=D0=BD=D0=B8=D0=BA=D0=B5=20=D1=81=D0=BE?= =?UTF-8?q?=D1=82=D1=80=D1=83=D0=B4=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=BA=D0=BE=D0=BB?= =?UTF-8?q?=D0=BE=D0=BD=D0=BA=D1=83=20=D0=B4=D0=BE=D0=BB=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C,=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=83?= =?UTF-8?q?=D1=8E=20=D0=BC=D1=8B=20=D0=B4=D0=BE=D0=B7=D0=B0=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D0=B8=D0=BC=20=D0=B8=D0=B7=20=D1=81=D0=BE=D0=BE?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D1=82=D1=81=D1=82=D0=B2=D1=83=D1=8E=D1=89?= =?UTF-8?q?=D0=B5=D0=B3=D0=BE=20=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87?= =?UTF-8?q?=D0=BD=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.lock | 396 ++++++++++-------- controllers/SiteController.php | 19 +- ...135950_create_employee_positions_table.php | 43 ++ models/EmployeePositions.php | 57 +++ models/EmployeePositionsSearch.php | 70 ++++ models/Employees.php | 25 +- models/EmployeesSearch.php | 42 +- .../EmployeePositionsController.php | 133 ++++++ .../views/employee-positions/_form.php | 28 ++ .../views/employee-positions/create.php | 19 + .../views/employee-positions/index.php | 31 ++ .../views/employee-positions/update.php | 19 + .../views/employee-positions/view.php | 34 ++ .../administrator/views/employees/_form.php | 23 +- .../administrator/views/employees/index.php | 3 +- .../administrator/views/employees/view.php | 1 + views/layouts/left.php | 95 ++--- 17 files changed, 769 insertions(+), 269 deletions(-) create mode 100644 migrations/m200409_135950_create_employee_positions_table.php create mode 100644 models/EmployeePositions.php create mode 100644 models/EmployeePositionsSearch.php create mode 100644 modules/administrator/controllers/EmployeePositionsController.php create mode 100644 modules/administrator/views/employee-positions/_form.php create mode 100644 modules/administrator/views/employee-positions/create.php create mode 100644 modules/administrator/views/employee-positions/index.php create mode 100644 modules/administrator/views/employee-positions/update.php create mode 100644 modules/administrator/views/employee-positions/view.php diff --git a/composer.lock b/composer.lock index 5cbd591..b99e20d 100644 --- a/composer.lock +++ b/composer.lock @@ -60,8 +60,7 @@ "dist": { "type": "zip", "url": "https://api.github.com/repos/twbs/bootstrap/zipball/68b0d231a13201eb14acd3dc84e51543d16e5f7e", - "reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e", - "shasum": null + "reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e" }, "require": { "bower-asset/jquery": ">=1.9.1,<4.0" @@ -76,14 +75,13 @@ "version": "3.3.11", "source": { "type": "git", - "url": "git@github.com:RobinHerbots/Inputmask.git", + "url": "https://github.com/RobinHerbots/Inputmask.git", "reference": "5e670ad62f50c738388d4dcec78d2888505ad77b" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/RobinHerbots/Inputmask/zipball/5e670ad62f50c738388d4dcec78d2888505ad77b", - "reference": "5e670ad62f50c738388d4dcec78d2888505ad77b", - "shasum": null + "reference": "5e670ad62f50c738388d4dcec78d2888505ad77b" }, "require": { "bower-asset/jquery": ">=1.7" @@ -98,14 +96,13 @@ "version": "3.4.1", "source": { "type": "git", - "url": "git@github.com:jquery/jquery-dist.git", + "url": "https://github.com/jquery/jquery-dist.git", "reference": "15bc73803f76bc53b654b9fdbbbc096f56d7c03d" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/jquery/jquery-dist/zipball/15bc73803f76bc53b654b9fdbbbc096f56d7c03d", - "reference": "15bc73803f76bc53b654b9fdbbbc096f56d7c03d", - "shasum": null + "reference": "15bc73803f76bc53b654b9fdbbbc096f56d7c03d" }, "type": "bower-asset", "license": [ @@ -123,8 +120,7 @@ "dist": { "type": "zip", "url": "https://api.github.com/repos/bestiejs/punycode.js/zipball/38c8d3131a82567bfef18da09f7f4db68c84f8a3", - "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3", - "shasum": null + "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3" }, "type": "bower-asset" }, @@ -139,8 +135,7 @@ "dist": { "type": "zip", "url": "https://api.github.com/repos/yiisoft/jquery-pjax/zipball/aef7b953107264f00234902a3880eb50dafc48be", - "reference": "aef7b953107264f00234902a3880eb50dafc48be", - "shasum": null + "reference": "aef7b953107264f00234902a3880eb50dafc48be" }, "require": { "bower-asset/jquery": ">=1.8" @@ -377,16 +372,16 @@ }, { "name": "egulias/email-validator", - "version": "2.1.15", + "version": "2.1.17", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "e834eea5306d85d67de5a05db5882911d5b29357" + "reference": "ade6887fd9bd74177769645ab5c474824f8a418a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/e834eea5306d85d67de5a05db5882911d5b29357", - "reference": "e834eea5306d85d67de5a05db5882911d5b29357", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/ade6887fd9bd74177769645ab5c474824f8a418a", + "reference": "ade6887fd9bd74177769645ab5c474824f8a418a", "shasum": "" }, "require": { @@ -431,7 +426,7 @@ "validation", "validator" ], - "time": "2020-01-20T21:40:59+00:00" + "time": "2020-02-13T22:36:52+00:00" }, { "name": "ezyang/htmlpurifier", @@ -721,6 +716,60 @@ ], "time": "2018-07-13T06:56:46+00:00" }, + { + "name": "kartik-v/yii2-bootstrap4-dropdown", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-bootstrap4-dropdown.git", + "reference": "394cb4f85d82522ec5918f1581bdad518b324498" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-bootstrap4-dropdown/zipball/394cb4f85d82522ec5918f1581bdad518b324498", + "reference": "394cb4f85d82522ec5918f1581bdad518b324498", + "shasum": "" + }, + "require": { + "kartik-v/yii2-krajee-base": ">=2.0" + }, + "suggest": { + "yiisoft/yii2-bootstrap4": "The Yii 2 Bootstrap 4 extension must be installed separately for this extension to work." + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\bs4dropdown\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "Enhanced Bootstrap 4 dropdown widget for Yii2 with nested submenu support", + "homepage": "https://github.com/kartik-v/yii2-bootstrap4-dropdown", + "keywords": [ + "bootstrap", + "dropdown", + "jquery", + "nested", + "submenu", + "yii2" + ], + "time": "2020-03-27T10:45:23+00:00" + }, { "name": "kartik-v/yii2-datecontrol", "version": "v1.9.7", @@ -884,19 +933,20 @@ }, { "name": "kartik-v/yii2-grid", - "version": "v3.3.4", + "version": "v3.3.5", "source": { "type": "git", "url": "https://github.com/kartik-v/yii2-grid.git", - "reference": "e889dd77373961794b6aa2e1d748c8c1e1e83ea8" + "reference": "e4ba0c68ecb864e1a158f16cc73a5e73a6cdf7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-grid/zipball/e889dd77373961794b6aa2e1d748c8c1e1e83ea8", - "reference": "e889dd77373961794b6aa2e1d748c8c1e1e83ea8", + "url": "https://api.github.com/repos/kartik-v/yii2-grid/zipball/e4ba0c68ecb864e1a158f16cc73a5e73a6cdf7c7", + "reference": "e4ba0c68ecb864e1a158f16cc73a5e73a6cdf7c7", "shasum": "" }, "require": { + "kartik-v/yii2-bootstrap4-dropdown": "~1.0", "kartik-v/yii2-dialog": "~1.0" }, "suggest": { @@ -932,7 +982,7 @@ "widget", "yii2" ], - "time": "2019-08-26T12:57:09+00:00" + "time": "2020-03-27T11:31:59+00:00" }, { "name": "kartik-v/yii2-helpers", @@ -2112,16 +2162,16 @@ }, { "name": "select2/select2", - "version": "4.0.12", + "version": "4.0.13", "source": { "type": "git", "url": "https://github.com/select2/select2.git", - "reference": "5765090318c4d382ae56463cfa25ba8ca7bdd495" + "reference": "45f2b83ceed5231afa7b3d5b12b58ad335edd82e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/select2/select2/zipball/5765090318c4d382ae56463cfa25ba8ca7bdd495", - "reference": "5765090318c4d382ae56463cfa25ba8ca7bdd495", + "url": "https://api.github.com/repos/select2/select2/zipball/45f2b83ceed5231afa7b3d5b12b58ad335edd82e", + "reference": "45f2b83ceed5231afa7b3d5b12b58ad335edd82e", "shasum": "" }, "type": "component", @@ -2146,7 +2196,7 @@ ], "description": "Select2 is a jQuery based replacement for select boxes.", "homepage": "https://select2.org/", - "time": "2019-11-06T01:34:17+00:00" + "time": "2020-01-28T05:01:22+00:00" }, { "name": "swiftmailer/swiftmailer", @@ -2212,16 +2262,16 @@ }, { "name": "symfony/polyfill-iconv", - "version": "v1.13.1", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "a019efccc03f1a335af6b4f20c30f5ea8060be36" + "reference": "ad6d62792bfbcfc385dd34b424d4fcf9712a32c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/a019efccc03f1a335af6b4f20c30f5ea8060be36", - "reference": "a019efccc03f1a335af6b4f20c30f5ea8060be36", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/ad6d62792bfbcfc385dd34b424d4fcf9712a32c8", + "reference": "ad6d62792bfbcfc385dd34b424d4fcf9712a32c8", "shasum": "" }, "require": { @@ -2233,7 +2283,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -2267,26 +2317,26 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-03-09T19:04:49+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.13.1", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46" + "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6f9c239e61e1b0c9229a28ff89a812dc449c3d46", - "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", + "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", "shasum": "" }, "require": { "php": ">=5.3.3", "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php72": "^1.9" + "symfony/polyfill-php72": "^1.10" }, "suggest": { "ext-intl": "For best performance" @@ -2294,7 +2344,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -2329,20 +2379,20 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-03-09T19:04:49+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.13.1", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac", "shasum": "" }, "require": { @@ -2354,7 +2404,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -2388,20 +2438,20 @@ "portable", "shim" ], - "time": "2019-11-27T14:18:11+00:00" + "time": "2020-03-09T19:04:49+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.13.1", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038" + "reference": "37b0976c78b94856543260ce09b460a7bc852747" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/66fea50f6cb37a35eea048d75a7d99a45b586038", - "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747", + "reference": "37b0976c78b94856543260ce09b460a7bc852747", "shasum": "" }, "require": { @@ -2410,7 +2460,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -2443,20 +2493,20 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-02-27T09:26:54+00:00" }, { "name": "yiisoft/yii2", - "version": "2.0.31", + "version": "2.0.34", "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-framework.git", - "reference": "0329b2db8bbf9719b1add17d6defd2d6045b4f09" + "reference": "ef2585379bc387433e150a62451a89a4b1e130d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/0329b2db8bbf9719b1add17d6defd2d6045b4f09", - "reference": "0329b2db8bbf9719b1add17d6defd2d6045b4f09", + "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/ef2585379bc387433e150a62451a89a4b1e130d7", + "reference": "ef2585379bc387433e150a62451a89a4b1e130d7", "shasum": "" }, "require": { @@ -2543,7 +2593,7 @@ "framework", "yii2" ], - "time": "2019-12-18T12:52:03+00:00" + "time": "2020-03-26T20:42:29+00:00" }, { "name": "yiisoft/yii2-bootstrap", @@ -2717,16 +2767,16 @@ "packages-dev": [ { "name": "behat/gherkin", - "version": "v4.6.0", + "version": "v4.6.2", "source": { "type": "git", "url": "https://github.com/Behat/Gherkin.git", - "reference": "ab0a02ea14893860bca00f225f5621d351a3ad07" + "reference": "51ac4500c4dc30cbaaabcd2f25694299df666a31" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/Gherkin/zipball/ab0a02ea14893860bca00f225f5621d351a3ad07", - "reference": "ab0a02ea14893860bca00f225f5621d351a3ad07", + "url": "https://api.github.com/repos/Behat/Gherkin/zipball/51ac4500c4dc30cbaaabcd2f25694299df666a31", + "reference": "51ac4500c4dc30cbaaabcd2f25694299df666a31", "shasum": "" }, "require": { @@ -2772,26 +2822,26 @@ "gherkin", "parser" ], - "time": "2019-01-16T14:22:17+00:00" + "time": "2020-03-17T14:03:26+00:00" }, { "name": "codeception/codeception", - "version": "4.0.x-dev", + "version": "4.x-dev", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "e610c15ebb73b56722c67e1c799bf0565f062899" + "reference": "55d8d1d882fa0777e47de17b04c29b3c50fe29e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/e610c15ebb73b56722c67e1c799bf0565f062899", - "reference": "e610c15ebb73b56722c67e1c799bf0565f062899", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/55d8d1d882fa0777e47de17b04c29b3c50fe29e7", + "reference": "55d8d1d882fa0777e47de17b04c29b3c50fe29e7", "shasum": "" }, "require": { "behat/gherkin": "^4.4.0", "codeception/lib-asserts": "^1.0", - "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.1.1", + "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.1.1 | ^9.0", "codeception/stub": "^2.0 | ^3.0", "ext-curl": "*", "ext-json": "*", @@ -2857,25 +2907,25 @@ "functional testing", "unit testing" ], - "time": "2020-01-14T14:44:10+00:00" + "time": "2020-03-23T17:07:20+00:00" }, { "name": "codeception/lib-asserts", - "version": "1.10.1", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/Codeception/lib-asserts.git", - "reference": "f052dfebad3e9bcafc66c22a7ef39cb1a30cebd2" + "reference": "1fdc310bf857c11d3703ae02689a2e482c71c5ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/lib-asserts/zipball/f052dfebad3e9bcafc66c22a7ef39cb1a30cebd2", - "reference": "f052dfebad3e9bcafc66c22a7ef39cb1a30cebd2", + "url": "https://api.github.com/repos/Codeception/lib-asserts/zipball/1fdc310bf857c11d3703ae02689a2e482c71c5ab", + "reference": "1fdc310bf857c11d3703ae02689a2e482c71c5ab", "shasum": "" }, "require": { "php": ">=7.2.0 <8.0", - "phpunit/phpunit": "^8.4" + "phpunit/phpunit": "^8.4 | ^9.0" }, "type": "library", "autoload": { @@ -2902,20 +2952,20 @@ "keywords": [ "codeception" ], - "time": "2019-11-23T20:16:40+00:00" + "time": "2020-02-11T10:45:21+00:00" }, { "name": "codeception/lib-innerbrowser", - "version": "1.2.3", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/Codeception/lib-innerbrowser.git", - "reference": "289028f011dcc954c530e946ea34bb7ce4ec2721" + "reference": "2123542b1325cc349ac68868abe74638bcb32ab6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/289028f011dcc954c530e946ea34bb7ce4ec2721", - "reference": "289028f011dcc954c530e946ea34bb7ce4ec2721", + "url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/2123542b1325cc349ac68868abe74638bcb32ab6", + "reference": "2123542b1325cc349ac68868abe74638bcb32ab6", "shasum": "" }, "require": { @@ -2955,7 +3005,7 @@ "keywords": [ "codeception" ], - "time": "2019-11-26T16:50:12+00:00" + "time": "2020-02-20T14:46:50+00:00" }, { "name": "codeception/module-asserts", @@ -3062,16 +3112,16 @@ }, { "name": "codeception/module-yii2", - "version": "1.0.1", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/Codeception/module-yii2.git", - "reference": "9796e9a990e80aa5f8b049563071c2825289a6ff" + "reference": "89ec2b34db0fe1c80d404d939ecc7ab07051b4b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/module-yii2/zipball/9796e9a990e80aa5f8b049563071c2825289a6ff", - "reference": "9796e9a990e80aa5f8b049563071c2825289a6ff", + "url": "https://api.github.com/repos/Codeception/module-yii2/zipball/89ec2b34db0fe1c80d404d939ecc7ab07051b4b7", + "reference": "89ec2b34db0fe1c80d404d939ecc7ab07051b4b7", "shasum": "" }, "require": { @@ -3109,7 +3159,7 @@ "codeception", "yii2" ], - "time": "2019-10-25T17:28:12+00:00" + "time": "2020-01-28T12:56:17+00:00" }, { "name": "codeception/phpunit-wrapper", @@ -3197,20 +3247,20 @@ }, { "name": "codeception/stub", - "version": "3.6.0", + "version": "3.6.1", "source": { "type": "git", "url": "https://github.com/Codeception/Stub.git", - "reference": "94874f511ab1025b1f4cb927884cdda5004ece64" + "reference": "a3ba01414cbee76a1bced9f9b6b169cc8d203880" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Stub/zipball/94874f511ab1025b1f4cb927884cdda5004ece64", - "reference": "94874f511ab1025b1f4cb927884cdda5004ece64", + "url": "https://api.github.com/repos/Codeception/Stub/zipball/a3ba01414cbee76a1bced9f9b6b169cc8d203880", + "reference": "a3ba01414cbee76a1bced9f9b6b169cc8d203880", "shasum": "" }, "require": { - "phpunit/phpunit": "^8.4" + "phpunit/phpunit": "^8.4 | ^9.0" }, "type": "library", "autoload": { @@ -3223,7 +3273,7 @@ "MIT" ], "description": "Flexible Stub wrapper for PHPUnit's Mock Builder", - "time": "2019-11-23T20:11:30+00:00" + "time": "2020-02-07T18:42:28+00:00" }, { "name": "codeception/verify", @@ -3708,41 +3758,38 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.4", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" }, "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpdocumentor/type-resolver": "0.4.*", - "phpunit/phpunit": "^6.4" + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -3753,33 +3800,36 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-12-28T18:55:12+00:00" + "time": "2020-02-22T12:28:44+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.0.1", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", "shasum": "" }, "require": { - "php": "^7.1", + "php": "^7.2", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.1", - "mockery/mockery": "~1", - "phpunit/phpunit": "^7.0" + "ext-tokenizer": "^7.2", + "mockery/mockery": "~1" }, "type": "library", "extra": { @@ -3803,7 +3853,7 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2019-08-22T18:11:29+00:00" + "time": "2020-02-18T18:59:58+00:00" }, { "name": "phpspec/php-diff", @@ -3845,16 +3895,16 @@ }, { "name": "phpspec/prophecy", - "version": "v1.10.2", + "version": "v1.10.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9", - "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { @@ -3904,7 +3954,7 @@ "spy", "stub" ], - "time": "2020-01-20T15:57:02+00:00" + "time": "2020-03-05T15:02:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4160,16 +4210,16 @@ }, { "name": "phpunit/phpunit", - "version": "8.5.2", + "version": "8.5.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "018b6ac3c8ab20916db85fa91bf6465acb64d1e0" + "reference": "67750516bc02f300e2742fed2f50177f8f37bedf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/018b6ac3c8ab20916db85fa91bf6465acb64d1e0", - "reference": "018b6ac3c8ab20916db85fa91bf6465acb64d1e0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/67750516bc02f300e2742fed2f50177f8f37bedf", + "reference": "67750516bc02f300e2742fed2f50177f8f37bedf", "shasum": "" }, "require": { @@ -4239,7 +4289,7 @@ "testing", "xunit" ], - "time": "2020-01-08T08:49:49+00:00" + "time": "2020-03-31T08:52:04+00:00" }, { "name": "psr/container", @@ -5100,16 +5150,16 @@ }, { "name": "symfony/console", - "version": "v5.0.3", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "345ab6ecb456b5147ea3b3271d7f1f00aadfd257" + "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/345ab6ecb456b5147ea3b3271d7f1f00aadfd257", - "reference": "345ab6ecb456b5147ea3b3271d7f1f00aadfd257", + "url": "https://api.github.com/repos/symfony/console/zipball/5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", + "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", "shasum": "" }, "require": { @@ -5172,20 +5222,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2020-01-19T11:13:19+00:00" + "time": "2020-03-30T11:42:42+00:00" }, { "name": "symfony/css-selector", - "version": "v5.0.3", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "ff60c90cb7950b592ebc84ad1289d0345bf24f9f" + "reference": "5f8d5271303dad260692ba73dfa21777d38e124e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/ff60c90cb7950b592ebc84ad1289d0345bf24f9f", - "reference": "ff60c90cb7950b592ebc84ad1289d0345bf24f9f", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/5f8d5271303dad260692ba73dfa21777d38e124e", + "reference": "5f8d5271303dad260692ba73dfa21777d38e124e", "shasum": "" }, "require": { @@ -5225,20 +5275,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2020-01-04T14:08:26+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/dom-crawler", - "version": "v4.4.3", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "b66fe8ccc850ea11c4cd31677706c1219768bea1" + "reference": "4d0fb3374324071ecdd94898367a3fa4b5563162" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/b66fe8ccc850ea11c4cd31677706c1219768bea1", - "reference": "b66fe8ccc850ea11c4cd31677706c1219768bea1", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/4d0fb3374324071ecdd94898367a3fa4b5563162", + "reference": "4d0fb3374324071ecdd94898367a3fa4b5563162", "shasum": "" }, "require": { @@ -5286,20 +5336,20 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2020-01-04T13:00:46+00:00" + "time": "2020-03-29T19:12:22+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v5.0.3", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "4a7a8cdca1120c091b4797f0e5bba69c1e783224" + "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4a7a8cdca1120c091b4797f0e5bba69c1e783224", - "reference": "4a7a8cdca1120c091b4797f0e5bba69c1e783224", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/24f40d95385774ed5c71dbf014edd047e2f2f3dc", + "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc", "shasum": "" }, "require": { @@ -5356,7 +5406,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2020-01-10T21:57:37+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -5418,16 +5468,16 @@ }, { "name": "symfony/finder", - "version": "v5.0.3", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "4176e7cb846fe08f32518b7e0ed8462e2db8d9bb" + "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/4176e7cb846fe08f32518b7e0ed8462e2db8d9bb", - "reference": "4176e7cb846fe08f32518b7e0ed8462e2db8d9bb", + "url": "https://api.github.com/repos/symfony/finder/zipball/600a52c29afc0d1caa74acbec8d3095ca7e9910d", + "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d", "shasum": "" }, "require": { @@ -5463,20 +5513,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2020-01-04T14:08:26+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.13.1", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" + "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/4719fa9c18b0464d399f1a63bf624b42b6fa8d14", + "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14", "shasum": "" }, "require": { @@ -5488,7 +5538,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -5521,20 +5571,20 @@ "polyfill", "portable" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-02-27T09:26:54+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.13.1", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "4b0e2222c55a25b4541305a053013d5647d3a25f" + "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/4b0e2222c55a25b4541305a053013d5647d3a25f", - "reference": "4b0e2222c55a25b4541305a053013d5647d3a25f", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", + "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", "shasum": "" }, "require": { @@ -5543,7 +5593,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -5579,7 +5629,7 @@ "portable", "shim" ], - "time": "2019-11-27T16:25:15+00:00" + "time": "2020-02-27T09:26:54+00:00" }, { "name": "symfony/service-contracts", @@ -5641,16 +5691,16 @@ }, { "name": "symfony/yaml", - "version": "v5.0.3", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a" + "reference": "ad5e9c83ade5bbb3a96a3f30588a0622708caefd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a", - "reference": "69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ad5e9c83ade5bbb3a96a3f30588a0622708caefd", + "reference": "ad5e9c83ade5bbb3a96a3f30588a0622708caefd", "shasum": "" }, "require": { @@ -5696,7 +5746,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2020-01-21T11:12:28+00:00" + "time": "2020-03-30T11:42:42+00:00" }, { "name": "theseer/tokenizer", @@ -5740,16 +5790,16 @@ }, { "name": "webmozart/assert", - "version": "1.6.0", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" + "reference": "aed98a490f9a8f78468232db345ab9cf606cf598" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", + "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598", + "reference": "aed98a490f9a8f78468232db345ab9cf606cf598", "shasum": "" }, "require": { @@ -5784,7 +5834,7 @@ "check", "validate" ], - "time": "2019-11-24T13:36:37+00:00" + "time": "2020-02-14T12:15:55+00:00" }, { "name": "yiisoft/yii2-debug", diff --git a/controllers/SiteController.php b/controllers/SiteController.php index 74ed272..481b585 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -107,13 +107,14 @@ class SiteController extends Controller return $this->goHome(); } -// public function actionAddAdmin() { -// $model = new Users(); -// $model->username = 'admin'; -// $model->email = 'admin@admin.ad'; -// $model->setPassword('admin'); -// if($model->save()) { -// echo 'ok'; -// } -// } + public function actionAddAdmin() { + $model = new Users(); + $model->username = 'admin'; + $model->email = 'admin@admin.ad'; + $model->isAdmin = 1; + $model->setPassword('admin'); + if($model->save()) { + echo 'ok'; + } + } } diff --git a/migrations/m200409_135950_create_employee_positions_table.php b/migrations/m200409_135950_create_employee_positions_table.php new file mode 100644 index 0000000..988d18d --- /dev/null +++ b/migrations/m200409_135950_create_employee_positions_table.php @@ -0,0 +1,43 @@ +createTable('{{%employee_positions}}', [ + 'id' => $this->primaryKey(), + 'name' => $this->string(64)->notNull()->unique() + ]); + + $this->addColumn('employees', 'position_id', 'integer default null'); + + $this->addForeignKey( + 'employees_position_fk', + 'employees', + 'position_id', + 'employee_positions', + 'id', + 'SET NULL' + ); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropForeignKey('employees_position_fk', 'employees'); + + $this->dropColumn('employees', 'position_id'); + + $this->dropTable('{{%employee_positions}}'); + } +} diff --git a/models/EmployeePositions.php b/models/EmployeePositions.php new file mode 100644 index 0000000..27c02e3 --- /dev/null +++ b/models/EmployeePositions.php @@ -0,0 +1,57 @@ + 64], + [['name'], 'unique'], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'name' => 'Должность', + ]; + } + + /** + * Gets query for [[Employees]]. + * + * @return \yii\db\ActiveQuery + */ + public function getEmployees() + { + return $this->hasMany(Employees::className(), ['position_id' => 'id']); + } +} diff --git a/models/EmployeePositionsSearch.php b/models/EmployeePositionsSearch.php new file mode 100644 index 0000000..08aa02d --- /dev/null +++ b/models/EmployeePositionsSearch.php @@ -0,0 +1,70 @@ + $query, + 'sort' => ['defaultOrder' => ['id' => SORT_DESC]] + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/models/Employees.php b/models/Employees.php index b6c217b..a933828 100644 --- a/models/Employees.php +++ b/models/Employees.php @@ -9,11 +9,14 @@ use Yii; * * @property int $id * @property int|null $object_id + * @property int|null $position_id * @property int $table_number * @property string|null $full_name * @property int|null $is_active * * @property Objects $object + * @property Objects $position + * @property string|null $positionName */ class Employees extends \yii\db\ActiveRecord { @@ -31,7 +34,7 @@ class Employees extends \yii\db\ActiveRecord public function rules() { return [ - [['object_id', 'is_active', 'table_number'], 'integer'], + [['object_id', 'position_id', 'is_active', 'table_number'], 'integer'], [['full_name', 'table_number', 'is_active'], 'required'], [['full_name'], 'string', 'max' => 128], [['object_id'], 'exist', 'skipOnError' => true, 'targetClass' => Objects::className(), 'targetAttribute' => ['object_id' => 'id']], @@ -50,6 +53,8 @@ class Employees extends \yii\db\ActiveRecord 'objectName' => 'Объект', 'full_name' => 'ФИО', 'is_active' => 'Активность', + 'position_id' => 'Должность', + 'positionName' => 'Должность', ]; } @@ -69,4 +74,22 @@ class Employees extends \yii\db\ActiveRecord { return !is_null($this->object) ? $this->object->name : null; } + + /** + * Gets query for [[Position]]. + * + * @return \yii\db\ActiveQuery + */ + public function getPosition() + { + return $this->hasOne(EmployeePositions::className(), ['id' => 'position_id']); + } + + /** + * @return string|null + */ + public function getPositionName() + { + return !is_null($this->position) ? $this->position->name : null; + } } diff --git a/models/EmployeesSearch.php b/models/EmployeesSearch.php index b26f17c..9062653 100644 --- a/models/EmployeesSearch.php +++ b/models/EmployeesSearch.php @@ -13,6 +13,7 @@ use app\models\Employees; class EmployeesSearch extends Employees { public $objectName; + public $positionName; /** * @inheritdoc @@ -21,7 +22,7 @@ class EmployeesSearch extends Employees { return [ [['id', 'object_id', 'is_active', 'table_number'], 'integer'], - [['full_name', 'objectName'], 'safe'], + [['full_name', 'objectName', 'positionName'], 'safe'], ]; } @@ -69,6 +70,10 @@ class EmployeesSearch extends Employees 'asc' => ['objects.name' => SORT_ASC], 'desc' => ['objects.name' => SORT_DESC] ], + 'positionName' => [ + 'asc' => ['employee_positions.name' => SORT_ASC], + 'desc' => ['employee_positions.name' => SORT_DESC] + ], 'is_active' => [ 'asc' => ['is_active' => SORT_ASC], 'desc' => ['is_active' => SORT_DESC] @@ -84,14 +89,15 @@ class EmployeesSearch extends Employees // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); $query->joinWith(['object']); + $query->joinWith(['position']); return $dataProvider; } - $this->addCondition($query, 'object_id'); // grid filtering conditions $query->andFilterWhere([ 'employees.id' => $this->id, 'object_id' => $this->object_id, + 'position_id' => $this->position_id, 'table_number' => $this->table_number, 'is_active' => $this->is_active, ]); @@ -99,27 +105,21 @@ class EmployeesSearch extends Employees $query->andFilterWhere(['like', 'full_name', $this->full_name]); $query->joinWith(['object' => function ($q) { - $q->where('objects.name LIKE "%' . $this->objectName . '%" OR objects.name IS NULL'); + $condition = 'objects.name LIKE "%' . $this->objectName . '%"'; + if (empty($this->objectName)) { + $condition .= ' OR objects.name IS NULL'; + } + $q->where($condition); }]); - return $dataProvider; - } + $query->joinWith(['position' => function ($q) { + $condition = 'employee_positions.name LIKE "%' . $this->positionName . '%"'; + if (empty($this->positionName)) { + $condition .= ' OR employee_positions.name IS NULL'; + } + $q->where($condition); + }]); - protected function addCondition($query, $attribute, $partialMatch = false) - { - if (($pos = strrpos($attribute, '.')) !== false) { - $modelAttribute = substr($attribute, $pos + 1); - } else { - $modelAttribute = $attribute; - } - $value = $this->$modelAttribute; - if (trim($value) === '') { - return; - } - if ($partialMatch) { - $query->andWhere(['like', $attribute, $value]); - } else { - $query->andWhere([$attribute => $value]); - } + return $dataProvider; } } diff --git a/modules/administrator/controllers/EmployeePositionsController.php b/modules/administrator/controllers/EmployeePositionsController.php new file mode 100644 index 0000000..95ce9f6 --- /dev/null +++ b/modules/administrator/controllers/EmployeePositionsController.php @@ -0,0 +1,133 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + 'access' => [ + 'class' => '\yii\filters\AccessControl', + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['superadmin'] + ], + ], + ], + ]; + } + + /** + * Lists all EmployeePositions models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new EmployeePositionsSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single EmployeePositions model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new EmployeePositions model. + * If creation is successful, the browser will be redirected to the 'index' page. + * @return mixed + */ + public function actionCreate() + { + $model = new EmployeePositions(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index']); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing EmployeePositions model. + * If update is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index']); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing EmployeePositions model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the EmployeePositions model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return EmployeePositions the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = EmployeePositions::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/modules/administrator/views/employee-positions/_form.php b/modules/administrator/views/employee-positions/_form.php new file mode 100644 index 0000000..b67c01e --- /dev/null +++ b/modules/administrator/views/employee-positions/_form.php @@ -0,0 +1,28 @@ + + +
+ +
+ + field($model, 'name')->textInput(['maxlength' => true]) ?> + +
+ + +
diff --git a/modules/administrator/views/employee-positions/create.php b/modules/administrator/views/employee-positions/create.php new file mode 100644 index 0000000..5f48cc4 --- /dev/null +++ b/modules/administrator/views/employee-positions/create.php @@ -0,0 +1,19 @@ +title = 'Создание должности'; +$this->params['breadcrumbs'][] = ['label' => 'Должности', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/modules/administrator/views/employee-positions/index.php b/modules/administrator/views/employee-positions/index.php new file mode 100644 index 0000000..18b8ad6 --- /dev/null +++ b/modules/administrator/views/employee-positions/index.php @@ -0,0 +1,31 @@ +title = 'Должности'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+
+ 'btn btn-success btn-flat']) ?> +
+
+ $dataProvider, + 'filterModel' => $searchModel, + 'layout' => "{items}\n{summary}\n{pager}", + 'columns' => [ + + 'id', + 'name', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
+
diff --git a/modules/administrator/views/employee-positions/update.php b/modules/administrator/views/employee-positions/update.php new file mode 100644 index 0000000..72e3edb --- /dev/null +++ b/modules/administrator/views/employee-positions/update.php @@ -0,0 +1,19 @@ +title = 'Редактирование должности: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Должности', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'редактирование'; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/modules/administrator/views/employee-positions/view.php b/modules/administrator/views/employee-positions/view.php new file mode 100644 index 0000000..05f12cb --- /dev/null +++ b/modules/administrator/views/employee-positions/view.php @@ -0,0 +1,34 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Employee Positions', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+
+ $model->id], ['class' + => 'btn btn-primary btn-flat']) ?> + $model->id], [ + 'class' => 'btn btn-danger btn-flat', + 'data' => [ + 'confirm' => 'Вы действительно хотите удалить?', + 'method' => 'post', + ], + ]) ?> +
+
+ $model, + 'attributes' => [ + 'id', + 'name', + ], + ]) ?> +
+
diff --git a/modules/administrator/views/employees/_form.php b/modules/administrator/views/employees/_form.php index 81baefc..689b316 100644 --- a/modules/administrator/views/employees/_form.php +++ b/modules/administrator/views/employees/_form.php @@ -1,24 +1,41 @@ all(), 'id', 'name'); +$objects = ArrayHelper::map(Objects::find()->all(), 'id', 'name'); + +$positions = ArrayHelper::map(EmployeePositions::find()->all(), 'id', 'name'); + ?>
- field($model, 'object_id')->dropDownList($objects) ?> + field($model, 'object_id')->widget(Select2::class, [ + 'data' => $objects, + 'options' => ['placeholder' => 'Выберите объект ...'], + 'pluginOptions' => [ + 'allowClear' => true + ], + ]) ?> + field($model, 'position_id')->widget(Select2::class, [ + 'data' => $positions, + 'options' => ['placeholder' => 'Выберите должность ...'], + 'pluginOptions' => [ + 'allowClear' => true + ], + ]) ?> field($model, 'table_number')->textInput(['maxlength' => true]) ?> diff --git a/modules/administrator/views/employees/index.php b/modules/administrator/views/employees/index.php index 8cb65f6..a5cce0c 100644 --- a/modules/administrator/views/employees/index.php +++ b/modules/administrator/views/employees/index.php @@ -19,11 +19,12 @@ $this->params['breadcrumbs'][] = $this->title; $dataProvider, 'filterModel' => $searchModel, - 'formatter' => ['class' => 'yii\i18n\Formatter','nullDisplay' => 'Мобильный'], + 'formatter' => ['class' => 'yii\i18n\Formatter'], 'layout' => "{items}\n{summary}\n{pager}", 'columns' => [ 'table_number', 'full_name', + 'positionName', 'objectName', [ 'attribute' => 'is_active', diff --git a/modules/administrator/views/employees/view.php b/modules/administrator/views/employees/view.php index 01d0217..864cf14 100644 --- a/modules/administrator/views/employees/view.php +++ b/modules/administrator/views/employees/view.php @@ -29,6 +29,7 @@ $this->params['breadcrumbs'][] = $this->title; 'attributes' => [ 'table_number', 'objectName', + 'positionName', 'full_name', [ 'attribute' => 'is_active', diff --git a/views/layouts/left.php b/views/layouts/left.php index 6803649..b6239f2 100644 --- a/views/layouts/left.php +++ b/views/layouts/left.php @@ -1,66 +1,39 @@ -- GitLab From 8c4b272d797aa8c1b18d241dada70a0da6ec21bc Mon Sep 17 00:00:00 2001 From: cangreen Date: Tue, 14 Apr 2020 13:51:40 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 5 +- composer.lock | 1101 ++++++++++++++--- ...48_alter_records_table_add_position_id.php | 52 + models/Records.php | 524 ++++---- models/RecordsSearch.php | 339 +++-- models/TableForm.php | 254 ++-- .../controllers/EmployeesController.php | 329 ++--- .../controllers/RecordsController.php | 302 +++-- modules/administrator/views/records/_form.php | 223 ++-- modules/administrator/views/records/index.php | 227 ++-- .../administrator/views/records/update.php | 4 + modules/administrator/views/records/view.php | 1 + modules/administrator/views/table/index.php | 139 +-- .../controllers/EmployeesController.php | 128 +- .../manager/controllers/RecordsController.php | 271 ++-- modules/manager/views/records/_form.php | 150 ++- modules/manager/views/records/index.php | 233 ++-- 17 files changed, 2615 insertions(+), 1667 deletions(-) create mode 100644 migrations/m200413_141548_alter_records_table_add_position_id.php diff --git a/composer.json b/composer.json index 2258590..3330bc6 100644 --- a/composer.json +++ b/composer.json @@ -19,12 +19,13 @@ "yiisoft/yii2-bootstrap": "~2.0.0", "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0", "dmstr/yii2-adminlte-asset": "^2.6", - "kartik-v/yii2-widget-depdrop": "^1.0", + "kartik-v/yii2-widget-depdrop": "dev-master", "kartik-v/yii2-datecontrol": "^1.9", "kartik-v/yii2-widget-datepicker": "^1.4", "kartik-v/yii2-widgets": "^3.4", "kartik-v/yii2-field-range": "^1.3", - "kartik-v/yii2-grid": "^3.3" + "kartik-v/yii2-grid": "^3.3", + "kartik-v/yii2-export": "^1.4" }, "require-dev": { "yiisoft/yii2-debug": "~2.1.0", diff --git a/composer.lock b/composer.lock index b99e20d..17a1ef3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1c9a25dc1f5d96ff29e41737a980068f", + "content-hash": "09f8e56a98048818e3e14ed05ea2bfca", "packages": [ { "name": "almasaeed2010/adminlte", @@ -75,7 +75,7 @@ "version": "3.3.11", "source": { "type": "git", - "url": "https://github.com/RobinHerbots/Inputmask.git", + "url": "git@github.com:RobinHerbots/Inputmask.git", "reference": "5e670ad62f50c738388d4dcec78d2888505ad77b" }, "dist": { @@ -873,6 +873,126 @@ ], "time": "2018-10-09T08:08:51+00:00" }, + { + "name": "kartik-v/yii2-dynagrid", + "version": "v1.5.1", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-dynagrid.git", + "reference": "16b9f2bb145a4e2eee2f36d7b3fa2d75907797c3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-dynagrid/zipball/16b9f2bb145a4e2eee2f36d7b3fa2d75907797c3", + "reference": "16b9f2bb145a4e2eee2f36d7b3fa2d75907797c3", + "shasum": "" + }, + "require": { + "kartik-v/yii2-grid": "~3.1", + "kartik-v/yii2-sortable": "~1.2", + "kartik-v/yii2-widget-activeform": "~1.4", + "kartik-v/yii2-widget-select2": "~2.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.5.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\dynagrid\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.", + "homepage": "https://github.com/kartik-v/yii2-dynagrid", + "keywords": [ + "columns", + "dynamic", + "extension", + "grid", + "hide", + "order", + "reorder", + "show", + "sort", + "visibility", + "widget", + "yii2" + ], + "time": "2019-02-23T19:25:47+00:00" + }, + { + "name": "kartik-v/yii2-export", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-export.git", + "reference": "7e8ff2d4ba2435ab6903692edd390ba8e84e3faa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-export/zipball/7e8ff2d4ba2435ab6903692edd390ba8e84e3faa", + "reference": "7e8ff2d4ba2435ab6903692edd390ba8e84e3faa", + "shasum": "" + }, + "require": { + "kartik-v/yii2-dynagrid": ">=1.4.5", + "kartik-v/yii2-mpdf": ">=1.0", + "phpoffice/phpspreadsheet": ">=1.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\export\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)", + "homepage": "https://github.com/kartik-v/yii2-export", + "keywords": [ + "OpenXML", + "csv", + "export", + "extension", + "html", + "json", + "pdf", + "spreadsheet", + "text", + "widget", + "xls", + "xlsx", + "yii2" + ], + "time": "2019-05-25T07:08:54+00:00" + }, { "name": "kartik-v/yii2-field-range", "version": "v1.3.5", @@ -1087,6 +1207,110 @@ ], "time": "2019-03-13T17:14:54+00:00" }, + { + "name": "kartik-v/yii2-mpdf", + "version": "v1.0.5", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-mpdf.git", + "reference": "908c8d15aec62cd0ae81a1ce8c1eadcc18c8f7fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-mpdf/zipball/908c8d15aec62cd0ae81a1ce8c1eadcc18c8f7fc", + "reference": "908c8d15aec62cd0ae81a1ce8c1eadcc18c8f7fc", + "shasum": "" + }, + "require": { + "mpdf/mpdf": "~7.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\mpdf\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "A Yii2 wrapper component for the mPDF library which generates PDF files from UTF-8 encoded HTML.", + "homepage": "https://github.com/kartik-v/yii2-mpdf", + "keywords": [ + "component", + "extension", + "html", + "mpdf", + "pdf", + "utf8", + "yii2" + ], + "time": "2018-10-13T07:38:33+00:00" + }, + { + "name": "kartik-v/yii2-sortable", + "version": "v1.2.2", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-sortable.git", + "reference": "a6f9a9adb873d6345de92bbe5e436ac1a1db30bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-sortable/zipball/a6f9a9adb873d6345de92bbe5e436ac1a1db30bc", + "reference": "a6f9a9adb873d6345de92bbe5e436ac1a1db30bc", + "shasum": "" + }, + "require": { + "kartik-v/yii2-krajee-base": ">=2.0.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\sortable\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "Create sortable lists and grids using HTML5 drag and drop API for Yii 2.0.", + "homepage": "https://github.com/kartik-v/yii2-sortable", + "keywords": [ + "bootstrap", + "extension", + "jquery", + "range", + "sortable", + "widget", + "yii2" + ], + "time": "2018-10-09T13:25:05+00:00" + }, { "name": "kartik-v/yii2-widget-activeform", "version": "v1.5.8", @@ -1407,16 +1631,16 @@ }, { "name": "kartik-v/yii2-widget-depdrop", - "version": "v1.0.6", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/kartik-v/yii2-widget-depdrop.git", - "reference": "ea347e3793fbd8273cc9bd1eb94c4b32bb55d318" + "reference": "4dffe1fd0c9d9d5b7e6231f6cd059dfa36d22b3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-widget-depdrop/zipball/ea347e3793fbd8273cc9bd1eb94c4b32bb55d318", - "reference": "ea347e3793fbd8273cc9bd1eb94c4b32bb55d318", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-depdrop/zipball/4dffe1fd0c9d9d5b7e6231f6cd059dfa36d22b3b", + "reference": "4dffe1fd0c9d9d5b7e6231f6cd059dfa36d22b3b", "shasum": "" }, "require": { @@ -1457,7 +1681,7 @@ "widget", "yii2" ], - "time": "2019-04-19T07:02:48+00:00" + "time": "2019-05-25T07:32:15+00:00" }, { "name": "kartik-v/yii2-widget-fileinput", @@ -1877,206 +2101,720 @@ "widget", "yii2" ], - "time": "2016-01-10T16:47:35+00:00" + "time": "2016-01-10T16:47:35+00:00" + }, + { + "name": "kartik-v/yii2-widget-timepicker", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-widget-timepicker.git", + "reference": "c1dacfc3712bedf4f694d878279189e440a24b21" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-timepicker/zipball/c1dacfc3712bedf4f694d878279189e440a24b21", + "reference": "c1dacfc3712bedf4f694d878279189e440a24b21", + "shasum": "" + }, + "require": { + "kartik-v/yii2-krajee-base": ">=2.0.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\time\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from yii2-widgets)", + "homepage": "https://github.com/kartik-v/yii2-widget-timepicker", + "keywords": [ + "bootstrap", + "extension", + "form", + "jquery", + "picker", + "plugin", + "time", + "widget", + "yii2" + ], + "time": "2018-10-09T11:58:19+00:00" + }, + { + "name": "kartik-v/yii2-widget-touchspin", + "version": "v1.2.3", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-widget-touchspin.git", + "reference": "1daca822ad11258242178155613da8e269e3df2b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-touchspin/zipball/1daca822ad11258242178155613da8e269e3df2b", + "reference": "1daca822ad11258242178155613da8e269e3df2b", + "shasum": "" + }, + "require": { + "kartik-v/yii2-krajee-base": ">=1.9" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\touchspin\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes & radios as toggle touchspines (sub repo split from yii2-widgets)", + "homepage": "https://github.com/kartik-v/yii2-widget-touchspin", + "keywords": [ + "bootstrap", + "extension", + "form", + "input", + "jquery", + "plugin", + "spinner", + "touch", + "widget", + "yii2" + ], + "time": "2018-09-05T11:59:34+00:00" + }, + { + "name": "kartik-v/yii2-widget-typeahead", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-widget-typeahead.git", + "reference": "7b7041a3cbbeb2db0a608e9f6c9b3f4f63b0069d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-typeahead/zipball/7b7041a3cbbeb2db0a608e9f6c9b3f4f63b0069d", + "reference": "7b7041a3cbbeb2db0a608e9f6c9b3f4f63b0069d", + "shasum": "" + }, + "require": { + "kartik-v/yii2-krajee-base": ">=2.0.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\typeahead\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "Enhanced Yii2 wrapper for the Twitter Typeahead plugin (sub repo split from yii2-widgets).", + "homepage": "https://github.com/kartik-v/yii2-widget-typeahead", + "keywords": [ + "dropdown", + "extension", + "form", + "jquery", + "plugin", + "typeahead", + "widget", + "yii2" + ], + "time": "2019-05-29T12:06:56+00:00" + }, + { + "name": "kartik-v/yii2-widgets", + "version": "v3.4.1", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-widgets.git", + "reference": "e5a030d700243a90eccf96a070380bd3b76e17a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-widgets/zipball/e5a030d700243a90eccf96a070380bd3b76e17a3", + "reference": "e5a030d700243a90eccf96a070380bd3b76e17a3", + "shasum": "" + }, + "require": { + "kartik-v/yii2-krajee-base": "*", + "kartik-v/yii2-widget-activeform": "*", + "kartik-v/yii2-widget-affix": "*", + "kartik-v/yii2-widget-alert": "*", + "kartik-v/yii2-widget-colorinput": "*", + "kartik-v/yii2-widget-datepicker": "*", + "kartik-v/yii2-widget-datetimepicker": "*", + "kartik-v/yii2-widget-depdrop": "*", + "kartik-v/yii2-widget-fileinput": "*", + "kartik-v/yii2-widget-growl": "*", + "kartik-v/yii2-widget-rangeinput": "*", + "kartik-v/yii2-widget-rating": "*", + "kartik-v/yii2-widget-select2": "*", + "kartik-v/yii2-widget-sidenav": "*", + "kartik-v/yii2-widget-spinner": "*", + "kartik-v/yii2-widget-switchinput": "*", + "kartik-v/yii2-widget-timepicker": "*", + "kartik-v/yii2-widget-touchspin": "*", + "kartik-v/yii2-widget-typeahead": "*" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\widgets\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "Collection of useful widgets for Yii Framework 2.0 extending functionalities for Bootstrap", + "homepage": "https://github.com/kartik-v/yii2-widgets", + "keywords": [ + "extension", + "form", + "widget", + "yii2" + ], + "time": "2018-10-09T17:40:19+00:00" + }, + { + "name": "markbaker/complex", + "version": "1.4.8", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "8eaa40cceec7bf0518187530b2e63871be661b72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/8eaa40cceec7bf0518187530b2e63871be661b72", + "reference": "8eaa40cceec7bf0518187530b2e63871be661b72", + "shasum": "" + }, + "require": { + "php": "^5.6.0|^7.0.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "phpcompatibility/php-compatibility": "^9.0", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "2.*", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^4.8.35|^5.4.0", + "sebastian/phpcpd": "2.*", + "squizlabs/php_codesniffer": "^3.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + }, + "files": [ + "classes/src/functions/abs.php", + "classes/src/functions/acos.php", + "classes/src/functions/acosh.php", + "classes/src/functions/acot.php", + "classes/src/functions/acoth.php", + "classes/src/functions/acsc.php", + "classes/src/functions/acsch.php", + "classes/src/functions/argument.php", + "classes/src/functions/asec.php", + "classes/src/functions/asech.php", + "classes/src/functions/asin.php", + "classes/src/functions/asinh.php", + "classes/src/functions/atan.php", + "classes/src/functions/atanh.php", + "classes/src/functions/conjugate.php", + "classes/src/functions/cos.php", + "classes/src/functions/cosh.php", + "classes/src/functions/cot.php", + "classes/src/functions/coth.php", + "classes/src/functions/csc.php", + "classes/src/functions/csch.php", + "classes/src/functions/exp.php", + "classes/src/functions/inverse.php", + "classes/src/functions/ln.php", + "classes/src/functions/log2.php", + "classes/src/functions/log10.php", + "classes/src/functions/negative.php", + "classes/src/functions/pow.php", + "classes/src/functions/rho.php", + "classes/src/functions/sec.php", + "classes/src/functions/sech.php", + "classes/src/functions/sin.php", + "classes/src/functions/sinh.php", + "classes/src/functions/sqrt.php", + "classes/src/functions/tan.php", + "classes/src/functions/tanh.php", + "classes/src/functions/theta.php", + "classes/src/operations/add.php", + "classes/src/operations/subtract.php", + "classes/src/operations/multiply.php", + "classes/src/operations/divideby.php", + "classes/src/operations/divideinto.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "time": "2020-03-11T20:15:49+00:00" + }, + { + "name": "markbaker/matrix", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "5348c5a67e3b75cd209d70103f916a93b1f1ed21" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/5348c5a67e3b75cd209d70103f916a93b1f1ed21", + "reference": "5348c5a67e3b75cd209d70103f916a93b1f1ed21", + "shasum": "" + }, + "require": { + "php": "^5.6.0|^7.0.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "dev-master", + "phploc/phploc": "^4", + "phpmd/phpmd": "dev-master", + "phpunit/phpunit": "^5.7", + "sebastian/phpcpd": "^3.0", + "squizlabs/php_codesniffer": "^3.0@dev" + }, + "type": "library", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + }, + "files": [ + "classes/src/functions/adjoint.php", + "classes/src/functions/antidiagonal.php", + "classes/src/functions/cofactors.php", + "classes/src/functions/determinant.php", + "classes/src/functions/diagonal.php", + "classes/src/functions/identity.php", + "classes/src/functions/inverse.php", + "classes/src/functions/minors.php", + "classes/src/functions/trace.php", + "classes/src/functions/transpose.php", + "classes/src/operations/add.php", + "classes/src/operations/directsum.php", + "classes/src/operations/subtract.php", + "classes/src/operations/multiply.php", + "classes/src/operations/divideby.php", + "classes/src/operations/divideinto.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "time": "2019-10-06T11:29:25+00:00" + }, + { + "name": "mpdf/mpdf", + "version": "v7.1.9", + "source": { + "type": "git", + "url": "https://github.com/mpdf/mpdf.git", + "reference": "a0fc1215d2306aa3b4ba6e97bd6ebe4bab6a88fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/mpdf/zipball/a0fc1215d2306aa3b4ba6e97bd6ebe4bab6a88fb", + "reference": "a0fc1215d2306aa3b4ba6e97bd6ebe4bab6a88fb", + "shasum": "" + }, + "require": { + "ext-gd": "*", + "ext-mbstring": "*", + "myclabs/deep-copy": "^1.7", + "paragonie/random_compat": "^1.4|^2.0|9.99.99", + "php": "^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0", + "psr/log": "^1.0", + "setasign/fpdi": "1.6.*" + }, + "require-dev": { + "mockery/mockery": "^0.9.5", + "phpunit/phpunit": "^5.0", + "squizlabs/php_codesniffer": "^2.7.0", + "tracy/tracy": "^2.4" + }, + "suggest": { + "ext-bcmath": "Needed for generation of some types of barcodes", + "ext-xml": "Needed mainly for SVG manipulation", + "ext-zlib": "Needed for compression of embedded resources, such as fonts" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-development": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Mpdf\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-only" + ], + "authors": [ + { + "name": "Matěj Humpál", + "role": "Developer, maintainer" + }, + { + "name": "Ian Back", + "role": "Developer (retired)" + } + ], + "description": "PHP library generating PDF files from UTF-8 encoded HTML", + "homepage": "https://mpdf.github.io", + "keywords": [ + "pdf", + "php", + "utf-8" + ], + "time": "2019-02-06T13:32:19+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.9.5", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2020-01-17T21:11:47+00:00" }, { - "name": "kartik-v/yii2-widget-timepicker", - "version": "v1.0.4", + "name": "paragonie/random_compat", + "version": "v9.99.99", "source": { "type": "git", - "url": "https://github.com/kartik-v/yii2-widget-timepicker.git", - "reference": "c1dacfc3712bedf4f694d878279189e440a24b21" + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-widget-timepicker/zipball/c1dacfc3712bedf4f694d878279189e440a24b21", - "reference": "c1dacfc3712bedf4f694d878279189e440a24b21", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", "shasum": "" }, "require": { - "kartik-v/yii2-krajee-base": ">=2.0.0" + "php": "^7" }, - "type": "yii2-extension", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" }, - "autoload": { - "psr-4": { - "kartik\\time\\": "src" - } + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." }, + "type": "library", "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Kartik Visweswaran", - "email": "kartikv2@gmail.com", - "homepage": "http://www.krajee.com/" + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" } ], - "description": "Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from yii2-widgets)", - "homepage": "https://github.com/kartik-v/yii2-widget-timepicker", + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", "keywords": [ - "bootstrap", - "extension", - "form", - "jquery", - "picker", - "plugin", - "time", - "widget", - "yii2" + "csprng", + "polyfill", + "pseudorandom", + "random" ], - "time": "2018-10-09T11:58:19+00:00" + "time": "2018-07-02T15:55:56+00:00" }, { - "name": "kartik-v/yii2-widget-touchspin", - "version": "v1.2.3", + "name": "phpoffice/phpspreadsheet", + "version": "1.11.0", "source": { "type": "git", - "url": "https://github.com/kartik-v/yii2-widget-touchspin.git", - "reference": "1daca822ad11258242178155613da8e269e3df2b" + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "c2a205e82f9cf1cc9fab86b79e808d86dd680470" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-widget-touchspin/zipball/1daca822ad11258242178155613da8e269e3df2b", - "reference": "1daca822ad11258242178155613da8e269e3df2b", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c2a205e82f9cf1cc9fab86b79e808d86dd680470", + "reference": "c2a205e82f9cf1cc9fab86b79e808d86dd680470", "shasum": "" }, "require": { - "kartik-v/yii2-krajee-base": ">=1.9" + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "ext-zip": "*", + "ext-zlib": "*", + "markbaker/complex": "^1.4", + "markbaker/matrix": "^1.2", + "php": "^7.1", + "psr/simple-cache": "^1.0" }, - "type": "yii2-extension", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } + "require-dev": { + "dompdf/dompdf": "^0.8.3", + "friendsofphp/php-cs-fixer": "^2.16", + "jpgraph/jpgraph": "^4.0", + "mpdf/mpdf": "^8.0", + "phpcompatibility/php-compatibility": "^9.3", + "phpunit/phpunit": "^7.5", + "squizlabs/php_codesniffer": "^3.5", + "tecnickcom/tcpdf": "^6.3" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer", + "jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer" }, + "type": "library", "autoload": { "psr-4": { - "kartik\\touchspin\\": "src" + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Kartik Visweswaran", - "email": "kartikv2@gmail.com", - "homepage": "http://www.krajee.com/" + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" } ], - "description": "A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes & radios as toggle touchspines (sub repo split from yii2-widgets)", - "homepage": "https://github.com/kartik-v/yii2-widget-touchspin", + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", "keywords": [ - "bootstrap", - "extension", - "form", - "input", - "jquery", - "plugin", - "spinner", - "touch", - "widget", - "yii2" + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" ], - "time": "2018-09-05T11:59:34+00:00" + "time": "2020-03-02T13:09:03+00:00" }, { - "name": "kartik-v/yii2-widget-typeahead", - "version": "v1.0.4", + "name": "psr/log", + "version": "1.1.3", "source": { "type": "git", - "url": "https://github.com/kartik-v/yii2-widget-typeahead.git", - "reference": "7b7041a3cbbeb2db0a608e9f6c9b3f4f63b0069d" + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-widget-typeahead/zipball/7b7041a3cbbeb2db0a608e9f6c9b3f4f63b0069d", - "reference": "7b7041a3cbbeb2db0a608e9f6c9b3f4f63b0069d", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", "shasum": "" }, "require": { - "kartik-v/yii2-krajee-base": ">=2.0.0" + "php": ">=5.3.0" }, - "type": "yii2-extension", + "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { "psr-4": { - "kartik\\typeahead\\": "src" + "Psr\\Log\\": "Psr/Log/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Kartik Visweswaran", - "email": "kartikv2@gmail.com", - "homepage": "http://www.krajee.com/" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "Enhanced Yii2 wrapper for the Twitter Typeahead plugin (sub repo split from yii2-widgets).", - "homepage": "https://github.com/kartik-v/yii2-widget-typeahead", + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", "keywords": [ - "dropdown", - "extension", - "form", - "jquery", - "plugin", - "typeahead", - "widget", - "yii2" + "log", + "psr", + "psr-3" ], - "time": "2019-05-29T12:06:56+00:00" + "time": "2020-03-23T09:12:05+00:00" }, { - "name": "kartik-v/yii2-widgets", - "version": "v3.4.1", + "name": "psr/simple-cache", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/kartik-v/yii2-widgets.git", - "reference": "e5a030d700243a90eccf96a070380bd3b76e17a3" + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-widgets/zipball/e5a030d700243a90eccf96a070380bd3b76e17a3", - "reference": "e5a030d700243a90eccf96a070380bd3b76e17a3", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", "shasum": "" }, "require": { - "kartik-v/yii2-krajee-base": "*", - "kartik-v/yii2-widget-activeform": "*", - "kartik-v/yii2-widget-affix": "*", - "kartik-v/yii2-widget-alert": "*", - "kartik-v/yii2-widget-colorinput": "*", - "kartik-v/yii2-widget-datepicker": "*", - "kartik-v/yii2-widget-datetimepicker": "*", - "kartik-v/yii2-widget-depdrop": "*", - "kartik-v/yii2-widget-fileinput": "*", - "kartik-v/yii2-widget-growl": "*", - "kartik-v/yii2-widget-rangeinput": "*", - "kartik-v/yii2-widget-rating": "*", - "kartik-v/yii2-widget-select2": "*", - "kartik-v/yii2-widget-sidenav": "*", - "kartik-v/yii2-widget-spinner": "*", - "kartik-v/yii2-widget-switchinput": "*", - "kartik-v/yii2-widget-timepicker": "*", - "kartik-v/yii2-widget-touchspin": "*", - "kartik-v/yii2-widget-typeahead": "*" + "php": ">=5.3.0" }, - "type": "yii2-extension", + "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" @@ -2084,29 +2822,28 @@ }, "autoload": { "psr-4": { - "kartik\\widgets\\": "src" + "Psr\\SimpleCache\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Kartik Visweswaran", - "email": "kartikv2@gmail.com", - "homepage": "http://www.krajee.com/" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "Collection of useful widgets for Yii Framework 2.0 extending functionalities for Bootstrap", - "homepage": "https://github.com/kartik-v/yii2-widgets", + "description": "Common interfaces for simple caching", "keywords": [ - "extension", - "form", - "widget", - "yii2" + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" ], - "time": "2018-10-09T17:40:19+00:00" + "time": "2017-10-23T01:57:42+00:00" }, { "name": "rmrevin/yii2-fontawesome", @@ -2198,6 +2935,55 @@ "homepage": "https://select2.org/", "time": "2020-01-28T05:01:22+00:00" }, + { + "name": "setasign/fpdi", + "version": "1.6.2", + "source": { + "type": "git", + "url": "https://github.com/Setasign/FPDI.git", + "reference": "a6ad58897a6d97cc2d2cd2adaeda343b25a368ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/a6ad58897a6d97cc2d2cd2adaeda343b25a368ea", + "reference": "a6ad58897a6d97cc2d2cd2adaeda343b25a368ea", + "shasum": "" + }, + "suggest": { + "setasign/fpdf": "FPDI will extend this class but as it is also possible to use \"tecnickcom/tcpdf\" as an alternative there's no fixed dependency configured.", + "setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.", + "setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF." + }, + "type": "library", + "autoload": { + "classmap": [ + "filters/", + "fpdi.php", + "fpdf_tpl.php", + "fpdi_pdf_parser.php", + "pdf_context.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Slabon", + "email": "jan.slabon@setasign.com", + "homepage": "https://www.setasign.com" + } + ], + "description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.", + "homepage": "https://www.setasign.com/fpdi", + "keywords": [ + "fpdf", + "fpdi", + "pdf" + ], + "time": "2017-05-11T14:25:49+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.2.3", @@ -3493,54 +4279,6 @@ ], "time": "2019-07-01T23:21:34+00:00" }, - { - "name": "myclabs/deep-copy", - "version": "1.9.5", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "replace": { - "myclabs/deep-copy": "self.version" - }, - "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2020-01-17T21:11:47+00:00" - }, { "name": "opis/closure", "version": "3.5.1", @@ -5996,6 +6734,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "kartik-v/yii2-widget-depdrop": 20, "codeception/codeception": 20 }, "prefer-stable": false, diff --git a/migrations/m200413_141548_alter_records_table_add_position_id.php b/migrations/m200413_141548_alter_records_table_add_position_id.php new file mode 100644 index 0000000..c0941fe --- /dev/null +++ b/migrations/m200413_141548_alter_records_table_add_position_id.php @@ -0,0 +1,52 @@ +addColumn('records','position_id', 'integer default null'); + + $this->addForeignKey( + 'records_positions_fk', + 'records', + 'position_id', + 'employee_positions', + 'id', + 'SET NULL' + ); + + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropForeignKey('records_positions_fk', 'records'); + + $this->dropColumn('records', 'position_id'); + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m200413_141548_alter_records_table_add_position_id cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/models/Records.php b/models/Records.php index b59cd63..9e89523 100644 --- a/models/Records.php +++ b/models/Records.php @@ -21,272 +21,294 @@ use yii\behaviors\TimestampBehavior; * @property int|null $table_code_id * @property Employees $employee * @property Objects $object + * @property EmployeePositions $position */ class Records extends \yii\db\ActiveRecord { - public $start_period = null; - - public $end_period = null; - - const SCENARIO_TABLE_CODE = 'table_code'; - - public function scenarios() - { - $scenarios = parent::scenarios(); - $scenarios[self::SCENARIO_TABLE_CODE] = [ - 'employee_id', 'object_id', 'start_period', 'end_period', 'created_at', 'type', 'table_code_id', 'details' - ]; - return $scenarios; - } - - /** - * {@inheritdoc} - */ - public static function tableName() - { - return 'records'; - } - - /** - * {@inheritdoc} - */ - public function rules() - { - return [ - [['employee_id', 'object_id', 'start', 'end', 'created_at', 'type'], 'required'], - [['employee_id', 'object_id', 'table_code_id', 'start', 'end', 'start_period', 'end_period', 'type', 'created_at'], 'integer'], - [['start'], 'checkStartDayIsCreateDay', 'skipOnError' => false, 'skipOnEmpty' => false], - [['end'], 'checkSameDay', 'skipOnError' => false, 'skipOnEmpty' => false], - [['end'], 'checkEndDate', 'skipOnError' => false, 'skipOnEmpty' => false], - [['type'], 'checkType', 'skipOnError' => false, 'skipOnEmpty' => false], - [['details'], 'string', 'max' => 1024], - [['employee_id'], 'exist', 'skipOnError' => true, 'targetClass' => Employees::className(), 'targetAttribute' => ['employee_id' => 'id']], - [['object_id'], 'exist', 'skipOnError' => true, 'targetClass' => Objects::className(), 'targetAttribute' => ['object_id' => 'id']], - [['table_code_id'], 'exist', 'skipOnError' => true, 'targetClass' => TableCodes::className(), 'targetAttribute' => ['table_code_id' => 'id']], - [['table_code_id'], 'checkIfWorkRecordExists', 'skipOnError' => false, 'skipOnEmpty' => false], - ]; - } - - /** - * {@inheritdoc} - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'employee_id' => 'ФИО соотрудника', - 'employeeFullName' => 'ФИО соотрудника', - 'employeeTableNumber' => 'Таб.№ сотрудника', - 'object_id' => 'Объект', - 'objectName' => 'Объект', - 'objectNumber' => 'Номер объекта', - 'start' => 'Дата/время начала', - 'end' => 'Дата/время окончания', - 'start_period' => 'Начало периода', - 'end_period' => 'Окончание периода', - 'type' => 'Тип записи', - 'created_at' => 'Дата/время создания', - 'table_code_id' => 'Код учёта', - 'code' => 'Код учёта', - 'details' => 'Примечание', - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getEmployee() - { - return $this->hasOne(Employees::className(), ['id' => 'employee_id']); - } - - /** - * @return string - */ - public function getEmployeeFullName() - { - return $this->employee->full_name; - } - - /** - * @return string - */ - public function getEmployeeTableNumber() - { - return $this->employee->table_number; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getObject() - { - return $this->hasOne(Objects::className(), ['id' => 'object_id']); - } - - /** - * @return string - */ - public function getObjectName() - { - return $this->object->name; - } - - /** - * @return string - */ - public function getObjectNumber() - { - return $this->object->object_number; - } - - /** - * Gets query for [[TableCode]]. - * - * @return \yii\db\ActiveQuery - */ - public function getTableCode() - { - return $this->hasOne(TableCodes::className(), ['id' => 'table_code_id']); - } - - public function getCode() - { - return is_null($this->table_code_id) ? null : $this->tableCode->code; - } - - /** - * Проверка, что дата окончания тот же день, что и дата начала - * @param $attribute - * @return bool - */ - public function checkSameDay($attribute) - { - $day = $this->getDay('start'); - - if ($this->$attribute < $day['dayStart'] || $this->$attribute > $day['dayEnd']) { - $this->addError($attribute, 'Дата начала и окончания должны быть в пределах одного дня'); - return false; + public $start_period = null; + + public $end_period = null; + + const SCENARIO_TABLE_CODE = 'table_code'; + + public function scenarios() + { + $scenarios = parent::scenarios(); + $scenarios[self::SCENARIO_TABLE_CODE] = [ + 'employee_id', 'object_id', 'start_period', 'end_period', 'created_at', 'type', 'table_code_id', 'details' + ]; + return $scenarios; + } + + /** + * {@inheritdoc} + */ + public static function tableName() + { + return 'records'; } - return true; - } - - - /** - * Проверка, что дата окончания не раньше даты начала - * @param $attribute - * @return bool - */ - public function checkEndDate($attribute) - { - if ($this->$attribute < $this->start) { - $this->addError($attribute, 'Дата окончания не может быть раньше даты начала'); - return false; + + /** + * {@inheritdoc} + */ + public function rules() + { + return [ + [['employee_id', 'object_id', 'start', 'end', 'created_at', 'type'], 'required'], + [['employee_id', 'object_id', 'table_code_id', 'start', 'end', 'start_period', 'end_period', 'type', 'created_at'], 'integer'], + [['start'], 'checkStartDayIsCreateDay', 'skipOnError' => false, 'skipOnEmpty' => false], + [['end'], 'checkSameDay', 'skipOnError' => false, 'skipOnEmpty' => false], + [['end'], 'checkEndDate', 'skipOnError' => false, 'skipOnEmpty' => false], + [['type'], 'checkType', 'skipOnError' => false, 'skipOnEmpty' => false], + [['details'], 'string', 'max' => 1024], + [['employee_id'], 'exist', 'skipOnError' => true, 'targetClass' => Employees::className(), 'targetAttribute' => ['employee_id' => 'id']], + [['object_id'], 'exist', 'skipOnError' => true, 'targetClass' => Objects::className(), 'targetAttribute' => ['object_id' => 'id']], + [['table_code_id'], 'exist', 'skipOnError' => true, 'targetClass' => TableCodes::className(), 'targetAttribute' => ['table_code_id' => 'id']], + [['position_id'], 'exist', 'skipOnError' => true, 'targetClass' => EmployeePositions::className(), 'targetAttribute' => ['position_id' => 'id']], + [['table_code_id'], 'checkIfWorkRecordExists', 'skipOnError' => false, 'skipOnEmpty' => false], + ]; } - } - - public function checkType($attribute) - { - $day = $this->getDay('start'); - $query = Records::find()->where([ - 'employee_id' => $this->employee_id, - 'type' => $this->$attribute - ])->andWhere([ - 'between', - 'start', - $day['dayStart'], - $day['dayEnd'] - ]); - - if (Yii::$app->controller->action->id === 'update') { - $query->andWhere([ - '!=', - 'id', - $this->id - ]); + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'employee_id' => 'ФИО соотрудника', + 'position_id' => 'Должность сотрудника', + 'positionName' => 'Должность сотрудника', + 'employeeFullName' => 'ФИО соотрудника', + 'employeeTableNumber' => 'Таб.№ сотрудника', + 'object_id' => 'Объект', + 'objectName' => 'Объект', + 'objectNumber' => 'Номер объекта', + 'start' => 'Дата/время начала', + 'end' => 'Дата/время окончания', + 'start_period' => 'Начало периода', + 'end_period' => 'Окончание периода', + 'type' => 'Тип записи', + 'created_at' => 'Дата/время создания', + 'table_code_id' => 'Код учёта', + 'code' => 'Код учёта', + 'details' => 'Примечание', + ]; } - $records = $query->all(); - if (count($records) !== 0) { - $this->addError($attribute, 'Не может быть более одной записи одного типа одного сотрудника в день'); - return false; + /** + * @return \yii\db\ActiveQuery + */ + public function getEmployee() + { + return $this->hasOne(Employees::className(), ['id' => 'employee_id']); } - } - - public function checkStartDayIsCreateDay($attribute) - { - if (Yii::$app->user->can('manager')) { - $day = $this->getDay('created_at'); - if ($this->$attribute < $day['dayStart'] || $this->$attribute > $day['dayEnd']) { - $this->addError($attribute, 'Доступна запись только в текущий день'); - return false; - } + + /** + * @return \yii\db\ActiveQuery + */ + public function getPosition() + { + return $this->hasOne(EmployeePositions::className(), ['id' => 'position_id']); } - } - - public function checkIfWorkRecordExists($attribute) { - $records = Records::find()->where([ - 'between', - $attribute, - $this->start, - $this->end, - ])->all(); - - if(count($records) !== 0) { - $this->addError($attribute, 'Уже есть запись в один из дней периода'); - return false; - } - } - - /** Форматирование интервала между датами в часы и минуты - * @return string - */ - - public function formatSecondsInterval() - { - $interval = $this->end - $this->start; - $hours = 0; - $minutes = 0; - if ($interval > 3600) { - $hours = floor($interval / 3600); - $interval = $interval % 3600; + + /** + * @return string|null + */ + public function getPositionName() + { + return !is_null($this->position) ? $this->position->name : null ; } - $minutes += floor($interval / 60); - $result = ''; - if ((int)$hours !== 0) { - $result .= "{$hours}ч "; + /** + * @return string + */ + public function getEmployeeFullName() + { + return $this->employee->full_name; } - if ((int)$minutes !== 0) { - $result .= "{$minutes}м "; + + /** + * @return string + */ + public function getEmployeeTableNumber() + { + return $this->employee->table_number; + } + + + /** + * @return \yii\db\ActiveQuery + */ + public function getObject() + { + return $this->hasOne(Objects::className(), ['id' => 'object_id']); + } + + /** + * @return string + */ + public function getObjectName() + { + return $this->object->name; + } + + /** + * @return string + */ + public function getObjectNumber() + { + return $this->object->object_number; + } + + /** + * Gets query for [[TableCode]]. + * + * @return \yii\db\ActiveQuery + */ + public function getTableCode() + { + return $this->hasOne(TableCodes::className(), ['id' => 'table_code_id']); } - return $result; - } - - /** - * Находим timestamp начала и конца дня для сравнения - * @param $attribute - * @return array - * @throws \yii\base\InvalidConfigException - */ - public function getDay($attribute) - { - $result = []; - $day = Yii::$app->formatter->asDate($this->$attribute); - $result['dayStart'] = Yii::$app->formatter->asTimestamp($day . ' 00:00:00'); - $result['dayEnd'] = Yii::$app->formatter->asTimestamp($day . ' 23:59:59'); - return $result; - } - - public function getDaysOfPeriod($start, $end) - { - $result = []; - for ($currentDate = $start; $currentDate <= $end; $currentDate += 86400) { - $result[] = $currentDate; + + public function getCode() + { + return is_null($this->table_code_id) ? null : $this->tableCode->code; + } + + /** + * Проверка, что дата окончания тот же день, что и дата начала + * @param $attribute + * @return bool + */ + public function checkSameDay($attribute) + { + $day = $this->getDay('start'); + + if ($this->$attribute < $day['dayStart'] || $this->$attribute > $day['dayEnd']) { + $this->addError($attribute, 'Дата начала и окончания должны быть в пределах одного дня'); + return false; + } + return true; + } + + + /** + * Проверка, что дата окончания не раньше даты начала + * @param $attribute + * @return bool + */ + public function checkEndDate($attribute) + { + if ($this->$attribute < $this->start) { + $this->addError($attribute, 'Дата окончания не может быть раньше даты начала'); + return false; + } + } + + public function checkType($attribute) + { + $day = $this->getDay('start'); + $query = Records::find()->where([ + 'employee_id' => $this->employee_id, + 'type' => $this->$attribute + ])->andWhere([ + 'between', + 'start', + $day['dayStart'], + $day['dayEnd'] + ]); + + if (Yii::$app->controller->action->id === 'update') { + $query->andWhere([ + '!=', + 'id', + $this->id + ]); + } + $records = $query->all(); + + if (count($records) !== 0) { + $this->addError($attribute, 'Не может быть более одной записи одного типа одного сотрудника в день'); + return false; + } + } + + public function checkStartDayIsCreateDay($attribute) + { + if (Yii::$app->user->can('manager')) { + $day = $this->getDay('created_at'); + if ($this->$attribute < $day['dayStart'] || $this->$attribute > $day['dayEnd']) { + $this->addError($attribute, 'Доступна запись только в текущий день'); + return false; + } + } + } + + public function checkIfWorkRecordExists($attribute) + { + $records = Records::find()->where([ + 'between', + $attribute, + $this->start, + $this->end, + ])->all(); + + if (count($records) !== 0) { + $this->addError($attribute, 'Уже есть запись в один из дней периода'); + return false; + } + } + + /** Форматирование интервала между датами в часы и минуты + * @return string + */ + + public function formatSecondsInterval() + { + $interval = $this->end - $this->start; + $hours = 0; + $minutes = 0; + if ($interval > 3600) { + $hours = floor($interval / 3600); + $interval = $interval % 3600; + } + $minutes += floor($interval / 60); + $result = ''; + + if ((int)$hours !== 0) { + $result .= "{$hours}ч "; + } + if ((int)$minutes !== 0) { + $result .= "{$minutes}м "; + } + return $result; + } + + /** + * Находим timestamp начала и конца дня для сравнения + * @param $attribute + * @return array + * @throws \yii\base\InvalidConfigException + */ + public function getDay($attribute) + { + $result = []; + $day = Yii::$app->formatter->asDate($this->$attribute); + $result['dayStart'] = Yii::$app->formatter->asTimestamp($day . ' 00:00:00'); + $result['dayEnd'] = Yii::$app->formatter->asTimestamp($day . ' 23:59:59'); + return $result; + } + + public function getDaysOfPeriod($start, $end) + { + $result = []; + for ($currentDate = $start; $currentDate <= $end; $currentDate += 86400) { + $result[] = $currentDate; + } + return $result; } - return $result; - } } diff --git a/models/RecordsSearch.php b/models/RecordsSearch.php index baf6523..bbc5dd2 100644 --- a/models/RecordsSearch.php +++ b/models/RecordsSearch.php @@ -6,191 +6,188 @@ use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use app\models\Records; +use yii\db\ActiveQuery; /** * RecordsSearch represents the model behind the search form of `app\models\Records`. */ class RecordsSearch extends Records { - public $employeeFullName; - public $employeeTableNumber; - public $objectNumber; - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['id', 'employee_id', 'object_id', 'type', 'employeeTableNumber', 'table_code_id'], 'integer'], - [['objectNumber', 'employeeFullName', 'start', 'end', 'created_at', 'details'], 'safe'], - ]; - } - - /** - * @inheritdoc - */ - public function scenarios() - { - // bypass scenarios() implementation in the parent class - return Model::scenarios(); - } - - /** - * Creates data provider instance with search query applied - * - * @param array $params - * - * @return ActiveDataProvider - */ - public function search($params) - { - $query = Records::find(); - $user = Users::findOne(Yii::$app->user->identity->getId()); - if (Yii::$app->user->can('manager')) { - $query->andWhere([ - 'records.object_id' => $user->object_id - ]); - } - if (Yii::$app->user->can('admin')) { - $query->andWhere(['IN', 'records.object_id', Objects::find()->select('id')->where(['hub_id' => $user->hub_id]) - ]); - } - - - // add conditions that should always apply here - - $dataProvider = new ActiveDataProvider([ - 'query' => $query, - ]); - - $dataProvider->setSort([ - 'attributes' => [ - 'id' => [ - 'asc' => ['id' => SORT_DESC], - 'desc' => ['id' => SORT_ASC] - ], - 'employeeFullName' => [ - 'asc' => ['employees.full_name' => SORT_ASC], - 'desc' => ['employees.full_name' => SORT_DESC] - ], - 'employeeTableNumber' => [ - 'asc' => ['employees.table_number' => SORT_ASC], - 'desc' => ['employees.table_number' => SORT_DESC] - ], - 'objectNumber' => [ - 'asc' => ['objects.object_number' => SORT_ASC], - 'desc' => ['objects.object_number' => SORT_DESC] - ], - - 'type' => [ - 'asc' => ['type' => SORT_ASC], - 'desc' => ['type' => SORT_DESC] - ], - 'start' => [ - 'asc' => ['start' => SORT_ASC], - 'desc' => ['start' => SORT_DESC] - ], - 'end' => [ - 'asc' => ['end' => SORT_ASC], - 'desc' => ['end' => SORT_DESC] - ], - 'created_at' => [ - 'asc' => ['created_at' => SORT_ASC], - 'desc' => ['created_at' => SORT_DESC] - ], - 'details' => [ - 'asc' => ['details' => SORT_ASC], - 'desc' => ['details' => SORT_DESC] - ], - 'table_code_id' => [ - 'asc' => ['table_code_id' => SORT_ASC], - 'desc' => ['table_code_id' => SORT_DESC] - ] - - ], - 'defaultOrder' => ['id' => SORT_DESC] - ]); - - - $this->load($params); - - if (!empty($this->start)) { - $this->filterByDate('start', $query); - } - - if (!empty($this->end)) { - $this->filterByDate('end', $query); - } - - if (!empty($this->created_at)) { - $this->filterByDate('created_at', $query); + public $employeeFullName; + public $positionName; + public $employeeTableNumber; + public $objectNumber; + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [['id', 'employee_id', 'object_id', 'type', 'employeeTableNumber', 'table_code_id'], 'integer'], + [['objectNumber', 'employeeFullName', 'positionName', 'start', 'end', 'created_at', 'details'], 'safe'], + ]; } - if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); - $query->joinWith(['employee']); - $query->joinWith(['object']); - return $dataProvider; + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); } - // grid filtering conditions - $query->andFilterWhere([ - 'records.id' => $this->id, - 'employee_id' => $this->employee_id, - 'type' => $this->type, - 'object_id' => $this->object_id, - 'table_code_id' => $this->table_code_id, + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = Records::find(); + $user = Users::findOne(Yii::$app->user->identity->getId()); + if (Yii::$app->user->can('manager')) { + $query->andWhere([ + 'records.object_id' => $user->object_id + ]); + } + if (Yii::$app->user->can('admin')) { + $query->andWhere(['IN', 'records.object_id', Objects::find()->select('id')->where(['hub_id' => $user->hub_id]) + ]); + } + + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $dataProvider->setSort([ + 'attributes' => [ + 'id' => [ + 'asc' => ['id' => SORT_DESC], + 'desc' => ['id' => SORT_ASC] + ], + 'employeeFullName' => [ + 'asc' => ['employees.full_name' => SORT_ASC], + 'desc' => ['employees.full_name' => SORT_DESC] + ], + 'employeeTableNumber' => [ + 'asc' => ['employees.table_number' => SORT_ASC], + 'desc' => ['employees.table_number' => SORT_DESC] + ], + 'positionName' => [ + 'asc' => ['employee_positions.name' => SORT_ASC], + 'desc' => ['employee_positions.name' => SORT_DESC] + ], + 'objectNumber' => [ + 'asc' => ['objects.object_number' => SORT_ASC], + 'desc' => ['objects.object_number' => SORT_DESC] + ], + + 'type' => [ + 'asc' => ['type' => SORT_ASC], + 'desc' => ['type' => SORT_DESC] + ], + 'start' => [ + 'asc' => ['start' => SORT_ASC], + 'desc' => ['start' => SORT_DESC] + ], + 'end' => [ + 'asc' => ['end' => SORT_ASC], + 'desc' => ['end' => SORT_DESC] + ], + 'created_at' => [ + 'asc' => ['created_at' => SORT_ASC], + 'desc' => ['created_at' => SORT_DESC] + ], + 'details' => [ + 'asc' => ['details' => SORT_ASC], + 'desc' => ['details' => SORT_DESC] + ], + 'table_code_id' => [ + 'asc' => ['table_code_id' => SORT_ASC], + 'desc' => ['table_code_id' => SORT_DESC] + ] + + ], + 'defaultOrder' => ['id' => SORT_DESC] + ]); + + + $this->load($params); + + if (!empty($this->start)) { + $this->filterByDate('start', $query); + } + + if (!empty($this->end)) { + $this->filterByDate('end', $query); + } + + if (!empty($this->created_at)) { + $this->filterByDate('created_at', $query); + } + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + $query->joinWith(['employee']); + $query->joinWith(['object']); + $query->joinWith(['position']); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'records.id' => $this->id, + 'employee_id' => $this->employee_id, + 'type' => $this->type, + 'object_id' => $this->object_id, + 'table_code_id' => $this->table_code_id, // 'start' => $this->start, // 'end' => $this->end, // 'created_at' => $this->created_at, - ]); - - $query->andFilterWhere(['like', 'records.details', $this->details]); - - $query->joinWith(['object' => function ($q) { - $q->where('objects.object_number LIKE "%' . $this->objectNumber . '%"'); - }]); - - $query->joinWith(['employee' => function ($q) { - $q->where('employees.full_name LIKE "%' . $this->employeeFullName . '%"'); - }]); - $query->joinWith(['employee' => function ($q) { - $q->where('employees.table_number LIKE "%' . $this->employeeTableNumber . '%"'); - }]); - + ]); + + $query->andFilterWhere(['like', 'records.details', $this->details]); + + $query->joinWith(['object' => function ($q) { + $q->where('objects.object_number LIKE "%' . $this->objectNumber . '%"'); + }]); + + $query->joinWith(['employee' => function ($q) { + $q->where('employees.full_name LIKE "%' . $this->employeeFullName . '%"'); + }]); + $query->joinWith(['employee' => function ($q) { + $q->where('employees.table_number LIKE "%' . $this->employeeTableNumber . '%"'); + }]); + $query->joinWith(['position' => function (ActiveQuery $q) { + $condition = 'employee_positions.name LIKE "%' . $this->positionName . '%"'; + if (empty($this->positionName)) { + $condition .= ' OR employee_positions.name IS NULL'; + } + $q->where($condition); + }]); + + + return $dataProvider; + } - return $dataProvider; - } - protected function addCondition($query, $attribute, $partialMatch = false) - { - if (($pos = strrpos($attribute, '.')) !== false) { - $modelAttribute = substr($attribute, $pos + 1); - } else { - $modelAttribute = $attribute; - } - $value = $this->$modelAttribute; - if (trim($value) === '') { - return; - } - if ($partialMatch) { - $query->andWhere(['like', $attribute, $value]); - } else { - $query->andWhere([$attribute => $value]); + private function filterByDate($attr, $query) + { + $dayStart = (int)\Yii::$app->formatter->asTimestamp($this->$attr . ' 00:00:00'); + $dayStop = (int)\Yii::$app->formatter->asTimestamp($this->$attr . ' 23:59:59'); + $query->andFilterWhere([ + 'between', + self::tableName() . ".$attr", + $dayStart, + $dayStop, + ]); } - } - - private function filterByDate($attr, $query) - { - $dayStart = (int)\Yii::$app->formatter->asTimestamp($this->$attr . ' 00:00:00'); - $dayStop = (int)\Yii::$app->formatter->asTimestamp($this->$attr . ' 23:59:59'); - $query->andFilterWhere([ - 'between', - self::tableName() . ".$attr", - $dayStart, - $dayStop, - ]); - } } diff --git a/models/TableForm.php b/models/TableForm.php index a1b70a5..8f3ceb6 100644 --- a/models/TableForm.php +++ b/models/TableForm.php @@ -8,138 +8,150 @@ use yii\data\ActiveDataProvider; class TableForm extends Model { - public $month; - public $object_id; - public $record_type; - - public function rules() - { - return [ - [['month'], 'string'], - [['object_id', 'record_type'], 'integer'], - [['month', 'object_id', 'record_type'], 'required'], - ]; - } - - public function getTable() - { - $records = $this->getRecords()->getModels(); - $date = explode('-', $this->month); - $days_count = cal_days_in_month(CAL_GREGORIAN, $date[0], $date[1]); - - $table = []; - $table_body = []; - foreach ($records as $record) { - $id = $record->employee_id; - $sum = 0; - if (!array_key_exists($id, $table_body)) { - $table_body[$id] = ['full_name' => $record->employee->full_name, 'table_number' => - $record->employee->table_number]; - for ($i = 1; $i <= $days_count; $i++) { - $recordDate = Yii::$app->formatter->asTimestamp("{$i}.{$date[0]}.{$date[1]}"); - if ($recordDate >= $record->getDay('start')['dayStart'] && $recordDate <= $record->getDay('end')['dayEnd']) { - if (!empty($record->table_code_id)) { - $table_body[$id][$i] = $record->code; + public $month; + public $object_id; + public $record_type; + + public function rules() + { + return [ + [['month'], 'string'], + [['object_id', 'record_type'], 'integer'], + [['month', 'object_id', 'record_type'], 'required'], + ]; + } + + public function getTable() + { + $records = $this->getRecords()->getModels(); + $date = explode('-', $this->month); + $days_count = cal_days_in_month(CAL_GREGORIAN, $date[0], $date[1]); + + $table = []; + $table_body = []; + foreach ($records as $record) { + $id = $record->employee_id; + $sum = 0; + if (!array_key_exists($id, $table_body)) { + $table_body[$id] = [ + 'full_name' => $record->employee->full_name, + 'table_number' => $record->employee->table_number, + 'position' => $record->positionName + ]; + for ($i = 1; $i <= $days_count; $i++) { + $recordDate = Yii::$app->formatter->asTimestamp("{$i}.{$date[0]}.{$date[1]}"); + if ($recordDate >= $record->getDay('start')['dayStart'] && $recordDate <= $record->getDay('end')['dayEnd']) { + if (!empty($record->table_code_id)) { + $table_body[$id][$i] = $record->code; + } else { + $table_body[$id][$i] = $record->end - $record->start; + $sum += $table_body[$id][$i]; + } + } else { + $table_body[$id][$i] = 0; + } + $table_body[$id]['sum'] = $sum; + } } else { - $table_body[$id][$i] = $record->end - $record->start; - $sum += $table_body[$id][$i]; + for ($i = 1; $i <= $days_count; $i++) { + $recordDate = Yii::$app->formatter->asTimestamp("{$i}.{$date[0]}.{$date[1]}"); + if ($recordDate >= $record->getDay('start')['dayStart'] && $recordDate <= $record->getDay('start') + ['dayEnd']) { + if (!empty($record->table_code_id)) { + $table_body[$id][$i] = $record->code; + } else { + $table_body[$id][$i] += $record->end - $record->start; + $table_body[$id]['sum'] += $record->end - $record->start; + } + } else { + continue; + } + } } - } else { - $table_body[$id][$i] = 0; - } - $table_body[$id]['sum'] = $sum; } - } else { - for ($i = 1; $i <= $days_count; $i++) { - $recordDate = Yii::$app->formatter->asTimestamp("{$i}.{$date[0]}.{$date[1]}"); - if ($recordDate >= $record->getDay('start')['dayStart'] && $recordDate <= $record->getDay('start') - ['dayEnd']) { - if (!empty($record->table_code_id)) { - $table_body[$id][$i] = $record->code; - } else { - $table_body[$id][$i] += $record->end - $record->start; - $table_body[$id]['sum'] += $record->end - $record->start; + + $table_body_formatted = []; + + foreach ($table_body as $id => $record) { + $table_body_formatted[$id]['ФИО'] = $table_body[$id]['full_name']; + $table_body_formatted[$id]['Таб. №'] = $table_body[$id]['table_number']; + $table_body_formatted[$id]['Должность'] = $table_body[$id]['position']; + foreach ($record as $key => $value) { + if (is_integer($key) && is_integer($value) || $key === 'sum') { + $table_body_formatted[$id][$key] = $this->formatInterval($value); + } else if ($key !== 'full_name' && $key !== 'table_number' && $key !== 'position') { + $table_body_formatted[$id][$key] = $value; + } } - } else { - continue; - } + $sum = $table_body_formatted[$id]['sum']; + unset($table_body_formatted[$id]['sum']); + $table_body_formatted[$id]['Сумма'] = $sum; } - } + $table['body'] = $table_body_formatted; + return $table; } - $table_body_formatted = []; - foreach ($table_body as $id => $record) { - $table_body_formatted[$id]['ФИО'] = $table_body[$id]['full_name']; - $table_body_formatted[$id]['Таб. №'] = $table_body[$id]['table_number']; - foreach ($record as $key => $value) { - if (is_integer($key) && is_integer($value) || $key === 'sum') { - $table_body_formatted[$id][$key] = $this->formatInterval($value); - } else if ($key !== 'full_name' && $key !== 'table_number') { - $table_body_formatted[$id][$key] = $value; - } - } - $sum = $table_body_formatted[$id]['sum']; - unset($table_body_formatted[$id]['sum']); - $table_body_formatted[$id]['Сумма'] = $sum; + /** + * @return ActiveDataProvider + */ + private function getRecords() + { + $query = Records::find()->where([ + 'object_id' => $this->object_id, + 'type' => $this->record_type + ])->andWhere([ + 'like', 'DATE_FORMAT(FROM_UNIXTIME(start), "%m-%Y")', $this->month] + ); + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + 'sort' => false, + 'pagination' => false, + ]); + + return $dataProvider; } - $table['body'] = $table_body_formatted; - return $table; - } - - - /** - * @return ActiveDataProvider - */ - private function getRecords() - { - $query = Records::find()->where([ - 'object_id' => $this->object_id, - 'type' => $this->record_type - ])->andWhere([ - 'like', 'DATE_FORMAT(FROM_UNIXTIME(start), "%m-%Y")', $this->month] - ); - - $dataProvider = new ActiveDataProvider([ - 'query' => $query, - 'sort' => false, - 'pagination' => false, - ]); - - return $dataProvider; - } - - private function formatInterval($interval) - { - $hours = 0; - $minutes = 0; - if ($interval > 3600) { - $hours = floor($interval / 3600); - $interval = $interval % 3600; + + private function formatInterval($interval) + { + $hours = 0; + $minutes = 0; + if ($interval > 3600) { + $hours = floor($interval / 3600); + $interval = $interval % 3600; + } + $minutes += floor($interval / 60); + $result = ''; + + if ((int)$hours !== 0) { + $result .= "{$hours}ч "; + } + if ((int)$minutes !== 0) { + $result .= "{$minutes}м "; + } + return $result; } - $minutes += floor($interval / 60); - $result = ''; - if ((int)$hours !== 0) { - $result .= "{$hours}ч "; + /** + * @return string|null + */ + public function getObjectName() + { + return Objects::findOne($this->object_id)->name; } - if ((int)$minutes !== 0) { - $result .= "{$minutes}м "; + + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'objectName' => 'Объект', + 'object_id' => 'Объект', + 'record_type' => 'Тип записи' + ]; + } - return $result; - } - - - /** - * {@inheritdoc} - */ - public function attributeLabels() - { - return [ - 'objectName' => 'Объект', - 'object_id' => 'Объект', - 'record_type' => 'Тип записи' - ]; - - } } \ No newline at end of file diff --git a/modules/administrator/controllers/EmployeesController.php b/modules/administrator/controllers/EmployeesController.php index df54f63..54cb1dc 100644 --- a/modules/administrator/controllers/EmployeesController.php +++ b/modules/administrator/controllers/EmployeesController.php @@ -17,177 +17,186 @@ use yii\filters\VerbFilter; */ class EmployeesController extends Controller { - /** - * @inheritdoc - */ - public function behaviors() - { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - 'access' => [ - 'class' => '\yii\filters\AccessControl', - 'rules' => [ - [ - 'allow' => true, - 'roles' => ['superadmin', 'admin'] - ], - ], - ], - ]; - } - - /** - * Lists all Employees models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new EmployeesSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - if (!Yii::$app->user->can('superadmin')) { - throw new ForbiddenHttpException('Доступ запрещен'); - } - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single Employees model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - if (!Yii::$app->user->can('superadmin')) { - throw new ForbiddenHttpException('Доступ запрещен'); + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + 'access' => [ + 'class' => '\yii\filters\AccessControl', + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['superadmin', 'admin'] + ], + ], + ], + ]; } - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new Employees model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - if (!Yii::$app->user->can('superadmin')) { - throw new ForbiddenHttpException('Доступ запрещен'); + /** + * Lists all Employees models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new EmployeesSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + if (!Yii::$app->user->can('superadmin')) { + throw new ForbiddenHttpException('Доступ запрещен'); + } + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); } - $model = new Employees(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('create', [ - 'model' => $model, - ]); + + /** + * Displays a single Employees model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + if (!Yii::$app->user->can('superadmin')) { + throw new ForbiddenHttpException('Доступ запрещен'); + } + + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); } - } - - /** - * Updates an existing Employees model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - */ - public function actionUpdate($id) - { - if (!Yii::$app->user->can('superadmin')) { - throw new ForbiddenHttpException('Доступ запрещен'); + + /** + * Creates a new Employees model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + if (!Yii::$app->user->can('superadmin')) { + throw new ForbiddenHttpException('Доступ запрещен'); + } + $model = new Employees(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } } - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); + + /** + * Updates an existing Employees model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + if (!Yii::$app->user->can('superadmin')) { + throw new ForbiddenHttpException('Доступ запрещен'); + } + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } } - } - - /** - * Deletes an existing Employees model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - */ - public function actionDelete($id) - { - if (!Yii::$app->user->can('superadmin')) { - throw new ForbiddenHttpException('Доступ запрещен'); + + /** + * Deletes an existing Employees model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + if (!Yii::$app->user->can('superadmin')) { + throw new ForbiddenHttpException('Доступ запрещен'); + } + + $this->findModel($id)->delete(); + + return $this->redirect(['index']); } - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - - /** - * Finds the Employees model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Employees the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Employees::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); + /** + * Finds the Employees model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Employees the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Employees::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } } - } - - public function actionGetEmployees() - { - Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; - $out = []; - $parents = $_POST['depdrop_parents']; - $object_id = $parents[0]; - $type_id = $parents[1]; - - if (isset($parents) && !empty($object_id) && !empty($type_id)) { - $objectQuery = (int)$type_id === 3 ? null : $object_id; - foreach (ArrayHelper::toArray(Employees::find()->where( - [ - 'object_id' => $objectQuery, - 'is_active' => true])->all()) as $employee) { - $out[] = ['id' => $employee['id'], 'name' => $employee['full_name']]; - } - return ['output' => $out, 'selected' => '']; + + /** + * Список позиций для виджета DepDrop во вью _form + * @return array + */ + public function actionGetEmployees() + { + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + $out = []; + $parents = $_POST['depdrop_parents']; + $object_id = $parents[0]; + $type_id = $parents[1]; + + if (isset($parents) && !empty($object_id) && !empty($type_id)) { + $query = Employees::find()->where(['is_active' => true]); + if((int)$type_id === 1) { + $query->andWhere(['object_id' => $object_id]); + } + + if((int)$type_id === 3) { + $query->where(['object_id' => null]); + } + + foreach (ArrayHelper::toArray($query->all()) as $employee) { + $out[] = ['id' => $employee['id'], 'name' => $employee['full_name']]; + } + return ['output' => $out, 'selected' => '']; + } + return ['output' => '', 'selected' => '']; } - return ['output' => '', 'selected' => '']; - } - - public function actionGetCodes() - { - Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; - $out = []; - $parents = $_POST['depdrop_parents']; - $type_id = $parents[0]; - - if ((int)$type_id === 1) { - $codes = ArrayHelper::map(TableCodes::find()->all(), 'id', 'code'); - - foreach ($codes as $key => $code) { - $out[] = ['id' => $key, 'name' => $code]; - } + + public function actionGetCodes() + { + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + $out = []; + $parents = $_POST['depdrop_parents']; + $type_id = $parents[0]; + + if ((int)$type_id === 1) { + $codes = ArrayHelper::map(TableCodes::find()->all(), 'id', 'code'); + + foreach ($codes as $key => $code) { + $out[] = ['id' => $key, 'name' => $code]; + } + } + return ['output' => $out, 'selected' => '']; } - return ['output' => $out, 'selected' => '']; - } } diff --git a/modules/administrator/controllers/RecordsController.php b/modules/administrator/controllers/RecordsController.php index fb41e0c..a1988ff 100644 --- a/modules/administrator/controllers/RecordsController.php +++ b/modules/administrator/controllers/RecordsController.php @@ -2,9 +2,12 @@ namespace app\modules\administrator\controllers; +use app\models\EmployeePositions; +use app\models\Employees; use Yii; use app\models\Records; use app\models\RecordsSearch; +use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; @@ -14,142 +17,175 @@ use yii\filters\VerbFilter; */ class RecordsController extends Controller { - /** - * @inheritdoc - */ - public function behaviors() - { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - 'access' => [ - 'class' => '\yii\filters\AccessControl', - 'rules' => [ - [ - 'allow' => true, - 'roles' => ['admin', 'superadmin'] - ], - ], - ], - ]; - } - - /** - * Lists all Records models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new RecordsSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single Records model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new Records model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new Records(); - if (!empty($_POST['Records']['start_period']) && !empty($_POST['Records']['end_period'])) { - $model->scenario = Records::SCENARIO_TABLE_CODE; - if ($model->load(Yii::$app->request->post()) && $this->createMultipleRecords($model)) { + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + 'access' => [ + 'class' => '\yii\filters\AccessControl', + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['admin', 'superadmin'] + ], + ], + ], + ]; + } + + /** + * Lists all Records models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new RecordsSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Records model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Records model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Records(); + if (!empty($_POST['Records']['start_period']) && !empty($_POST['Records']['end_period'])) { + $model->scenario = Records::SCENARIO_TABLE_CODE; + if ($model->load(Yii::$app->request->post()) && $this->createMultipleRecords($model)) { + return $this->redirect(['index']); + } + } else if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index']); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Records model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index']); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Records model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + return $this->redirect(['index']); - } - } else if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['index']); - } else { - return $this->render('create', [ - 'model' => $model, - ]); } - } - - /** - * Updates an existing Records model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - */ - public function actionUpdate($id) - { - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['index']); - } else { - return $this->render('update', [ - 'model' => $model, - ]); + + /** + * Finds the Records model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Records the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Records::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } } - } - - /** - * Deletes an existing Records model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - */ - public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - - /** - * Finds the Records model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Records the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Records::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); + + protected function createMultipleRecords($model) + { + $daysOfPeriod = $model->getDaysOfPeriod($model->start_period, $model->end_period); + foreach ($daysOfPeriod as $day) { + $record = new Records(); + $record->created_at = $model->created_at; + $record->object_id = $model->object_id; + $record->employee_id = $model->employee_id; + $record->type = $model->type; + $record->start = $day; + $record->end = $day + 86399; + $record->table_code_id = $model->table_code_id; + $record->details = $model->details; + $record->save(); + } + return true; } - } - - protected function createMultipleRecords($model) - { - $daysOfPeriod = $model->getDaysOfPeriod($model->start_period, $model->end_period); - foreach ($daysOfPeriod as $day) { - $record = new Records(); - $record->created_at = $model->created_at; - $record->object_id = $model->object_id; - $record->employee_id = $model->employee_id; - $record->type = $model->type; - $record->start = $day; - $record->end = $day + 86399; - $record->table_code_id = $model->table_code_id; - $record->details = $model->details; - $record->save(); + + /** + * Получение данных для виджета DepDrop во вью _form + * @return array + */ + public function actionGetPositions() + { + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + $out = []; + $parents = $_POST['depdrop_parents']; + $employee_id = $parents[0]; + $type_id = $parents[1]; + + if (isset($parents) && !empty($employee_id) && !empty($type_id)) { + + $positions = null; + + if ((int)$type_id === 1 || (int)$type_id === 3) { + $employee = Employees::findOne($employee_id); + $positions = EmployeePositions::find()->where(['id' => $employee->position_id])->all(); + } + + if ((int)$type_id === 2) { + $positions = EmployeePositions::find()->all(); + } + + foreach (ArrayHelper::toArray($positions) as $position) { + $out[] = ['id' => $position['id'], 'name' => $position['name']]; + } + return ['output' => $out, 'selected' => '']; + } + return ['output' => '', 'selected' => '']; } - return true; - } } diff --git a/modules/administrator/views/records/_form.php b/modules/administrator/views/records/_form.php index 84d1a71..006b83b 100644 --- a/modules/administrator/views/records/_form.php +++ b/modules/administrator/views/records/_form.php @@ -1,5 +1,6 @@ user->identity->getId()); + if (Yii::$app->user->can('admin')) { - $query->andWhere(['hub_id' => $user->hub_id]); + $query->andWhere(['hub_id' => $user->hub_id]); } -$objects = $objects + ArrayHelper::map($query->all(), 'id', 'name'); -$codes = $codes + ArrayHelper::map($codesQuery->all(), 'id', 'code'); + +$objects = ArrayHelper::map($query->all(), 'id', 'name'); +$codes = ArrayHelper::map($codesQuery->all(), 'id', 'code'); +$positions = ArrayHelper::map(EmployeePositions::find()->all(), 'id', 'name'); + + ?>
- false]); ?> -
- - field($model, 'created_at')->widget(DateControl::classname(), [ - 'type' => DateControl::FORMAT_DATETIME, - 'widgetOptions' => [ - 'pluginOptions' => [ - 'autoclose' => true, - 'todayBtn' => true - ] - ] - ]); ?> - - field($model, 'object_id')->widget(Select2::className(), [ - 'data' => $objects, - 'options' => ['placeholder' => 'Выберите объект ...'], - 'pluginOptions' => [ - 'allowClear' => true - ], - ]) ?> - - field($model, 'type')->dropDownList([ - null => '...', - 1 => 'Рабочий', - 2 => 'Подработка', - 3 => 'Мобильный', - ]) ?> - - field($model, 'employee_id')->widget(DepDrop::className(), [ - 'options' => [ - 'placeholder' => !empty($model->employee) ? $model->employee->full_name : '' - ], - 'pluginOptions' => [ - 'depends' => ['records-object_id', 'records-type'], - 'placeholder' => 'Выбор сотрудника...', - 'url' => Url::to(['/administrator/employees/get-employees']) - ] - ]) ?> - - field($model, 'table_code_id')->widget(DepDrop::className(), [ - 'pluginOptions' => [ - 'depends' => ['records-type'], - 'placeholder' => 'Выбор кода учёта...', - 'url' => Url::to(['/administrator/employees/get-codes']) - ] - ]) ?> - -
- field($model, 'start')->widget(DateControl::classname(), [ - 'type' => DateControl::FORMAT_DATETIME, - 'widgetOptions' => [ - 'pluginOptions' => [ - 'autoclose' => true, - 'todayBtn' => true - ] - ] - ]); ?> - - - field($model, 'end')->widget(DateControl::classname(), [ - 'type' => DateControl::FORMAT_DATETIME, - 'widgetOptions' => [ - 'pluginOptions' => [ - 'autoclose' => true, - 'todayBtn' => true - ] - ] - ]); ?> + false]); ?> +
+ + field($model, 'created_at')->widget(DateControl::classname(), [ + 'type' => DateControl::FORMAT_DATETIME, + 'widgetOptions' => [ + 'pluginOptions' => [ + 'autoclose' => true, + 'todayBtn' => true + ] + ] + ]); ?> + + field($model, 'object_id')->widget(Select2::className(), [ + 'data' => $objects, + 'options' => ['placeholder' => 'Выберите объект ...'], + 'pluginOptions' => [ + 'allowClear' => true + ], + ]) ?> + + field($model, 'type')->dropDownList([ + null => '...', + 1 => 'Рабочий', + 2 => 'Подработка', + 3 => 'Мобильный', + ]) ?> + + field($model, 'employee_id')->widget(DepDrop::className(), [ + 'type' => DepDrop::TYPE_SELECT2, + 'select2Options' => ['pluginOptions' => ['allowClear' => true]], + 'options' => [ + 'placeholder' => !empty($model->employee) ? $model->employee->full_name : '' + ], + 'pluginOptions' => [ + 'depends' => ['records-object_id', 'records-type'], + 'initialize' => true, + 'placeholder' => 'Выбор сотрудника...', + 'url' => Url::to(['/administrator/employees/get-employees']) + ] + ]) ?> + field($model, 'position_id')->widget(DepDrop::className(), [ + 'type' => DepDrop::TYPE_SELECT2, + 'select2Options' => ['pluginOptions' => ['allowClear' => true]], + 'pluginOptions' => [ + 'depends' => ['records-employee_id', 'records-type'], + 'initialize' => true, + 'placeholder' => 'Выбор должности...', + 'url' => Url::to(['/administrator/records/get-positions']) + ] + ]) ?> + + field($model, 'table_code_id')->widget(DepDrop::className(), [ + 'pluginOptions' => [ + 'depends' => ['records-type'], + 'initialize' => true, + 'placeholder' => 'Выбор кода учёта...', + 'url' => Url::to(['/administrator/employees/get-codes']) + ] + ]) ?> + +
+ field($model, 'start')->widget(DateControl::classname(), [ + 'type' => DateControl::FORMAT_DATETIME, + 'widgetOptions' => [ + 'pluginOptions' => [ + 'autoclose' => true, + 'todayBtn' => true + ] + ] + ]); ?> + + + field($model, 'end')->widget(DateControl::classname(), [ + 'type' => DateControl::FORMAT_DATETIME, + 'widgetOptions' => [ + 'pluginOptions' => [ + 'autoclose' => true, + 'todayBtn' => true + ] + ] + ]); ?> +
+ + + field($model, 'details')->textarea() ?>
- - - - +
diff --git a/modules/administrator/views/records/index.php b/modules/administrator/views/records/index.php index 2c82aef..8d11d64 100644 --- a/modules/administrator/views/records/index.php +++ b/modules/administrator/views/records/index.php @@ -14,128 +14,129 @@ use app\models\TableCodes; $this->title = 'Записи'; $this->params['breadcrumbs'][] = $this->title; $types = [ - 1 => 'Рабочий', - 2 => 'Подработка', - 3 => 'Мобильный', + 1 => 'Рабочий', + 2 => 'Подработка', + 3 => 'Мобильный', ]; $codes = ArrayHelper::map(TableCodes::find()->all(), 'id', 'code'); ?>
-
- 'btn btn-success btn-flat']) ?> -
-
- $dataProvider, - 'filterModel' => $searchModel, - 'layout' => "{items}\n{summary}\n{pager}", - 'responsive' => true, - 'hover' => true, - 'krajeeDialogSettings' => ['useNative' => true], - 'toolbar' => [ - [ - 'options' => ['class' => 'btn-group mr-2'] - ], - '{export}', - '{toggleData}', - ], - 'export' => [ - 'label' => 'Выгрузить', - 'showConfirmAlert' => false, - 'header' => '', - ], - 'exportConfig' => [ - GridView::EXCEL => ['label' => 'Excel'], - - ], - 'panel' => [ - 'type' => GridView::TYPE_DEFAULT, - ], - 'columns' => [ - [ - 'attribute' => 'created_at', - 'value' => function (Records $model) { - return Yii::$app->formatter->asDatetime($model->created_at); - }, - 'filter' => DatePicker::widget([ - 'model' => $searchModel, - 'attribute' => 'created_at', - 'language' => 'ru', - 'pluginOptions' => [ - 'autoclose' => true, - 'todayHighlight' => true, - 'format' => 'dd.mm.yyyy', +
+ 'btn btn-success btn-flat']) ?> +
+
+ $dataProvider, + 'filterModel' => $searchModel, + 'layout' => "{items}\n{summary}\n{pager}", + 'responsive' => true, + 'hover' => true, + 'krajeeDialogSettings' => ['useNative' => true], + 'toolbar' => [ + [ + 'options' => ['class' => 'btn-group mr-2'] + ], + '{export}', + '{toggleData}', + ], + 'export' => [ + 'label' => 'Выгрузить', + 'showConfirmAlert' => false, + 'header' => '', ], - ]), - ], - 'employeeFullName', - 'employeeTableNumber', - 'objectNumber', - [ - 'attribute' => 'type', - 'filter' => $types, - 'value' => function (Records $model) { - $types = [ - 1 => 'Рабочий', - 2 => 'Подработка', - 3 => 'Мобильный', - ]; - return $types[$model->type]; - } - ], - [ - 'attribute' => 'start', - 'value' => function (Records $model) { - return Yii::$app->formatter->asDatetime($model->start); - }, - 'filter' => DatePicker::widget([ - 'model' => $searchModel, - 'attribute' => 'start', - 'language' => 'ru', - 'pluginOptions' => [ - 'autoclose' => true, - 'todayHighlight' => true, - 'format' => 'dd.mm.yyyy', + 'exportConfig' => [ + GridView::EXCEL => ['label' => 'Excel'], + ], - ]), - ], - [ - 'attribute' => 'end', - 'value' => function (Records $model) { - return Yii::$app->formatter->asDatetime($model->end); - }, - 'filter' => DatePicker::widget([ - 'model' => $searchModel, - 'attribute' => 'end', - 'language' => 'ru', - 'pluginOptions' => [ - 'autoclose' => true, - 'todayHighlight' => true, - 'format' => 'dd.mm.yyyy', + 'panel' => [ + 'type' => GridView::TYPE_DEFAULT, ], - ]), - ], - [ - 'attribute' => 'table_code_id', - 'filter' => $codes, - 'value' => function (Records $model) { - return $model->code; - } - ], - 'details', - [ - 'label' => 'Часы', - 'value' => function (Records $model) { - return $model->formatSecondsInterval(); - } + 'columns' => [ + [ + 'attribute' => 'created_at', + 'value' => function (Records $model) { + return Yii::$app->formatter->asDatetime($model->created_at); + }, + 'filter' => DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'created_at', + 'language' => 'ru', + 'pluginOptions' => [ + 'autoclose' => true, + 'todayHighlight' => true, + 'format' => 'dd.mm.yyyy', + ], + ]), + ], + 'employeeFullName', + 'employeeTableNumber', + 'positionName', + 'objectNumber', + [ + 'attribute' => 'type', + 'filter' => $types, + 'value' => function (Records $model) { + $types = [ + 1 => 'Рабочий', + 2 => 'Подработка', + 3 => 'Мобильный', + ]; + return $types[$model->type]; + } + ], + [ + 'attribute' => 'start', + 'value' => function (Records $model) { + return Yii::$app->formatter->asDatetime($model->start); + }, + 'filter' => DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'start', + 'language' => 'ru', + 'pluginOptions' => [ + 'autoclose' => true, + 'todayHighlight' => true, + 'format' => 'dd.mm.yyyy', + ], + ]), + ], + [ + 'attribute' => 'end', + 'value' => function (Records $model) { + return Yii::$app->formatter->asDatetime($model->end); + }, + 'filter' => DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'end', + 'language' => 'ru', + 'pluginOptions' => [ + 'autoclose' => true, + 'todayHighlight' => true, + 'format' => 'dd.mm.yyyy', + ], + ]), + ], + [ + 'attribute' => 'table_code_id', + 'filter' => $codes, + 'value' => function (Records $model) { + return $model->code; + } + ], + 'details', + [ + 'label' => 'Часы', + 'value' => function (Records $model) { + return $model->formatSecondsInterval(); + } - ], - // 'updated_at', + ], + // 'updated_at', - ['class' => 'yii\grid\ActionColumn'], - ], - ]); ?> -
+ ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/modules/administrator/views/records/update.php b/modules/administrator/views/records/update.php index 0ad0944..ced0d2e 100644 --- a/modules/administrator/views/records/update.php +++ b/modules/administrator/views/records/update.php @@ -17,3 +17,7 @@ $this->params['breadcrumbs'][] = 'редактирование'; ]) ?>
+ +registerJsFile('/js/recordUpdate.js', ['depends' => \yii\web\JqueryAsset::className()]) +?> diff --git a/modules/administrator/views/records/view.php b/modules/administrator/views/records/view.php index 0fbbfb6..10a369c 100644 --- a/modules/administrator/views/records/view.php +++ b/modules/administrator/views/records/view.php @@ -29,6 +29,7 @@ $this->params['breadcrumbs'][] = $this->title; 'attributes' => [ 'id', 'employeeFullName', + 'position Name', 'objectName', 'start:datetime', 'end:datetime', diff --git a/modules/administrator/views/table/index.php b/modules/administrator/views/table/index.php index 23144d7..e7250e2 100644 --- a/modules/administrator/views/table/index.php +++ b/modules/administrator/views/table/index.php @@ -15,82 +15,83 @@ $this->params['breadcrumbs'][] = $this->title; $query = \app\models\Objects::find(); $user = Users::findOne(Yii::$app->user->identity->getId()); -if(Yii::$app->user->can('admin')) { - $query->andWhere(['hub_id' => $user->hub_id]); +if (Yii::$app->user->can('admin')) { + $query->andWhere(['hub_id' => $user->hub_id]); } $objects = \yii\helpers\ArrayHelper::map($query->all(), 'id', 'name'); ?>
-
- - - field($model, 'object_id')->widget(Select2::className(), [ - 'data' => $objects, - 'options' => ['placeholder' => 'Выберите объект ...'], - 'pluginOptions' => [ - 'allowClear' => true - ], - ]) ?> - - field($model, 'record_type')->dropDownList([ - 1 => 'Рабочий', - 2 => 'Подработка', - 3 => 'Мобильный', - ]) ?> - - field($model, 'month')->widget(DatePicker::classname(), [ - 'options' => ['placeholder' => Yii::t('app', 'месяц/год')], - 'pluginOptions' => [ - 'autoclose' => true, - 'startView' => 'year', - 'minViewMode' => 'months', - 'format' => 'mm-yyyy' - ] - ])->label(false); ?> - - -
- object_id)): ?> - getTable() ?> - $table['body'] - ]); - ?> - $dataProvider, - 'responsive' => true, - 'hover' => true, - 'toolbar' => [ - [ - 'options' => ['class' => 'btn-group mr-2'] - ], - '{export}', - ], - 'export' => [ - 'label' => 'Выгрузить', - 'showConfirmAlert' => false, - 'header' => '', - ], - 'exportConfig' => [ - GridView::EXCEL => ['label' => 'Excel'], - - ], - 'panel' => [ - 'type' => GridView::TYPE_DEFAULT, - ], - - - ]) ?> - -
diff --git a/modules/manager/controllers/EmployeesController.php b/modules/manager/controllers/EmployeesController.php index 094d9c6..5148b03 100644 --- a/modules/manager/controllers/EmployeesController.php +++ b/modules/manager/controllers/EmployeesController.php @@ -16,78 +16,82 @@ use yii\filters\VerbFilter; */ class EmployeesController extends Controller { - /** - * @inheritdoc - */ - public function behaviors() - { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - 'access' => [ - 'class' => '\yii\filters\AccessControl', - 'rules' => [ - [ - 'allow' => true, - 'roles' => ['manager'] - ], - ], - ], - ]; - } + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + 'access' => [ + 'class' => '\yii\filters\AccessControl', + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['manager'] + ], + ], + ], + ]; + } - /** - * Lists all Employees models. - * @return mixed - */ + /** + * Lists all Employees models. + * @return mixed + */ - public function actionGetEmployees() - { - $user = \app\models\Users::findOne(Yii::$app->user->identity->getId()); - Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; - $out = []; - if (isset($_POST['depdrop_parents'])) { - $parents = $_POST['depdrop_parents']; - if ($parents != null) { - $type_id = $parents[0]; - if ((int)$type_id !== 0) { - $object_id = (int)$type_id !== 3 ? $user->object_id : null; - foreach (ArrayHelper::toArray(Employees::find()->where([ - 'object_id' => $object_id, 'is_active' => true - ])->all()) as $employee) { - $out[] = ['id' => $employee['id'], 'name' => $employee['full_name']]; - } - } + public function actionGetEmployees() + { + $user = \app\models\Users::findOne(Yii::$app->user->identity->getId()); + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + $out = []; + if (isset($_POST['depdrop_parents'])) { + $parents = $_POST['depdrop_parents']; + if ($parents != null) { + $type_id = $parents[0]; + $object_id = (int)$type_id !== 3 ? $user->object_id : null; + $query = Employees::find()->where(['is_active' => true]); + if ((int)$type_id === 1) { + $query->andWhere(['object_id' => $object_id]); + } + if ((int)$type_id === 3) { + $query->where(['object_id' => null]); + } + foreach (ArrayHelper::toArray($query->all()) as $employee) { + $out[] = ['id' => $employee['id'], 'name' => $employee['full_name']]; + } - return ['output' => $out, 'selected' => '']; - } + + return ['output' => $out, 'selected' => '']; + } + } + return ['output' => '', 'selected' => '']; } - return ['output' => '', 'selected' => '']; - } - public function actionGetCodes() - { - Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; - $out = []; - $parents = $_POST['depdrop_parents']; - $type_id = $parents[0]; + public function actionGetCodes() + { + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + $out = []; + $parents = $_POST['depdrop_parents']; + $type_id = $parents[0]; - if ((int)$type_id === 1) { - $query = TableCodes::find()->where(['admin_only' => false]); - $codes = ArrayHelper::map($query->all(), 'id', 'code'); + if ((int)$type_id === 1) { + $query = TableCodes::find()->where(['admin_only' => false]); + $codes = ArrayHelper::map($query->all(), 'id', 'code'); - foreach ($codes as $key => $code) { - $out[] = ['id' => $key, 'name' => $code]; - } + foreach ($codes as $key => $code) { + $out[] = ['id' => $key, 'name' => $code]; + } + } + return ['output' => $out, 'selected' => '']; } - return ['output' => $out, 'selected' => '']; - } } diff --git a/modules/manager/controllers/RecordsController.php b/modules/manager/controllers/RecordsController.php index b47cf8f..aa6644a 100644 --- a/modules/manager/controllers/RecordsController.php +++ b/modules/manager/controllers/RecordsController.php @@ -2,9 +2,12 @@ namespace app\modules\manager\controllers; +use app\models\EmployeePositions; +use app\models\Employees; use Yii; use app\models\Records; use app\models\RecordsSearch; +use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; @@ -14,126 +17,160 @@ use yii\filters\VerbFilter; */ class RecordsController extends Controller { - /** - * @inheritdoc - */ - public function behaviors() - { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - 'access' => [ - 'class' => '\yii\filters\AccessControl', - 'rules' => [ - [ - 'allow' => true, - 'roles' => ['manager'] - ], - ], - ], - ]; - } - - /** - * Lists all Records models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new RecordsSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single Records model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new Records model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new Records(); - $user = \app\models\Users::findOne(Yii::$app->user->identity->getId()); - $model->object_id = $user->object_id; - if (!empty($model->table_code_id)) { - $model->scenario = Records::SCENARIO_TABLE_CODE; + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + 'access' => [ + 'class' => '\yii\filters\AccessControl', + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['manager'] + ], + ], + ], + ]; } - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['index']); - } else { - $model->created_at = date('U'); - return $this->render('create', [ - 'model' => $model, - ]); + /** + * Lists all Records models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new RecordsSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Records model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Records model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Records(); + $user = \app\models\Users::findOne(Yii::$app->user->identity->getId()); + $model->object_id = $user->object_id; + if (!empty($model->table_code_id)) { + $model->scenario = Records::SCENARIO_TABLE_CODE; + } + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index']); + } else { + $model->created_at = date('U'); + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Records model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index']); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Records model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); } - } - - /** - * Updates an existing Records model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - */ - public function actionUpdate($id) - { - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['index']); - } else { - return $this->render('update', [ - 'model' => $model, - ]); + + /** + * Finds the Records model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Records the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Records::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } } - } - - /** - * Deletes an existing Records model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - */ - public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - - /** - * Finds the Records model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Records the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Records::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); + + + /** + * Получение данных для виджета DepDrop во вью _form + * @return array + */ + public function actionGetPositions() + { + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + $out = []; + $parents = $_POST['depdrop_parents']; + $employee_id = $parents[0]; + $type_id = $parents[1]; + + if (isset($parents) && !empty($employee_id) && !empty($type_id)) { + + $positions = null; + + if ((int)$type_id === 1 || (int)$type_id === 3) { + $employee = Employees::findOne($employee_id); + $positions = EmployeePositions::find()->where(['id' => $employee->position_id])->all(); + } + + if ((int)$type_id === 2) { + $positions = EmployeePositions::find()->all(); + } + + foreach (ArrayHelper::toArray($positions) as $position) { + $out[] = ['id' => $position['id'], 'name' => $position['name']]; + } + return ['output' => $out, 'selected' => '']; + } + return ['output' => '', 'selected' => '']; } - } } diff --git a/modules/manager/views/records/_form.php b/modules/manager/views/records/_form.php index 29ccd77..b1726b6 100644 --- a/modules/manager/views/records/_form.php +++ b/modules/manager/views/records/_form.php @@ -18,74 +18,88 @@ $user = \app\models\Users::findOne(Yii::$app->user->identity->getId()); ?>
- false]); ?> -
- - field($model, 'created_at')->widget(DateControl::classname(), [ - 'type' => DateControl::FORMAT_DATETIME, - 'disabled' => true, - 'autoWidget' => false - ]); ?> - - field($model, 'object_id')->dropDownList([$user->object_id => $user->object->name], [ - 'disabled' => true, - ]) ?> - - field($model, 'type')->dropDownList([ - 0 => '...', - 1 => 'Рабочий', - 2 => 'Подработка', - 3 => 'Мобильный', - ]) ?> - - field($model, 'employee_id')->widget(DepDrop::className(), [ - 'options' => [ - 'placeholder' => !empty($model->employee) ? $model->employee->full_name : '' - ], - 'pluginOptions' => [ - 'depends' => ['records-type'], - 'placeholder' => 'Выбор сотрудника...', - 'url' => Url::to(['/manager/employees/get-employees']) - ] - ]) ?> - - field($model, 'table_code_id')->widget(DepDrop::className(), [ - 'pluginOptions' => [ - 'depends' => ['records-type'], - 'placeholder' => 'Выбор кода учёта...', - 'url' => Url::to(['/manager/employees/get-codes']) - ] - ]) ?> -
- - field($model, 'start')->widget(DateControl::classname(), [ - 'type' => DateControl::FORMAT_DATETIME, - 'widgetOptions' => [ - 'pluginOptions' => [ - 'autoclose' => true, - 'todayBtn' => true, - ] - ] - ]); ?> - - - field($model, 'end')->widget(DateControl::classname(), [ - 'type' => DateControl::FORMAT_DATETIME, - 'widgetOptions' => [ - 'pluginOptions' => [ - 'autoclose' => true, - 'todayBtn' => true - ] - ] - ]); ?> + false]); ?> +
+ field($model, 'created_at')->widget(DateControl::classname(), [ + 'type' => DateControl::FORMAT_DATETIME, + 'disabled' => true, + 'autoWidget' => false + ]); ?> + + field($model, 'object_id')->dropDownList([$user->object_id => $user->object->name], [ + 'disabled' => true, + ]) ?> + + field($model, 'type')->dropDownList([ + 0 => '...', + 1 => 'Рабочий', + 2 => 'Подработка', + 3 => 'Мобильный', + ]) ?> + + field($model, 'employee_id')->widget(DepDrop::className(), [ + 'type' => DepDrop::TYPE_SELECT2, + 'options' => [ + 'placeholder' => !empty($model->employee) ? $model->employee->full_name : '' + ], + 'pluginOptions' => [ + 'depends' => ['records-type'], + 'initialize' => true, + 'placeholder' => 'Выбор сотрудника...', + 'url' => Url::to(['/manager/employees/get-employees']) + ] + ]) ?> + + field($model, 'position_id')->widget(DepDrop::className(), [ + 'type' => DepDrop::TYPE_SELECT2, + 'select2Options' => ['pluginOptions' => ['allowClear' => true]], + 'pluginOptions' => [ + 'depends' => ['records-employee_id', 'records-type'], + 'initialize' => true, + 'placeholder' => 'Выбор должности...', + 'url' => Url::to(['/manager/records/get-positions']) + ] + ]) ?> + + field($model, 'table_code_id')->widget(DepDrop::className(), [ + 'pluginOptions' => [ + 'depends' => ['records-type'], + 'initialize' => true, + 'placeholder' => 'Выбор кода учёта...', + 'url' => Url::to(['/manager/employees/get-codes']) + ] + ]) ?> +
+ + field($model, 'start')->widget(DateControl::classname(), [ + 'type' => DateControl::FORMAT_DATETIME, + 'widgetOptions' => [ + 'pluginOptions' => [ + 'autoclose' => true, + 'todayBtn' => true, + ] + ] + ]); ?> + + + field($model, 'end')->widget(DateControl::classname(), [ + 'type' => DateControl::FORMAT_DATETIME, + 'widgetOptions' => [ + 'pluginOptions' => [ + 'autoclose' => true, + 'todayBtn' => true + ] + ] + ]); ?> + +
+ + field($model, 'details')->textarea() ?> + +
+ - - field($model, 'details')->textarea() ?> - -
- - +
diff --git a/modules/manager/views/records/index.php b/modules/manager/views/records/index.php index ee83114..2360741 100644 --- a/modules/manager/views/records/index.php +++ b/modules/manager/views/records/index.php @@ -14,131 +14,132 @@ use kartik\widgets\DatePicker; $this->title = 'Записи'; $this->params['breadcrumbs'][] = $this->title; $types = [ - 1 => 'Рабочий', - 2 => 'Подработка', - 3 => 'Мобильный', + 1 => 'Рабочий', + 2 => 'Подработка', + 3 => 'Мобильный', ]; $codes = ArrayHelper::map(TableCodes::find()->all(), 'id', 'code'); ?>
-
- 'btn btn-success btn-flat']) ?> -
-
- $dataProvider, - 'filterModel' => $searchModel, - 'layout' => "{items}\n{summary}\n{pager}", - 'responsive' => true, - 'hover' => true, - 'krajeeDialogSettings' => ['useNative' => true], - 'toolbar' => [ - [ - 'options' => ['class' => 'btn-group mr-2'] - ], - '{export}', - '{toggleData}', - ], - 'export' => [ - 'label' => 'Выгрузить', - 'showConfirmAlert' => false, - 'header' => '', - ], - 'exportConfig' => [ - GridView::EXCEL => ['label' => 'Excel'], - - ], - 'panel' => [ - 'type' => GridView::TYPE_DEFAULT, - ], - 'columns' => [ - [ - 'attribute' => 'created_at', - 'value' => function (Records $model) { - return Yii::$app->formatter->asDatetime($model->created_at); - }, - 'filter' => DatePicker::widget([ - 'model' => $searchModel, - 'attribute' => 'created_at', - 'language' => 'ru', - 'pluginOptions' => [ - 'autoclose' => true, - 'todayHighlight' => true, - 'format' => 'dd.mm.yyyy', +
+ 'btn btn-success btn-flat']) ?> +
+
+ $dataProvider, + 'filterModel' => $searchModel, + 'layout' => "{items}\n{summary}\n{pager}", + 'responsive' => true, + 'hover' => true, + 'krajeeDialogSettings' => ['useNative' => true], + 'toolbar' => [ + [ + 'options' => ['class' => 'btn-group mr-2'] + ], + '{export}', + '{toggleData}', + ], + 'export' => [ + 'label' => 'Выгрузить', + 'showConfirmAlert' => false, + 'header' => '', ], - ]), - ], - 'employeeFullName', - 'employeeTableNumber', - 'objectNumber', - [ - 'attribute' => 'type', - 'filter' => $types, - 'value' => function (Records $model) { - $types = [ - 1 => 'Рабочий', - 2 => 'Подработка', - 3 => 'Мобильный', - ]; - return $types[$model->type]; - } - ], - [ - 'attribute' => 'start', - 'value' => function (Records $model) { - return Yii::$app->formatter->asDatetime($model->start); - }, - 'filter' => DatePicker::widget([ - 'model' => $searchModel, - 'attribute' => 'start', - 'language' => 'ru', - 'pluginOptions' => [ - 'autoclose' => true, - 'todayHighlight' => true, - 'format' => 'dd.mm.yyyy', + 'exportConfig' => [ + GridView::EXCEL => ['label' => 'Excel'], + ], - ]), - ], - [ - 'attribute' => 'end', - 'value' => function (Records $model) { - return Yii::$app->formatter->asDatetime($model->end); - }, - 'filter' => DatePicker::widget([ - 'model' => $searchModel, - 'attribute' => 'end', - 'language' => 'ru', - 'pluginOptions' => [ - 'autoclose' => true, - 'todayHighlight' => true, - 'format' => 'dd.mm.yyyy', + 'panel' => [ + 'type' => GridView::TYPE_DEFAULT, ], - ]), - ], - [ - 'attribute' => 'table_code_id', - 'filter' => $codes, - 'value' => function(Records $model) { - return $model->code; - } - ], - [ - 'label' => 'Часы', - 'value' => function (Records $model) { + 'columns' => [ + [ + 'attribute' => 'created_at', + 'value' => function (Records $model) { + return Yii::$app->formatter->asDatetime($model->created_at); + }, + 'filter' => DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'created_at', + 'language' => 'ru', + 'pluginOptions' => [ + 'autoclose' => true, + 'todayHighlight' => true, + 'format' => 'dd.mm.yyyy', + ], + ]), + ], + 'employeeFullName', + 'employeeTableNumber', + 'positionName', + 'objectNumber', + [ + 'attribute' => 'type', + 'filter' => $types, + 'value' => function (Records $model) { + $types = [ + 1 => 'Рабочий', + 2 => 'Подработка', + 3 => 'Мобильный', + ]; + return $types[$model->type]; + } + ], + [ + 'attribute' => 'start', + 'value' => function (Records $model) { + return Yii::$app->formatter->asDatetime($model->start); + }, + 'filter' => DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'start', + 'language' => 'ru', + 'pluginOptions' => [ + 'autoclose' => true, + 'todayHighlight' => true, + 'format' => 'dd.mm.yyyy', + ], + ]), + ], + [ + 'attribute' => 'end', + 'value' => function (Records $model) { + return Yii::$app->formatter->asDatetime($model->end); + }, + 'filter' => DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'end', + 'language' => 'ru', + 'pluginOptions' => [ + 'autoclose' => true, + 'todayHighlight' => true, + 'format' => 'dd.mm.yyyy', + ], + ]), + ], + [ + 'attribute' => 'table_code_id', + 'filter' => $codes, + 'value' => function (Records $model) { + return $model->code; + } + ], + [ + 'label' => 'Часы', + 'value' => function (Records $model) { - return !empty($model->table_code_id) ? '' : $model->formatSecondsInterval(); - } + return !empty($model->table_code_id) ? '' : $model->formatSecondsInterval(); + } - ], - 'details', - // 'updated_at', + ], + 'details', + // 'updated_at', - [ - 'class' => 'yii\grid\ActionColumn', - 'template' => '{view} {update}' - ], - ], - ]); ?> -
+ [ + 'class' => 'yii\grid\ActionColumn', + 'template' => '{view} {update}' + ], + ], + ]); ?> +
-- GitLab