diff --git a/.gitignore b/.gitignore index c5cceb4704..97764aef75 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,22 @@ docker-compose.yml phinx.php phinx.yml +# IDE Files +## PHPStorm InteliJ *.idea + +## Visual Studio +*.vscode + +## Eclipse +.buildpath +.project +.settings + +## Vi *~ +*.swp + # Vagrant /.gitkeep /.vagrant @@ -19,7 +33,6 @@ phinx.yml Vagrantfile deploy/.ruby-version ieducar/configuration/ieducar.ini -*.vscode ieducar/modules/Reports ieducar/intranet/filaunica ieducar/intranet/reservavaga diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 655cfa1f37..bf25a33a26 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,39 +1,41 @@ filter: excluded_paths: - - 'ieducar/tests/*' - - 'ieducar/misc/**/*' - - 'ieducar/intranet/scripts/jquery' - - 'ieducar/intranet/scripts/scriptaculous' - - 'ieducar/intranet/scripts/prototype' - - 'ieducar/intranet/scripts/select2' - - 'ieducar/intranet/scripts/graficos' - - 'ieducar/modules/Portabilis/Assets/Plugins/AjaxChosen/' - - 'ieducar/modules/Portabilis/Assets/Plugins/Chosen/' + - 'ieducar/tests/*' + - 'ieducar/misc/**/*' + - 'ieducar/intranet/scripts/jquery' + - 'ieducar/intranet/scripts/scriptaculous' + - 'ieducar/intranet/scripts/prototype' + - 'ieducar/intranet/scripts/select2' + - 'ieducar/intranet/scripts/graficos' + - 'ieducar/modules/Portabilis/Assets/Plugins/AjaxChosen/' + - 'ieducar/modules/Portabilis/Assets/Plugins/Chosen/' checks: php: code_rating: true tools: - external_code_coverage: true - php_analyzer: true - php_changetracking: true - php_code_sniffer: - config: - standard: "PSR2" - php_cpd: true - php_mess_detector: true - php_pdepend: true - sensiolabs_security_checker: true + php_analyzer: true + php_changetracking: true + php_code_sniffer: + config: + standard: "PSR2" + php_cpd: true + php_mess_detector: true + php_pdepend: true + sensiolabs_security_checker: true build: + environment: postgresql: true - dependencies: - after: + before: - psql -c "CREATE DATABASE ieducar_test WITH OWNER = scrutinizer ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' TEMPLATE template0" + after: - cp phinx.php.scrutinizer phinx.php - - vendor/bin/phinx seed:run -s StartingSeed -s StartingForeignKeysSeed - - vendor/bin/phinx migrate - + - ieducar/vendor/bin/phinx seed:run -s StartingSeed -s StartingForeignKeysSeed + - ieducar/vendor/bin/phinx migrate + tests: + override: + command: "true" diff --git a/.travis.yml b/.travis.yml index 34366a621c..bb788fdc24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: postgresql: 9.5 apt: packages: - - postgresql-9.5 + - postgresql-9.5 cache: directories: - $HOME/.composer/cache @@ -18,5 +18,11 @@ matrix: - composer install - vendor/bin/phinx seed:run -s StartingSeed -s StartingForeignKeysSeed - vendor/bin/phinx migrate + - sed -i -e '//g' ieducar/phpunit.xml + - sed -i -e 's/CORE_EXT_CONFIGURATION_ENV" value="testing/CORE_EXT_CONFIGURATION_ENV" value="travis/g' ieducar/phpunit.xml + - sed -i -e 's/API_URI" value="http:\/\/localhost/API_URI" value="http:\/\/localhost:8000/g' ieducar/phpunit.xml + - CORE_EXT_CONFIGURATION_ENV=travis php -S localhost:8000 -t ieducar/ & + script: + - composer test after_success: - vendor/bin/php-coveralls --verbose diff --git a/composer.lock b/composer.lock index 5c8523a226..c943459f97 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "cakephp/cache", - "version": "3.6.10", + "version": "3.6.12", "source": { "type": "git", "url": "https://github.com/cakephp/cache.git", - "reference": "bbaf1f3d1e615f7af1889053ff503a086f9f7671" + "reference": "5941977c584843b9ddb32ec864a9483fbef88d52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/cache/zipball/bbaf1f3d1e615f7af1889053ff503a086f9f7671", - "reference": "bbaf1f3d1e615f7af1889053ff503a086f9f7671", + "url": "https://api.github.com/repos/cakephp/cache/zipball/5941977c584843b9ddb32ec864a9483fbef88d52", + "reference": "5941977c584843b9ddb32ec864a9483fbef88d52", "shasum": "" }, "require": { @@ -47,11 +47,11 @@ "caching", "cakephp" ], - "time": "2018-07-19T10:51:03+00:00" + "time": "2018-09-01T17:00:52+00:00" }, { "name": "cakephp/collection", - "version": "3.6.10", + "version": "3.6.12", "source": { "type": "git", "url": "https://github.com/cakephp/collection.git", @@ -97,7 +97,7 @@ }, { "name": "cakephp/core", - "version": "3.6.10", + "version": "3.6.12", "source": { "type": "git", "url": "https://github.com/cakephp/core.git", @@ -146,16 +146,16 @@ }, { "name": "cakephp/database", - "version": "3.6.10", + "version": "3.6.12", "source": { "type": "git", "url": "https://github.com/cakephp/database.git", - "reference": "12234e6f6f6d69692849b16f496767a15fbc7b64" + "reference": "1494d12bc2b42cb1e844936cbbdd686a5e36235d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/database/zipball/12234e6f6f6d69692849b16f496767a15fbc7b64", - "reference": "12234e6f6f6d69692849b16f496767a15fbc7b64", + "url": "https://api.github.com/repos/cakephp/database/zipball/1494d12bc2b42cb1e844936cbbdd686a5e36235d", + "reference": "1494d12bc2b42cb1e844936cbbdd686a5e36235d", "shasum": "" }, "require": { @@ -192,20 +192,20 @@ "database abstraction", "pdo" ], - "time": "2018-07-19T10:51:03+00:00" + "time": "2018-09-28T10:56:48+00:00" }, { "name": "cakephp/datasource", - "version": "3.6.10", + "version": "3.6.12", "source": { "type": "git", "url": "https://github.com/cakephp/datasource.git", - "reference": "05fb1bfa34fad9385b6500857e9da432f5c45abe" + "reference": "44222238fa97e32d39e48bb2add4933ccffbd896" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/datasource/zipball/05fb1bfa34fad9385b6500857e9da432f5c45abe", - "reference": "05fb1bfa34fad9385b6500857e9da432f5c45abe", + "url": "https://api.github.com/repos/cakephp/datasource/zipball/44222238fa97e32d39e48bb2add4933ccffbd896", + "reference": "44222238fa97e32d39e48bb2add4933ccffbd896", "shasum": "" }, "require": { @@ -242,20 +242,20 @@ "entity", "query" ], - "time": "2018-07-26T19:56:06+00:00" + "time": "2018-09-28T10:56:48+00:00" }, { "name": "cakephp/utility", - "version": "3.6.10", + "version": "3.6.12", "source": { "type": "git", "url": "https://github.com/cakephp/utility.git", - "reference": "93b37e7747c95a10d6638d39d0e1f867d98c9ef9" + "reference": "14b61586db830a84aedadd57be2825f40cc29e09" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/utility/zipball/93b37e7747c95a10d6638d39d0e1f867d98c9ef9", - "reference": "93b37e7747c95a10d6638d39d0e1f867d98c9ef9", + "url": "https://api.github.com/repos/cakephp/utility/zipball/14b61586db830a84aedadd57be2825f40cc29e09", + "reference": "14b61586db830a84aedadd57be2825f40cc29e09", "shasum": "" }, "require": { @@ -295,7 +295,7 @@ "string", "utility" ], - "time": "2018-07-26T19:56:06+00:00" + "time": "2018-09-05T00:44:03+00:00" }, { "name": "cocur/slugify", @@ -608,16 +608,16 @@ }, { "name": "egulias/email-validator", - "version": "2.1.5", + "version": "2.1.6", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "54859fabea8b3beecbb1a282888d5c990036b9e3" + "reference": "0578b32b30b22de3e8664f797cf846fc9246f786" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/54859fabea8b3beecbb1a282888d5c990036b9e3", - "reference": "54859fabea8b3beecbb1a282888d5c990036b9e3", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/0578b32b30b22de3e8664f797cf846fc9246f786", + "reference": "0578b32b30b22de3e8664f797cf846fc9246f786", "shasum": "" }, "require": { @@ -661,7 +661,7 @@ "validation", "validator" ], - "time": "2018-08-16T20:49:45+00:00" + "time": "2018-09-25T20:47:26+00:00" }, { "name": "erusev/parsedown", @@ -1048,32 +1048,32 @@ }, { "name": "jakub-onderka/php-console-color", - "version": "0.1", + "version": "v0.2", "source": { "type": "git", "url": "https://github.com/JakubOnderka/PHP-Console-Color.git", - "reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1" + "reference": "d5deaecff52a0d61ccb613bb3804088da0307191" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/e0b393dacf7703fc36a4efc3df1435485197e6c1", - "reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1", + "url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/d5deaecff52a0d61ccb613bb3804088da0307191", + "reference": "d5deaecff52a0d61ccb613bb3804088da0307191", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": ">=5.4.0" }, "require-dev": { "jakub-onderka/php-code-style": "1.0", - "jakub-onderka/php-parallel-lint": "0.*", + "jakub-onderka/php-parallel-lint": "1.0", "jakub-onderka/php-var-dump-check": "0.*", - "phpunit/phpunit": "3.7.*", + "phpunit/phpunit": "~4.3", "squizlabs/php_codesniffer": "1.*" }, "type": "library", "autoload": { - "psr-0": { - "JakubOnderka\\PhpConsoleColor": "src/" + "psr-4": { + "JakubOnderka\\PhpConsoleColor\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1083,11 +1083,10 @@ "authors": [ { "name": "Jakub Onderka", - "email": "jakub.onderka@gmail.com", - "homepage": "http://www.acci.cz" + "email": "jakub.onderka@gmail.com" } ], - "time": "2014-04-08T15:00:19+00:00" + "time": "2018-09-29T17:23:10+00:00" }, { "name": "jakub-onderka/php-console-highlighter", @@ -1135,16 +1134,16 @@ }, { "name": "laravel/framework", - "version": "v5.6.35", + "version": "v5.6.39", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "02abbe2091404ebe032a6d5a83075031b7072ebe" + "reference": "37bb306f516669ab4f888c16003f694313ab299e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/02abbe2091404ebe032a6d5a83075031b7072ebe", - "reference": "02abbe2091404ebe032a6d5a83075031b7072ebe", + "url": "https://api.github.com/repos/laravel/framework/zipball/37bb306f516669ab4f888c16003f694313ab299e", + "reference": "37bb306f516669ab4f888c16003f694313ab299e", "shasum": "" }, "require": { @@ -1270,20 +1269,20 @@ "framework", "laravel" ], - "time": "2018-08-27T13:18:24+00:00" + "time": "2018-10-04T14:50:41+00:00" }, { "name": "laravel/tinker", - "version": "v1.0.7", + "version": "v1.0.8", "source": { "type": "git", "url": "https://github.com/laravel/tinker.git", - "reference": "e3086ee8cb1f54a39ae8dcb72d1c37d10128997d" + "reference": "cafbf598a90acde68985660e79b2b03c5609a405" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/tinker/zipball/e3086ee8cb1f54a39ae8dcb72d1c37d10128997d", - "reference": "e3086ee8cb1f54a39ae8dcb72d1c37d10128997d", + "url": "https://api.github.com/repos/laravel/tinker/zipball/cafbf598a90acde68985660e79b2b03c5609a405", + "reference": "cafbf598a90acde68985660e79b2b03c5609a405", "shasum": "" }, "require": { @@ -1333,30 +1332,30 @@ "laravel", "psysh" ], - "time": "2018-05-17T13:42:07+00:00" + "time": "2018-10-12T19:39:35+00:00" }, { "name": "league/flysystem", - "version": "1.0.46", + "version": "1.0.48", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2" + "reference": "a6ded5b2f6055e2db97b4b859fdfca2b952b78aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2", - "reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/a6ded5b2f6055e2db97b4b859fdfca2b952b78aa", + "reference": "a6ded5b2f6055e2db97b4b859fdfca2b952b78aa", "shasum": "" }, "require": { + "ext-fileinfo": "*", "php": ">=5.5.9" }, "conflict": { "league/flysystem-sftp": "<1.0.6" }, "require-dev": { - "ext-fileinfo": "*", "phpspec/phpspec": "^3.4", "phpunit/phpunit": "^5.7.10" }, @@ -1417,7 +1416,7 @@ "sftp", "storage" ], - "time": "2018-08-22T07:45:22+00:00" + "time": "2018-10-15T13:53:10+00:00" }, { "name": "monolog/monolog", @@ -1552,16 +1551,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.0.3", + "version": "v4.1.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bd088dc940a418f09cda079a9b5c7c478890fb8d" + "reference": "d0230c5c77a7e3cfa69446febf340978540958c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bd088dc940a418f09cda079a9b5c7c478890fb8d", - "reference": "bd088dc940a418f09cda079a9b5c7c478890fb8d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/d0230c5c77a7e3cfa69446febf340978540958c0", + "reference": "d0230c5c77a7e3cfa69446febf340978540958c0", "shasum": "" }, "require": { @@ -1577,7 +1576,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -1599,7 +1598,7 @@ "parser", "php" ], - "time": "2018-07-15T17:25:16+00:00" + "time": "2018-10-10T09:24:14+00:00" }, { "name": "paragonie/random_compat", @@ -1842,23 +1841,23 @@ }, { "name": "psy/psysh", - "version": "v0.9.7", + "version": "v0.9.9", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "4f5b6c090948773a8bfeea6a0f07ab7d0b24e932" + "reference": "9aaf29575bb8293206bb0420c1e1c87ff2ffa94e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/4f5b6c090948773a8bfeea6a0f07ab7d0b24e932", - "reference": "4f5b6c090948773a8bfeea6a0f07ab7d0b24e932", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/9aaf29575bb8293206bb0420c1e1c87ff2ffa94e", + "reference": "9aaf29575bb8293206bb0420c1e1c87ff2ffa94e", "shasum": "" }, "require": { "dnoegel/php-xdg-base-dir": "0.1", "ext-json": "*", "ext-tokenizer": "*", - "jakub-onderka/php-console-highlighter": "0.3.*", + "jakub-onderka/php-console-highlighter": "0.3.*|0.4.*", "nikic/php-parser": "~1.3|~2.0|~3.0|~4.0", "php": ">=5.4.0", "symfony/console": "~2.3.10|^2.4.2|~3.0|~4.0", @@ -1912,7 +1911,7 @@ "interactive", "shell" ], - "time": "2018-08-11T15:54:43+00:00" + "time": "2018-10-13T15:16:03+00:00" }, { "name": "ramsey/uuid", @@ -2072,16 +2071,16 @@ }, { "name": "swiftmailer/swiftmailer", - "version": "v6.1.2", + "version": "v6.1.3", "source": { "type": "git", "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "7d760881d266d63c5e7a1155cbcf2ac656a31ca8" + "reference": "8ddcb66ac10c392d3beb54829eef8ac1438595f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/7d760881d266d63c5e7a1155cbcf2ac656a31ca8", - "reference": "7d760881d266d63c5e7a1155cbcf2ac656a31ca8", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/8ddcb66ac10c392d3beb54829eef8ac1438595f4", + "reference": "8ddcb66ac10c392d3beb54829eef8ac1438595f4", "shasum": "" }, "require": { @@ -2127,20 +2126,20 @@ "mail", "mailer" ], - "time": "2018-07-13T07:04:35+00:00" + "time": "2018-09-11T07:12:52+00:00" }, { "name": "symfony/config", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "76015a3cc372b14d00040ff58e18e29f69eba717" + "reference": "b3d4d7b567d7a49e6dfafb6d4760abc921177c96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/76015a3cc372b14d00040ff58e18e29f69eba717", - "reference": "76015a3cc372b14d00040ff58e18e29f69eba717", + "url": "https://api.github.com/repos/symfony/config/zipball/b3d4d7b567d7a49e6dfafb6d4760abc921177c96", + "reference": "b3d4d7b567d7a49e6dfafb6d4760abc921177c96", "shasum": "" }, "require": { @@ -2190,20 +2189,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2018-08-08T06:37:38+00:00" + "time": "2018-09-08T13:24:10+00:00" }, { "name": "symfony/console", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "ca80b8ced97cf07390078b29773dc384c39eee1f" + "reference": "dc7122fe5f6113cfaba3b3de575d31112c9aa60b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/ca80b8ced97cf07390078b29773dc384c39eee1f", - "reference": "ca80b8ced97cf07390078b29773dc384c39eee1f", + "url": "https://api.github.com/repos/symfony/console/zipball/dc7122fe5f6113cfaba3b3de575d31112c9aa60b", + "reference": "dc7122fe5f6113cfaba3b3de575d31112c9aa60b", "shasum": "" }, "require": { @@ -2258,20 +2257,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:24:31+00:00" + "time": "2018-10-03T08:15:46+00:00" }, { "name": "symfony/css-selector", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "2a4df7618f869b456f9096781e78c57b509d76c7" + "reference": "d67de79a70a27d93c92c47f37ece958bf8de4d8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/2a4df7618f869b456f9096781e78c57b509d76c7", - "reference": "2a4df7618f869b456f9096781e78c57b509d76c7", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/d67de79a70a27d93c92c47f37ece958bf8de4d8a", + "reference": "d67de79a70a27d93c92c47f37ece958bf8de4d8a", "shasum": "" }, "require": { @@ -2311,20 +2310,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2018-07-26T09:10:45+00:00" + "time": "2018-10-02T16:36:10+00:00" }, { "name": "symfony/debug", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "47ead688f1f2877f3f14219670f52e4722ee7052" + "reference": "e3f76ce6198f81994e019bb2b4e533e9de1b9b90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/47ead688f1f2877f3f14219670f52e4722ee7052", - "reference": "47ead688f1f2877f3f14219670f52e4722ee7052", + "url": "https://api.github.com/repos/symfony/debug/zipball/e3f76ce6198f81994e019bb2b4e533e9de1b9b90", + "reference": "e3f76ce6198f81994e019bb2b4e533e9de1b9b90", "shasum": "" }, "require": { @@ -2367,11 +2366,11 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2018-08-03T11:13:38+00:00" + "time": "2018-10-02T16:36:10+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -2434,16 +2433,16 @@ }, { "name": "symfony/filesystem", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "c0f5f62db218fa72195b8b8700e4b9b9cf52eb5e" + "reference": "596d12b40624055c300c8b619755b748ca5cf0b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/c0f5f62db218fa72195b8b8700e4b9b9cf52eb5e", - "reference": "c0f5f62db218fa72195b8b8700e4b9b9cf52eb5e", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/596d12b40624055c300c8b619755b748ca5cf0b5", + "reference": "596d12b40624055c300c8b619755b748ca5cf0b5", "shasum": "" }, "require": { @@ -2480,20 +2479,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2018-08-18T16:52:46+00:00" + "time": "2018-10-02T12:40:59+00:00" }, { "name": "symfony/finder", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "e162f1df3102d0b7472805a5a9d5db9fcf0a8068" + "reference": "1f17195b44543017a9c9b2d437c670627e96ad06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/e162f1df3102d0b7472805a5a9d5db9fcf0a8068", - "reference": "e162f1df3102d0b7472805a5a9d5db9fcf0a8068", + "url": "https://api.github.com/repos/symfony/finder/zipball/1f17195b44543017a9c9b2d437c670627e96ad06", + "reference": "1f17195b44543017a9c9b2d437c670627e96ad06", "shasum": "" }, "require": { @@ -2529,20 +2528,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:24:31+00:00" + "time": "2018-10-03T08:47:56+00:00" }, { "name": "symfony/http-foundation", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "3a5c91e133b220bb882b3cd773ba91bf39989345" + "reference": "d528136617ff24f530e70df9605acc1b788b08d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/3a5c91e133b220bb882b3cd773ba91bf39989345", - "reference": "3a5c91e133b220bb882b3cd773ba91bf39989345", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/d528136617ff24f530e70df9605acc1b788b08d4", + "reference": "d528136617ff24f530e70df9605acc1b788b08d4", "shasum": "" }, "require": { @@ -2583,20 +2582,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2018-08-27T17:47:02+00:00" + "time": "2018-10-03T08:48:45+00:00" }, { "name": "symfony/http-kernel", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "33de0a1ff2e1720096189e3ced682d7a4e8f5e35" + "reference": "f5e7c15a5d010be0e16ce798594c5960451d4220" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/33de0a1ff2e1720096189e3ced682d7a4e8f5e35", - "reference": "33de0a1ff2e1720096189e3ced682d7a4e8f5e35", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/f5e7c15a5d010be0e16ce798594c5960451d4220", + "reference": "f5e7c15a5d010be0e16ce798594c5960451d4220", "shasum": "" }, "require": { @@ -2670,7 +2669,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2018-08-28T06:17:42+00:00" + "time": "2018-10-03T12:53:38+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2846,16 +2845,16 @@ }, { "name": "symfony/process", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "86cdb930a6a855b0ab35fb60c1504cb36184f843" + "reference": "ee33c0322a8fee0855afcc11fff81e6b1011b529" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/86cdb930a6a855b0ab35fb60c1504cb36184f843", - "reference": "86cdb930a6a855b0ab35fb60c1504cb36184f843", + "url": "https://api.github.com/repos/symfony/process/zipball/ee33c0322a8fee0855afcc11fff81e6b1011b529", + "reference": "ee33c0322a8fee0855afcc11fff81e6b1011b529", "shasum": "" }, "require": { @@ -2891,20 +2890,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-08-03T11:13:38+00:00" + "time": "2018-10-02T12:40:59+00:00" }, { "name": "symfony/routing", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "a5784c2ec4168018c87b38f0e4f39d2278499f51" + "reference": "537803f0bdfede36b9acef052d2e4d447d9fa0e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/a5784c2ec4168018c87b38f0e4f39d2278499f51", - "reference": "a5784c2ec4168018c87b38f0e4f39d2278499f51", + "url": "https://api.github.com/repos/symfony/routing/zipball/537803f0bdfede36b9acef052d2e4d447d9fa0e9", + "reference": "537803f0bdfede36b9acef052d2e4d447d9fa0e9", "shasum": "" }, "require": { @@ -2968,20 +2967,20 @@ "uri", "url" ], - "time": "2018-08-03T07:58:40+00:00" + "time": "2018-10-02T12:40:59+00:00" }, { "name": "symfony/translation", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "fa2182669f7983b7aa5f1a770d053f79f0ef144f" + "reference": "9f0b61e339160a466ebcde167a6c5521c810e304" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/fa2182669f7983b7aa5f1a770d053f79f0ef144f", - "reference": "fa2182669f7983b7aa5f1a770d053f79f0ef144f", + "url": "https://api.github.com/repos/symfony/translation/zipball/9f0b61e339160a466ebcde167a6c5521c810e304", + "reference": "9f0b61e339160a466ebcde167a6c5521c810e304", "shasum": "" }, "require": { @@ -3037,20 +3036,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2018-08-07T12:45:11+00:00" + "time": "2018-10-02T16:36:10+00:00" }, { "name": "symfony/var-dumper", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "a05426e27294bba7b0226ffc17dd01a3c6ef9777" + "reference": "60319b45653580b0cdacca499344577d87732f16" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/a05426e27294bba7b0226ffc17dd01a3c6ef9777", - "reference": "a05426e27294bba7b0226ffc17dd01a3c6ef9777", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/60319b45653580b0cdacca499344577d87732f16", + "reference": "60319b45653580b0cdacca499344577d87732f16", "shasum": "" }, "require": { @@ -3112,20 +3111,20 @@ "debug", "dump" ], - "time": "2018-08-02T09:24:26+00:00" + "time": "2018-10-02T16:36:10+00:00" }, { "name": "symfony/yaml", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "b832cc289608b6d305f62149df91529a2ab3c314" + "reference": "367e689b2fdc19965be435337b50bc8adf2746c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/b832cc289608b6d305f62149df91529a2ab3c314", - "reference": "b832cc289608b6d305f62149df91529a2ab3c314", + "url": "https://api.github.com/repos/symfony/yaml/zipball/367e689b2fdc19965be435337b50bc8adf2746c9", + "reference": "367e689b2fdc19965be435337b50bc8adf2746c9", "shasum": "" }, "require": { @@ -3171,7 +3170,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-08-18T16:52:46+00:00" + "time": "2018-10-02T16:36:10+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -3562,16 +3561,16 @@ }, { "name": "filp/whoops", - "version": "2.2.0", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "181c4502d8f34db7aed7bfe88d4f87875b8e947a" + "reference": "a9f129b99df316f847584d482c89c14a9f796e2b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/181c4502d8f34db7aed7bfe88d4f87875b8e947a", - "reference": "181c4502d8f34db7aed7bfe88d4f87875b8e947a", + "url": "https://api.github.com/repos/filp/whoops/zipball/a9f129b99df316f847584d482c89c14a9f796e2b", + "reference": "a9f129b99df316f847584d482c89c14a9f796e2b", "shasum": "" }, "require": { @@ -3590,7 +3589,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, "autoload": { @@ -3619,20 +3618,20 @@ "throwable", "whoops" ], - "time": "2018-03-03T17:56:25+00:00" + "time": "2018-10-20T09:00:00+00:00" }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.13.0", + "version": "v2.13.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "7136aa4e0c5f912e8af82383775460d906168a10" + "reference": "54814c62d5beef3ba55297b9b3186ed8b8a1b161" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/7136aa4e0c5f912e8af82383775460d906168a10", - "reference": "7136aa4e0c5f912e8af82383775460d906168a10", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/54814c62d5beef3ba55297b9b3186ed8b8a1b161", + "reference": "54814c62d5beef3ba55297b9b3186ed8b8a1b161", "shasum": "" }, "require": { @@ -3643,7 +3642,7 @@ "ext-tokenizer": "*", "php": "^5.6 || >=7.0 <7.3", "php-cs-fixer/diff": "^1.3", - "symfony/console": "^3.2 || ^4.0", + "symfony/console": "^3.4.17 || ^4.1.6", "symfony/event-dispatcher": "^3.0 || ^4.0", "symfony/filesystem": "^3.0 || ^4.0", "symfony/finder": "^3.0 || ^4.0", @@ -3679,11 +3678,6 @@ "php-cs-fixer" ], "type": "application", - "extra": { - "branch-alias": { - "dev-master": "2.13-dev" - } - }, "autoload": { "psr-4": { "PhpCsFixer\\": "src/" @@ -3715,7 +3709,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2018-08-23T13:15:44+00:00" + "time": "2018-10-21T00:32:10+00:00" }, { "name": "fzaninotto/faker", @@ -3817,16 +3811,16 @@ }, { "name": "laravel/dusk", - "version": "v4.0.0", + "version": "v4.0.2", "source": { "type": "git", "url": "https://github.com/laravel/dusk.git", - "reference": "5facdb15f5952ed28c711e89b30adce74fa388c7" + "reference": "9810f8609c8b53d9a3bac7d38c56530e0d77a6bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/dusk/zipball/5facdb15f5952ed28c711e89b30adce74fa388c7", - "reference": "5facdb15f5952ed28c711e89b30adce74fa388c7", + "url": "https://api.github.com/repos/laravel/dusk/zipball/9810f8609c8b53d9a3bac7d38c56530e0d77a6bb", + "reference": "9810f8609c8b53d9a3bac7d38c56530e0d77a6bb", "shasum": "" }, "require": { @@ -3874,7 +3868,7 @@ "testing", "webdriver" ], - "time": "2018-08-12T01:53:48+00:00" + "time": "2018-10-03T15:37:05+00:00" }, { "name": "mikey179/vfsStream", @@ -3924,16 +3918,16 @@ }, { "name": "mockery/mockery", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "99e29d3596b16dabe4982548527d5ddf90232e99" + "reference": "100633629bf76d57430b86b7098cd6beb996a35a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/99e29d3596b16dabe4982548527d5ddf90232e99", - "reference": "99e29d3596b16dabe4982548527d5ddf90232e99", + "url": "https://api.github.com/repos/mockery/mockery/zipball/100633629bf76d57430b86b7098cd6beb996a35a", + "reference": "100633629bf76d57430b86b7098cd6beb996a35a", "shasum": "" }, "require": { @@ -3942,8 +3936,7 @@ "php": ">=5.6.0" }, "require-dev": { - "phpdocumentor/phpdocumentor": "^2.9", - "phpunit/phpunit": "~5.7.10|~6.5" + "phpunit/phpunit": "~5.7.10|~6.5|~7.0" }, "type": "library", "extra": { @@ -3986,7 +3979,7 @@ "test double", "testing" ], - "time": "2018-05-08T08:54:48+00:00" + "time": "2018-10-02T21:52:37+00:00" }, { "name": "myclabs/deep-copy", @@ -4038,16 +4031,16 @@ }, { "name": "nunomaduro/collision", - "version": "v2.0.3", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "b1f606399ae77e9479b5597cd1aa3d8ea0078176" + "reference": "1149ad9f36f61b121ae61f5f6de820fc77b51e6b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/b1f606399ae77e9479b5597cd1aa3d8ea0078176", - "reference": "b1f606399ae77e9479b5597cd1aa3d8ea0078176", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/1149ad9f36f61b121ae61f5f6de820fc77b51e6b", + "reference": "1149ad9f36f61b121ae61f5f6de820fc77b51e6b", "shasum": "" }, "require": { @@ -4057,9 +4050,9 @@ "symfony/console": "~2.8|~3.3|~4.0" }, "require-dev": { - "laravel/framework": "5.6.*", - "phpstan/phpstan": "^0.9.2", - "phpunit/phpunit": "~7.2" + "laravel/framework": "5.7.*", + "phpstan/phpstan": "^0.10", + "phpunit/phpunit": "~7.3" }, "type": "library", "extra": { @@ -4097,7 +4090,7 @@ "php", "symfony" ], - "time": "2018-06-16T22:05:52+00:00" + "time": "2018-10-03T20:01:54+00:00" }, { "name": "phar-io/manifest", @@ -4604,16 +4597,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "6.0.7", + "version": "6.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a" + "reference": "b097681a19a48e52706f57e47a09594bac4f7cab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/865662550c384bc1db7e51d29aeda1c2c161d69a", - "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b097681a19a48e52706f57e47a09594bac4f7cab", + "reference": "b097681a19a48e52706f57e47a09594bac4f7cab", "shasum": "" }, "require": { @@ -4624,7 +4617,7 @@ "phpunit/php-text-template": "^1.2.1", "phpunit/php-token-stream": "^3.0", "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1", + "sebastian/environment": "^3.1 || ^4.0", "sebastian/version": "^2.0.1", "theseer/tokenizer": "^1.1" }, @@ -4637,7 +4630,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.0-dev" + "dev-master": "6.1-dev" } }, "autoload": { @@ -4663,25 +4656,28 @@ "testing", "xunit" ], - "time": "2018-06-01T07:51:50+00:00" + "time": "2018-10-18T09:01:38+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "cecbc684605bb0cc288828eb5d65d93d5c676d3c" + "reference": "050bedf145a257b1ff02746c31894800e5122946" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cecbc684605bb0cc288828eb5d65d93d5c676d3c", - "reference": "cecbc684605bb0cc288828eb5d65d93d5c676d3c", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", "shasum": "" }, "require": { "php": "^7.1" }, + "require-dev": { + "phpunit/phpunit": "^7.1" + }, "type": "library", "extra": { "branch-alias": { @@ -4710,7 +4706,7 @@ "filesystem", "iterator" ], - "time": "2018-06-11T11:44:00+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", @@ -4853,16 +4849,16 @@ }, { "name": "phpunit/phpunit", - "version": "7.3.2", + "version": "7.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "34705f81bddc3f505b9599a2ef96e2b4315ba9b8" + "reference": "c5a120ade60992bd671a912188ee9ee9f8083bbd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/34705f81bddc3f505b9599a2ef96e2b4315ba9b8", - "reference": "34705f81bddc3f505b9599a2ef96e2b4315ba9b8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c5a120ade60992bd671a912188ee9ee9f8083bbd", + "reference": "c5a120ade60992bd671a912188ee9ee9f8083bbd", "shasum": "" }, "require": { @@ -4883,11 +4879,11 @@ "phpunit/php-timer": "^2.0", "sebastian/comparator": "^3.0", "sebastian/diff": "^3.0", - "sebastian/environment": "^3.1", + "sebastian/environment": "^3.1 || ^4.0", "sebastian/exporter": "^3.1", "sebastian/global-state": "^2.0", "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^1.0", + "sebastian/resource-operations": "^2.0", "sebastian/version": "^2.0.1" }, "conflict": { @@ -4907,7 +4903,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.3-dev" + "dev-master": "7.4-dev" } }, "autoload": { @@ -4933,7 +4929,7 @@ "testing", "xunit" ], - "time": "2018-08-22T06:39:21+00:00" + "time": "2018-10-18T09:02:52+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -5415,25 +5411,25 @@ }, { "name": "sebastian/resource-operations", - "version": "1.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -5453,7 +5449,7 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28T20:34:47+00:00" + "time": "2018-10-04T04:07:39+00:00" }, { "name": "sebastian/version", @@ -5500,16 +5496,16 @@ }, { "name": "symfony/options-resolver", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "1913f1962477cdbb13df951f8147d5da1fe2412c" + "reference": "40f0e40d37c1c8a762334618dea597d64bbb75ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/1913f1962477cdbb13df951f8147d5da1fe2412c", - "reference": "1913f1962477cdbb13df951f8147d5da1fe2412c", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/40f0e40d37c1c8a762334618dea597d64bbb75ff", + "reference": "40f0e40d37c1c8a762334618dea597d64bbb75ff", "shasum": "" }, "require": { @@ -5550,7 +5546,7 @@ "configuration", "options" ], - "time": "2018-07-26T08:55:25+00:00" + "time": "2018-09-18T12:45:12+00:00" }, { "name": "symfony/polyfill-php70", @@ -5613,16 +5609,16 @@ }, { "name": "symfony/stopwatch", - "version": "v4.1.4", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "966c982df3cca41324253dc0c7ffe76b6076b705" + "reference": "5bfc064125b73ff81229e19381ce1c34d3416f4b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/966c982df3cca41324253dc0c7ffe76b6076b705", - "reference": "966c982df3cca41324253dc0c7ffe76b6076b705", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/5bfc064125b73ff81229e19381ce1c34d3416f4b", + "reference": "5bfc064125b73ff81229e19381ce1c34d3416f4b", "shasum": "" }, "require": { @@ -5658,7 +5654,7 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:00:49+00:00" + "time": "2018-10-02T12:40:59+00:00" }, { "name": "theseer/tokenizer", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000000..0a4e73d53d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +version: '3' + +services: + + nginx: + container_name: nginx + build: docker/nginx + links: + - php + ports: + - 8888:80 + working_dir: /application + volumes: + - ./:/application + + php: + container_name: php + build: docker/php + links: + - postgres + - redis + environment: + CORE_EXT_CONFIGURATION_ENV: development + XDEBUG_IDEKEY: xdebug + XDEBUG_REMOTE_HOST: 127.0.0.1 + XDEBUG_REMOTE_PORT: 9000 + XDEBUG_REMOTE_ENABLE: 1 + working_dir: /application + volumes: + - ./:/application + + postgres: + container_name: postgres + image: postgres:9.5 + environment: + POSTGRES_USER: ieducar + POSTGRES_PASSWORD: ieducar + ports: + - 5432:5432 + volumes: + - /var/lib/postgresql/data + + redis: + container_name: redis + image: redis + restart: always diff --git a/ieducar/configuration/ieducar.ini.example b/ieducar/configuration/ieducar.ini.example index a8773c0031..9240f9745c 100644 --- a/ieducar/configuration/ieducar.ini.example +++ b/ieducar/configuration/ieducar.ini.example @@ -79,7 +79,7 @@ report.show_error_details = true report.default_factory = Portabilis_Report_ReportFactoryPHPJasper ; Define o diretório dos arquivos fontes dos relatórios -report.source_path = /home/portabilis/ieducar/ieducar/modules/Reports/ReportSources +report.source_path = /home/portabilis/ieducar/ieducar/modules/Reports/ReportSources/ ; Configurações da entidade (instituicao) ; define o nome da entidade a ser exibido no topo @@ -131,8 +131,9 @@ modules.error.send_notification_email = true ;modules.error.notification_email = username@domain.com.br modules.error.show_details = true modules.error.track = false -modules.error.tracker_name = +modules.error.tracker_name = EMAIL modules.error.honeybadger_key = +modules.error.email_recipient = ; Configurações google.com/recaptcha (confirmação humana, para evitar robos) app.recaptcha.public_key = diff --git a/ieducar/configuration/testing.ini b/ieducar/configuration/testing.ini.scrutinizer similarity index 100% rename from ieducar/configuration/testing.ini rename to ieducar/configuration/testing.ini.scrutinizer diff --git a/ieducar/configuration/testing.ini.semaphore b/ieducar/configuration/testing.ini.semaphore new file mode 100644 index 0000000000..97404ed33d --- /dev/null +++ b/ieducar/configuration/testing.ini.semaphore @@ -0,0 +1,23 @@ +[production] +app.database.dbname = ieducar_test +app.database.username = runner +app.database.hostname = localhost +app.database.password = semaphoredb +app.database.port = 5432 +app.name = "i-Educar" + +app.admin.reports.sql_tempo = 3 +app.admin.reports.pagina_tempo = 5 +app.admin.reports.emails[] = + +[development : production] + +[testing : development] + +app.locale.country = 45 +app.locale.province = SP +app.locale.timezone = America/Sao_Paulo +apis.access_key = "" +apis.secret_key = "" + +app.template.vars.instituicao = i-Educar \ No newline at end of file diff --git a/ieducar/configuration/travis.ini b/ieducar/configuration/travis.ini new file mode 100644 index 0000000000..6bc4f471ca --- /dev/null +++ b/ieducar/configuration/travis.ini @@ -0,0 +1,23 @@ +[production] +app.database.dbname = travis +app.database.username = postgres +app.database.hostname = localhost +app.database.password = +app.database.port = 5432 +app.name = "i-Educar" + +app.admin.reports.sql_tempo = 3 +app.admin.reports.pagina_tempo = 5 +app.admin.reports.emails[] = + +[development : production] + +[travis : development] + +app.locale.country = 45 +app.locale.province = SP +app.locale.timezone = America/Sao_Paulo +apis.access_key = "" +apis.secret_key = "" + +app.template.vars.instituicao = i-Educar diff --git a/ieducar/intranet/educar_abandono_cad.php b/ieducar/intranet/educar_abandono_cad.php index 8615866863..7e22218fe0 100644 --- a/ieducar/intranet/educar_abandono_cad.php +++ b/ieducar/intranet/educar_abandono_cad.php @@ -24,11 +24,14 @@ * 02111-1307, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -require_once ("include/clsBase.inc.php"); -require_once ("include/clsCadastro.inc.php"); -require_once ("include/clsBanco.inc.php"); -require_once( "include/pmieducar/geral.inc.php"); +require_once 'include/clsBase.inc.php'; +require_once 'include/clsCadastro.inc.php'; +require_once 'include/clsBanco.inc.php'; +require_once 'include/pmieducar/geral.inc.php'; require_once 'lib/Portabilis/Date/Utils.php'; +require_once 'modules/Avaliacao/Model/NotaAlunoDataMapper.php'; +require_once 'modules/Avaliacao/Model/NotaComponenteMediaDataMapper.php'; +require_once 'lib/App/Model/MatriculaSituacao.php'; class clsIndexBase extends clsBase { @@ -193,6 +196,13 @@ function Novo() $enturmacao->marcaAlunoAbandono($this->data_cancel); } + + $notaAlunoId = (new Avaliacao_Model_NotaAlunoDataMapper()) + ->findAll(['id'], ['matricula_id' => $obj_matricula->cod_matricula])[0]->get('id'); + + (new Avaliacao_Model_NotaComponenteMediaDataMapper()) + ->updateSituation($notaAlunoId, App_Model_MatriculaSituacao::ABANDONO); + $this->mensagem .= "Abandono realizado com sucesso.
"; header( "Location: educar_matricula_det.php?cod_matricula={$this->ref_cod_matricula}" ); return true; diff --git a/ieducar/intranet/educar_ano_letivo_modulo_cad.php b/ieducar/intranet/educar_ano_letivo_modulo_cad.php index 8ac92f91ee..8780e04f6a 100644 --- a/ieducar/intranet/educar_ano_letivo_modulo_cad.php +++ b/ieducar/intranet/educar_ano_letivo_modulo_cad.php @@ -1,499 +1,641 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Prefeitura Municipal de Itajaí - * @category i-Educar - * @license @@license@@ - * @package iEd_Pmieducar - * @since Arquivo disponível desde a versão 1.0.0 - * @version $Id$ - */ - require_once 'include/clsBase.inc.php'; require_once 'include/clsCadastro.inc.php'; require_once 'include/clsBanco.inc.php'; require_once 'include/pmieducar/geral.inc.php'; require_once 'Portabilis/Date/Utils.php'; - +require_once 'Portabilis/View/Helper/Application.php'; require_once 'App/Date/Utils.php'; - require_once 'ComponenteCurricular/Model/TurmaDataMapper.php'; -/** - * clsIndexBase class. - * - * @author Prefeitura Municipal de Itajaí - * @category i-Educar - * @license @@license@@ - * @package iEd_Pmieducar - * @since Classe disponível desde a versão 1.0.0 - * @version @@package_version@@ - */ class clsIndexBase extends clsBase { - function Formular() - { - $this->SetTitulo($this->_instituicao . ' i-Educar - Ano Letivo Módulo'); - $this->processoAp = 561; - $this->addEstilo("localizacaoSistema"); - } + + public function Formular() + { + $this->SetTitulo($this->_instituicao . ' Ano Letivo Etapa'); + $this->processoAp = 561; + $this->addEstilo('localizacaoSistema'); + } } -/** - * indice class. - * - * @author Prefeitura Municipal de Itajaí - * @category i-Educar - * @license @@license@@ - * @package iEd_Pmieducar - * @since Classe disponível desde a versão 1.0.0 - * @version @@package_version@@ - */ class indice extends clsCadastro { - var $pessoa_logada; - var $ref_ano; - var $ref_ref_cod_escola; - var $sequencial; - var $ref_cod_modulo; - var $data_inicio; - var $data_fim; + public $pessoa_logada; - var $ano_letivo_modulo; + public $ref_ano; - function Inicializar() - { - $retorno = 'Novo'; + public $ref_ref_cod_escola; - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); + public $sequencial; - $this->ref_cod_modulo = $_GET['ref_cod_modulo']; - $this->ref_ref_cod_escola = $_GET['ref_cod_escola']; - $this->ref_ano = $_GET['ano']; + public $ref_cod_modulo; - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra(561, $this->pessoa_logada, 7, - 'educar_escola_lst.php'); + public $data_inicio; - if (is_numeric($this->ref_ano) && is_numeric($this->ref_ref_cod_escola)) { - $obj = new clsPmieducarEscolaAnoLetivo($this->ref_ref_cod_escola, $this->ref_ano); - $registro = $obj->detalhe(); + public $data_fim; - if ($registro) { - if ($obj_permissoes->permissao_excluir(561, $this->pessoa_logada, 7)) { - $this->fexcluir = TRUE; - } + public $ano_letivo_modulo; - $retorno = 'Editar'; - } - } + public $modulos = []; - $this->url_cancelar = $_GET['referrer'] ? - $_GET['referrer'] . '?cod_escola=' . $this->ref_ref_cod_escola: - 'educar_escola_lst.php'; - - $localizacao = new LocalizacaoSistema(); - $localizacao->entradaCaminhos( array( - $_SERVER['SERVER_NAME']."/intranet" => "Início", - "educar_index.php" => "Escola", - "" => "Módulos do ano letivo" - )); - $this->enviaLocalizacao($localizacao->montar()); - - $this->nome_url_cancelar = 'Cancelar'; - - return $retorno; - } - - function Gerar() - { - if ($_POST) { - foreach ($_POST as $campo => $val) { - $this->$campo = $this->$campo ? $this->$campo : $val; - } - } + public $etapas = []; - // Primary keys - $this->campoOculto('ref_ano', $this->ref_ano); - $this->campoOculto('ref_ref_cod_escola', $this->ref_ref_cod_escola); + public function Inicializar() + { + $retorno = 'Novo'; - $obj_escola = new clsPmieducarEscola($this->ref_ref_cod_escola); - $det_escola = $obj_escola->detalhe(); - $ref_cod_instituicao = $det_escola['ref_cod_instituicao']; + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); - $obj = new clsPmieducarAnoLetivoModulo(); - $obj->setOrderBy('sequencial ASC'); - $registros = $obj->lista($this->ref_ano - 1, $this->ref_ref_cod_escola); - $cont = 0; - $modulosAnoAnterior = ""; - if ($registros) { + $this->ref_cod_modulo = $_GET['ref_cod_modulo']; + $this->ref_ref_cod_escola = $_GET['ref_cod_escola']; + $this->ref_ano = $_GET['ano']; - $tabela = ""; - $tabela .= "
Módulos do ano anterior (".($this->ref_ano - 1).")
"; - $tabela .= ""; - $tabela .= ""; + $obj_permissoes = new clsPermissoes(); - $existeBissexto = false; + $obj_permissoes->permissao_cadastra( + 561, + $this->pessoa_logada, + 7, + 'educar_escola_lst.php' + ); - foreach ($registros as $campo) { - $cor = "#f5f9fd"; - $cont++; - $tabela .= ""; + if (is_numeric($this->ref_ano) && is_numeric($this->ref_ref_cod_escola)) { + $obj = new clsPmieducarEscolaAnoLetivo($this->ref_ref_cod_escola, $this->ref_ano); + $registro = $obj->detalhe(); - $ano = date_parse_from_format("Y-m-d", $campo['data_inicio']); - $ano = $ano["year"]; + if ($registro) { + if ($obj_permissoes->permissao_excluir(561, $this->pessoa_logada, 7)) { + $this->fexcluir = true; + } - $novaDataInicio = str_replace($ano, $this->ref_ano, $campo['data_inicio']); - $novaDataFim = str_replace($ano, $this->ref_ano, $campo['data_fim']); + $retorno = 'Editar'; - if (Portabilis_Date_Utils::checkDateBissexto($novaDataInicio) - || Portabilis_Date_Utils::checkDateBissexto($novaDataFim)) { - $existeBissexto = true; + $etapasObj = new clsPmieducarAnoLetivoModulo(); + $etapasObj->setOrderBy('sequencial ASC'); + $this->etapas = $etapasObj->lista($this->ref_ano, $this->ref_ref_cod_escola); + $this->ref_cod_modulo = $this->etapas[0]['ref_cod_modulo']; + } } - } - - if ($existeBissexto) { - $tabela .= " - - - "; - } - - $tabela .="
EtapaPeríodo
{$cont}".dataFromPgToBr($campo['data_inicio'])." à ".dataFromPgToBr($campo['data_fim'])."
Observação:A data 29/02/$this->ref_ano não poderá ser migrada pois $this->ref_ano não é um ano bissexto, portanto será substituída por 28/02/$this->ref_ano.
"; - $tabela .= "
Adicione os módulos abaixo para {$this->ref_ano} semelhante ao exemplo do ano anterior:
"; - $tabela .= "
"; - } - + $this->url_cancelar = $_GET['referrer'] + ? $_GET['referrer'] . '?cod_escola=' . $this->ref_ref_cod_escola + : 'educar_escola_lst.php'; - $ref_ano_ = $this->ref_ano; - $this->campoTexto('ref_ano_', 'Ano', $ref_ano_, 4, 4, FALSE, FALSE, FALSE, - '', '', '', '', TRUE); + $localizacao = new LocalizacaoSistema(); + $localizacao->entradaCaminhos([ + $_SERVER['SERVER_NAME'].'/intranet' => 'Início', + 'educar_index.php' => 'Escola', + '' => 'Etapas do ano letivo' + ]); - $this->campoQuebra(); - if ($tabela) - $this->campoRotulo('modulosAnoAnterior', '-', $tabela); + $this->enviaLocalizacao($localizacao->montar()); + $this->nome_url_cancelar = 'Cancelar'; - $this->campoQuebra(); + return $retorno; + } - // Novo módulos do ano letivo + public function Gerar() + { + if ($_POST) { + foreach ($_POST as $campo => $val) { + $this->$campo = $this->$campo ? $this->$campo : $val; + } + } - $opcoesCampoModulo = array('' => 'Selecione'); - if (class_exists("clsPmieducarModulo")) { - $objTemp = new clsPmieducarModulo(); - $objTemp->setOrderby('nm_tipo ASC'); + // Primary keys + $this->campoOculto('ref_ano', $this->ref_ano); + $this->campoOculto('ref_ref_cod_escola', $this->ref_ref_cod_escola); + + $obj_escola = new clsPmieducarEscola($this->ref_ref_cod_escola); + $det_escola = $obj_escola->detalhe(); + $ref_cod_instituicao = $det_escola['ref_cod_instituicao']; + + $obj = new clsPmieducarAnoLetivoModulo(); + $obj->setOrderBy('sequencial ASC'); + $registros = $obj->lista($this->ref_ano - 1, $this->ref_ref_cod_escola); + $cont = 0; + + if ($registros) { + $tabela = ''; + $tabela .= "
Etapas do ano anterior (".($this->ref_ano - 1).')
'; + $tabela .= ''; + $tabela .= ''; + + $existeBissexto = false; + + foreach ($registros as $campo) { + $cor = '#f5f9fd'; + $cont++; + $tabela .= "'; + + $ano = date_parse_from_format('Y-m-d', $campo['data_inicio']); + $ano = $ano['year']; + + $novaDataInicio = str_replace($ano, $this->ref_ano, $campo['data_inicio']); + $novaDataFim = str_replace($ano, $this->ref_ano, $campo['data_fim']); + + if ( + Portabilis_Date_Utils::checkDateBissexto($novaDataInicio) + || Portabilis_Date_Utils::checkDateBissexto($novaDataFim) + ) { + $existeBissexto = true; + } + } + + if ($existeBissexto) { + $tabela .= " + + + "; + } - $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, 1, $ref_cod_instituicao); + $tabela .='
EtapaPeríodo
{$cont}".dataFromPgToBr($campo['data_inicio']).' à '.dataFromPgToBr($campo['data_fim']).'
Observação:A data 29/02/$this->ref_ano não poderá ser migrada pois $this->ref_ano não é um ano bissexto, portanto será substituída por 28/02/$this->ref_ano.
'; + $tabela .= "
Adicione as etapas abaixo para {$this->ref_ano} semelhante ao exemplo do ano anterior:
"; + $tabela .= '
'; + } - if (is_array($lista) && count($lista)) { - foreach ($lista as $registro) { - $opcoesCampoModulo[$registro['cod_modulo']] = $registro['nm_tipo']; + $ref_ano_ = $this->ref_ano; + + $this->campoTexto( + 'ref_ano_', + 'Ano', + $ref_ano_, + 4, + 4, + false, + false, + false, + '', + '', + '', + '', + true + ); + + $opcoesCampoModulo = []; + + if (class_exists('clsPmieducarModulo')) { + $objTemp = new clsPmieducarModulo(); + $objTemp->setOrderby('nm_tipo ASC'); + + $lista = $objTemp->lista( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + $ref_cod_instituicao + ); + + if (is_array($lista) && count($lista)) { + $this->modulos = $lista; + + foreach ($lista as $registro) { + $opcoesCampoModulo[$registro['cod_modulo']] = sprintf('%s - %d etapa(s)', $registro['nm_tipo'], $registro['num_etapas']); + } + } + } else { + $opcoesCampoModulo = ['' => 'Erro na geração']; } - } - } - else { - $opcoesCampoModulo = array('' => 'Erro na geração'); - } - if (is_numeric($this->ref_ano) && is_numeric($this->ref_ref_cod_escola) && !$_POST) { - - $obj = new clsPmieducarAnoLetivoModulo(); - $obj->setOrderBy('sequencial ASC'); - $registros = $obj->lista($this->ref_ano, $this->ref_ref_cod_escola); - - $qtd_registros = 0; - if( $registros ) - { - foreach ( $registros AS $campo ) - { - $this->ano_letivo_modulo[$qtd_registros][] = $campo["ref_cod_modulo"]; - $this->ano_letivo_modulo[$qtd_registros][] = dataFromPgToBr($campo['data_inicio']); - $this->ano_letivo_modulo[$qtd_registros][] = dataFromPgToBr($campo['data_fim']); - $this->ano_letivo_modulo[$qtd_registros][] = $campo["dias_letivos"]; - $qtd_registros++; + $this->campoLista( + 'ref_cod_modulo', + 'Etapa', + $opcoesCampoModulo, + $this->ref_cod_modulo, + null, + null, + null, + null, + null, + true + ); + + if ($tabela) { + $this->campoQuebra(); + $this->campoRotulo('modulosAnoAnterior', '-', $tabela); } - } - $this->campoTabelaInicio("modulos_ano_letivo","Módulos do ano letivo",array("Módulo","Data inicial","Data final", "Dias Letivos"),$this->ano_letivo_modulo); + $this->campoQuebra(); - $this->campoLista('ref_cod_modulo', 'Módulo', $opcoesCampoModulo, - $this->ref_cod_modulo, NULL, NULL, NULL, NULL, NULL, TRUE); + if (is_numeric($this->ref_ano) && is_numeric($this->ref_ref_cod_escola) && !$_POST) { + $qtd_registros = 0; - $this->campoData( "data_inicio", "Hora", $this->data_inicio,true); - $this->campoData( "data_fim", "Hora", $this->data_fim, true); - $this->campoNumero( "dias_letivos", "Dias Letivos", $this->dias_letivos, 6, 3, false); - $this->campoTabelaFim(); - } + foreach ($this->etapas as $campo) { + $this->ano_letivo_modulo[$qtd_registros][] = dataFromPgToBr($campo['data_inicio']); + $this->ano_letivo_modulo[$qtd_registros][] = dataFromPgToBr($campo['data_fim']); + $this->ano_letivo_modulo[$qtd_registros][] = $campo['dias_letivos']; + $qtd_registros++; + } - } + $this->campoTabelaInicio( + 'modulos_ano_letivo', + 'Etapas do ano letivo', + ['Data inicial', 'Data final', 'Dias Letivos'], + $this->ano_letivo_modulo + ); - function Novo() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); + $this->campoData('data_inicio', 'Hora', $this->data_inicio, true); + $this->campoData('data_fim', 'Hora', $this->data_fim, true); + $this->campoNumero('dias_letivos', 'Dias Letivos', $this->dias_letivos, 6, 3, false); - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra(561, $this->pessoa_logada, 7, - 'educar_escola_lst.php'); + $this->campoTabelaFim(); + } - if ($this->ref_cod_modulo && $this->data_inicio && $this->data_fim) { + Portabilis_View_Helper_Application::loadJavascript($this, [ + '/modules/Portabilis/Assets/Javascripts/Validator.js', + '/intranet/scripts/etapas.js' + ]); + } - $this->copiarTurmasUltimoAno($this->ref_ref_cod_escola, $this->ref_ano); - Portabilis_Utils_Database::selectField("SELECT pmieducar.copiaAnosLetivos({$this->ref_ano}::smallint, {$this->ref_ref_cod_escola});"); + public function Novo() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj_permissoes = new clsPermissoes(); + + $obj_permissoes->permissao_cadastra( + 561, + $this->pessoa_logada, + 7, + 'educar_escola_lst.php' + ); + + if ($this->ref_cod_modulo && $this->data_inicio && $this->data_fim) { + $this->copiarTurmasUltimoAno($this->ref_ref_cod_escola, $this->ref_ano); + Portabilis_Utils_Database::selectField("SELECT pmieducar.copiaAnosLetivos({$this->ref_ano}::smallint, {$this->ref_ref_cod_escola});"); + + $obj = new clsPmieducarEscolaAnoLetivo( + $this->ref_ref_cod_escola, + $this->ref_ano, + $this->pessoa_logada, + null, + 0, + null, + null, + 1, + 1 + ); + + $cadastrou = $obj->cadastra(); + + if ($cadastrou) { + foreach ($this->data_inicio as $key => $campo) { + $this->data_inicio[$key] = dataToBanco($this->data_inicio[$key]); + $this->data_fim[$key] = dataToBanco($this->data_fim[$key]); + + if ($this->dias_letivos[$key] == '') { + $this->dias_letivos[$key] = '0'; + } + + $obj = new clsPmieducarAnoLetivoModulo( + $this->ref_ano, + $this->ref_ref_cod_escola, + $key + 1, + $this->ref_cod_modulo, + $this->data_inicio[$key], + $this->data_fim[$key], + $this->dias_letivos[$key] + ); + + $cadastrou1 = $obj->cadastra(); + + if (!$cadastrou1) { + $this->mensagem = 'Cadastro não realizado.
'; + + return false; + } + } + + $this->mensagem .= 'Cadastro efetuado com sucesso.
'; + header('Location: educar_escola_det.php?cod_escola=' . $this->ref_ref_cod_escola . '#ano_letivo'); + + die(); + } + + $this->mensagem = 'Cadastro não realizado.
'; + + return false; + } - $obj = new clsPmieducarEscolaAnoLetivo($this->ref_ref_cod_escola, - $this->ref_ano, $this->pessoa_logada, NULL, 0, NULL, NULL, 1, 1 - ); + $this->mensagem = 'Cadastro não realizado.
'; - $cadastrou = $obj->cadastra(); + return false; + } - if ($cadastrou) { + public function Editar() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra( + 561, + $this->pessoa_logada, + 7, + 'educar_escola_lst.php' + ); + + if ($this->ref_cod_modulo && $this->data_inicio && $this->data_fim) { + $obj = new clsPmieducarAnoLetivoModulo($this->ref_ano, $this->ref_ref_cod_escola); + $excluiu = $obj->excluirTodos(); + + if ($excluiu) { + foreach ($this->data_inicio as $key => $campo) { + $this->data_inicio[$key] = dataToBanco($this->data_inicio[$key]); + $this->data_fim[$key] = dataToBanco($this->data_fim[$key]); + + if ($this->dias_letivos[$key] == '') { + $this->dias_letivos[$key] = '0'; + } + + $obj = new clsPmieducarAnoLetivoModulo( + $this->ref_ano, + $this->ref_ref_cod_escola, + $key + 1, + $this->ref_cod_modulo, + $this->data_inicio[$key], + $this->data_fim[$key], + $this->dias_letivos[$key] + ); + + $cadastrou1 = $obj->cadastra(); + + if (!$cadastrou1) { + $this->mensagem = 'Edição não realizada.
'; + + return false; + } + } + + $this->mensagem .= 'Edição efetuada com sucesso.
'; + header('Location: educar_escola_lst.php'); + die(); + } + } - foreach ($this->ref_cod_modulo as $key => $campo) { - $this->data_inicio[$key] = dataToBanco($this->data_inicio[$key]); - $this->data_fim[$key] = dataToBanco($this->data_fim[$key]); - if ($this->dias_letivos[$key] == '') - $this->dias_letivos[$key] = '0'; - $obj = new clsPmieducarAnoLetivoModulo($this->ref_ano, - $this->ref_ref_cod_escola, $key+1, - $this->ref_cod_modulo[$key], $this->data_inicio[$key], - $this->data_fim[$key], $this->dias_letivos[$key] - ); + echo ''; + $this->mensagem = 'Edição não realizada.
'; - $cadastrou1 = $obj->cadastra(); + return false; + } - if (! $cadastrou1) { - $this->mensagem = 'Cadastro não realizado.
'; - return FALSE; - } + public function Excluir() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj_permissoes = new clsPermissoes(); + + $obj_permissoes->permissao_excluir( + 561, + $this->pessoa_logada, + 7, + 'educar_escola_lst.php' + ); + + $obj = new clsPmieducarEscolaAnoLetivo( + $this->ref_ref_cod_escola, + $this->ref_ano, + null, + $this->pessoa_logada, + null, + null, + null, + 0 + ); + + $excluiu = $obj->excluir(); + + if ($excluiu) { + $obj = new clsPmieducarAnoLetivoModulo($this->ref_ano, $this->ref_ref_cod_escola); + $excluiu1 = $obj->excluirTodos(); + + if ($excluiu1) { + $this->mensagem .= 'Exclusão efetuada com sucesso.
'; + header('Location: educar_escola_lst.php'); + die(); + } + + $this->mensagem = 'Exclusão não realizada.
'; + + return false; } - $this->mensagem .= 'Cadastro efetuado com sucesso.
'; - header('Location: educar_escola_det.php?cod_escola='.$this->ref_ref_cod_escola.'#ano_letivo'); + $this->mensagem = 'Exclusão não realizada.
'; - die(); - } - - $this->mensagem = 'Cadastro não realizado.
'; - return FALSE; + return false; } - echo ''; - $this->mensagem = 'Cadastro não realizado.
'; - return FALSE; - } - - function Editar() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra(561, $this->pessoa_logada, 7, - 'educar_escola_lst.php'); - - if ($this->ref_cod_modulo && $this->data_inicio && $this->data_fim) { - $obj = new clsPmieducarAnoLetivoModulo($this->ref_ano, $this->ref_ref_cod_escola); - $excluiu = $obj->excluirTodos(); - - if ($excluiu) { - - foreach ($this->ref_cod_modulo as $key => $campo) { - $this->data_inicio[$key] = dataToBanco($this->data_inicio[$key]); - $this->data_fim[$key] = dataToBanco($this->data_fim[$key]); - if ($this->dias_letivos[$key] == '') - $this->dias_letivos[$key] = '0'; - $obj = new clsPmieducarAnoLetivoModulo($this->ref_ano, - $this->ref_ref_cod_escola, $key+1, - $this->ref_cod_modulo[$key], $this->data_inicio[$key], - $this->data_fim[$key], $this->dias_letivos[$key] - ); - - $cadastrou1 = $obj->cadastra(); - - if (! $cadastrou1) { - $this->mensagem = 'Edição não realizada.
'; - return FALSE; - } + public function copiarTurmasUltimoAno($escolaId, $anoDestino) + { + $sql = 'select ano, turmas_por_ano from pmieducar.escola_ano_letivo where ref_cod_escola = $1 ' . + 'and ativo = 1 and ano in (select max(ano) from pmieducar.escola_ano_letivo where ' . + 'ref_cod_escola = $1 and ativo = 1)'; + + $ultimoAnoLetivo = Portabilis_Utils_Database::selectRow($sql, $escolaId); + $anoTurmasPorAno = $ultimoAnoLetivo['turmas_por_ano'] == 1 ? $ultimoAnoLetivo['ano'] : null; + $turmasEscola = new clsPmieducarTurma(); + $turmasEscola = $turmasEscola->lista( + null, + null, + null, + null, + $escolaId, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + false, + null, + true, + null, + null, + $anoTurmasPorAno + ); + + foreach ($turmasEscola as $turma) { + $this->copiarTurma($turma, $ultimoAnoLetivo['ano'], $anoDestino); } - - $this->mensagem .= 'Edição efetuada com sucesso.
'; - header('Location: educar_escola_lst.php'); - die(); - } } - echo ""; - $this->mensagem = 'Edição não realizada.
'; - return FALSE; - } - - function Excluir() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_excluir(561, $this->pessoa_logada, 7, - 'educar_escola_lst.php'); - - $obj = new clsPmieducarEscolaAnoLetivo($this->ref_ref_cod_escola, - $this->ref_ano, NULL, $this->pessoa_logada, NULL, NULL, NULL, 0); - - $excluiu = $obj->excluir(); - - if ($excluiu) { - $obj = new clsPmieducarAnoLetivoModulo($this->ref_ano, $this->ref_ref_cod_escola); - $excluiu1 = $obj->excluirTodos(); - - if ($excluiu1) { - $this->mensagem .= 'Exclusão efetuada com sucesso.
'; - header('Location: educar_escola_lst.php'); - die(); - } - - $this->mensagem = 'Exclusão não realizada.
'; - return FALSE; + public function copiarTurma($turmaOrigem, $anoOrigem, $anoDestino) + { + $sql = 'select 1 from turma where ativo = 1 and visivel = true + and ref_ref_cod_escola = $1 and nm_turma = $2 and ref_ref_cod_serie = $3 and ano = $4 limit 1'; + + $params = [ + $turmaOrigem['ref_ref_cod_escola'], + $turmaOrigem['nm_turma'], + $turmaOrigem['ref_ref_cod_serie'], + $anoDestino + ]; + + $existe = Portabilis_Utils_Database::selectField($sql, $params); + + if ($existe != 1) { + $fields = [ + 'ref_usuario_exc', + 'ref_usuario_cad', + 'ref_ref_cod_serie', + 'ref_ref_cod_escola', + 'ref_cod_infra_predio_comodo', + 'nm_turma', + 'sgl_turma', + 'max_aluno', + 'multiseriada', + 'data_cadastro', + 'data_exclusao', + 'ativo', + 'ref_cod_turma_tipo', + 'hora_inicial', + 'hora_final', + 'hora_inicio_intervalo', + 'hora_fim_intervalo', + 'ref_cod_regente', + 'ref_cod_instituicao_regente', + 'ref_cod_instituicao', + 'ref_cod_curso', + 'ref_ref_cod_serie_mult', + 'ref_ref_cod_escola_mult', + 'visivel', + 'turma_turno_id', + 'tipo_boletim', + 'ano', + 'dias_semana', + 'atividades_complementares', + 'atividades_aee', + 'turma_unificada', + 'tipo_atendimento', + 'etapa_educacenso', + 'cod_curso_profissional', + 'tipo_mediacao_didatico_pedagogico', + 'nao_informar_educacenso', + 'turma_mais_educacao' + ]; + + $turmaDestino = new clsPmieducarTurma(); + + foreach ($fields as $fieldName) { + $turmaDestino->$fieldName = $turmaOrigem[$fieldName]; + } + + $turmaDestino->ano = $anoDestino; + $turmaDestinoId = $turmaDestino->cadastra(); + + $this->copiarComponenteCurricularTurma($turmaOrigem['cod_turma'], $turmaDestinoId); + $this->copiarModulosTurma($turmaOrigem['cod_turma'], $turmaDestinoId, $anoOrigem, $anoDestino); + } } - $this->mensagem = 'Exclusão não realizada.
'; - return FALSE; - } - - function copiarTurmasUltimoAno($escolaId, $anoDestino) { - $sql = 'select ano, turmas_por_ano from pmieducar.escola_ano_letivo where ref_cod_escola = $1 ' . - 'and ativo = 1 and ano in (select max(ano) from pmieducar.escola_ano_letivo where ' . - 'ref_cod_escola = $1 and ativo = 1)'; - - $ultimoAnoLetivo = Portabilis_Utils_Database::selectRow($sql, $escolaId); - - $anoTurmasPorAno = $ultimoAnoLetivo['turmas_por_ano'] == 1 ? $ultimoAnoLetivo['ano'] : null; - - $turmasEscola = new clsPmieducarTurma(); - $turmasEscola = $turmasEscola->lista(null, null, null, null, $escolaId, null, null, null, - null, null, null, null, null, null, 1, null, null, - null, null, null, null, null, null, null, null, null, - null, null, null, null, null, false, null, true, null, - null, $anoTurmasPorAno); - - foreach ($turmasEscola as $turma) - $this->copiarTurma($turma, $ultimoAnoLetivo['ano'], $anoDestino); - } + public function copiarComponenteCurricularTurma($turmaOrigemId, $turmaDestinoId) + { + $dataMapper = new ComponenteCurricular_Model_TurmaDataMapper(); + $componentesTurmaOrigem = $dataMapper->findAll([], ['turma' => $turmaOrigemId]); + + foreach ($componentesTurmaOrigem as $componenteTurmaOrigem) { + $data = [ + 'componenteCurricular' => $componenteTurmaOrigem->get('componenteCurricular'), + 'escola' => $componenteTurmaOrigem->get('escola'), + 'cargaHoraria' => $componenteTurmaOrigem->get('cargaHoraria'), + 'turma' => $turmaDestinoId, + // está sendo mantido o mesmo ano_escolar_id, uma vez que não foi + // foi encontrado de onde o valor deste campo é obtido. + 'anoEscolar' => $componenteTurmaOrigem->get('anoEscolar') + ]; + + $componenteTurmaDestino = $dataMapper->createNewEntityInstance($data); + $dataMapper->save($componenteTurmaDestino); + } + } - function copiarTurma($turmaOrigem, $anoOrigem, $anoDestino) { - $sql = "select 1 from turma where ativo = 1 and visivel = true - and ref_ref_cod_escola = $1 and nm_turma = $2 and ref_ref_cod_serie = $3 and ano = $4 limit 1"; + public function copiarModulosTurma($turmaOrigemId, $turmaDestinoId, $anoOrigem, $anoDestino) + { + $modulosTurmaOrigem = new clsPmieducarTurmaModulo(); + $modulosTurmaOrigem = $modulosTurmaOrigem->lista($turmaOrigemId); - $params = array( - $turmaOrigem['ref_ref_cod_escola'], - $turmaOrigem['nm_turma'], - $turmaOrigem['ref_ref_cod_serie'], - $anoDestino - ); + foreach ($modulosTurmaOrigem as $moduloOrigem) { + $moduloDestino = new clsPmieducarTurmaModulo(); - $existe = Portabilis_Utils_Database::selectField($sql, $params); + $moduloDestino->ref_cod_modulo = $moduloOrigem['ref_cod_modulo']; + $moduloDestino->sequencial = $moduloOrigem['sequencial']; + $moduloDestino->ref_cod_turma = $turmaDestinoId; - if ($existe != 1) { - $fields = array('ref_usuario_exc', 'ref_usuario_cad', 'ref_ref_cod_serie', 'ref_ref_cod_escola', - 'ref_cod_infra_predio_comodo', 'nm_turma', 'sgl_turma', 'max_aluno', 'multiseriada', - 'data_cadastro', 'data_exclusao', 'ativo', 'ref_cod_turma_tipo', 'hora_inicial', 'hora_final', - 'hora_inicio_intervalo', 'hora_fim_intervalo', 'ref_cod_regente', 'ref_cod_instituicao_regente', - 'ref_cod_instituicao', 'ref_cod_curso', 'ref_ref_cod_serie_mult', 'ref_ref_cod_escola_mult', - 'visivel', 'turma_turno_id', 'tipo_boletim', 'ano', 'dias_semana', 'atividades_complementares', - 'atividades_aee', 'turma_unificada', 'tipo_atendimento', 'etapa_educacenso', - 'cod_curso_profissional', 'tipo_mediacao_didatico_pedagogico', - 'nao_informar_educacenso', 'turma_mais_educacao'); + $moduloDestino->data_inicio = str_replace( + $anoOrigem, + $anoDestino, + $moduloOrigem['data_inicio'] + ); - $turmaDestino = new clsPmieducarTurma(); + $moduloDestino->data_fim = str_replace( + $anoOrigem, + $anoDestino, + $moduloOrigem['data_fim'] + ); - foreach ($fields as $fieldName) - $turmaDestino->$fieldName = $turmaOrigem[$fieldName]; + if (Portabilis_Date_Utils::checkDateBissexto($moduloDestino->data_inicio)) { + $moduloDestino->data_inicio = str_replace(29, 28, $moduloDestino->data_inicio); + } - $turmaDestino->ano = $anoDestino; - $turmaDestinoId = $turmaDestino->cadastra(); + if (Portabilis_Date_Utils::checkDateBissexto($moduloDestino->data_fim)) { + $moduloDestino->data_fim = str_replace(29, 28, $moduloDestino->data_fim); + } - $this->copiarComponenteCurricularTurma($turmaOrigem['cod_turma'], $turmaDestinoId); - $this->copiarModulosTurma($turmaOrigem['cod_turma'], $turmaDestinoId, $anoOrigem, $anoDestino); - } - } - - function copiarComponenteCurricularTurma($turmaOrigemId, $turmaDestinoId) { - $dataMapper = new ComponenteCurricular_Model_TurmaDataMapper(); - $componentesTurmaOrigem = $dataMapper->findAll(array(), array('turma' => $turmaOrigemId)); - - foreach ($componentesTurmaOrigem as $componenteTurmaOrigem) { - $data = array( - 'componenteCurricular' => $componenteTurmaOrigem->get('componenteCurricular'), - 'escola' => $componenteTurmaOrigem->get('escola'), - 'cargaHoraria' => $componenteTurmaOrigem->get('cargaHoraria'), - 'turma' => $turmaDestinoId, - - // está sendo mantido o mesmo ano_escolar_id, uma vez que não foi - // foi encontrado de onde o valor deste campo é obtido. - 'anoEscolar' => $componenteTurmaOrigem->get('anoEscolar') - ); - - $componenteTurmaDestino = $dataMapper->createNewEntityInstance($data); - $dataMapper->save($componenteTurmaDestino); + $moduloDestino->cadastra(); + } } - } - - function copiarModulosTurma($turmaOrigemId, $turmaDestinoId, $anoOrigem, $anoDestino) { - $modulosTurmaOrigem = new clsPmieducarTurmaModulo(); - $modulosTurmaOrigem = $modulosTurmaOrigem->lista($turmaOrigemId); - foreach ($modulosTurmaOrigem as $moduloOrigem) { - $moduloDestino = new clsPmieducarTurmaModulo(); + public function gerarJsonDosModulos() + { + $retorno = []; - $moduloDestino->ref_cod_modulo = $moduloOrigem['ref_cod_modulo']; - $moduloDestino->sequencial = $moduloOrigem['sequencial']; - $moduloDestino->ref_cod_turma = $turmaDestinoId; - - $moduloDestino->data_inicio = str_replace( - $anoOrigem, $anoDestino, $moduloOrigem['data_inicio'] - ); - - $moduloDestino->data_fim = str_replace( - $anoOrigem, $anoDestino, $moduloOrigem['data_fim'] - ); - - if (Portabilis_Date_Utils::checkDateBissexto($moduloDestino->data_inicio)) { - $moduloDestino->data_inicio = str_replace(29, 28, $moduloDestino->data_inicio); - } - - if (Portabilis_Date_Utils::checkDateBissexto($moduloDestino->data_fim)) { - $moduloDestino->data_fim = str_replace(29, 28, $moduloDestino->data_fim); - } + foreach ($this->modulos as $modulo) { + $retorno[$modulo['cod_modulo']] = [ + 'label' => $modulo['nm_tipo'], + 'etapas' => (int)$modulo['num_etapas'] + ]; + } - $moduloDestino->cadastra(); + return json_encode($retorno); } - } } // Instancia objeto de página @@ -502,12 +644,12 @@ function copiarModulosTurma($turmaOrigemId, $turmaDestinoId, $anoOrigem, $anoDes // Instancia objeto de conteúdo $miolo = new indice(); -// Atribui o conteúdo à página +// Atribui o conteúdo à página $pagina->addForm($miolo); // Gera o código HTML $pagina->MakeAll(); ?> diff --git a/ieducar/intranet/educar_consulta_movimento_geral.php b/ieducar/intranet/educar_consulta_movimento_geral.php new file mode 100644 index 0000000000..70cde977ac --- /dev/null +++ b/ieducar/intranet/educar_consulta_movimento_geral.php @@ -0,0 +1,88 @@ +SetTitulo($this->_instituicao . ' i-Educar - Consulta de movimento geral'); + $this->addEstilo("localizacaoSistema"); + $this->processoAp = 9998900; + } +} + +class indice extends clsCadastro +{ + const PROCESSO_AP = 9998900; + + public $ano; + + public $curso = []; + + public $data_inicial; + + public $data_final; + + public function Inicializar() + { + $this->ano = $this->getQueryString('ano'); + $this->curso = $this->getQueryString('curso'); + $this->data_inicial = $this->getQueryString('data_inicial'); + $this->data_final = $this->getQueryString('data_final'); + + $obj_permissoes = new clsPermissoes(); + + $obj_permissoes->permissao_cadastra( + self::PROCESSO_AP, + $this->pessoa_logada, + 7, + 'educar_index.php' + ); + + $this->nome_url_sucesso = 'Continuar'; + $this->url_cancelar = 'educar_index.php'; + $this->nome_url_cancelar = 'Cancelar'; + + $this->breadcrumb('Consulta de movimento geral', ['educar_index.php' => 'Escola']); + + return 'Novo'; + } + + public function Gerar() + { + $this->inputsHelper()->dynamic(['ano', 'instituicao']); + $this->inputsHelper()->multipleSearchCurso('', ['label' => 'Cursos','required' => false]); + $this->inputsHelper()->dynamic(['dataInicial', 'dataFinal']); + } + + public function Novo() + { + $obj_permissoes = new clsPermissoes(); + + $obj_permissoes->permissao_cadastra( + self::PROCESSO_AP, + $this->pessoa_logada, + 7, + 'index.php' + ); + + $queryString = http_build_query([ + 'ano' => $this->ano, + 'curso' => $this->curso, + 'data_inicial' => $this->data_inicial, + 'data_final' => $this->data_final, + ]); + + $url = '/intranet/educar_consulta_movimento_geral_lst.php?' . $queryString; + + $this->simpleRedirect($url); + } +} + +$pagina = new clsIndexBase(); +$miolo = new indice(); + +$pagina->addForm($miolo); +$pagina->MakeAll(); diff --git a/ieducar/intranet/educar_consulta_movimento_geral_lst.php b/ieducar/intranet/educar_consulta_movimento_geral_lst.php new file mode 100644 index 0000000000..69b4684794 --- /dev/null +++ b/ieducar/intranet/educar_consulta_movimento_geral_lst.php @@ -0,0 +1,199 @@ +SetTitulo($this->_instituicao . ' i-Educar - Consulta de movimento geral'); + $this->processoAp = 9998900; + } +} + +class indice extends clsListagem +{ + public function Gerar() + { + $params = []; + $params['ano'] = $this->getQueryString('ano'); + $params['curso'] = $this->getQueryString('curso'); + $params['data_inicial'] = $this->getQueryString('data_inicial'); + $params['data_final'] = $this->getQueryString('data_final'); + + $this->breadcrumb('Consulta de movimento geral', ['educar_index.php' => 'Escola']); + + $required = [ + 'ano', + 'data_inicial', + 'data_final' + ]; + + foreach ($required as $req) { + if (empty($params[$req])) { + $this->simpleRedirect('/intranet/educar_index.php'); + } + } + + $params['data_inicial'] = Portabilis_Date_Utils::brToPgSQL($params['data_inicial']); + $params['data_final'] = Portabilis_Date_Utils::brToPgSQL($params['data_final']); + $params['seleciona_curso'] = empty($params['curso']) ? 0 : 1; + + $base = new clsBanco(); + $base->FraseConexao(); + $connectionString = 'pgsql:' . $base->getFraseConexao(); + $data = (new MovimentoGeralQueryFactory(new \PDO($connectionString), $params)) + ->getData(); + + $this->titulo = 'Parâmetros'; + $this->acao = 'go("/intranet/educar_consulta_movimento_geral.php")'; + $this->nome_acao = "Nova consulta"; + $cursos = []; + + if (empty($params['curso'])) { + $cursos[] = 'Todos'; + } else { + $cursoIds = join(', ', $params['curso']); + + $dadosCursos = (array)Portabilis_Utils_Database::fetchPreparedQuery( + "select nm_curso from pmieducar.curso where cod_curso in ({$cursoIds});" + ); + + foreach ($dadosCursos as $curso) { + $cursos[] = $curso['nm_curso']; + } + } + + $this->addCabecalhos([ + 'Ano', + 'Cursos', + 'Data inicial', + 'Data final' + ]); + + $this->addLinhas([ + filter_var($params['ano'], FILTER_SANITIZE_STRING), + join('
', $cursos), + filter_var($this->getQueryString('data_inicial'), FILTER_SANITIZE_STRING), + filter_var($this->getQueryString('data_final'), FILTER_SANITIZE_STRING) + ]); + + $params['curso'] = empty($params['curso']) ? '' : join(',', $params['curso']); + $linkTemplate = '%d'; + + foreach ($data as $key => $value) { + foreach ($value as $k => $v) { + switch ($k) { + case 'cod_escola': + case 'escola': + case 'ciclo': + case 'aee': + case 'localizacao': + continue; + break; + default: + $paramsCopy = $params; + $paramsCopy['escola'] = $value['cod_escola']; + $paramsCopy = json_encode($paramsCopy); + $data[$key][$k] = sprintf($linkTemplate, $paramsCopy, $k, $v); + } + } + } + + $data = json_encode($data); + + $tableScript = <<'); + table.push(''); + table.push('Resultados'); + table.push(''); + + table.push(''); + table.push('Escola'); + table.push('Ed. Inf. Integ.'); + table.push('Ed. Inf. Parc..'); + table.push('1° Ano'); + table.push('2° Ano'); + table.push('3° Ano'); + table.push('4° Ano'); + table.push('5° Ano'); + table.push('6° Ano'); + table.push('7° Ano'); + table.push('8° Ano'); + table.push('9° Ano'); + table.push('Eliminados'); + table.push('Rem.'); + table.push('Recla.'); + table.push('Óbito'); + table.push('Localização'); + table.push(''); + + table.push(''); + table.push('AD'); + table.push('AB'); + table.push('TR'); + table.push(''); + + for (let i = 0; i < data.length; i++) { + let item = data[i]; + let cellClass = ((i % 2) === 0) ? 'formlttd' : 'formmdtd'; + + table.push(''); + table.push('' + item.escola + ' ' + item.ciclo + item.aee + ''); + table.push('' + item.ed_inf_int + ''); + table.push('' + item.ed_inf_parc + ''); + table.push('' + item.ano_1 + ''); + table.push('' + item.ano_2 + ''); + table.push('' + item.ano_3 + ''); + table.push('' + item.ano_4 + ''); + table.push('' + item.ano_5 + ''); + table.push('' + item.ano_6 + ''); + table.push('' + item.ano_7 + ''); + table.push('' + item.ano_8 + ''); + table.push('' + item.ano_9 + ''); + table.push('' + item.admitidos + ''); + table.push('' + item.aband + ''); + table.push('' + item.transf + ''); + table.push('' + item.rem + ''); + table.push('' + item.recla + ''); + table.push('' + item.obito + ''); + table.push('' + item.localizacao + ''); + table.push(''); + } + + table.push(''); + table.push('Legenda
* Escola possui AEE
** Escola possui regime por ciclo
*** Escola possui regime por ciclo e AEE'); + table.push(''); + table.push(''); + + let base = document.querySelectorAll('#corpo')[0]; + let wrapper= document.createElement('div'); + wrapper.innerHTML = table.join(''); + let tableObj = wrapper.firstChild; + + base.appendChild(tableObj); +})(); +JS; + + Portabilis_View_Helper_Application::embedJavascript($this, $tableScript, false); + Portabilis_View_Helper_Application::loadJavascript($this, ['/intranet/scripts/consulta_movimentos.js']); + } +} + +$pagina = new clsIndex(); +$miolo = new indice(); +$pagina->addForm($miolo); +$pagina->MakeAll(); diff --git a/ieducar/intranet/educar_consulta_movimento_mensal.php b/ieducar/intranet/educar_consulta_movimento_mensal.php new file mode 100644 index 0000000000..21027c89b5 --- /dev/null +++ b/ieducar/intranet/educar_consulta_movimento_mensal.php @@ -0,0 +1,111 @@ +SetTitulo($this->_instituicao . ' i-Educar - Consulta de movimento mensal'); + $this->addEstilo("localizacaoSistema"); + $this->processoAp = 9998910; + } +} + +class indice extends clsCadastro +{ + const PROCESSO_AP = 9998910; + + public $ano; + + public $ref_cod_instituicao; + + public $ref_cod_escola; + + public $ref_cod_curso; + + public $ref_cod_serie; + + public $ref_cod_turma; + + public $data_inicial; + + public $data_final; + + public function Inicializar() + { + $this->ano = $this->getQueryString('ano'); + $this->ref_cod_instituicao = $this->getQueryString('ref_cod_instituicao'); + $this->ref_cod_escola = $this->getQueryString('ref_cod_escola'); + $this->ref_cod_curso = $this->getQueryString('ref_cod_curso'); + $this->ref_cod_serie = $this->getQueryString('ref_cod_serie'); + $this->ref_cod_turma = $this->getQueryString('ref_cod_turma'); + $this->data_inicial = $this->getQueryString('data_inicial'); + $this->data_final = $this->getQueryString('data_final'); + + $obj_permissoes = new clsPermissoes(); + + $obj_permissoes->permissao_cadastra( + self::PROCESSO_AP, + $this->pessoa_logada, + 7, + 'educar_index.php' + ); + + $this->nome_url_sucesso = 'Continuar'; + $this->url_cancelar = 'educar_index.php'; + $this->nome_url_cancelar = 'Cancelar'; + + $this->breadcrumb('Consulta de movimento mensal', ['educar_index.php' => 'Escola']); + + return 'Novo'; + } + + public function Gerar() + { + $this->inputsHelper()->dynamic(array('ano', 'instituicao', 'escola')); + $this->inputsHelper()->dynamic(array('curso', 'serie', 'turma'), array('required' => false)); + $this->inputsHelper()->dynamic(array('dataInicial', 'dataFinal')); + } + + public function Novo() + { + $obj_permissoes = new clsPermissoes(); + + $obj_permissoes->permissao_cadastra( + self::PROCESSO_AP, + $this->pessoa_logada, + 7, + 'index.php' + ); + + $campos = [ + 'ano', + 'ref_cod_instituicao', + 'ref_cod_escola', + 'ref_cod_curso', + 'ref_cod_serie', + 'ref_cod_turma', + 'data_inicial', + 'data_final', + ]; + + $queryString = []; + + foreach ($campos as $campo) { + $queryString[$campo] = $this->{$campo}; + } + + $queryString = http_build_query($queryString); + $url = 'educar_consulta_movimento_mensal_lst.php?' . $queryString; + + $this->simpleRedirect($url); + } +} + +$pagina = new clsIndexBase(); +$miolo = new indice(); + +$pagina->addForm($miolo); +$pagina->MakeAll(); diff --git a/ieducar/intranet/educar_consulta_movimento_mensal_lst.php b/ieducar/intranet/educar_consulta_movimento_mensal_lst.php new file mode 100644 index 0000000000..df8df028cc --- /dev/null +++ b/ieducar/intranet/educar_consulta_movimento_mensal_lst.php @@ -0,0 +1,261 @@ +SetTitulo($this->_instituicao . ' i-Educar - Consulta de movimento mensal'); + $this->processoAp = 9998910; + } +} + +class indice extends clsListagem +{ + public function Gerar() + { + $params = []; + + $params['ano'] = $this->getQueryString('ano'); + $params['instituicao'] = $this->getQueryString('ref_cod_instituicao'); + $params['escola'] = $this->getQueryString('ref_cod_escola'); + $params['curso'] = $this->getQueryString('ref_cod_curso'); + $params['serie'] = $this->getQueryString('ref_cod_serie'); + $params['turma'] = $this->getQueryString('ref_cod_turma'); + $params['data_inicial'] = $this->getQueryString('data_inicial'); + $params['data_final'] = $this->getQueryString('data_final'); + + $this->breadcrumb('Consulta de movimento mensal', ['educar_index.php' => 'Escola']); + + $required = [ + 'ano', + 'instituicao', + 'escola', + 'data_inicial', + 'data_final' + ]; + + foreach ($required as $req) { + if (empty($params[$req])) { + $this->simpleRedirect('/intranet/educar_index.php'); + } + } + + $params['data_inicial'] = Portabilis_Date_Utils::brToPgSQL($params['data_inicial']); + $params['data_final'] = Portabilis_Date_Utils::brToPgSQL($params['data_final']); + + $base = new clsBanco(); + $base->FraseConexao(); + $connectionString = 'pgsql:' . $base->getFraseConexao(); + $data = (new MovimentoMensalQueryFactory(new \PDO($connectionString), $params)) + ->getData(); + + $this->titulo = 'Parâmetros'; + $this->acao = 'go("/intranet/educar_consulta_movimento_mensal.php")'; + $this->nome_acao = "Nova consulta"; + + $escola = 'Todas'; + $curso = 'Todos'; + $serie = 'Todas'; + $turma = 'Todas'; + + if (!empty($params['escola'])) { + $dados = (array)Portabilis_Utils_Database::fetchPreparedQuery(" + select + juridica.fantasia + from + pmieducar.escola + inner join + cadastro.juridica on juridica.idpes = escola.ref_idpes + where true + and escola.cod_escola = {$params['escola']} + limit 1; + "); + + $escola = $dados[0]['fantasia']; + } + + if (!empty($params['curso'])) { + $dados = (array)Portabilis_Utils_Database::fetchPreparedQuery( + "select nm_curso from pmieducar.curso where cod_curso = {$params['curso']};" + ); + + $curso = $dados[0]['nm_curso']; + } + + if (!empty($params['serie'])) { + $dados = (array)Portabilis_Utils_Database::fetchPreparedQuery( + "select nm_serie from pmieducar.serie where cod_serie = {$params['serie']};" + ); + + $serie = $dados[0]['nm_serie']; + } + + if (!empty($params['turma'])) { + $dados = (array)Portabilis_Utils_Database::fetchPreparedQuery( + "select nm_turma from pmieducar.turma where cod_turma = {$params['turma']};" + ); + + $turma = $dados[0]['nm_turma']; + } + + $this->addCabecalhos([ + 'Ano', + 'Escola', + 'Curso', + 'Série', + 'Turma', + 'Data inicial', + 'Data final' + ]); + + $this->addLinhas([ + filter_var($params['ano'], FILTER_SANITIZE_STRING), + $escola, + $curso, + $serie, + $turma, + filter_var($this->getQueryString('data_inicial'), FILTER_SANITIZE_STRING), + filter_var($this->getQueryString('data_final'), FILTER_SANITIZE_STRING) + ]); + + $linkTemplate = '%d'; + + foreach ($data as $key => $value) { + foreach ($value as $k => $v) { + switch ($k) { + case 'cod_serie': + case 'nm_serie': + case 'nm_turma': + case 'turno': + case 'mat_ini_t': + case 'mat_final_m': + case 'mat_final_f': + case 'mat_final_t': + continue; + break; + default: + $paramsCopy = $params; + $paramsCopy['serie'] = $value['cod_serie']; + $paramsCopy['turma'] = $value['cod_turma']; + $paramsCopy = json_encode($paramsCopy); + $data[$key][$k] = sprintf($linkTemplate, $paramsCopy, $k, $v); + } + } + } + + $data = json_encode($data); + + $tableScript = <<'); + table.push(''); + table.push('Resultados'); + table.push(''); + + table.push(''); + table.push('Série'); + table.push('Turma'); + table.push('Turno'); + table.push('Matrícula inicial'); + table.push('Alunos'); + table.push('Matrícula final'); + table.push(''); + + table.push(''); + table.push('M'); + table.push('F'); + table.push('T'); + table.push('Transf.'); + table.push('Aband.'); + table.push('Admitido'); + table.push('Óbito'); + table.push('Reclassif.'); + table.push('Troca (entrou)'); + table.push('Troca (saiu)'); + table.push('M'); + table.push('F'); + table.push('T'); + table.push(''); + + table.push(''); + table.push('M'); + table.push('F'); + table.push('M'); + table.push('F'); + table.push('M'); + table.push('F'); + table.push('M'); + table.push('F'); + table.push('M'); + table.push('F'); + table.push('M'); + table.push('F'); + table.push('M'); + table.push('F'); + table.push(''); + + for (let i = 0; i < data.length; i++) { + let item = data[i]; + let cellClass = ((i % 2) === 0) ? 'formlttd' : 'formmdtd'; + + table.push(''); + table.push('' + item.nm_serie + ''); + table.push('' + item.nm_turma + ''); + table.push('' + item.turno + ''); + table.push('' + item.mat_ini_m + ''); + table.push('' + item.mat_ini_f + ''); + table.push('' + item.mat_ini_t + ''); + table.push('' + item.mat_transf_m + ''); + table.push('' + item.mat_transf_f + ''); + table.push('' + item.mat_aband_m + ''); + table.push('' + item.mat_aband_f + ''); + table.push('' + item.mat_admit_m + ''); + table.push('' + item.mat_admit_f + ''); + table.push('' + item.mat_falecido_m + ''); + table.push('' + item.mat_falecido_f + ''); + table.push('' + item.mat_reclassificados_m + ''); + table.push('' + item.mat_reclassificados_f + ''); + table.push('' + item.mat_trocae_m + ''); + table.push('' + item.mat_trocae_f + ''); + table.push('' + item.mat_trocas_m + ''); + table.push('' + item.mat_trocas_f + ''); + table.push('' + item.mat_final_m + ''); + table.push('' + item.mat_final_f + ''); + table.push('' + item.mat_final_t + ''); + table.push(''); + } + + table.push(''); + + let base = document.querySelectorAll('#corpo')[0]; + let wrapper= document.createElement('div'); + wrapper.innerHTML = table.join(''); + let tableObj = wrapper.firstChild; + + base.appendChild(tableObj); +})(); +JS; + + Portabilis_View_Helper_Application::embedJavascript($this, $tableScript, false); + Portabilis_View_Helper_Application::loadJavascript($this, ['/intranet/scripts/consulta_movimentos.js']); + } +} + +$pagina = new clsIndex(); +$miolo = new indice(); +$pagina->addForm($miolo); +$pagina->MakeAll(); diff --git a/ieducar/intranet/educar_disciplina_dependencia_cad.php b/ieducar/intranet/educar_disciplina_dependencia_cad.php index e3e8f0d7df..17bec5df61 100644 --- a/ieducar/intranet/educar_disciplina_dependencia_cad.php +++ b/ieducar/intranet/educar_disciplina_dependencia_cad.php @@ -237,15 +237,16 @@ function validaQuantidadeDisciplinasDependencia() { $db = new clsBanco(); $db->consulta("SELECT (CASE - WHEN escola.utiliza_regra_diferenciada THEN regra_avaliacao_diferenciada.qtd_disciplinas_dependencia - ELSE regra_avaliacao.qtd_disciplinas_dependencia - END) AS qtd_disciplinas_dependencia - FROM pmieducar.escola, - pmieducar.serie - LEFT JOIN modules.regra_avaliacao ON (serie.regra_avaliacao_id = regra_avaliacao.id) - LEFT JOIN modules.regra_avaliacao AS regra_avaliacao_diferenciada ON (serie.regra_avaliacao_diferenciada_id = regra_avaliacao_diferenciada.id) - WHERE serie.cod_serie = {$this->ref_cod_serie} - AND escola.cod_escola = {$this->ref_cod_escola}"); + WHEN escola.utiliza_regra_diferenciada AND serie.regra_avaliacao_diferenciada_id IS NOT NULL + THEN regra_avaliacao_diferenciada.qtd_disciplinas_dependencia + ELSE regra_avaliacao.qtd_disciplinas_dependencia + END) AS qtd_disciplinas_dependencia + FROM pmieducar.escola, + pmieducar.serie + LEFT JOIN modules.regra_avaliacao ON (serie.regra_avaliacao_id = regra_avaliacao.id) + LEFT JOIN modules.regra_avaliacao AS regra_avaliacao_diferenciada ON (serie.regra_avaliacao_diferenciada_id = regra_avaliacao_diferenciada.id) + WHERE serie.cod_serie = {$this->ref_cod_serie} + AND escola.cod_escola = {$this->ref_cod_escola}"); $db->ProximoRegistro(); $m = $db->Tupla(); @@ -386,4 +387,4 @@ function Excluir() $pagina->addForm($miolo); // Gera o código HTML -$pagina->MakeAll(); \ No newline at end of file +$pagina->MakeAll(); diff --git a/ieducar/intranet/educar_dispensa_disciplina_cad.php b/ieducar/intranet/educar_dispensa_disciplina_cad.php index 9dcac396e1..e34ce1b420 100644 --- a/ieducar/intranet/educar_dispensa_disciplina_cad.php +++ b/ieducar/intranet/educar_dispensa_disciplina_cad.php @@ -1,522 +1,489 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Prefeitura Municipal de Itajaí - * @category i-Educar - * @license @@license@@ - * @package iEd_Pmieducar - * @since Arquivo disponível desde a versão 1.0.0 - * @version $Id$ - */ - require_once 'include/clsBase.inc.php'; require_once 'include/clsCadastro.inc.php'; -require_once 'include/clsBanco.inc.php'; require_once 'include/pmieducar/geral.inc.php'; require_once 'App/Model/IedFinder.php'; -require_once 'include/modules/clsModulesAuditoriaGeral.inc.php'; - -/** - * clsIndexBase class. - * - * @author Prefeitura Municipal de Itajaí - * @category i-Educar - * @license @@license@@ - * @package iEd_Pmieducar - * @since Classe disponível desde a versão 1.0.0 - * @version @@package_version@@ - */ +require_once 'Avaliacao/Model/NotaAlunoDataMapper.php'; +require_once 'Avaliacao/Model/NotaComponenteDataMapper.php'; +require_once 'Avaliacao/Model/FaltaAlunoDataMapper.php'; +require_once 'Avaliacao/Model/FaltaComponenteDataMapper.php'; +require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php'; + class clsIndexBase extends clsBase { - function Formular() - { - $this->SetTitulo($this->_instituicao . ' i-Educar - Dispensa Componente Curricular'); - $this->processoAp = 578; - $this->addEstilo("localizacaoSistema"); - } + public function Formular() + { + $this->SetTitulo($this->_instituicao . ' i-Educar - Dispensa Componente Curricular'); + $this->processoAp = 578; + $this->addEstilo('localizacaoSistema'); + } } -/** - * indice class. - * - * @author Prefeitura Municipal de Itajaí - * @category i-Educar - * @license @@license@@ - * @package iEd_Pmieducar - * @since Classe disponível desde a versão 1.0.0 - * @version @@package_version@@ - */ class indice extends clsCadastro { - var $pessoa_logada; - - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_cod_tipo_dispensa; - var $data_cadastro; - var $data_exclusao; - var $ativo; - var $observacao; - var $cod_dispensa; - var $ref_cod_matricula; - var $ref_cod_turma; - var $ref_cod_serie; - var $ref_cod_disciplina; - var $ref_sequencial; - var $ref_cod_instituicao; - var $ref_cod_escola; - - function Inicializar() - { - $retorno = 'Novo'; - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $this->ref_cod_disciplina = $_GET['ref_cod_disciplina']; - $this->ref_cod_matricula = $_GET['ref_cod_matricula']; - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, - 'educar_dispensa_disciplina_lst.php?ref_ref_cod_matricula=' . $this->ref_cod_matricula); - - if (is_numeric($this->ref_cod_matricula)) { - $obj_matricula = new clsPmieducarMatricula($this->ref_cod_matricula, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); - - $det_matricula = $obj_matricula->detalhe(); - - if (!$det_matricula) { - header('Location: educar_matricula_lst.php'); - die(); - } + public $ref_usuario_exc; + public $ref_usuario_cad; + public $ref_cod_tipo_dispensa; + public $data_cadastro; + public $data_exclusao; + public $ativo; + public $observacao; + public $cod_dispensa; + public $ref_cod_matricula; + public $ref_cod_turma; + public $ref_cod_serie; + public $ref_cod_disciplina; + public $ref_sequencial; + public $ref_cod_instituicao; + public $ref_cod_escola; + public $modoEdicao; + + public function Inicializar() + { + $retorno = 'Novo'; + + $this->ref_cod_disciplina = $this->getQueryString('ref_cod_disciplina'); + $this->ref_cod_matricula = $this->getQueryString('ref_cod_matricula'); - $this->ref_cod_escola = $det_matricula['ref_ref_cod_escola']; - $this->ref_cod_serie = $det_matricula['ref_ref_cod_serie']; - } - else { - header('Location: educar_matricula_lst.php'); - die(); + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, 'educar_dispensa_disciplina_lst.php?ref_ref_cod_matricula=' . $this->ref_cod_matricula); + + if (is_numeric($this->ref_cod_matricula)) { + $obj_matricula = new clsPmieducarMatricula($this->ref_cod_matricula, null, null, null, null, null, null, null, null, null, 1); + $det_matricula = $obj_matricula->detalhe(); + $this->redirectIf(!$det_matricula, 'educar_matricula_lst.php'); + $this->ref_cod_escola = $det_matricula['ref_ref_cod_escola']; + $this->ref_cod_serie = $det_matricula['ref_ref_cod_serie']; + } else { + header('Location: educar_matricula_lst.php'); + die(); + } + + if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && + is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina)) { + $obj = new clsPmieducarDispensaDisciplina( + $this->ref_cod_matricula, + $this->ref_cod_serie, + $this->ref_cod_escola, + $this->ref_cod_disciplina + ); + + $registro = $obj->detalhe(); + + if ($registro) { + // passa todos os valores obtidos no registro para atributos do objeto + foreach ($registro as $campo => $val) { + $this->$campo = $val; + } + + $this->cod_dispensa = $registro['cod_dispensa']; + + $obj_permissoes = new clsPermissoes(); + + if ($obj_permissoes->permissao_excluir(578, $this->pessoa_logada, 7)) { + $this->fexcluir = true; + } + + $retorno = 'Editar'; + } + } + + $this->url_cancelar = $retorno == 'Editar' ? + sprintf( + 'educar_dispensa_disciplina_det.php?ref_cod_matricula=%d&ref_cod_serie=%d&ref_cod_escola=%d&ref_cod_disciplina=%d', + $registro['ref_cod_matricula'], + $registro['ref_cod_serie'], + $registro['ref_cod_escola'], + $registro['ref_cod_disciplina'] + ) : + 'educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula; + + $this->nome_url_cancelar = 'Cancelar'; + + $this->breadcrumb('Dispensa de componentes curriculares',['educar_index.php' => 'Escola']); + $this->modoEdicao = $retorno == 'Editar'; + return $retorno; } - if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && - is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) - ) { - $obj = new clsPmieducarDispensaDisciplina($this->ref_cod_matricula, - $this->ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_disciplina); + public function Gerar() + { + /** + * Busca dados da matricula + */ + $obj_ref_cod_matricula = new clsPmieducarMatricula(); + $detalhe_aluno = array_shift($obj_ref_cod_matricula->lista($this->ref_cod_matricula)); + $this->ano = $detalhe_aluno['ano']; + + $obj_aluno = new clsPmieducarAluno(); + $det_aluno = array_shift($det_aluno = $obj_aluno->lista($detalhe_aluno['ref_cod_aluno'], null, null, null, null, null, null, null, null, null, 1)); + + $obj_escola = new clsPmieducarEscola($this->ref_cod_escola, null, null, null, null, null, null, null, null, null, 1); - $registro = $obj->detalhe(); + $det_escola = $obj_escola->detalhe(); + $this->ref_cod_instituicao = $det_escola['ref_cod_instituicao']; - if ($registro) { - // passa todos os valores obtidos no registro para atributos do objeto - foreach ($registro as $campo => $val) { - $this->$campo = $val; + $obj_matricula_turma = new clsPmieducarMatriculaTurma(); + $lst_matricula_turma = $obj_matricula_turma->lista($this->ref_cod_matricula, null, null, null, null, null, null, null, 1, $this->ref_cod_serie, null, $this->ref_cod_escola ); + + if (is_array($lst_matricula_turma)) { + $det = array_shift($lst_matricula_turma); + $this->ref_cod_turma = $det['ref_cod_turma']; + $this->ref_sequencial = $det['sequencial']; } - $this->cod_dispensa = $registro['cod_dispensa']; + $this->campoRotulo('nm_aluno', 'Nome do Aluno', $det_aluno['nome_aluno']); - $obj_permissoes = new clsPermissoes(); + if (!isset($this->ref_cod_turma)) { + $this->mensagem = 'Para dispensar um aluno de um componente curricular, é necessário que este esteja enturmado.'; - if ($obj_permissoes->permissao_excluir(578, $this->pessoa_logada, 7)) { - $this->fexcluir = TRUE; + return; } - $retorno = 'Editar'; - } - } + // primary keys + $this->campoOculto('ref_cod_matricula', $this->ref_cod_matricula); + $this->campoOculto('ref_cod_serie', $this->ref_cod_serie); + $this->campoOculto('ref_cod_escola', $this->ref_cod_escola); + $this->campoOculto('cod_dispensa', $this->cod_dispensa); + + $this->campoOculto('ano', $this->ano); + $this->campoOculto('ref_cod_instituicao', $this->ref_cod_instituicao); + $this->campoOculto('ref_cod_turma', $this->ref_cod_turma); + + $opcoes = ['' => 'Selecione']; + + // Seleciona os componentes curriculares da turma + try { + $componentes = App_Model_IedFinder::getComponentesTurma( + $this->ref_cod_serie, + $this->ref_cod_escola, + $this->ref_cod_turma + ); + } catch (App_Model_Exception $e) { + $this->mensagem = $e->getMessage(); + + return; + } - $this->url_cancelar = $retorno == 'Editar' ? - sprintf('educar_dispensa_disciplina_det.php?ref_cod_matricula=%d&ref_cod_serie=%d&ref_cod_escola=%d&ref_cod_disciplina=%d', - $registro['ref_cod_matricula'], $registro['ref_cod_serie'], - $registro['ref_cod_escola'], $registro['ref_cod_disciplina']) : - 'educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula; - - $this->nome_url_cancelar = 'Cancelar'; - - $localizacao = new LocalizacaoSistema(); - $localizacao->entradaCaminhos( array( - $_SERVER['SERVER_NAME']."/intranet" => "Início", - "educar_index.php" => "Escola", - "" => "Dispensa de componentes curriculares" - )); - $this->enviaLocalizacao($localizacao->montar()); - - return $retorno; - } - - function Gerar() - { - /** - * Busca dados da matricula - */ - $obj_ref_cod_matricula = new clsPmieducarMatricula(); - $detalhe_aluno = array_shift($obj_ref_cod_matricula->lista($this->ref_cod_matricula)); - - $obj_aluno = new clsPmieducarAluno(); - $det_aluno = array_shift($det_aluno = $obj_aluno->lista($detalhe_aluno['ref_cod_aluno'], - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1)); - - $obj_escola = new clsPmieducarEscola($this->ref_cod_escola, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, 1); - - $det_escola = $obj_escola->detalhe(); - $this->ref_cod_instituicao = $det_escola['ref_cod_instituicao']; - - $obj_matricula_turma = new clsPmieducarMatriculaTurma(); - $lst_matricula_turma = $obj_matricula_turma->lista($this->ref_cod_matricula, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie, NULL, - $this->ref_cod_escola); - - if (is_array($lst_matricula_turma)) { - $det = array_shift($lst_matricula_turma); - $this->ref_cod_turma = $det['ref_cod_turma']; - $this->ref_sequencial = $det['sequencial']; - } + foreach ($componentes as $componente) { + $opcoes[$componente->id] = $componente->nome; + } - $this->campoRotulo('nm_aluno', 'Nome do Aluno', $det_aluno['nome_aluno']); + if ($this->modoEdicao) { + $this->campoRotulo('nm_disciplina', 'Disciplina', $opcoes[$this->ref_cod_disciplina]); + $this->campoOculto('ref_cod_disciplina', $this->ref_cod_disciplina); + } else { + $this->inputsHelper()->multipleSearchComponenteCurricular(null, ['label' => 'Componentes lecionados', 'required' => true], ['searchForArea' => true]); + } - if (!isset($this->ref_cod_turma)) { - $this->mensagem = 'Para dispensar um aluno de um componente curricular, é necessário que este esteja enturmado.'; - return; - } + $opcoes = ['' => 'Selecione']; - // primary keys - $this->campoOculto('ref_cod_matricula', $this->ref_cod_matricula); - $this->campoOculto('ref_cod_serie', $this->ref_cod_serie); - $this->campoOculto('ref_cod_escola', $this->ref_cod_escola); - $this->campoOculto('cod_dispensa', $this->cod_dispensa); + $objTemp = new clsPmieducarTipoDispensa(); - $opcoes = array('' => 'Selecione'); + if ($this->ref_cod_instituicao) { + $lista = $objTemp->lista(null, null, null, null, null, null, null, null, null, 1, $this->ref_cod_instituicao); + } else { + $lista = $objTemp->lista(null, null, null, null, null, null, null, null, null, 1); + } - // Seleciona os componentes curriculares da turma - try { - $componentes = App_Model_IedFinder::getComponentesTurma($this->ref_cod_serie, - $this->ref_cod_escola, $this->ref_cod_turma); - } - catch (App_Model_Exception $e) { - $this->mensagem = $e->getMessage(); - return; - } + if (is_array($lista) && count($lista)) { + foreach ($lista as $registro) { + $opcoes[$registro['cod_tipo_dispensa']] = $registro['nm_tipo']; + } + } - foreach ($componentes as $componente) { - $opcoes[$componente->id] = $componente->nome; + $this->campoLista( + 'ref_cod_tipo_dispensa', + 'Tipo Dispensa', + $opcoes, + $this->ref_cod_tipo_dispensa + ); + $this->montaEtapas(); + $this->campoMemo('observacao', 'Observação', $this->observacao, 60, 10, false); } - if ($this->ref_cod_disciplina) { - $this->campoRotulo('nm_disciplina', 'Disciplina', $opcoes[$this->ref_cod_disciplina]); - $this->campoOculto('ref_cod_disciplina', $this->ref_cod_disciplina); - } - else { - $this->campoLista('ref_cod_disciplina', 'Disciplina', $opcoes, - $this->ref_cod_disciplina); + public function existeComponenteSerie($serieId, $escolaId, $disciplinaId) + { + try { + App_Model_IedFinder::getEscolaSerieDisciplina( + $serieId, + $escolaId, + null, + $disciplinaId + ); + } catch (Exception $e) { + return false; + } + + return true; } - $opcoes = array('' => 'Selecione'); + public function Novo() + { + if (empty($this->etapa)) { + $this->mensagem = 'É necessário informar pelo menos uma etapa.'; - $objTemp = new clsPmieducarTipoDispensa(); + return false; + } - if ($this->ref_cod_instituicao) { - $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, 1, $this->ref_cod_instituicao); - } - else { - $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); - } + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, 'educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); + $disciplinasNaoExistentesNaSerieDaEscola = []; + + foreach ($this->componentecurricular as $disciplinaId) { + $this->ref_cod_disciplina = $disciplinaId; + $dadosDaDispensa = $this->obtemDadosDaDispensa(); + $objetoDispensa = $this->montaObjetoDispensa($dadosDaDispensa); + + if (!$this->existeComponenteSerie($dadosDaDispensa['ref_cod_serie'], $dadosDaDispensa['ref_cod_escola'], $disciplinaId)) { + $disciplinasNaoExistentesNaSerieDaEscola[] = $this->nomeDisciplina($disciplinaId); + continue; + } + + if ($objetoDispensa->existe()) { + $dadosDaDispensa['cod_dispensa'] = $objetoDispensa->detalhe()['cod_dispensa']; + $objDispensaEtapa = new clsPmieducarDispensaDisciplinaEtapa(); + $excluiDispensaEtapa = $objDispensaEtapa->excluirTodos($dadosDaDispensa['cod_dispensa']); + $objetoDispensa->edita(); + $this->cadastraEtapasDaDispensa($dadosDaDispensa); + continue; + } + + $codigoDispensa = $objetoDispensa->cadastra(); + if (!$codigoDispensa) { + $this->mensagem = 'Cadastro não realizado.
'; + + return false; + } + $dadosDaDispensa['cod_dispensa'] = $codigoDispensa; + $this->cadastraEtapasDaDispensa($dadosDaDispensa); + } - if (is_array($lista) && count($lista)) { - foreach ($lista as $registro) { - $opcoes[$registro['cod_tipo_dispensa']] = $registro['nm_tipo']; - } - } + if (count($disciplinasNaoExistentesNaSerieDaEscola) > 0) { + $disciplinas = implode(", ", $disciplinasNaoExistentesNaSerieDaEscola); + $this->mensagem = "O(s) componente(s):{$disciplinas}. não está(ão) habilitado(s) na série da escola."; + return false; + } - $this->campoLista('ref_cod_tipo_dispensa', 'Tipo Dispensa', $opcoes, - $this->ref_cod_tipo_dispensa); - - $this->montaEtapas(); - - $this->campoMemo('observacao', 'Observação', $this->observacao, 60, 10, FALSE); - } - - function existeComponenteSerie() - { - $db = new clsBanco(); - $sql = "SELECT EXISTS (SELECT 1 - FROM pmieducar.escola_serie_disciplina - WHERE ref_ref_cod_serie = {$this->ref_cod_serie} - AND ref_ref_cod_escola = {$this->ref_cod_escola} - AND ref_cod_disciplina = {$this->ref_cod_disciplina} - AND escola_serie_disciplina.ativo = 1)"; - return dbBool($db->campoUnico($sql)); - } - - function Novo() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - if(empty($this->etapa)){ - $this->mensagem = 'É necessário informar pelo menos uma etapa.'; - return false; + $this->mensagem .= 'Cadastro efetuado com sucesso.
'; + header('Location: educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); + die(); } - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, - 'educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); + public function Editar() + { + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, 'educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); + + $dadosDaDispensa = $this->obtemDadosDaDispensa(); + $objetoDispensa = $this->montaObjetoDispensa($dadosDaDispensa); - $sql = 'SELECT MAX(cod_dispensa) + 1 FROM pmieducar.dispensa_disciplina'; - $db = new clsBanco(); - $max_cod_dispensa = $db->CampoUnico($sql); + $objDispensaEtapa = new clsPmieducarDispensaDisciplinaEtapa(); + $excluiDispensaEtapa = $objDispensaEtapa->excluirTodos($dadosDaDispensa['cod_dispensa']); - // Caso não exista nenhuma dispensa, atribui o código 1, tabela não utiliza sequences - $max_cod_dispensa = $max_cod_dispensa > 0 ? $max_cod_dispensa : 1; + $this->cadastraEtapasDaDispensa($dadosDaDispensa); - $obj = new clsPmieducarDispensaDisciplina($this->ref_cod_matricula, - $this->ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_disciplina, NULL, - $this->pessoa_logada, $this->ref_cod_tipo_dispensa, NULL, NULL, 1, - $this->observacao, $max_cod_dispensa); + $editou = $objetoDispensa->edita(); + if ($editou) { + $this->mensagem .= 'Edição efetuada com sucesso.
'; + header('Location: educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); + die(); + } - if ($obj->existe()) { - $obj = new clsPmieducarDispensaDisciplina($this->ref_cod_matricula, - $this->ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_disciplina, - $this->pessoa_logada, NULL, $this->ref_cod_tipo_dispensa, NULL, NULL, 1, - $this->observacao); + $this->mensagem = 'Edição não realizada.
'; - $obj->edita(); - header('Location: educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); - die(); - } - - if(!$this->existeComponenteSerie()) { - $this->mensagem = 'O componente não está habilitado na série da escola.'; - $this->url_cancelar = 'educar_disciplina_dependencia_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula; - $this->nome_url_cancelar = 'Cancelar'; return false; } - $cadastrou = $obj->cadastra(); - if ($cadastrou) { + public function Excluir() + { + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_excluir(578, $this->pessoa_logada, 7, 'educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); - $detalhe = $obj->detalhe(); - $auditoria = new clsModulesAuditoriaGeral("dispensa_disciplina", $this->pessoa_logada, $max_cod_dispensa); - $auditoria->inclusao($detalhe); + $dadosDaDispensa = $this->obtemDadosDaDispensa(); + $objetoDispensa = $this->montaObjetoDispensa($dadosDaDispensa); - foreach ($this->etapa as $etapa) { - $get_notas_lancadas = App_Model_IedFinder::getNotasLancadasAluno($this->ref_cod_matricula, $this->ref_cod_disciplina, $etapa); + $objDispensaEtapa = new clsPmieducarDispensaDisciplinaEtapa(); + $excluiDispensaEtapa = $objDispensaEtapa->excluirTodos($this->cod_dispensa); + $excluiu = $objetoDispensa->excluir(); - if($get_notas_lancadas[0]['matricula_id'] == ''){ - break; - } - else{ - $cod_matricula = $get_notas_lancadas[0]['matricula_id']; - $disciplina = $get_notas_lancadas[0]['componente_curricular_id']; - $nota = $get_notas_lancadas[0]['nota']; - $etapa_nota = $get_notas_lancadas[0]['etapa']; - if($get_notas_lancadas[0]['nota_recuperacao'] == '') $nota_recuperacao = 'NULL'; - if($get_notas_lancadas[0]['nota_recuperacao_especifica'] == '') $nota_recuperacao_especifica = 'NULL'; - - $db->Consulta("INSERT INTO pmieducar.auditoria_nota_dispensa (ref_cod_matricula, ref_cod_componente_curricular, nota, etapa, nota_recuperacao, nota_recuperacao_especifica, data_cadastro) - VALUES($cod_matricula, $disciplina, $nota, $etapa_nota, $nota_recuperacao, $nota_recuperacao_especifica, NOW())"); - - $db->Consulta("DELETE - FROM modules.nota_componente_curricular AS ncc USING modules.nota_aluno AS na - WHERE na.id = ncc.nota_aluno_id - AND na.matricula_id = $this->ref_cod_matricula - AND ncc.componente_curricular_id = $this->ref_cod_disciplina - AND ncc.etapa = $etapa::CHARACTER VARYING "); + if ($excluiu) { + $this->mensagem .= 'Exclusão efetuada com sucesso.
'; + header('Location: educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); + die(); } - } - - $tipo_falta = $db->CampoUnico("SELECT tipo_falta FROM modules.falta_aluno WHERE matricula_id = $this->ref_cod_matricula"); - if($tipo_falta == 2){ - foreach ($this->etapa as $etapa) { - $get_faltas_lancadas = App_Model_IedFinder::getFaltasLancadasAluno($this->ref_cod_matricula, $this->ref_cod_disciplina, $etapa); - - if($get_faltas_lancadas[0]['matricula_id'] == ''){ - break; - } - else{ - $cod_matricula = $get_faltas_lancadas[0]['matricula_id']; - $disciplina = $get_faltas_lancadas[0]['componente_curricular_id']; - $quantidade = $get_faltas_lancadas[0]['quantidade']; - $etapa_falta = $get_faltas_lancadas[0]['etapa']; - - $db->Consulta("INSERT INTO pmieducar.auditoria_falta_componente_dispensa (ref_cod_matricula, ref_cod_componente_curricular, quantidade, etapa, data_cadastro) - VALUES ($cod_matricula, $disciplina, $quantidade, $etapa_falta, NOW())"); - - $db->Consulta("DELETE - FROM modules.falta_componente_curricular AS fcc USING modules.falta_aluno AS fa - WHERE fa.id = fcc.falta_aluno_id - AND fa.matricula_id = $this->ref_cod_matricula - AND fcc.componente_curricular_id = $this->ref_cod_disciplina - AND fcc.etapa = $etapa::CHARACTER VARYING "); - } - } - } - - foreach ($this->etapa as $e) { - $objDispensaEtapa = new clsPmieducarDispensaDisciplinaEtapa($max_cod_dispensa, $e); - $cadastra = $objDispensaEtapa->cadastra(); - } - $this->mensagem .= 'Cadastro efetuado com sucesso.
'; - header('Location: educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); - die(); - } - $this->mensagem = 'Cadastro não realizado.
'; - echo ""; - return FALSE; - } + $this->mensagem = 'Exclusão não realizada.
'; - function Editar() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, - 'educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); + return false; + } - $obj = new clsPmieducarDispensaDisciplina($this->ref_cod_matricula, - $this->ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_disciplina, - $this->pessoa_logada, NULL, $this->ref_cod_tipo_dispensa, NULL, NULL, 1, - $this->observacao); + public function montaEtapas() + { + //Pega matricula para pegar curso, escola e ano + $objMatricula = new clsPmieducarMatricula(); + $dadosMatricula = $objMatricula->lista($this->ref_cod_matricula); + //Pega curso para pegar padrao ano escolar + $objCurso = new clsPmieducarCurso(); + $dadosCurso = $objCurso->lista($dadosMatricula[0]['ref_cod_curso']); + $padraoAnoEscolar = $dadosCurso[0]['padrao_ano_escolar']; + //Pega escola e ano para pegar as etapas em ano letivo modulo + $escolaId = $dadosMatricula[0]['ref_ref_cod_escola']; + $ano = $dadosMatricula[0]['ano']; + //Pega dados da enturmação atual + $objMatriculaTurma = new clsPmieducarMatriculaTurma(); + $seqMatriculaTurma = $objMatriculaTurma->getUltimaEnturmacao($this->ref_cod_matricula); + $dadosMatriculaTurma = $objMatriculaTurma->lista($this->ref_cod_matricula, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, $seqMatriculaTurma); + //Pega etapas definidas na escola + $objAnoLetivoMod = new clsPmieducarAnoLetivoModulo(); + $dadosAnoLetivoMod = $objAnoLetivoMod->lista($ano, $escolaId); + //Pega etapas definida na turma + $objTurmaModulo = new clsPmieducarTurmaModulo(); + $dadosTurmaModulo = $objTurmaModulo->lista($dadosMatriculaTurma[0]['ref_cod_turma']); + //Define de onde as etapas serão pegas + if ($padraoAnoEscolar == 1) { + $dadosEtapa = $dadosAnoLetivoMod; + } else { + $dadosEtapa = $dadosTurmaModulo; + } + //Pega nome do modulo + $objModulo = new clsPmieducarModulo(); + $dadosModulo = $objModulo->lista($dadosEtapa[0]['ref_cod_modulo']); + $nomeModulo = $dadosModulo[0]['nm_tipo']; + + foreach ($dadosEtapa as $modulo) { + $checked = ''; + $objDispensaEtapa = new clsPmieducarDispensaDisciplinaEtapa($this->cod_dispensa, $modulo['sequencial']); + $verificaSeExiste = $objDispensaEtapa->existe(); + if ($verificaSeExiste) { + $checked = 'checked'; + } + $conteudoHtml .= '
'; + $conteudoHtml .= "'; + $conteudoHtml .= '
'; + } - $objDispensaEtapa = new clsPmieducarDispensaDisciplinaEtapa(); - $excluiDispensaEtapa = $objDispensaEtapa->excluirTodos($this->cod_dispensa); + $etapas = ''; + $etapas .= sprintf('', $conteudoHtml); + $etapas .= '
%s
'; - foreach ($this->etapa as $e) { - $objDispensaEtapa = new clsPmieducarDispensaDisciplinaEtapa($this->cod_dispensa, $e); - $cadastra = $objDispensaEtapa->cadastra(); + $this->campoRotulo( + 'etapas_', + 'Etapas', + "
$etapas
" + ); } - $detalheAntigo = $obj->detalhe(); - $editou = $obj->edita(); - if ($editou) { + public function obtemDadosDaDispensa() + { + $dadosDaDispensa = [ + 'cod_dispensa' => $this->cod_dispensa, + 'ref_cod_matricula' => $this->ref_cod_matricula, + 'ref_cod_serie' => $this->ref_cod_serie, + 'ref_cod_escola' => $this->ref_cod_escola, + 'ref_cod_disciplina' => $this->ref_cod_disciplina, + 'ref_usuario_exc' => $this->pessoa_logada, + 'ref_usuario_cad' => $this->pessoa_logada, + 'ref_cod_tipo_dispensa' => $this->ref_cod_tipo_dispensa, + 'observacao' => $this->observacao, + 'etapas' => $this->etapa + ]; + + return $dadosDaDispensa; + } - $auditoria = new clsModulesAuditoriaGeral("dispensa_disciplina", $this->pessoa_logada, $this->cod_dispensa); - $auditoria->alteracao($detalheAntigo, $obj->detalhe()); - $this->mensagem .= 'Edição efetuada com sucesso.
'; - header('Location: educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); - die(); + public function montaObjetoDispensa($dadosDaDispensa = []) + { + $objetoDispensa = new clsPmieducarDispensaDisciplina( + $dadosDaDispensa['ref_cod_matricula'], + $dadosDaDispensa['ref_cod_serie'], + $dadosDaDispensa['ref_cod_escola'], + $dadosDaDispensa['ref_cod_disciplina'], + $dadosDaDispensa['ref_usuario_exc'], + $dadosDaDispensa['ref_usuario_cad'], + $dadosDaDispensa['ref_cod_tipo_dispensa'], + null, + null, + 1, + $dadosDaDispensa['observacao'] + ); + + return $objetoDispensa; } - $this->mensagem = 'Edição não realizada.
'; - echo ""; - return FALSE; - } - - function Excluir() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_excluir(578, $this->pessoa_logada, 7, - 'educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); - - $obj = new clsPmieducarDispensaDisciplina($this->ref_cod_matricula, - $this->ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_disciplina, - $this->pessoa_logada, null, $this->ref_cod_tipo_dispensa, NULL, NULL, 0, - $this->observacao); - - $objDispensaEtapa = new clsPmieducarDispensaDisciplinaEtapa(); - $excluiDispensaEtapa = $objDispensaEtapa->excluirTodos($this->cod_dispensa); - - $detalhe = $obj->detalhe(); - $excluiu = $obj->excluir(); - - if ($excluiu) { - $auditoria = new clsModulesAuditoriaGeral("dispensa_disciplina", $this->pessoa_logada, $this->cod_dispensa); - $auditoria->exclusao($detalhe); - $this->mensagem .= 'Exclusão efetuada com sucesso.
'; - header('Location: educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); - die(); + public function cadastraEtapasDaDispensa($dadosDaDispensa) + { + foreach ($dadosDaDispensa['etapas'] as $etapa) { + $this->removeNotasDaDisciplinaNaEtapa( + $dadosDaDispensa['ref_cod_matricula'], + $dadosDaDispensa['ref_cod_disciplina'], + $etapa + ); + $this->removeFaltasDaDisciplinaNaEtapa( + $dadosDaDispensa['ref_cod_matricula'], + $dadosDaDispensa['ref_cod_disciplina'], + $etapa + ); + $objetoEtapaDaDispensa = new clsPmieducarDispensaDisciplinaEtapa($dadosDaDispensa['cod_dispensa'], $etapa); + $cadastra = $objetoEtapaDaDispensa->cadastra(); + } } - $this->mensagem = 'Exclusão não realizada.
'; - echo ""; - return FALSE; - } - - function montaEtapas(){ - //Pega matricula para pegar curso, escola e ano - $objMatricula = new clsPmieducarMatricula(); - $dadosMatricula = $objMatricula->lista($this->ref_cod_matricula); - //Pega curso para pegar padrao ano escolar - $objCurso = new clsPmieducarCurso(); - $dadosCurso = $objCurso->lista($dadosMatricula[0]['ref_cod_curso']); - $padraoAnoEscolar = $dadosCurso[0]['padrao_ano_escolar']; - //Pega escola e ano para pegar as etapas em ano letivo modulo - $escolaId = $dadosMatricula[0]['ref_ref_cod_escola']; - $ano = $dadosMatricula[0]['ano']; - //Pega dados da enturmação atual - $objMatriculaTurma = new clsPmieducarMatriculaTurma(); - $seqMatriculaTurma = $objMatriculaTurma->getUltimaEnturmacao($this->ref_cod_matricula); - $dadosMatriculaTurma = $objMatriculaTurma->lista($this->ref_cod_matricula, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $seqMatriculaTurma); - //Pega etapas definidas na escola - $objAnoLetivoMod = new clsPmieducarAnoLetivoModulo(); - $dadosAnoLetivoMod = $objAnoLetivoMod->lista($ano, $escolaId); - //Pega etapas definida na turma - $objTurmaModulo = new clsPmieducarTurmaModulo(); - $dadosTurmaModulo = $objTurmaModulo->lista($dadosMatriculaTurma[0]['ref_cod_turma']); - //Define de onde as etapas serão pegas - if ($padraoAnoEscolar == 1) { - $dadosEtapa = $dadosAnoLetivoMod; - }else{ - $dadosEtapa = $dadosTurmaModulo; + public function removeNotasDaDisciplinaNaEtapa($matriculaId, $disciplinaId, $etapa) + { + $notaAlunoMapper = new Avaliacao_Model_NotaAlunoDataMapper(); + $notaAluno = $notaAlunoMapper->findAll([], ['matricula_id' => $matriculaId]); + $notaAluno = $notaAluno[0]->id; + if (empty($notaAluno)) { + return false; + } + $notaComponenteCurricularMapper = new Avaliacao_Model_NotaComponenteDataMapper(); + $notaComponenteCurricular = $notaComponenteCurricularMapper->findAll([], [ + 'nota_aluno_id' => $notaAluno, + 'componente_curricular_id' => $disciplinaId, + 'etapa' => $etapa + ]); + if (empty($notaComponenteCurricular)) { + return false; + } + $notaComponenteCurricularMapper->delete($notaComponenteCurricular[0]); + + return true; } - //Pega nome do modulo - $objModulo = new clsPmieducarModulo(); - $dadosModulo = $objModulo->lista($dadosEtapa[0]['ref_cod_modulo']); - $nomeModulo = $dadosModulo[0]['nm_tipo']; - - foreach ($dadosEtapa as $modulo) { - $checked = ''; - $objDispensaEtapa = new clsPmieducarDispensaDisciplinaEtapa($this->cod_dispensa, $modulo['sequencial']); - $verificaSeExiste = $objDispensaEtapa->existe(); - if ($verificaSeExiste) { - $checked = 'checked'; - } - $conteudoHtml .= '
'; - $conteudoHtml .= ""; - $conteudoHtml .= '
'; + + public function removeFaltasDaDisciplinaNaEtapa($matriculaId, $disciplinaId, $etapa) + { + $faltaAlunoMapper = new Avaliacao_Model_FaltaAlunoDataMapper(); + $faltaAluno = $faltaAlunoMapper->findAll([], ['matricula_id' => $matriculaId]); + $faltaAluno = $faltaAluno[0]->id; + if (empty($faltaAluno)) { + return false; + } + $faltaComponenteCurricularMapper = new Avaliacao_Model_FaltaComponenteDataMapper(); + $faltaComponenteCurricular = $faltaComponenteCurricularMapper->findAll([], [ + 'falta_aluno_id' => $faltaAluno, + 'componente_curricular_id' => $disciplinaId, + 'etapa' => $etapa + ]); + if (empty($faltaComponenteCurricular)) { + return false; + } + $faltaComponenteCurricularMapper->delete($faltaComponenteCurricular[0]); + + return true; } - $etapas = ''; - $etapas .= sprintf('', $conteudoHtml); - $etapas .= '
%s
'; + private function nomeDisciplina($disciplinaId){ + $mapper = new ComponenteCurricular_Model_ComponenteDataMapper(); + $componenteCurricular = $mapper->find($disciplinaId)->nome; - $this->campoRotulo('etapas_', 'Etapas', - "
$etapas
"); - } + return $componenteCurricular; + } } // Instancia objeto de página @@ -529,4 +496,4 @@ function montaEtapas(){ $pagina->addForm($miolo); // Gera o código HTML -$pagina->MakeAll(); \ No newline at end of file +$pagina->MakeAll(); diff --git a/ieducar/intranet/educar_distribuicao_uniforme_cad.php b/ieducar/intranet/educar_distribuicao_uniforme_cad.php index a9f14093ce..783534efb4 100644 --- a/ieducar/intranet/educar_distribuicao_uniforme_cad.php +++ b/ieducar/intranet/educar_distribuicao_uniforme_cad.php @@ -1,25 +1,4 @@ SetTitulo( "{$this->_instituicao} i-Educar - Distribuição de uniforme" ); - $this->processoAp = "578"; + $this->SetTitulo("{$this->_instituicao} i-Educar - Distribuição de uniforme"); + $this->processoAp = 578; $this->addEstilo('localizacaoSistema'); } } @@ -46,259 +25,433 @@ class indice extends clsCadastro * * @var int */ - var $pessoa_logada; - - var $cod_distribuicao_uniforme; - var $ref_cod_aluno; - var $ano; - var $agasalho_qtd; - var $camiseta_curta_qtd; - var $camiseta_longa_qtd; - var $meias_qtd; - var $bermudas_tectels_qtd; - var $bermudas_coton_qtd; - var $tenis_qtd; - var $data; - var $agasalho_tm; - var $camiseta_curta_tm; - var $camiseta_longa_tm; - var $meias_tm; - var $bermudas_tectels_tm; - var $bermudas_coton_tm; - var $tenis_tm; - var $ref_cod_escola; - - function Inicializar() + public $pessoa_logada; + + public $cod_distribuicao_uniforme; + + public $ref_cod_aluno; + + public $ano; + + public $agasalho_qtd; + + public $camiseta_curta_qtd; + + public $camiseta_longa_qtd; + + public $meias_qtd; + + public $bermudas_tectels_qtd; + + public $bermudas_coton_qtd; + + public $tenis_qtd; + + public $data; + + public $agasalho_tm; + + public $camiseta_curta_tm; + + public $camiseta_longa_tm; + + public $meias_tm; + + public $bermudas_tectels_tm; + + public $bermudas_coton_tm; + + public $tenis_tm; + + public $ref_cod_escola; + + public $kit_completo; + + public $camiseta_infantil_qtd; + + public $camiseta_infantil_tm; + + public function Inicializar() { - $retorno = "Novo"; - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); + $retorno = 'Novo'; - $this->cod_distribuicao_uniforme=$_GET["cod_distribuicao_uniforme"]; - $this->ref_cod_aluno=$_GET["ref_cod_aluno"]; + $this->cod_distribuicao_uniforme=$_GET['cod_distribuicao_uniforme']; + $this->ref_cod_aluno=$_GET['ref_cod_aluno']; $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 578, $this->pessoa_logada, 7, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); + $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"); + + if (is_numeric($this->ref_cod_aluno) && is_numeric($this->cod_distribuicao_uniforme)) { + + $obj = new clsPmieducarDistribuicaoUniforme($this->cod_distribuicao_uniforme); - if( is_numeric( $this->ref_cod_aluno ) && is_numeric( $this->cod_distribuicao_uniforme ) ) - { - $obj = new clsPmieducarDistribuicaoUniforme( $this->cod_distribuicao_uniforme ); $registro = $obj->detalhe(); - if( $registro ) - { - foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto + + if ($registro) { + foreach ($registro as $campo => $val) { $this->$campo = $val; + } $this->data = Portabilis_Date_Utils::pgSqlToBr($this->data); $this->kit_completo = dbBool($this->kit_completo); - if( $obj_permissoes->permissao_excluir( 578, $this->pessoa_logada, 7 ) ) - { + if ($obj_permissoes->permissao_excluir(578, $this->pessoa_logada, 7)) { $this->fexcluir = true; } - $retorno = "Editar"; + + $retorno = 'Editar'; } } - $this->url_cancelar = ($retorno == "Editar") ? "educar_distribuicao_uniforme_det.php?ref_cod_aluno={$registro["ref_cod_aluno"]}&cod_distribuicao_uniforme={$registro["cod_distribuicao_uniforme"]}" : "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"; - $this->nome_url_cancelar = "Cancelar"; - $localizacao = new LocalizacaoSistema(); - $localizacao->entradaCaminhos( array( - $_SERVER['SERVER_NAME']."/intranet" => "Início", - "educar_index.php" => "Escola", - "" => "Distribuições de uniforme escolar" - )); - $this->enviaLocalizacao($localizacao->montar()); + $this->url_cancelar = $retorno == 'Editar' + ? "educar_distribuicao_uniforme_det.php?ref_cod_aluno={$registro['ref_cod_aluno']}&cod_distribuicao_uniforme={$registro['cod_distribuicao_uniforme']}" + : "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"; + + $this->nome_url_cancelar = 'Cancelar'; + + $this->breadcrumb('Distribuições de uniforme escolar', [ + 'educar_index.php' => 'Escola', + ]); return $retorno; } - function Gerar() + public function Gerar() { - if( $_POST ) - foreach( $_POST AS $campo => $val ) - $this->$campo = ( !$this->$campo ) ? $val : $this->$campo ; - - // primary keys - $this->campoOculto( "ref_cod_aluno", $this->ref_cod_aluno ); - $this->campoOculto( "cod_distribuicao_uniforme", $this->cod_distribuicao_uniforme ); - - $this->campoNumero( "ano", "Ano", $this->ano, 4, 4, true ); - $this->inputsHelper()->date('data', array( 'label' => "Data da distribuição", 'value' => $this->data, 'placeholder' => '')); + if ($_POST) { + foreach ($_POST as $campo => $val) { + $this->$campo = !$this->$campo ? $val : $this->$campo; + } + } - $opcoes = array("" => "Selecione"); - $objTemp = new clsPmieducarEscola(); + $objEscola = new clsPmieducarEscola(); + $lista = $objEscola->lista(); - $lista = $objTemp->lista(null, null, null, $det_matricula['ref_cod_instituicao']); + $escolaOpcoes = ['' => 'Selecione']; - foreach ($lista as $escola){ - $opcoes["{$escola['cod_escola']}"] = "{$escola['nome']}"; + foreach ($lista as $escola) { + $escolaOpcoes["{$escola['cod_escola']}"] = "{$escola['nome']}"; } - $this->campoLista("ref_cod_escola", "Escola", $opcoes, $this->ref_cod_escola, '', false, '(Responsável pela distribuição do uniforme)', '', false, true); - - $this->inputsHelper()->checkbox('kit_completo', array( 'label' => "Kit completo", 'value' => $this->kit_completo)); - // $this->campoNumero( "agasalho_qtd", "Quantidade de agasalhos (jaqueta e calça)", $this->agasalho_qtd, 2, 2, false ); - $options = array('required' => false, 'label' => 'Quantidade de agasalhos (jaqueta e calça)', 'value' => $this->agasalho_qtd, 'max_length' => 2, 'size' => 2, 'inline' => true); - $this->inputsHelper()->integer('agasalho_qtd', $options); - $options = array('required' => false, 'label' => ' Tamanho', 'value' => $this->agasalho_tm, 'max_length' => 10, 'size' => 10); - $this->inputsHelper()->text('agasalho_tm', $options); - // $this->campoNumero( "camiseta_curta_qtd", "Quantidade de camisetas (manga curta)", $this->camiseta_curta_qtd, 2, 2, false); - $options = array('required' => false, 'label' => 'Quantidade de camisetas (manga curta)', 'value' => $this->camiseta_curta_qtd, 'max_length' => 2, 'size' => 2, 'inline' => true); - $this->inputsHelper()->integer('camiseta_curta_qtd', $options); - $options = array('required' => false, 'label' => ' Tamanho', 'value' => $this->camiseta_curta_tm, 'max_length' => 10, 'size' => 10); - $this->inputsHelper()->text('camiseta_curta_tm', $options); - // $this->campoNumero( "camiseta_longa_qtd", "Quantidade de camisetas (manga longa)", $this->camiseta_longa_qtd, 2, 2, false); - $options = array('required' => false, 'label' => 'Quantidade de camisetas (manga longa)', 'value' => $this->camiseta_longa_qtd, 'max_length' => 2, 'size' => 2, 'inline' => true); - $this->inputsHelper()->integer('camiseta_longa_qtd', $options); - $options = array('required' => false, 'label' => ' Tamanho', 'value' => $this->camiseta_longa_tm, 'max_length' => 10, 'size' => 10); - $this->inputsHelper()->text('camiseta_longa_tm', $options); - // $this->campoNumero( "meias_qtd", "Quantidade de meias", $this->meias_qtd, 2, 2, false); - $options = array('required' => false, 'label' => 'Quantidade de meias', 'value' => $this->meias_qtd, 'max_length' => 2, 'size' => 2, 'inline' => true); - $this->inputsHelper()->integer('meias_qtd', $options); - $options = array('required' => false, 'label' => ' Tamanho', 'value' => $this->meias_tm, 'max_length' => 10, 'size' => 10); - $this->inputsHelper()->text('meias_tm', $options); - // $this->campoNumero( "bermudas_tectels_qtd", "Bermudas tectels (masculino)", $this->bermudas_tectels_qtd, 2, 2, false); - $options = array('required' => false, 'label' => 'Bermudas tectels (masculino)', 'value' => $this->bermudas_tectels_qtd, 'max_length' => 2, 'size' => 2, 'inline' => true); - $this->inputsHelper()->integer('bermudas_tectels_qtd', $options); - $options = array('required' => false, 'label' => ' Tamanho', 'value' => $this->bermudas_tectels_tm, 'max_length' => 10, 'size' => 10); - $this->inputsHelper()->text('bermudas_tectels_tm', $options); - // $this->campoNumero( "bermudas_coton_qtd", "Bermudas coton (feminino)", $this->bermudas_coton_qtd, 2, 2, false); - $options = array('required' => false, 'label' => 'Bermudas coton (feminino)', 'value' => $this->bermudas_coton_qtd, 'max_length' => 2, 'size' => 2, 'inline' => true); - $this->inputsHelper()->integer('bermudas_coton_qtd', $options); - $options = array('required' => false, 'label' => ' Tamanho', 'value' => $this->bermudas_coton_tm, 'max_length' => 10, 'size' => 10); - $this->inputsHelper()->text('bermudas_coton_tm', $options); - // $this->campoNumero( "tamanho", "Tênis", $this->tenis_qtd, 2, 2, false); - $options = array('required' => false, 'label' => 'Tênis', 'value' => $this->tenis_qtd, 'max_length' => 2, 'size' => 2, 'inline' => true); - $this->inputsHelper()->integer('tenis_qtd', $options); - $options = array('required' => false, 'label' => ' Tamanho', 'value' => $this->tenis_tm, 'max_length' => 10, 'size' => 10); - $this->inputsHelper()->text('tenis_tm', $options); + $this->campoOculto('ref_cod_aluno', $this->ref_cod_aluno); + + $this->campoOculto('cod_distribuicao_uniforme', $this->cod_distribuicao_uniforme); + + $this->campoNumero('ano', 'Ano', $this->ano, 4, 4, true); + + $this->inputsHelper()->date('data', [ + 'label' => 'Data da distribuição', + 'value' => $this->data, + 'placeholder' => '', + 'size' => 10 + ]); + + $this->campoLista( + 'ref_cod_escola', + 'Escola', + $escolaOpcoes, + $this->ref_cod_escola, + '', + false, + '(Responsável pela distribuição do uniforme)', + '', + false, + true + ); + + $this->inputsHelper()->checkbox('kit_completo', [ + 'label' => 'Kit completo', 'value' => $this->kit_completo + ]); + + $this->inputsHelper()->integer('agasalho_qtd', [ + 'required' => false, + 'label' => 'Quantidade de agasalhos (jaqueta e calça)', + 'value' => $this->agasalho_qtd, + 'max_length' => 2, + 'size' => 2, + 'inline' => true, + 'placeholder' => '' + ]); + + $this->inputsHelper()->text('agasalho_tm', [ + 'required' => false, + 'label' => ' Tamanho', + 'value' => $this->agasalho_tm, + 'max_length' => 10, + 'size' => 10 + ]); + + + $this->inputsHelper()->integer('camiseta_curta_qtd', [ + 'required' => false, + 'label' => 'Quantidade de camisetas (manga curta)', + 'value' => $this->camiseta_curta_qtd, + 'max_length' => 2, + 'size' => 2, + 'inline' => true, + 'placeholder' => '' + ]); + + $this->inputsHelper()->text('camiseta_curta_tm', [ + 'required' => false, + 'label' => ' Tamanho', + 'value' => $this->camiseta_curta_tm, + 'max_length' => 10, + 'size' => 10 + ]); + + $this->inputsHelper()->integer('camiseta_longa_qtd', [ + 'required' => false, + 'label' => 'Quantidade de camisetas (manga longa)', + 'value' => $this->camiseta_longa_qtd, + 'max_length' => 2, + 'size' => 2, + 'inline' => true, + 'placeholder' => '' + ]); + + $this->inputsHelper()->text('camiseta_longa_tm', [ + 'required' => false, + 'label' => ' Tamanho', + 'value' => $this->camiseta_longa_tm, + 'max_length' => 10, + 'size' => 10 + ]); + + $this->inputsHelper()->integer('camiseta_infantil_qtd', [ + 'required' => false, + 'label' => 'Quantidade de camisetas infantis (sem manga)', + 'value' => $this->camiseta_infantil_qtd, + 'max_length' => 2, + 'size' => 2, + 'inline' => true, + 'placeholder' => '' + ]); + + $this->inputsHelper()->text('camiseta_infantil_tm', [ + 'required' => false, + 'label' => ' Tamanho', + 'value' => $this->camiseta_infantil_tm, + 'max_length' => 10, + 'size' => 10 + ]); + + $this->inputsHelper()->integer('meias_qtd', [ + 'required' => false, + 'label' => 'Quantidade de meias', + 'value' => $this->meias_qtd, + 'max_length' => 2, + 'size' => 2, + 'inline' => true, + 'placeholder' => '' + ]); + + $this->inputsHelper()->text('meias_tm', [ + 'required' => false, + 'label' => ' Tamanho', + 'value' => $this->meias_tm, + 'max_length' => 10, + 'size' => 10 + ]); + + $this->inputsHelper()->integer('bermudas_tectels_qtd', [ + 'required' => false, + 'label' => 'Bermudas tectels (masculino)', + 'value' => $this->bermudas_tectels_qtd, + 'max_length' => 2, + 'size' => 2, + 'inline' => true, + 'placeholder' => '' + ]); + + $this->inputsHelper()->text('bermudas_tectels_tm', [ + 'required' => false, + 'label' => ' Tamanho', + 'value' => $this->bermudas_tectels_tm, + 'max_length' => 10, + 'size' => 10 + ]); + + $this->inputsHelper()->integer('bermudas_coton_qtd', [ + 'required' => false, + 'label' => 'Bermudas coton (feminino)', + 'value' => $this->bermudas_coton_qtd, + 'max_length' => 2, + 'size' => 2, + 'inline' => true, + 'placeholder' => '' + ]); + + $this->inputsHelper()->text('bermudas_coton_tm', [ + 'required' => false, + 'label' => ' Tamanho', + 'value' => $this->bermudas_coton_tm, + 'max_length' => 10, + 'size' => 10 + ]); + + $this->inputsHelper()->integer('tenis_qtd', [ + 'required' => false, + 'label' => 'Tênis', + 'value' => $this->tenis_qtd, + 'max_length' => 2, + 'size' => 2, + 'inline' => true, + 'placeholder' => '' + ]); + + $this->inputsHelper()->text('tenis_tm', [ + 'required' => false, + 'label' => ' Tamanho', + 'value' => $this->tenis_tm, + 'max_length' => 10, + 'size' => 10 + ]); } - function Novo() + public function Novo() { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - $this->data = Portabilis_Date_Utils::brToPgSQL($this->data); $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 578, $this->pessoa_logada, 7, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); + $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"); $obj_tmp = $obj = new clsPmieducarDistribuicaoUniforme(); $lista_tmp = $obj_tmp->lista($this->ref_cod_aluno, $this->ano); - if($lista_tmp){ - $this->mensagem = "Já existe uma distribuição cadastrada para este ano, por favor, verifique.
"; + if ($lista_tmp) { + $this->mensagem = 'Já existe uma distribuição cadastrada para este ano, por favor, verifique.
'; + return false; } - $obj = new clsPmieducarDistribuicaoUniforme( null, $this->ref_cod_aluno, $this->ano, !is_null($this->kit_completo), $this->agasalho_qtd, - $this->camiseta_curta_qtd, $this->camiseta_longa_qtd, $this->meias_qtd, $this->bermudas_tectels_qtd, - $this->bermudas_coton_qtd, $this->tenis_qtd, $this->data, - $this->agasalho_tm, $this->camiseta_curta_tm, $this->camiseta_longa_tm, $this->meias_tm, - $this->bermudas_tectels_tm, $this->bermudas_coton_tm, $this->tenis_tm, $this->ref_cod_escola); + $obj = new clsPmieducarDistribuicaoUniforme( + null, + $this->ref_cod_aluno, + $this->ano, + !is_null($this->kit_completo), + $this->agasalho_qtd, + $this->camiseta_curta_qtd, + $this->camiseta_longa_qtd, + $this->meias_qtd, + $this->bermudas_tectels_qtd, + $this->bermudas_coton_qtd, + $this->tenis_qtd, + $this->data, + $this->agasalho_tm, + $this->camiseta_curta_tm, + $this->camiseta_longa_tm, + $this->meias_tm, + $this->bermudas_tectels_tm, + $this->bermudas_coton_tm, + $this->tenis_tm, + $this->ref_cod_escola, + $this->camiseta_infantil_qtd, + $this->camiseta_infantil_tm + ); + $this->cod_distribuicao_uniforme = $cadastrou = $obj->cadastra(); - if( $cadastrou ) - { - $distribuicao = new clsPmieducarDistribuicaoUniforme($this->cod_distribuicao_uniforme); - $distribuicao = $distribuicao->detalhe(); - $auditoria = new clsModulesAuditoriaGeral("distribuicao_uniforme", $this->pessoa_logada, $this->cod_distribuicao_uniforme); - $auditoria->inclusao($distribuicao); - - $this->mensagem .= "Cadastro efetuado com sucesso.
"; - header( "Location: educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); - die(); - return true; + + if ($cadastrou) { + $distribuicao = new clsPmieducarDistribuicaoUniforme($this->cod_distribuicao_uniforme); + $distribuicao = $distribuicao->detalhe(); + + $auditoria = new clsModulesAuditoriaGeral('distribuicao_uniforme', $this->pessoa_logada, $this->cod_distribuicao_uniforme); + $auditoria->inclusao($distribuicao); + + $this->redirectIf(true, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"); } - $this->mensagem = "Cadastro não realizado.
"; + $this->mensagem = 'Cadastro não realizado.
'; + return false; } - function Editar() + public function Editar() { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - $this->data = Portabilis_Date_Utils::brToPgSQL($this->data); $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 578, $this->pessoa_logada, 7, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); + $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"); $obj_tmp = $obj = new clsPmieducarDistribuicaoUniforme(); $lista_tmp = $obj_tmp->lista($this->ref_cod_aluno, $this->ano); - if($lista_tmp){ + if ($lista_tmp) { foreach ($lista_tmp as $reg) { - if ($reg['cod_distribuicao_uniforme'] != $this->cod_distribuicao_uniforme){ - $this->mensagem = "Já existe uma distribuição cadastrada para este ano, por favor, verifique.
"; + if ($reg['cod_distribuicao_uniforme'] != $this->cod_distribuicao_uniforme) { + $this->mensagem = 'Já existe uma distribuição cadastrada para este ano, por favor, verifique.
'; + return false; } } } - $obj = new clsPmieducarDistribuicaoUniforme( $this->cod_distribuicao_uniforme, $this->ref_cod_aluno, $this->ano, !is_null($this->kit_completo), - $this->agasalho_qtd, $this->camiseta_curta_qtd, $this->camiseta_longa_qtd, $this->meias_qtd, - $this->bermudas_tectels_qtd, $this->bermudas_coton_qtd, $this->tenis_qtd, $this->data, - $this->agasalho_tm, $this->camiseta_curta_tm, $this->camiseta_longa_tm, $this->meias_tm, - $this->bermudas_tectels_tm, $this->bermudas_coton_tm, $this->tenis_tm, $this->ref_cod_escola); - $detalheAntigo = $obj->detalhe(); + $obj = new clsPmieducarDistribuicaoUniforme( + $this->cod_distribuicao_uniforme, + $this->ref_cod_aluno, + $this->ano, + !is_null($this->kit_completo), + $this->agasalho_qtd, + $this->camiseta_curta_qtd, + $this->camiseta_longa_qtd, + $this->meias_qtd, + $this->bermudas_tectels_qtd, + $this->bermudas_coton_qtd, + $this->tenis_qtd, + $this->data, + $this->agasalho_tm, + $this->camiseta_curta_tm, + $this->camiseta_longa_tm, + $this->meias_tm, + $this->bermudas_tectels_tm, + $this->bermudas_coton_tm, + $this->tenis_tm, + $this->ref_cod_escola, + $this->camiseta_infantil_qtd, + $this->camiseta_infantil_tm + ); + + $detalheAntigo = $obj->detalhe(); $editou = $obj->edita(); - if( $editou ) - { - $auditoria = new clsModulesAuditoriaGeral("distribuicao_uniforme", $this->pessoa_logada, $this->cod_distribuicao_uniforme); - $auditoria->alteracao($detalheAntigo, $obj->detalhe()); - - $this->mensagem .= "Edção efetuada com sucesso.
"; - header( "Location: educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); - die(); - return true; + + if ($editou) { + $auditoria = new clsModulesAuditoriaGeral('distribuicao_uniforme', $this->pessoa_logada, $this->cod_distribuicao_uniforme); + $auditoria->alteracao($detalheAntigo, $obj->detalhe()); + + $this->redirectIf(true, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"); } - $this->mensagem = "Edção não realizada.
"; + $this->mensagem = 'Edição não realizada.
'; + return false; } - function Excluir() + public function Excluir() { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_excluir( 578, $this->pessoa_logada, 7, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); - + $obj_permissoes->permissao_excluir(578, $this->pessoa_logada, 7, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"); - $obj = new clsPmieducarDistribuicaoUniforme( $this->cod_distribuicao_uniforme); - $detalhe = $obj->detalhe(); + $obj = new clsPmieducarDistribuicaoUniforme($this->cod_distribuicao_uniforme); + $detalhe = $obj->detalhe(); $excluiu = $obj->excluir(); - if( $excluiu ) - { - $auditoria = new clsModulesAuditoriaGeral("distribuicao_uniforme", $this->pessoa_logada, $this->cod_distribuicao_uniforme); - $auditoria->exclusao($detalhe); - $this->mensagem .= "Exclusão efetuada com sucesso.
"; - header( "Location: educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); - die(); - return true; + + if ($excluiu) { + $auditoria = new clsModulesAuditoriaGeral('distribuicao_uniforme', $this->pessoa_logada, $this->cod_distribuicao_uniforme); + $auditoria->exclusao($detalhe); + + $this->redirectIf(true, "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"); } - $this->mensagem = "Exclusão não realizada.
"; + $this->mensagem = 'Exclusão não realizada.
'; + return false; } } -// cria uma extensao da classe base $pagina = new clsIndexBase(); -// cria o conteudo -$miolo = new indice(); -// adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); -// gera o html +$pagina->addForm(new indice()); $pagina->MakeAll(); ?> @@ -308,6 +461,7 @@ function bloqueiaCamposQuantidade(){ $j('#agasalho_qtd').val('').attr('disabled', 'disabled'); $j('#camiseta_curta_qtd').val('').attr('disabled', 'disabled'); $j('#camiseta_longa_qtd').val('').attr('disabled', 'disabled'); + $j('#camiseta_infantil_qtd').val('').attr('disabled', 'disabled'); $j('#meias_qtd').val('').attr('disabled', 'disabled'); $j('#bermudas_tectels_qtd').val('').attr('disabled', 'disabled'); $j('#bermudas_coton_qtd').val('').attr('disabled', 'disabled'); @@ -319,6 +473,7 @@ function liberaCamposQuantidade(){ $j('#agasalho_qtd').removeAttr('disabled'); $j('#camiseta_curta_qtd').removeAttr('disabled'); $j('#camiseta_longa_qtd').removeAttr('disabled'); + $j('#camiseta_infantil_qtd').removeAttr('disabled'); $j('#meias_qtd').removeAttr('disabled'); $j('#bermudas_tectels_qtd').removeAttr('disabled'); $j('#bermudas_coton_qtd').removeAttr('disabled'); diff --git a/ieducar/intranet/educar_distribuicao_uniforme_det.php b/ieducar/intranet/educar_distribuicao_uniforme_det.php index 4241d0e36b..9e203f1bc4 100644 --- a/ieducar/intranet/educar_distribuicao_uniforme_det.php +++ b/ieducar/intranet/educar_distribuicao_uniforme_det.php @@ -1,38 +1,18 @@ SetTitulo( "{$this->_instituicao} i-Educar - Histórico Escolar" ); - $this->processoAp = "578"; + $this->SetTitulo("{$this->_instituicao} i-Educar - Distribuições de uniforme escolar"); + $this->processoAp = '578'; $this->addEstilo('localizacaoSistema'); } } @@ -44,106 +24,87 @@ class indice extends clsDetalhe * * @var int */ - var $titulo; - - var $cod_distribuicao_uniforme; - var $ref_cod_aluno; + public $titulo; - function Gerar() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - session_write_close(); + public $cod_distribuicao_uniforme; - $this->titulo = "Histórico Escolar - Detalhe"; + public $ref_cod_aluno; - $this->cod_distribuicao_uniforme=$_GET["cod_distribuicao_uniforme"]; - $this->ref_cod_aluno=$_GET["ref_cod_aluno"]; + public function Gerar() + { + $this->titulo = 'Distribuições de uniforme escolar - Detalhe'; + $this->cod_distribuicao_uniforme = $_GET['cod_distribuicao_uniforme']; + $this->ref_cod_aluno = $_GET['ref_cod_aluno']; - $tmp_obj = new clsPmieducarDistribuicaoUniforme( $this->cod_distribuicao_uniforme); + $tmp_obj = new clsPmieducarDistribuicaoUniforme($this->cod_distribuicao_uniforme); $registro = $tmp_obj->detalhe(); - if( ! $registro ) - { - header( "location: educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); + if (!$registro) { + header("location: educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"); die(); } $obj_aluno = new clsPmieducarAluno(); - $lst_aluno = $obj_aluno->lista( $registro["ref_cod_aluno"],null,null,null,null,null,null,null,null,null,1 ); - if ( is_array($lst_aluno) ) + $lst_aluno = $obj_aluno->lista($registro['ref_cod_aluno'], null, null, null, null, null, null, null, null, null, 1); - { + if (is_array($lst_aluno)) { $det_aluno = array_shift($lst_aluno); - $nm_aluno = $det_aluno["nome_aluno"]; + $nm_aluno = $det_aluno['nome_aluno']; } - if( $nm_aluno ) - { - $this->addDetalhe( array( "Aluno", "{$nm_aluno}") ); + if ($nm_aluno) { + $this->addDetalhe(['Aluno', "{$nm_aluno}"]); } - if( $registro["ano"] ) - { - $this->addDetalhe( array( "Ano", "{$registro["ano"]}") ); + if ($registro['ano']) { + $this->addDetalhe(['Ano', "{$registro['ano']}"]); } - if( $registro["data"] ) - { - $this->addDetalhe( array( Portabilis_String_Utils::toLatin1("Data da distribuição"), Portabilis_Date_Utils::pgSQLToBr($registro["data"]) ) ); + if ($registro['data']) { + $this->addDetalhe(['Data da distribuição', Portabilis_Date_Utils::pgSQLToBr($registro['data'])]); } - if ( $registro["ref_cod_escola"]){ + if ($registro['ref_cod_escola']) { $obj_escola = new clsPmieducarEscola(); - $lst_escola = $obj_escola->lista($registro["ref_cod_escola"]); - if ( is_array($lst_escola) ){ + $lst_escola = $obj_escola->lista($registro['ref_cod_escola']); + + if (is_array($lst_escola)) { $det_escola = array_shift($lst_escola); - $nm_escola = $det_escola["nome"]; - $this->addDetalhe(array("Escola fornecedora", Portabilis_String_Utils::toLatin1($nm_escola))); + $nm_escola = $det_escola['nome']; + $this->addDetalhe(['Escola fornecedora', Portabilis_String_Utils::toLatin1($nm_escola)]); } - } - if( dbBool($registro["kit_completo"]) ) - $this->addDetalhe( array( "Recebeu kit completo", "Sim") ); - else{ - $this->addDetalhe( array( "Recebeu kit completo", Portabilis_String_Utils::toLatin1("Não")) ); - - $this->addDetalhe( array( Portabilis_String_Utils::toLatin1("Quantidade de agasalhos (jaqueta e calça)"), $registro['agasalho_qtd'] ?: '0' )); - $this->addDetalhe( array( "Quantidade de camisetas (manga curta)", $registro['camiseta_curta_qtd'] ?: '0' )); - $this->addDetalhe( array( "Quantidade de camisetas (manga longa)", $registro['camiseta_longa_qtd'] ?: '0' )); - $this->addDetalhe( array( "Quantidade de meias", $registro['meias_qtd'] ?: '0' )); - $this->addDetalhe( array( "Bermudas tectels (masculino)", $registro['bermudas_tectels_qtd'] ?: '0' )); - $this->addDetalhe( array( "Bermudas coton (feminino)", $registro['bermudas_coton_qtd'] ?: '0' )); - $this->addDetalhe( array( Portabilis_String_Utils::toLatin1("Quantidade de tênis"), $registro['tenis_qtd'] ?: '0' )); + if (dbBool($registro['kit_completo'])) { + $this->addDetalhe(['Recebeu kit completo', 'Sim']); + } else { + $this->addDetalhe(['Recebeu kit completo', Portabilis_String_Utils::toLatin1('Não')]); + $this->addDetalhe([Portabilis_String_Utils::toLatin1('Quantidade de agasalhos (jaqueta e calça)'), $registro['agasalho_qtd'] ?: '0']); + $this->addDetalhe(['Quantidade de camisetas (manga curta)', $registro['camiseta_curta_qtd'] ?: '0']); + $this->addDetalhe(['Quantidade de camisetas (manga longa)', $registro['camiseta_longa_qtd'] ?: '0']); + $this->addDetalhe(['Quantidade de camisetas infantis (sem manga)', $registro['camiseta_infantil_qtd'] ?: '0']); + $this->addDetalhe(['Quantidade de meias', $registro['meias_qtd'] ?: '0']); + $this->addDetalhe(['Bermudas tectels (masculino)', $registro['bermudas_tectels_qtd'] ?: '0']); + $this->addDetalhe(['Bermudas coton (feminino)', $registro['bermudas_coton_qtd'] ?: '0']); + $this->addDetalhe([Portabilis_String_Utils::toLatin1('Quantidade de tênis'), $registro['tenis_qtd'] ?: '0']); } $obj_permissoes = new clsPermissoes(); - if( $obj_permissoes->permissao_cadastra( 578, $this->pessoa_logada, 7 ) ) - { - $this->url_novo = "educar_distribuicao_uniforme_cad.php?ref_cod_aluno={$registro["ref_cod_aluno"]}"; - $this->url_editar = "educar_distribuicao_uniforme_cad.php?ref_cod_aluno={$registro["ref_cod_aluno"]}&cod_distribuicao_uniforme={$registro["cod_distribuicao_uniforme"]}"; + + if ($obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7)) { + $this->url_novo = "educar_distribuicao_uniforme_cad.php?ref_cod_aluno={$registro['ref_cod_aluno']}"; + $this->url_editar = "educar_distribuicao_uniforme_cad.php?ref_cod_aluno={$registro['ref_cod_aluno']}&cod_distribuicao_uniforme={$registro['cod_distribuicao_uniforme']}"; } - $this->url_cancelar = "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$registro["ref_cod_aluno"]}"; - $this->largura = "100%"; + $this->url_cancelar = "educar_distribuicao_uniforme_lst.php?ref_cod_aluno={$registro['ref_cod_aluno']}"; + $this->largura = '100%'; - $localizacao = new LocalizacaoSistema(); - $localizacao->entradaCaminhos( array( - $_SERVER['SERVER_NAME']."/intranet" => "Início", - "educar_index.php" => "Escola", - "" => "Distribuições de uniforme escolar" - )); - $this->enviaLocalizacao($localizacao->montar()); + $this->breadcrumb('Distribuições de uniforme escolar', [ + 'educar_index.php' => 'Escola' + ]); } } -// cria uma extensao da classe base $pagina = new clsIndexBase(); -// cria o conteudo -$miolo = new indice(); -// adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); -// gera o html +$pagina->addForm(new indice()); $pagina->MakeAll(); -?> \ No newline at end of file diff --git a/ieducar/intranet/educar_documentacao_instituicao_cad.php b/ieducar/intranet/educar_documentacao_instituicao_cad.php index 6e14ecdce5..56ff931223 100644 --- a/ieducar/intranet/educar_documentacao_instituicao_cad.php +++ b/ieducar/intranet/educar_documentacao_instituicao_cad.php @@ -72,8 +72,7 @@ function Inicializar() function Gerar() { - Portabilis_View_Helper_Application::loadJavascript($this, array('/modules/Cadastro/Assets/Javascripts/Instituicao.js')); - Portabilis_View_Helper_Application::loadStylesheet($this, array('/modules/Cadastro/Assets/Stylesheets/Instituicao.css')); + Portabilis_View_Helper_Application::loadJavascript($this, array('/modules/Cadastro/Assets/Javascripts/DocumentacaoPadrao.js')); $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada); $obj_usuario_det = $obj_usuario->detalhe(); diff --git a/ieducar/intranet/educar_escola_serie_lst.php b/ieducar/intranet/educar_escola_serie_lst.php index 9588588778..df71eae298 100644 --- a/ieducar/intranet/educar_escola_serie_lst.php +++ b/ieducar/intranet/educar_escola_serie_lst.php @@ -92,7 +92,7 @@ function Gerar() $this->pessoa_logada = $_SESSION['id_pessoa']; session_write_close(); - $this->titulo = 'Escola Série - Listagem'; + $this->titulo = 'Escola Série - Listagem'; foreach( $_GET AS $var => $val ) // passa todos os valores obtidos no GET para atributos do objeto $this->$var = ( $val === '' ) ? null: $val; @@ -107,7 +107,7 @@ function Gerar() $obj_permissao = new clsPermissoes(); $nivel_usuario = $obj_permissao->nivel_acesso($this->pessoa_logada); $lista_busca[] = 'Escola'; - $lista_busca[] = 'Instituição'; + $lista_busca[] = 'Instituição'; $lista_busca[] = 'Escola'; $this->addCabecalhos($lista_busca); @@ -129,7 +129,7 @@ function Gerar() $lista = $obj_escola_serie->lista( $this->ref_cod_escola, - $this->ref_ref_cod_serie, + $this->ref_cod_serie, NULL, NULL, NULL, diff --git a/ieducar/intranet/educar_falecido_cad.php b/ieducar/intranet/educar_falecido_cad.php index 2a10e94f71..640a2065e4 100644 --- a/ieducar/intranet/educar_falecido_cad.php +++ b/ieducar/intranet/educar_falecido_cad.php @@ -29,6 +29,9 @@ require_once "include/clsBanco.inc.php"; require_once "include/pmieducar/geral.inc.php"; require_once "lib/Portabilis/Date/Utils.php"; +require_once 'modules/Avaliacao/Model/NotaAlunoDataMapper.php'; +require_once 'modules/Avaliacao/Model/NotaComponenteMediaDataMapper.php'; +require_once 'lib/App/Model/MatriculaSituacao.php'; class clsIndexBase extends clsBase { @@ -150,6 +153,13 @@ function Novo() $enturmacao->marcaAlunoFalecido($this->data_cancel); } + + $notaAlunoId = (new Avaliacao_Model_NotaAlunoDataMapper()) + ->findAll(['id'], ['matricula_id' => $obj_matricula->cod_matricula])[0]->get('id'); + + (new Avaliacao_Model_NotaComponenteMediaDataMapper()) + ->updateSituation($notaAlunoId, App_Model_MatriculaSituacao::FALECIDO); + $this->mensagem .= "Alteração realizado com sucesso.
"; header( "Location: educar_matricula_det.php?cod_matricula={$this->ref_cod_matricula}" ); return true; diff --git a/ieducar/intranet/educar_instituicao_cad.php b/ieducar/intranet/educar_instituicao_cad.php index 6015f31ffc..87d65a48e9 100644 --- a/ieducar/intranet/educar_instituicao_cad.php +++ b/ieducar/intranet/educar_instituicao_cad.php @@ -14,111 +14,91 @@ class clsIndexBase extends clsBase { - function Formular() + public function Formular() { - $this->SetTitulo("{$this->_instituicao} i-Educar - Instituição"); - $this->processoAp = "559"; - $this->addEstilo("localizacaoSistema"); + $this->SetTitulo("{$this->_instituicao} i-Educar - Instituição"); + $this->processoAp = '559'; } } class indice extends clsCadastro { - /** - * Referencia pega da session para o idpes do usuario atual - * - * @var int - */ - var $pessoa_logada; - - var $cod_instituicao; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_idtlog; - var $ref_sigla_uf; - var $cep; - var $cidade; - var $bairro; - var $logradouro; - var $numero; - var $complemento; - var $nm_responsavel; - var $ddd_telefone; - var $telefone; - var $data_cadastro; - var $data_exclusao; - var $ativo; - var $nm_instituicao; - var $data_base_transferencia; - var $data_base_remanejamento; - var $exigir_vinculo_turma_professor; - var $exigir_dados_socioeconomicos; - var $controlar_espaco_utilizacao_aluno; - var $percentagem_maxima_ocupacao_salas; - var $quantidade_alunos_metro_quadrado; - var $gerar_historico_transferencia; - var $controlar_posicao_historicos; - var $matricula_apenas_bairro_escola; - var $restringir_historico_escolar; - var $restringir_multiplas_enturmacoes; - var $permissao_filtro_abandono_transferencia; - var $multiplas_reserva_vaga; - var $permitir_carga_horaria; - var $reserva_integral_somente_com_renda; - var $data_base_matricula; - var $data_expiracao_reserva_vaga; - var $data_fechamento; - var $componente_curricular_turma; - var $reprova_dependencia_ano_concluinte; - var $bloqueia_matricula_serie_nao_seguinte; - var $data_educacenso; - var $altera_atestado_para_declaracao; - var $obrigar_campos_censo; - var $obrigar_documento_pessoa; - var $orgao_regional; - var $exigir_lancamentos_anteriores; - - function Inicializar() + public $cod_instituicao; + public $ref_usuario_exc; + public $ref_usuario_cad; + public $ref_idtlog; + public $ref_sigla_uf; + public $cep; + public $cidade; + public $bairro; + public $logradouro; + public $numero; + public $complemento; + public $nm_responsavel; + public $ddd_telefone; + public $telefone; + public $data_cadastro; + public $data_exclusao; + public $ativo; + public $nm_instituicao; + public $data_base_transferencia; + public $data_base_remanejamento; + public $exigir_vinculo_turma_professor; + public $exigir_dados_socioeconomicos; + public $controlar_espaco_utilizacao_aluno; + public $percentagem_maxima_ocupacao_salas; + public $quantidade_alunos_metro_quadrado; + public $gerar_historico_transferencia; + public $controlar_posicao_historicos; + public $matricula_apenas_bairro_escola; + public $restringir_historico_escolar; + public $restringir_multiplas_enturmacoes; + public $permissao_filtro_abandono_transferencia; + public $multiplas_reserva_vaga; + public $permitir_carga_horaria; + public $reserva_integral_somente_com_renda; + public $data_base_matricula; + public $data_expiracao_reserva_vaga; + public $data_fechamento; + public $componente_curricular_turma; + public $reprova_dependencia_ano_concluinte; + public $bloqueia_matricula_serie_nao_seguinte; + public $data_educacenso; + public $altera_atestado_para_declaracao; + public $obrigar_campos_censo; + public $obrigar_documento_pessoa; + public $orgao_regional; + public $exigir_lancamentos_anteriores; + public $exibir_apenas_professores_alocados; + + public function Inicializar() { - $retorno = "Novo"; - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); + $retorno = 'Novo'; $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra(559, $this->pessoa_logada, 3, "educar_instituicao_lst.php"); + $obj_permissoes->permissao_cadastra(559, $this->pessoa_logada, 3, 'educar_instituicao_lst.php'); - $this->cod_instituicao = $_GET["cod_instituicao"]; + $this->cod_instituicao = $this->getQueryString('cod_instituicao'); if (is_numeric($this->cod_instituicao)) { - $obj = new clsPmieducarInstituicao($this->cod_instituicao); $registro = $obj->detalhe(); if ($registro) { - foreach ($registro AS $campo => $val) { // passa todos os valores obtidos no registro para atributos do objeto + foreach ($registro as $campo => $val) { // passa todos os valores obtidos no registro para atributos do objeto $this->$campo = $val; } $this->data_cadastro = dataFromPgToBr($this->data_cadastro); $this->data_exclusao = dataFromPgToBr($this->data_exclusao); $this->fexcluir = $obj_permissoes->permissao_excluir(559, $this->pessoa_logada, 3); - $retorno = "Editar"; + $retorno = 'Editar'; } } - $this->url_cancelar = ($retorno == "Editar") ? "educar_instituicao_det.php?cod_instituicao={$registro["cod_instituicao"]}" : "educar_instituicao_lst.php"; - $this->nome_url_cancelar = "Cancelar"; - - $nomeMenu = $retorno == "Editar" ? $retorno : "Cadastrar"; - $localizacao = new LocalizacaoSistema(); - $localizacao->entradaCaminhos( - array( - $_SERVER['SERVER_NAME'] . "/intranet" => "Início", - "educar_index.php" => "Escola", - "" => "{$nomeMenu} instituição" - ) - ); - $this->enviaLocalizacao($localizacao->montar()); + $this->url_cancelar = ($retorno == 'Editar') ? "educar_instituicao_det.php?cod_instituicao={$registro['cod_instituicao']}" : 'educar_instituicao_lst.php'; + $this->nome_url_cancelar = 'Cancelar'; + + $this->breadcrumb('Instituição', ['educar_index.php' => 'Escola']); $this->gerar_historico_transferencia = dbBool($this->gerar_historico_transferencia); $this->controlar_posicao_historicos = dbBool($this->controlar_posicao_historicos); @@ -137,26 +117,26 @@ function Inicializar() $this->obrigar_campos_censo = dbBool($this->obrigar_campos_censo); $this->obrigar_documento_pessoa = dbBool($this->obrigar_documento_pessoa); $this->exigir_lancamentos_anteriores = dbBool($this->exigir_lancamentos_anteriores); - + $this->exibir_apenas_professores_alocados = dbBool($this->exibir_apenas_professores_alocados); return $retorno; } - function Gerar() + public function Gerar() { // primary keys - $this->campoOculto("cod_instituicao", $this->cod_instituicao); + $this->campoOculto('cod_instituicao', $this->cod_instituicao); // text - $this->campoTexto("nm_instituicao", "Nome da Instituição", $this->nm_instituicao, 30, 255, true); - $this->campoCep("cep", "CEP", int2CEP($this->cep), true, "-", false, false); - $this->campoTexto("logradouro", "Logradouro", $this->logradouro, 30, 255, true); - $this->campoTexto("bairro", "Bairro", $this->bairro, 30, 40, true); - $this->campoTexto("cidade", "Cidade", $this->cidade, 30, 60, true); + $this->campoTexto('nm_instituicao', 'Nome da Instituição', $this->nm_instituicao, 30, 255, true); + $this->campoCep('cep', 'CEP', int2CEP($this->cep), true, '-', false, false); + $this->campoTexto('logradouro', 'Logradouro', $this->logradouro, 30, 255, true); + $this->campoTexto('bairro', 'Bairro', $this->bairro, 30, 40, true); + $this->campoTexto('cidade', 'Cidade', $this->cidade, 30, 60, true); // foreign keys - $opcoes = array("" => "Selecione"); - if (class_exists("clsTipoLogradouro")) { + $opcoes = ['' => 'Selecione']; + if (class_exists('clsTipoLogradouro')) { $objTemp = new clsTipoLogradouro(); $lista = $objTemp->lista(); if (is_array($lista) && count($lista)) { @@ -166,13 +146,13 @@ function Gerar() } } else { echo ""; - $opcoes = array("" => "Erro na geracao"); + $opcoes = ['' => 'Erro na geracao']; } - $this->campoLista("ref_idtlog", "Tipo do Logradouro", $opcoes, $this->ref_idtlog, "", false, "", "", false, true); + $this->campoLista('ref_idtlog', 'Tipo do Logradouro', $opcoes, $this->ref_idtlog, '', false, '', '', false, true); // foreign keys - $opcoes = array("" => "Selecione"); - if (class_exists("clsUf")) { + $opcoes = ['' => 'Selecione']; + if (class_exists('clsUf')) { $objTemp = new clsUf(); $lista = $objTemp->lista(); if (is_array($lista) && count($lista)) { @@ -183,84 +163,144 @@ function Gerar() } } else { echo ""; - $opcoes = array("" => "Erro na geracao"); + $opcoes = ['' => 'Erro na geracao']; } - $this->campoLista("ref_sigla_uf", "UF", $opcoes, $this->ref_sigla_uf, "", false, "", "", false, true); - - $this->campoNumero("numero", "Número", $this->numero, 6, 6); - $this->campoTexto("complemento", "Complemento", $this->complemento, 30, 50, false); - $this->campoTexto("nm_responsavel", "Nome do Responsável", $this->nm_responsavel, 30, 255, true); - $this->campoNumero("ddd_telefone", "DDD Telefone", $this->ddd_telefone, 2, 2); - $this->campoNumero("telefone", "Telefone", $this->telefone, 11, 11); - - - $this->campoData('data_base_transferencia', 'Data máxima para deslocamento', Portabilis_Date_Utils::pgSQLToBr($this->data_base_transferencia), null, null, false); + $this->campoLista('ref_sigla_uf', 'UF', $opcoes, $this->ref_sigla_uf, '', false, '', '', false, true); - $this->campoData('data_base_remanejamento', 'Data máxima para troca de sala', Portabilis_Date_Utils::pgSQLToBr($this->data_base_remanejamento), null, null, false); + $this->campoNumero('numero', 'Número', $this->numero, 6, 6); + $this->campoTexto('complemento', 'Complemento', $this->complemento, 30, 50, false); + $this->campoTexto('nm_responsavel', 'Nome do Responsável', $this->nm_responsavel, 30, 255, true); + $this->campoNumero('ddd_telefone', 'DDD Telefone', $this->ddd_telefone, 2, 2); + $this->campoNumero('telefone', 'Telefone', $this->telefone, 11, 11); ///$hiddenInputOptions = array('options' => array('value' => $this->coordenador_transporte)); //$helperOptions = array('objectName' => 'gestor', 'hiddenInputOptions' => $hiddenInputOptions); - $options = array('label' => 'Coordenador(a) de transporte', + $options = ['label' => 'Coordenador(a) de transporte', 'size' => 50, 'value' => $this->coordenador_transporte, - 'required' => false); + 'required' => false]; $this->inputsHelper()->simpleSearchPessoa('coordenador_transporte', $options, $helperOptions); - $this->campoCheck("exigir_vinculo_turma_professor", "Exigir vínculo com turma para lançamento de notas do professor?", $this->exigir_vinculo_turma_professor); + $opcoes = []; + if (!empty($this->ref_sigla_uf)) { + $opcoes = [null => 'Selecione']; + $orgaoRegional = new Educacenso_Model_OrgaoRegionalDataMapper(); + $orgaosRegionais = $orgaoRegional->findAll( + ['sigla_uf', 'codigo'], + ['sigla_uf' => $this->ref_sigla_uf], + ['codigo' => 'asc'], + false + ); + foreach ($orgaosRegionais as $orgaoRegional) { + $opcoes[$orgaoRegional->codigo] = $orgaoRegional->codigo; + } + } else { + $opcoes = [null => 'Informe uma UF']; + } - $this->campoCheck("gerar_historico_transferencia", "Gerar histórico de transferência ao transferir matrícula?", $this->gerar_historico_transferencia); + $options = ['label' => 'Código do órgão regional de ensino', 'resources' => $opcoes, 'value' => $this->orgao_regional, 'required' => false, 'size' => 70,]; + $this->inputsHelper()->select('orgao_regional', $options); - $this->campoCheck("controlar_posicao_historicos", "Permitir controlar posicionamento dos históricos em seu respectivo documento", $this->controlar_posicao_historicos); + $this->campoRotulo('gerais','Gerais'); + $this->campoCheck('obrigar_documento_pessoa', 'Exigir documento (RG, CPF ou Certidão de nascimento / casamento) no cadastro pessoa / aluno', $this->obrigar_documento_pessoa); + + $this->campoRotulo('datas','Datas'); + $this->campoData('data_base_transferencia', 'Data máxima para deslocamento', Portabilis_Date_Utils::pgSQLToBr($this->data_base_transferencia), null, null, false); + $this->campoData('data_base_remanejamento', 'Data máxima para troca de sala', Portabilis_Date_Utils::pgSQLToBr($this->data_base_remanejamento), null, null, false); + $this->inputsHelper()->text( + 'data_base', + [ + 'label' => 'Data base para matrícula (dia/mês)', + 'size' => 5, + 'max_length' => 5, + 'placeholder' => 'dd/mm', + 'required' => false, + 'value' => Portabilis_Date_Utils::pgSQLToBr_ddmm($this->data_base_matricula) + ] + ); + $this->campoData('data_expiracao_reserva_vaga', 'Data para indeferimento automático da reserva de vaga', Portabilis_Date_Utils::pgSQLToBr($this->data_expiracao_reserva_vaga), null, null, false); + $this->inputsHelper()->text( + 'data_fechamento', + [ + 'label' => 'Data de fechamento das turmas para matrícula', + 'size' => 5, + 'max_length' => 5, + 'placeholder' => 'dd/mm', + 'required' => false, + 'value' => Portabilis_Date_Utils::pgSQLToBr_ddmm($this->data_fechamento) + ] + ); + $this->inputsHelper()->date( + 'data_educacenso', + [ + 'label' => 'Data de referência do Educacenso', + 'required' => false, + 'placeholder' => 'dd/mm/yyyy', + 'value' => $this->data_educacenso + ] + ); + + $this->campoRotulo('historicos','Históricos'); + $this->campoCheck('gerar_historico_transferencia', 'Gerar histórico de transferência ao transferir matrícula?', $this->gerar_historico_transferencia); + $this->campoCheck('controlar_posicao_historicos', 'Permitir controlar posicionamento dos históricos em seu respectivo documento', $this->controlar_posicao_historicos); + $this->campoCheck('restringir_historico_escolar', 'Restringir modificações de históricos escolares?', $this->restringir_historico_escolar, null, false, false, false, 'Com esta opção selecionada, somente será possível cadastrar/editar históricos escolares de alunos que pertençam a mesma escola do funcionário.'); + $this->campoCheck('permitir_carga_horaria', 'Não permitir definir C.H. por componente no histórico escolar', $this->permitir_carga_horaria, null, false, false, false, 'Caso a opção estiver habilitda, não será possivel adicionar carga horária na tabela de disciplinas do histórico do aluno.'); + + $this->campoRotulo('reserva_vaga','Reserva de vaga'); + $this->multiplas_reserva_vaga = isset($this->cod_instituicao) ? dbBool($this->multiplas_reserva_vaga) : true; + $this->campoCheck('multiplas_reserva_vaga', 'Permitir múltiplas reservas de vagas para o mesmo candidato em escolas diferentes', $this->multiplas_reserva_vaga); + $this->campoCheck('reserva_integral_somente_com_renda', 'Permitir reserva de vaga para o turno integral somente quando a renda for informada', $this->reserva_integral_somente_com_renda); + $this->campoCheck('exigir_dados_socioeconomicos', 'Exigir dados socioeconômico na reserva de vaga para turno integral', $this->exigir_dados_socioeconomicos); - $this->campoCheck("matricula_apenas_bairro_escola", "Permitir matrícula de alunos apenas do bairro da escola?", $this->matricula_apenas_bairro_escola); + $this->campoRotulo('relatorios','Relatórios'); + $this->campoCheck('permissao_filtro_abandono_transferencia', 'Não permitir a apresentação de alunos com matrícula em abandono ou transferida na emissão do relatório de frequência', $this->permissao_filtro_abandono_transferencia); + $this->campoCheck('altera_atestado_para_declaracao', 'Alterar nome do título do menu e relatórios de Atestado para Declaração', $this->altera_atestado_para_declaracao); + $this->campoCheck('exibir_apenas_professores_alocados', 'Exibir apenas professores alocados nos filtros de emissão do Diário de classe', $this->exibir_apenas_professores_alocados); - $this->campoCheck("restringir_historico_escolar", "Restringir modificações de históricos escolares?", $this->restringir_historico_escolar, null, false, false, false, 'Com esta opção selecionada, somente será possível cadastrar/editar históricos escolares de alunos que pertençam a mesma escola do funcionário.'); + $this->campoRotulo('processos_escolares','Processos escolares'); + $this->campoCheck('exigir_vinculo_turma_professor', 'Exigir vínculo com turma para lançamento de notas do professor?', $this->exigir_vinculo_turma_professor); - $this->campoCheck("controlar_espaco_utilizacao_aluno", "Controlar espaço utilizado pelo aluno?", $this->controlar_espaco_utilizacao_aluno); + + $this->campoCheck('matricula_apenas_bairro_escola', 'Permitir matrícula de alunos apenas do bairro da escola?', $this->matricula_apenas_bairro_escola); + + + + $this->campoCheck('controlar_espaco_utilizacao_aluno', 'Controlar espaço utilizado pelo aluno?', $this->controlar_espaco_utilizacao_aluno); $this->campoMonetario( - "percentagem_maxima_ocupacao_salas", - "Percentagem máxima de ocupação da sala", + 'percentagem_maxima_ocupacao_salas', + 'Percentagem máxima de ocupação da sala', Portabilis_Currency_Utils::moedaUsToBr($this->percentagem_maxima_ocupacao_salas), 6, 6, false ); - $this->campoNumero("quantidade_alunos_metro_quadrado", "Quantidade máxima de alunos permitidos por metro quadrado", $this->quantidade_alunos_metro_quadrado, 6, 6); + $this->campoNumero('quantidade_alunos_metro_quadrado', 'Quantidade máxima de alunos permitidos por metro quadrado', $this->quantidade_alunos_metro_quadrado, 6, 6); - $this->campoCheck("restringir_multiplas_enturmacoes", "Não permitir múltiplas enturmações para o aluno no mesmo curso e série/ano", $this->restringir_multiplas_enturmacoes); - $this->campoCheck("permissao_filtro_abandono_transferencia", "Não permitir a apresentação de alunos com matrícula em abandono ou transferida na emissão do relatório de frequência", $this->permissao_filtro_abandono_transferencia); - - $this->multiplas_reserva_vaga = isset($this->cod_instituicao) ? dbBool($this->multiplas_reserva_vaga) : true; - $this->campoCheck("multiplas_reserva_vaga", "Permitir múltiplas reservas de vagas para o mesmo candidato em escolas diferentes", $this->multiplas_reserva_vaga); + $this->campoCheck('restringir_multiplas_enturmacoes', 'Não permitir múltiplas enturmações para o aluno no mesmo curso e série/ano', $this->restringir_multiplas_enturmacoes); $this->permitir_carga_horaria = isset($this->cod_instituicao) ? dbBool($this->permitir_carga_horaria) : true; - $this->campoCheck("permitir_carga_horaria", "Não permitir definir C.H. por componente no histórico escolar", $this->permitir_carga_horaria, null, false, false, false, 'Caso a opção estiver habilitda, não será possivel adicionar carga horária na tabela de disciplinas do histórico do aluno.'); - $this->campoCheck("reserva_integral_somente_com_renda", "Permitir reserva de vaga para o turno integral somente quando a renda for informada", $this->reserva_integral_somente_com_renda); - $this->campoCheck("exigir_dados_socioeconomicos", "Exigir dados socioeconômico na reserva de vaga para turno integral", $this->exigir_dados_socioeconomicos); $this->campoCheck( - "componente_curricular_turma", - "Permitir definir componentes curriculares diferenciados nas turmas", + 'componente_curricular_turma', + 'Permitir definir componentes curriculares diferenciados nas turmas', $this->componente_curricular_turma ); $this->campoCheck( - "reprova_dependencia_ano_concluinte", - "Não permitir dependência em séries/anos concluintes", + 'reprova_dependencia_ano_concluinte', + 'Não permitir dependência em séries/anos concluintes', $this->reprova_dependencia_ano_concluinte, null, false, false, false, - "Caso marcado, o aluno que reprovar em algum componente em ano concluinte será automaticamente reprovado." + 'Caso marcado, o aluno que reprovar em algum componente em ano concluinte será automaticamente reprovado.' ); - $this->campoCheck("bloqueia_matricula_serie_nao_seguinte", "Não permitir matrículas que não respeitem a sequência de enturmação", $this->bloqueia_matricula_serie_nao_seguinte); - $this->campoCheck("altera_atestado_para_declaracao", "Alterar nome do título do menu e relatórios de Atestado para Declaração", $this->altera_atestado_para_declaracao); + $this->campoCheck('bloqueia_matricula_serie_nao_seguinte', 'Não permitir matrículas que não respeitem a sequência de enturmação', $this->bloqueia_matricula_serie_nao_seguinte); - $this->campoCheck("obrigar_campos_censo", "Obrigar o preenchimento dos campos exigidos pelo Censo escolar", $this->obrigar_campos_censo); - $this->campoCheck("obrigar_documento_pessoa", "Exigir documento (RG, CPF ou Certidão de nascimento / casamento) no cadastro pessoa / aluno", $this->obrigar_documento_pessoa); + $this->campoCheck('obrigar_campos_censo', 'Obrigar o preenchimento dos campos exigidos pelo Censo escolar', $this->obrigar_campos_censo); $this->campoCheck( 'exigir_lancamentos_anteriores', @@ -268,71 +308,17 @@ function Gerar() $this->exigir_lancamentos_anteriores ); - $this->inputsHelper()->text( - 'data_base', - array( - 'label' => 'Data base para matrícula (dia/mês)', - 'size' => 5, - 'max_length' => 5, - 'placeholder' => 'dd/mm', - 'required' => false, - 'value' => Portabilis_Date_Utils::pgSQLToBr_ddmm($this->data_base_matricula) - ) - ); - - $this->campoData('data_expiracao_reserva_vaga', 'Data para indeferimento automático da reserva de vaga', Portabilis_Date_Utils::pgSQLToBr($this->data_expiracao_reserva_vaga), null, null, false); - - $this->inputsHelper()->text( - 'data_fechamento', - array( - 'label' => 'Data de fechamento das turmas para matrícula', - 'size' => 5, - 'max_length' => 5, - 'placeholder' => 'dd/mm', - 'required' => false, - 'value' => Portabilis_Date_Utils::pgSQLToBr_ddmm($this->data_fechamento) - ) - ); - - $this->inputsHelper()->date( - 'data_educacenso', - array( - 'label' => 'Data de referência do Educacenso', - 'required' => false, - 'placeholder' => 'dd/mm/yyyy', - 'value' => $this->data_educacenso - ) - ); - - $opcoes = array(); - if (!empty($this->ref_sigla_uf)) { - $opcoes = array(null => 'Selecione'); - $orgaoRegional = new Educacenso_Model_OrgaoRegionalDataMapper(); - $orgaosRegionais = $orgaoRegional->findAll( - array('sigla_uf', 'codigo'), - array('sigla_uf' => $this->ref_sigla_uf), - array('codigo' => 'asc'), - FALSE - ); - foreach ($orgaosRegionais as $orgaoRegional) { - $opcoes[$orgaoRegional->codigo] = $orgaoRegional->codigo; - } - } else { - $opcoes = array(null => 'Informe uma UF'); - } - - $options = array('label' => 'Código do órgão regional de ensino', 'resources' => $opcoes, 'value' => $this->orgao_regional, 'required' => false, 'size' => 70,); - $this->inputsHelper()->select('orgao_regional', $options); + $scripts = ['/modules/Cadastro/Assets/Javascripts/Instituicao.js']; + Portabilis_View_Helper_Application::loadJavascript($this, $scripts); + $styles = array ('/modules/Cadastro/Assets/Stylesheets/Instituicao.css'); + Portabilis_View_Helper_Application::loadStylesheet($this, $styles); } - function Novo() + public function Novo() { - header("Location: educar_instituicao_lst.php"); + header('Location: educar_instituicao_lst.php'); - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - $obj = new clsPmieducarInstituicao(null, $this->ref_usuario_exc, $this->pessoa_logada, $this->ref_idtlog, $this->ref_sigla_uf, str_replace("-", "", $this->cep), $this->cidade, $this->bairro, $this->logradouro, $this->numero, $this->complemento, $this->nm_responsavel, $this->ddd_telefone, $this->telefone, $this->data_cadastro, $this->data_exclusao, 1, str_replace("'", "''", $this->nm_instituicao), null, null, $this->quantidade_alunos_metro_quadrado); + $obj = new clsPmieducarInstituicao(null, $this->ref_usuario_exc, $this->pessoa_logada, $this->ref_idtlog, $this->ref_sigla_uf, str_replace('-', '', $this->cep), $this->cidade, $this->bairro, $this->logradouro, $this->numero, $this->complemento, $this->nm_responsavel, $this->ddd_telefone, $this->telefone, $this->data_cadastro, $this->data_exclusao, 1, str_replace('\'', '\'\'', $this->nm_instituicao), null, null, $this->quantidade_alunos_metro_quadrado); $obj->data_base_remanejamento = Portabilis_Date_Utils::brToPgSQL($this->data_base_remanejamento); $obj->data_base_transferencia = Portabilis_Date_Utils::brToPgSQL($this->data_base_transferencia); $obj->data_expiracao_reserva_vaga = Portabilis_Date_Utils::brToPgSQL($this->data_expiracao_reserva_vaga); @@ -362,33 +348,32 @@ function Novo() $obj->obrigar_documento_pessoa = !is_null($this->obrigar_documento_pessoa); $obj->orgao_regional = $this->orgao_regional; $obj->exigir_lancamentos_anteriores = !is_null($this->exigir_lancamentos_anteriores); + $obj->exibir_apenas_professores_alocados = !is_null($this->exibir_apenas_professores_alocados); $cod_instituicao = $cadastrou = $obj->cadastra(); if ($cadastrou) { $instituicao = new clsPmieducarInstituicao($cod_instituicao); $instituicao = $instituicao->detalhe(); - $auditoria = new clsModulesAuditoriaGeral("instituicao", $this->pessoa_logada, $cod_instituicao); + $auditoria = new clsModulesAuditoriaGeral('instituicao', $this->pessoa_logada, $cod_instituicao); $auditoria->inclusao($instituicao); $obj_altera = new alteraAtestadoParaDeclaracao(is_null($this->altera_atestado_para_declaracao) ? false : true); $obj_altera->editaMenus(); - $this->mensagem .= "Cadastro efetuado com sucesso.
"; - header("Location: educar_instituicao_lst.php"); + $this->mensagem .= 'Cadastro efetuado com sucesso.
'; + header('Location: educar_instituicao_lst.php'); die(); + return true; } - $this->mensagem = "Cadastro não realizado.
"; + $this->mensagem = 'Cadastro não realizado.
'; echo ""; + return false; } - function Editar() + public function Editar() { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj = new clsPmieducarInstituicao($this->cod_instituicao, $this->ref_usuario_exc, $this->pessoa_logada, $this->ref_idtlog, $this->ref_sigla_uf, str_replace("-", "", $this->cep), $this->cidade, $this->bairro, $this->logradouro, $this->numero, $this->complemento, $this->nm_responsavel, $this->ddd_telefone, $this->telefone, $this->data_cadastro, $this->data_exclusao, 1, str_replace("'", "''", $this->nm_instituicao), null, null, $this->quantidade_alunos_metro_quadrado); + $obj = new clsPmieducarInstituicao($this->cod_instituicao, $this->ref_usuario_exc, $this->pessoa_logada, $this->ref_idtlog, $this->ref_sigla_uf, str_replace('-', '', $this->cep), $this->cidade, $this->bairro, $this->logradouro, $this->numero, $this->complemento, $this->nm_responsavel, $this->ddd_telefone, $this->telefone, $this->data_cadastro, $this->data_exclusao, 1, str_replace('\'', '\'\'', $this->nm_instituicao), null, null, $this->quantidade_alunos_metro_quadrado); $obj->data_base_remanejamento = Portabilis_Date_Utils::brToPgSQL($this->data_base_remanejamento); $obj->data_base_transferencia = Portabilis_Date_Utils::brToPgSQL($this->data_base_transferencia); $obj->data_expiracao_reserva_vaga = Portabilis_Date_Utils::brToPgSQL($this->data_expiracao_reserva_vaga); @@ -417,56 +402,58 @@ function Editar() $obj->obrigar_documento_pessoa = !is_null($this->obrigar_documento_pessoa); $obj->orgao_regional = $this->orgao_regional; $obj->exigir_lancamentos_anteriores = !is_null($this->exigir_lancamentos_anteriores); + $obj->exibir_apenas_professores_alocados = !is_null($this->exibir_apenas_professores_alocados); $detalheAntigo = $obj->detalhe(); $editou = $obj->edita(); if ($editou) { $detalheAtual = $obj->detalhe(); - $auditoria = new clsModulesAuditoriaGeral("instituicao", $this->pessoa_logada, $this->cod_instituicao); + $auditoria = new clsModulesAuditoriaGeral('instituicao', $this->pessoa_logada, $this->cod_instituicao); $auditoria->alteracao($detalheAntigo, $detalheAtual); $obj_altera = new alteraAtestadoParaDeclaracao(is_null($this->altera_atestado_para_declaracao) ? false : true); $obj_altera->editaMenus(); - $this->mensagem .= "Edição efetuada com sucesso.
"; - header("Location: educar_instituicao_lst.php"); + $this->mensagem .= 'Edição efetuada com sucesso.
'; + header('Location: educar_instituicao_lst.php'); die(); + return true; } - $this->mensagem = "Edição não realizada.
"; + $this->mensagem = 'Edição não realizada.
'; echo ""; + return false; } - function Excluir() + public function Excluir() { - header("Location: educar_instituicao_lst.php"); - - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); + header('Location: educar_instituicao_lst.php'); $verificaEscolasVinculadas = new clsPmieducarEscola(); $listaEscolasVinculadas = $verificaEscolasVinculadas->lista(null, null, null, $this->cod_instituicao); if (is_array($listaEscolasVinculadas)) { - $this->mensagem = "Exclusão não realizada. Esta instituicão possui escolas vinculadas.
"; + $this->mensagem = 'Exclusão não realizada. Esta instituicão possui escolas vinculadas.
'; + return false; } else { $obj = new clsPmieducarInstituicao($this->cod_instituicao, $this->pessoa_logada, $this->ref_usuario_cad, $this->ref_idtlog, $this->ref_sigla_uf, $this->cep, $this->cidade, $this->bairro, $this->logradouro, $this->numero, $this->complemento, $this->nm_responsavel, $this->ddd_telefone, $this->telefone, $this->data_cadastro, $this->data_exclusao, $this->ativo); $instituicao = $obj->detalhe(); $excluiu = $obj->excluir(); if ($excluiu) { - $auditoria = new clsModulesAuditoriaGeral("instituicao", $this->pessoa_logada, $this->cod_instituicao); + $auditoria = new clsModulesAuditoriaGeral('instituicao', $this->pessoa_logada, $this->cod_instituicao); $auditoria->exclusao($instituicao); - $this->mensagem .= "Exclusão efetuada com sucesso.
"; - header("Location: educar_instituicao_lst.php"); + $this->mensagem .= 'Exclusão efetuada com sucesso.
'; + header('Location: educar_instituicao_lst.php'); die(); + return true; } - $this->mensagem = "Exclusão não realizada.
"; + $this->mensagem = 'Exclusão não realizada.
'; echo ""; + return false; } } @@ -483,25 +470,6 @@ function Excluir() ?> "; } + + $notaAlunoId = (new Avaliacao_Model_NotaAlunoDataMapper()) + ->findAll(['id'], ['matricula_id' => $this->cod_matricula])[0]->get('id'); + + (new Avaliacao_Model_NotaComponenteMediaDataMapper()) + ->updateSituation($notaAlunoId, App_Model_MatriculaSituacao::RECLASSIFICADO); + //window.location='educar_matricula_det.php?cod_matricula={$this->cod_matricula}&ref_cod_aluno={$this->ref_cod_aluno}'; echo " \ No newline at end of file + diff --git a/ieducar/intranet/educar_modulo_cad.php b/ieducar/intranet/educar_modulo_cad.php index 882d96ae44..c8468867e1 100644 --- a/ieducar/intranet/educar_modulo_cad.php +++ b/ieducar/intranet/educar_modulo_cad.php @@ -1,29 +1,5 @@ SetTitulo( "{$this->_instituicao} i-Educar - Módulo" ); + $this->SetTitulo( "{$this->_instituicao} i-Educar - Etapa" ); $this->processoAp = "584"; $this->addEstilo("localizacaoSistema"); } @@ -54,6 +30,7 @@ class indice extends clsCadastro var $ref_usuario_cad; var $nm_tipo; var $descricao; + var $num_etapas; var $num_meses; var $num_semanas; var $data_cadastro; @@ -71,19 +48,26 @@ function Inicializar() $this->cod_modulo=$_GET["cod_modulo"]; $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 584, $this->pessoa_logada, 3, "educar_modulo_lst.php" ); - - if( is_numeric( $this->cod_modulo ) ) + $obj_permissoes->permissao_cadastra( + 584, + $this->pessoa_logada, + 3, + "educar_modulo_lst.php" + ); + + if (is_numeric($this->cod_modulo)) { - $obj = new clsPmieducarModulo( $this->cod_modulo ); + $obj = new clsPmieducarModulo($this->cod_modulo); $registro = $obj->detalhe(); - if( $registro ) + if ($registro) { - foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto + // passa todos os valores obtidos no registro para atributos do objeto + foreach ($registro AS $campo => $val) { $this->$campo = $val; + } $obj_permissoes = new clsPermissoes(); - if( $obj_permissoes->permissao_excluir( 584, $this->pessoa_logada, 3 ) ) + if ($obj_permissoes->permissao_excluir( 584, $this->pessoa_logada, 3)) { $this->fexcluir = true; } @@ -91,14 +75,16 @@ function Inicializar() } } $this->url_cancelar = ($retorno == "Editar") ? "educar_modulo_det.php?cod_modulo={$registro["cod_modulo"]}" : "educar_modulo_lst.php"; - + $nomeMenu = $retorno == "Editar" ? $retorno : "Cadastrar"; $localizacao = new LocalizacaoSistema(); - $localizacao->entradaCaminhos( array( - $_SERVER['SERVER_NAME']."/intranet" => "Início", - "educar_index.php" => "Escola", - "" => "{$nomeMenu} módulo" - )); + $localizacao->entradaCaminhos( + array( + $_SERVER['SERVER_NAME']."/intranet" => "Início", + "educar_index.php" => "Escola", + "" => "{$nomeMenu} etapa" + ) + ); $this->enviaLocalizacao($localizacao->montar()); $this->nome_url_cancelar = "Cancelar"; @@ -117,42 +103,17 @@ function Gerar() $obj_permissoes = new clsPermissoes(); $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada); - // foreign keys -// if ($nivel_usuario == 1) -// { -// $opcoes = array( "" => "Selecione" ); -// if( class_exists( "clsPmieducarInstituicao" ) ) -// { -// $obj_instituicao = new clsPmieducarInstituicao(); -// $lista = $obj_instituicao->lista(null,null,null,null,null,null,null,null,null,null,null,null,null,1); -// if ( is_array( $lista ) && count( $lista ) ) -// { -// foreach ( $lista as $registro ) -// { -// $opcoes["{$registro['cod_instituicao']}"] = "{$registro['nm_instituicao']}"; -// } -// } -// } -// else -// { -// echo ""; -// $opcoes = array( "" => "Erro na geração" ); -// } -// $this->campoLista( "ref_cod_instituicao", "Instituicão", $opcoes, $this->ref_cod_instituicao); -// } -// else if ($nivel_usuario == 2) -// { -// $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada); -// $obj_usuario_det = $obj_usuario->detalhe(); -// $this->ref_cod_instituicao = $obj_usuario_det["ref_cod_instituicao"]; -// $this->campoOculto( "ref_cod_instituicao", $this->ref_cod_instituicao ); -// } - - // text - $this->campoTexto( "nm_tipo", "Módulo", $this->nm_tipo, 30, 255, true ); - $this->campoMemo( "descricao", "Descrição", $this->descricao, 60, 5, false ); - $this->campoNumero( "num_meses", "Número Meses", $this->num_meses, 2, 2, true ); - $this->campoNumero( "num_semanas", "Número Semanas", $this->num_semanas, 2, 2, true ); + $option = false; + if ($this->existeEtapaNaEscola() or $this->existeEtapaNaTurma()) + { + $option = true; + } + + $this->campoTexto( "nm_tipo", "Etapa", $this->nm_tipo, 30, 255, true ); + $this->campoMemo( "descricao", "Descrição", $this->descricao, 60, 5, false ); + $this->campoNumero( "num_etapas", "Número de etapas", $this->num_etapas, 2, 2, true, null, null, null, null, null, $option); + $this->campoNumero( "num_meses", "Número de meses", $this->num_meses, 2, 2, false ); + $this->campoNumero( "num_semanas", "Número de semanas", $this->num_semanas, 2, 2, false ); } function Novo() @@ -162,12 +123,11 @@ function Novo() @session_write_close(); $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 584, $this->pessoa_logada, 3, "educar_modulo_lst.php" ); - + $obj_permissoes->permissao_cadastra(584, $this->pessoa_logada, 3, "educar_modulo_lst.php"); - $obj = new clsPmieducarModulo( null, null, $this->pessoa_logada, $this->nm_tipo, $this->descricao, $this->num_meses, $this->num_semanas, null, null, 1, $this->ref_cod_instituicao ); + $obj = new clsPmieducarModulo( null, null, $this->pessoa_logada, $this->nm_tipo, $this->descricao, $this->num_meses, $this->num_semanas, null, null, 1, $this->ref_cod_instituicao, $this->num_etapas); $cadastrou = $obj->cadastra(); - if( $cadastrou ) + if ($cadastrou) { $modulo = new clsPmieducarModulo($cadastrou); $modulo = $modulo->detalhe(); @@ -181,7 +141,7 @@ function Novo() return true; } - $this->mensagem = "Cadastro não realizado.
"; + $this->mensagem = "Cadastro não realizado.
"; echo ""; return false; } @@ -196,25 +156,24 @@ function Editar() $moduloDetalheAntes = $moduloDetalhe->detalhe(); $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 584, $this->pessoa_logada, 3, "educar_modulo_lst.php" ); + $obj_permissoes->permissao_cadastra(584, $this->pessoa_logada, 3, "educar_modulo_lst.php"); - - $obj = new clsPmieducarModulo($this->cod_modulo, $this->pessoa_logada, null, $this->nm_tipo, $this->descricao, $this->num_meses, $this->num_semanas, null, null, 1, $this->ref_cod_instituicao ); + $obj = new clsPmieducarModulo($this->cod_modulo, $this->pessoa_logada, null, $this->nm_tipo, $this->descricao, $this->num_meses, $this->num_semanas, null, null, 1, $this->ref_cod_instituicao, $this->num_etapas ); $editou = $obj->edita(); - if( $editou ) + if ($editou) { $moduloDetalheDepois = $moduloDetalhe->detalhe(); $auditoria = new clsModulesAuditoriaGeral("modulo", $this->pessoa_logada, $this->cod_modulo); $auditoria->alteracao($moduloDetalheAntes, $moduloDetalheDepois); - $this->mensagem .= "Edição efetuada com sucesso.
"; + $this->mensagem .= "Edição efetuada com sucesso.
"; header( "Location: educar_modulo_lst.php" ); die(); return true; } - $this->mensagem = "Edição não realizada.
"; - echo ""; + $this->mensagem = "Edição não realizada.
"; + echo ""; return false; } @@ -227,25 +186,61 @@ function Excluir() $obj_permissoes = new clsPermissoes(); $obj_permissoes->permissao_excluir( 584, $this->pessoa_logada, 3, "educar_modulo_lst.php" ); - $obj = new clsPmieducarModulo($this->cod_modulo, $this->pessoa_logada, null,null,null,null,null,null,null, 0 ); $modulo = $obj->detalhe(); + + if ($this->existeEtapaNaEscola() or $this->existeEtapaNaTurma()) + { + $this->mensagem = "Exclusão não realizada.
"; + $this->url_cancelar = "educar_modulo_det.php?cod_modulo={$modulo["cod_modulo"]}"; + return false; + } + $excluiu = $obj->excluir(); - if( $excluiu ) + if ($excluiu) { $auditoria = new clsModulesAuditoriaGeral("modulo", $this->pessoa_logada, $this->cod_modulo); $auditoria->exclusao($modulo); - $this->mensagem .= "Exclusão efetuada com sucesso.
"; + $this->mensagem .= "Exclusão efetuada com sucesso.
"; header( "Location: educar_modulo_lst.php" ); die(); return true; } - $this->mensagem = "Exclusão não realizada.
"; - echo ""; + $this->mensagem = "Exclusão não realizada.
"; + echo ""; return false; } + + function existeEtapaNaEscola() + { + if (! $this->cod_modulo) + { + return false; + } + + $obj = new clsPmieducarAnoLetivoModulo($this->cod_modulo); + $result = $obj->lista(null, null, null, $this->cod_modulo); + + return !empty($result); + } + + function existeEtapaNaTurma() + { + if (! $this->cod_modulo) { + return false; + } + + $obj = new clsPmieducarTurmaModulo($this->cod_modulo); + $result = $obj->lista(null, $this->cod_modulo); + + if (! $result > 0) { + return false; + } + + return true; + } } // cria uma extensao da classe base diff --git a/ieducar/intranet/educar_modulo_det.php b/ieducar/intranet/educar_modulo_det.php index 363a452194..cb15273de5 100644 --- a/ieducar/intranet/educar_modulo_det.php +++ b/ieducar/intranet/educar_modulo_det.php @@ -1,39 +1,15 @@ SetTitulo( "{$this->_instituicao} i-Educar - Módulo" ); + $this->SetTitulo("{$this->_instituicao} i-Educar - Etapa"); $this->processoAp = "584"; $this->addEstilo("localizacaoSistema"); } @@ -53,6 +29,7 @@ class indice extends clsDetalhe var $ref_usuario_cad; var $nm_tipo; var $descricao; + var $num_etapas; var $num_meses; var $num_semanas; var $data_cadastro; @@ -66,17 +43,16 @@ function Gerar() $this->pessoa_logada = $_SESSION['id_pessoa']; session_write_close(); - $this->titulo = "Módulo - Detalhe"; + $this->titulo = "Etapa - Detalhe"; - $this->cod_modulo=$_GET["cod_modulo"]; - $tmp_obj = new clsPmieducarModulo( $this->cod_modulo ); + $tmp_obj = new clsPmieducarModulo($this->cod_modulo); $registro = $tmp_obj->detalhe(); - if( ! $registro ) + if (! $registro) { - header( "location: educar_modulo_lst.php" ); + header("location: educar_modulo_lst.php"); die(); } @@ -85,40 +61,67 @@ function Gerar() $obj_instituicao = new clsPmieducarInstituicao($registro["ref_cod_instituicao"]); $obj_instituicao_det = $obj_instituicao->detalhe(); $registro["ref_cod_instituicao"] = $obj_instituicao_det['nm_instituicao']; - } - else - { - $cod_instituicao = "Erro na geração"; - echo ""; + } else { + $cod_instituicao = "Erro na geração"; + echo ""; } $obj_permissao = new clsPermissoes(); $nivel_usuario = $obj_permissao->nivel_acesso($this->pessoa_logada); if ($nivel_usuario == 1) { - if( $registro["ref_cod_instituicao"] ) + if ($registro["ref_cod_instituicao"]) { - $this->addDetalhe( array( "Instituição", "{$registro["ref_cod_instituicao"]}") ); + $this->addDetalhe( + array( + "Instituição", + "{$registro["ref_cod_instituicao"]}" + ) + ); } } - if( $registro["nm_tipo"] ) + if ($registro["nm_tipo"]) { - $this->addDetalhe( array( "Módulo", "{$registro["nm_tipo"]}") ); + $this->addDetalhe( + array("Etapa", + "{$registro["nm_tipo"]}" + ) + ); } - if( $registro["descricao"] ) + if ($registro["descricao"]) { - $this->addDetalhe( array( "Descrição", "{$registro["descricao"]}") ); + $this->addDetalhe( + array( + "Descrição", + "{$registro["descricao"]}" + ) + ); } - if( $registro["num_meses"] ) + $this->addDetalhe( + array( + "Número de etapas", + "{$registro["num_etapas"]}" + ) + ); + if ($registro["num_meses"]) { - $this->addDetalhe( array( "Número Meses", "{$registro["num_meses"]}") ); + $this->addDetalhe( + array( + "Número de meses", + "{$registro["num_meses"]}" + ) + ); } - if( $registro["num_semanas"] ) + if ($registro["num_semanas"]) { - $this->addDetalhe( array( "Número Semanas", "{$registro["num_semanas"]}") ); + $this->addDetalhe( + array( + "Número de semanas", + "{$registro["num_semanas"]}" + ) + ); } - - if( $obj_permissao->permissao_cadastra( 584, $this->pessoa_logada, 3 ) ) + if ($obj_permissao->permissao_cadastra(584, $this->pessoa_logada, 3)) { $this->url_novo = "educar_modulo_cad.php"; $this->url_editar = "educar_modulo_cad.php?cod_modulo={$registro["cod_modulo"]}"; @@ -128,11 +131,11 @@ function Gerar() $this->largura = "100%"; $localizacao = new LocalizacaoSistema(); - $localizacao->entradaCaminhos( array( - $_SERVER['SERVER_NAME']."/intranet" => "Início", + $localizacao->entradaCaminhos(array( + $_SERVER['SERVER_NAME']."/intranet" => "Início", "educar_index.php" => "Escola", - "" => "Detalhe do módulo" - )); + "" => "Detalhe da etapa" + )); $this->enviaLocalizacao($localizacao->montar()); } } @@ -142,7 +145,7 @@ function Gerar() // cria o conteudo $miolo = new indice(); // adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); +$pagina->addForm($miolo); // gera o html $pagina->MakeAll(); ?> \ No newline at end of file diff --git a/ieducar/intranet/educar_modulo_lst.php b/ieducar/intranet/educar_modulo_lst.php index ecbfd75633..e855788b61 100644 --- a/ieducar/intranet/educar_modulo_lst.php +++ b/ieducar/intranet/educar_modulo_lst.php @@ -1,39 +1,15 @@ SetTitulo( "{$this->_instituicao} i-Educar - Módulo" ); + $this->SetTitulo("{$this->_instituicao} i-Educar - Etapa"); $this->processoAp = "584"; $this->addEstilo("localizacaoSistema"); } @@ -74,6 +50,7 @@ class indice extends clsListagem var $ref_usuario_cad; var $nm_tipo; var $descricao; + var $num_etapas; var $num_meses; var $num_semanas; var $data_cadastro; @@ -87,70 +64,40 @@ function Gerar() $this->pessoa_logada = $_SESSION['id_pessoa']; session_write_close(); - $this->titulo = "Módulo - Listagem"; - - foreach( $_GET AS $var => $val ) // passa todos os valores obtidos no GET para atributos do objeto - $this->$var = ( $val === "" ) ? null: $val; + $this->titulo = "Etapa - Listagem"; - + // passa todos os valores obtidos no GET para atributos do objeto + foreach ($_GET AS $var => $val) { + $this->$var = ($val === "") ? null : $val; + } $lista_busca = array( - "Módulo", - "Número Meses" + "Etapa", + "Número de meses" ); $obj_permissoes = new clsPermissoes(); $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada); - if ($nivel_usuario == 1) - $lista_busca[] = "Instituição"; + if ($nivel_usuario == 1) { + $lista_busca[] = "Instituição"; + } $this->addCabecalhos($lista_busca); - // Filtros de Foreign Keys - include("include/pmieducar/educar_campo_lista.php"); + include ("include/pmieducar/educar_campo_lista.php"); - // Filtros de Foreign Keys -/* if ($nivel_usuario == 1) - { - $opcoes = array( "" => "Selecione" ); - if( class_exists( "clsPmieducarInstituicao" ) ) - { - $obj_instituicao = new clsPmieducarInstituicao(); - $lista = $obj_instituicao->lista(null,null,null,null,null,null,null,null,null,null,null,null,null,1); - if ( is_array( $lista ) && count( $lista ) ) - { - foreach ( $lista as $registro ) - { - $opcoes["{$registro['cod_instituicao']}"] = "{$registro['nm_instituicao']}"; - } - } - } - else - { - echo ""; - $opcoes = array( "" => "Erro na geração" ); - } - $this->campoLista( "ref_cod_instituicao", "Instituicão", $opcoes, $this->ref_cod_instituicao, null,null,null,null,null,false ); - } - else if ($nivel_usuario == 2) - { - $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada); - $obj_usuario_det = $obj_usuario->detalhe(); - $this->ref_cod_instituicao = $obj_usuario_det["ref_cod_instituicao"]; - } -*/ // outros Filtros - $this->campoTexto( "nm_tipo", "Módulo", $this->nm_tipo, 30, 255, false ); - $this->campoNumero( "num_meses", "Número Meses", $this->num_meses, 2, 2, false ); + $this->campoTexto("nm_tipo", "Etapa", $this->nm_tipo, 30, 255, false); + $this->campoNumero("num_meses", "Número de meses", $this->num_meses, 2, 2, false); // Paginador $this->limite = 20; - $this->offset = ( $_GET["pagina_{$this->nome}"] ) ? $_GET["pagina_{$this->nome}"]*$this->limite-$this->limite: 0; + $this->offset = ($_GET["pagina_{$this->nome}"]) ? $_GET["pagina_{$this->nome}"]*$this->limite-$this->limite: 0; $obj_modulo = new clsPmieducarModulo(); - $obj_modulo->setOrderby( "nm_tipo ASC" ); - $obj_modulo->setLimite( $this->limite, $this->offset ); + $obj_modulo->setOrderby("nm_tipo ASC"); + $obj_modulo->setLimite($this->limite, $this->offset); $lista = $obj_modulo->lista( null, @@ -171,36 +118,35 @@ function Gerar() $total = $obj_modulo->_total; // monta a lista - if( is_array( $lista ) && count( $lista ) ) + if(is_array($lista) && count($lista)) { - foreach ( $lista AS $registro ) + foreach ($lista AS $registro) { // pega detalhes de foreign_keys - if( class_exists( "clsPmieducarInstituicao" ) ) + if (class_exists("clsPmieducarInstituicao")) { - $obj_cod_instituicao = new clsPmieducarInstituicao( $registro["ref_cod_instituicao"] ); + $obj_cod_instituicao = new clsPmieducarInstituicao($registro["ref_cod_instituicao"]); $obj_cod_instituicao_det = $obj_cod_instituicao->detalhe(); $registro["ref_cod_instituicao"] = $obj_cod_instituicao_det["nm_instituicao"]; - } - else - { - $registro["ref_cod_instituicao"] = "Erro na geração"; - echo ""; + } else { + $registro["ref_cod_instituicao"] = "Erro na geração"; + echo ""; } $lista_busca = array( "{$registro["nm_tipo"]}", "{$registro["num_meses"]}" ); - if ($nivel_usuario == 1) + if ($nivel_usuario == 1) { $lista_busca[] = "{$registro["ref_cod_instituicao"]}"; + } $this->addLinhas($lista_busca); } } - $this->addPaginador2( "educar_modulo_lst.php", $total, $_GET, $this->nome, $this->limite ); + $this->addPaginador2("educar_modulo_lst.php", $total, $_GET, $this->nome, $this->limite); - if( $obj_permissoes->permissao_cadastra( 584, $this->pessoa_logada, 3 ) ) + if($obj_permissoes->permissao_cadastra(584, $this->pessoa_logada, 3)) { $this->acao = "go(\"educar_modulo_cad.php\")"; $this->nome_acao = "Novo"; @@ -209,20 +155,23 @@ function Gerar() $this->largura = "100%"; $localizacao = new LocalizacaoSistema(); - $localizacao->entradaCaminhos( array( - $_SERVER['SERVER_NAME']."/intranet" => "Início", - "educar_index.php" => "Escola", - "" => "Listagem de módulos" - )); + $localizacao->entradaCaminhos( + array( + $_SERVER['SERVER_NAME']."/intranet" => "Início", + "educar_index.php" => "Escola", + "" => "Listagem de etapas" + ) + ); $this->enviaLocalizacao($localizacao->montar()); } } + // cria uma extensao da classe base $pagina = new clsIndexBase(); // cria o conteudo $miolo = new indice(); // adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); +$pagina->addForm($miolo); // gera o html $pagina->MakeAll(); ?> \ No newline at end of file diff --git a/ieducar/intranet/educar_servidor_vinculo_turma_cad.php b/ieducar/intranet/educar_servidor_vinculo_turma_cad.php index b6df0c4f2e..bc64ee467e 100644 --- a/ieducar/intranet/educar_servidor_vinculo_turma_cad.php +++ b/ieducar/intranet/educar_servidor_vinculo_turma_cad.php @@ -154,7 +154,7 @@ public function Gerar() $this->inputsHelper()->checkbox('permite_lancar_faltas_componente', $options); $this->inputsHelper()->checkbox('selecionar_todos', ['label' => 'Selecionar/remover todos']); - $this->inputsHelper()->multipleSearchComponenteCurricular(null, ['label' => 'Componentes lecionados', 'required' => true]); + $this->inputsHelper()->multipleSearchComponenteCurricular(null, ['label' => 'Componentes lecionados', 'required' => true], ['searchForArea' => true]); $scripts = [ '/modules/Cadastro/Assets/Javascripts/ServidorVinculoTurma.js' diff --git a/ieducar/intranet/educar_transferencia_solicitacao_cad.php b/ieducar/intranet/educar_transferencia_solicitacao_cad.php index a46e71c26d..16fe0cd246 100644 --- a/ieducar/intranet/educar_transferencia_solicitacao_cad.php +++ b/ieducar/intranet/educar_transferencia_solicitacao_cad.php @@ -24,11 +24,16 @@ * 02111-1307, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -require_once ("include/clsBase.inc.php"); -require_once ("include/clsCadastro.inc.php"); -require_once ("include/clsBanco.inc.php"); -require_once( "include/pmieducar/geral.inc.php" ); +require_once 'include/clsBase.inc.php'; +require_once 'include/clsCadastro.inc.php'; +require_once 'include/clsBanco.inc.php'; +require_once 'include/pmieducar/geral.inc.php'; require_once 'lib/Portabilis/Date/Utils.php'; +require_once 'modules/Avaliacao/Model/NotaAlunoDataMapper.php'; +require_once 'modules/Avaliacao/Model/NotaComponenteMediaDataMapper.php'; +require_once 'lib/App/Model/MatriculaSituacao.php'; +require_once 'modules/Avaliacao/Views/PromocaoApiController.php'; +require_once 'lib/CoreExt/Controller/Request.php'; class clsIndexBase extends clsBase { @@ -134,6 +139,19 @@ function reabrirMatricula($matriculaId) { $detEnturmacao = $detEnturmacao['data_enturmacao']; $enturmacao->data_enturmacao = $detEnturmacao; $enturmacao->edita(); + + $instituicaoId = (new clsBanco)->unicoCampo("select cod_instituicao from pmieducar.instituicao where ativo = 1 order by cod_instituicao asc limit 1;"); + + $fakeRequest = new CoreExt_Controller_Request(['data' => [ + 'oper' => 'post', + 'resource' => 'promocao', + 'instituicao_id' => $instituicaoId, + 'matricula_id' => $matriculaId + ]]); + + $promocaoApi = new PromocaoApiController(); + $promocaoApi->setRequest($fakeRequest); + $promocaoApi->Gerar(); } } @@ -297,10 +315,16 @@ function Novo() $det_matricula = $obj->detalhe(); $obj->data_cancel = $this->data_cancel; $obj->edita(); + + $notaAlunoId = (new Avaliacao_Model_NotaAlunoDataMapper()) + ->findAll(['id'], ['matricula_id' => $obj->cod_matricula])[0]->get('id'); + + (new Avaliacao_Model_NotaComponenteMediaDataMapper()) + ->updateSituation($notaAlunoId, App_Model_MatriculaSituacao::TRANSFERIDO); + $this->mensagem .= "Cadastro efetuado com sucesso.
"; header( "Location: educar_matricula_det.php?cod_matricula={$this->ref_cod_matricula}" ); die(); - return true; } // } // else diff --git a/ieducar/intranet/educar_turma_cad.php b/ieducar/intranet/educar_turma_cad.php index a5ab4fdf3f..49fbf6dab4 100644 --- a/ieducar/intranet/educar_turma_cad.php +++ b/ieducar/intranet/educar_turma_cad.php @@ -110,7 +110,7 @@ class indice extends clsCadastro var $ref_cod_serie_mult; // Inclui módulo - var $turma_modulo; + var $turma_modulo = []; var $incluir_modulo; var $excluir_modulo; @@ -138,6 +138,8 @@ class indice extends clsCadastro var $etapas_utilizadas; var $definirComponentePorEtapa; + var $modulos = []; + var $retorno; var $dias_da_semana = array( @@ -447,47 +449,52 @@ function Gerar() $this->montaListaComponentesSerieEscola(); + $objTemp = new clsPmieducarModulo(); + $objTemp->setOrderby('nm_tipo ASC'); - $opcoesCampoModulo = array('' => 'Selecione'); - if (class_exists("clsPmieducarModulo")) { - $objTemp = new clsPmieducarModulo(); - $objTemp->setOrderby('nm_tipo ASC'); + $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, 1, $ref_cod_instituicao); - $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, 1, $ref_cod_instituicao); + $opcoesCampoModulo = []; - if (is_array($lista) && count($lista)) { - foreach ($lista as $registro) { - $opcoesCampoModulo[$registro['cod_modulo']] = $registro['nm_tipo']; - } + if (is_array($lista) && count($lista)) { + $this->modulos = $lista; + foreach ($lista as $registro) { + $opcoesCampoModulo[$registro['cod_modulo']] = sprintf('%s - %d etapa(s)', $registro['nm_tipo'], $registro['num_etapas']); } } - else { - $opcoesCampoModulo = array('' => 'Erro na geração'); - } - if (is_numeric($this->ano) && is_numeric($this->ref_cod_escola) && is_numeric($this->cod_turma)) { - $objAno = new clsPmieducarAnoLetivoModulo(); - $objAno->setOrderBy('sequencial ASC'); + $registros = []; + if (is_numeric($this->cod_turma)) { $objTurma = new clsPmieducarTurmaModulo(); $objTurma->setOrderBy('sequencial ASC'); - if (is_array($objTurma->lista($this->cod_turma))) { - $registros = $objTurma->lista($this->cod_turma); - }else{ - $registros = $objAno->lista($this->ano, $this->ref_cod_escola); - } + $registros = $objTurma->lista($this->cod_turma); + } + + if ( + empty($registros) + && is_numeric($this->ano) + && is_numeric($this->ref_cod_escola) + ) { + $objAno = new clsPmieducarAnoLetivoModulo(); + $objAno->setOrderBy('sequencial ASC'); + + $registros = $objAno->lista($this->ano, $this->ref_cod_escola); } if ($this->padrao_ano_escolar != 1) { $qtd_registros = 0; + $moduloSelecionado = 0; + if( $registros ) { + $moduloSelecionado = $registros[0]['ref_cod_modulo']; + foreach ( $registros AS $campo ) { - $this->turma_modulo[$qtd_registros][] = $campo["ref_cod_modulo"]; $this->turma_modulo[$qtd_registros][] = dataFromPgToBr($campo['data_inicio']); $this->turma_modulo[$qtd_registros][] = dataFromPgToBr($campo['data_fim']); $this->turma_modulo[$qtd_registros][] = $campo["dias_letivos"]; @@ -496,9 +503,24 @@ function Gerar() } } - $this->campoTabelaInicio("turma_modulo","Módulos da turma",array("Módulo","Data inicial","Data final", "Dias Letivos"),$this->turma_modulo); + $this->campoQuebra2(); - $this->campoLista('ref_cod_modulo', 'Módulo', $opcoesCampoModulo, $this->ref_cod_modulo, NULL, NULL, NULL, NULL, NULL, FALSE); + $this->campoRotulo('etapas_cabecalho', 'Etapas da turma'); + + $this->campoLista( + 'ref_cod_modulo', + 'Etapa', + $opcoesCampoModulo, + $moduloSelecionado, + null, + null, + null, + null, + null, + true + ); + + $this->campoTabelaInicio("turma_modulo", "Etapas", array("Data inicial", "Data final", "Dias Letivos"), $this->turma_modulo); $this->campoData('data_inicio', 'Data Início', $this->data_inicio, FALSE); $this->campoData('data_fim', 'Data Fim', $this->data_fim, FALSE); @@ -596,8 +618,10 @@ function Gerar() $this->inputsHelper()->booleanSelect('turma_mais_educacao', $options); $scripts = array( - '/modules/Cadastro/Assets/Javascripts/Turma.js' + '/modules/Cadastro/Assets/Javascripts/Turma.js', + '/intranet/scripts/etapas.js' ); + Portabilis_View_Helper_Application::loadJavascript($this, $scripts); $styles = array ('/modules/Cadastro/Assets/Stylesheets/Turma.css'); @@ -1027,9 +1051,11 @@ function atualizaModulos() function montaModulos() { - foreach ($this->ref_cod_modulo as $key => $modulo) { - $turmaModulo[$key]['sequencial'] = $key+1; - $turmaModulo[$key]['ref_cod_modulo'] = $this->ref_cod_modulo[$key]; + // itera pelo campo `data_inicio`, um dos campos referentes às etapas, + // para definir sequencialmente os dados de cada etapa + foreach ($this->data_inicio as $key => $modulo) { + $turmaModulo[$key]['sequencial'] = $key + 1; + $turmaModulo[$key]['ref_cod_modulo'] = $this->ref_cod_modulo; $turmaModulo[$key]['data_inicio'] = $this->data_inicio[$key]; $turmaModulo[$key]['data_fim'] = $this->data_fim[$key]; $turmaModulo[$key]['dias_letivos'] = $this->dias_letivos[$key]; @@ -1041,7 +1067,7 @@ function montaModulos() function cadastraModulo($modulo) { $modulo['data_inicio'] = dataToBanco($modulo['data_inicio']); - $modulo['data_fim'] = dataToBanco($modulo['data_fim']); + $modulo['data_fim'] = dataToBanco($modulo['data_fim']); $objModulo = new clsPmieducarTurmaModulo($this->cod_turma); $objModulo->ref_cod_modulo = $modulo['ref_cod_modulo']; @@ -1062,14 +1088,13 @@ function cadastraModulo($modulo) function verificaModulos() { $cursoPadraoAnoEscolar = $this->padrao_ano_escolar == 1; - $possuiModulosInformados = (count($this->ref_cod_modulo) > 1 || $this->ref_cod_modulo[0] != ''); + $possuiModulosInformados = (count($this->data_inicio) > 1 || $this->data_inicio[0] != ''); if ($cursoPadraoAnoEscolar) { return true; } if (!$possuiModulosInformados) { - echo ''; $this->mensagem = 'Edição não realizada.'; return false; } @@ -1221,6 +1246,20 @@ protected function canCreateTurma($escolaId, $serieId, $turnoId) { return true; } + + public function gerarJsonDosModulos() + { + $retorno = []; + + foreach ($this->modulos as $modulo) { + $retorno[$modulo['cod_modulo']] = [ + 'label' => $modulo['nm_tipo'], + 'etapas' => (int)$modulo['num_etapas'] + ]; + } + + return json_encode($retorno); + } } // Instancia objeto de página @@ -1236,6 +1275,8 @@ protected function canCreateTurma($escolaId, $serieId, $turnoId) { $pagina->MakeAll(); ?> "); } diff --git a/ieducar/intranet/include/clsBase.inc.php b/ieducar/intranet/include/clsBase.inc.php index 80ba291b6e..748e719ff4 100644 --- a/ieducar/intranet/include/clsBase.inc.php +++ b/ieducar/intranet/include/clsBase.inc.php @@ -50,7 +50,6 @@ require_once 'Portabilis/Utils/User.php'; require_once 'Portabilis/String/Utils.php'; -require_once 'modules/Error/Mailers/NotificationMailer.php'; require_once 'Portabilis/Assets/Version.php'; require_once 'include/pessoa/clsCadastroFisicaFoto.inc.php'; @@ -894,7 +893,6 @@ function MakeAll() @session_write_close(); error_log("Erro inesperado (pego em clsBase): " . $e->getMessage()); - (new NotificationMailer)->unexpectedError($e->getMessage()); die(""); } diff --git a/ieducar/intranet/include/clsCadastro.inc.php b/ieducar/intranet/include/clsCadastro.inc.php index 7d95d02041..6b2d27a272 100644 --- a/ieducar/intranet/include/clsCadastro.inc.php +++ b/ieducar/intranet/include/clsCadastro.inc.php @@ -311,7 +311,8 @@ function RenderHTML() } $retorno .= "
\n\n"; - $titulo = $this->titulo ? $this->titulo : "{$this->tipoacao} {$this->titulo_aplication}"; + $applicationTitle = $this->titulo_aplication ?? ''; + $titulo = isset($this->titulo) ? $this->titulo : "{$this->tipoacao} {$applicationTitle}"; /** * Adiciona os botoes de help para a pagina atual @@ -665,26 +666,26 @@ function setColor(color) $retorno .= "\n}\n"; $retorno .= "\n"; - if ($this->acao_enviar && $this->botao_enviar) { + if (!empty($this->acao_enviar) && !empty($this->botao_enviar)) { $retorno .= "  "; } - if ($this->fexcluir) { + if (!empty($this->fexcluir)) { $retorno .= "  "; } - if ($this->bot_alt) { + if (!empty($this->bot_alt)) { $retorno .= "  "; } - if ($this->excluir_Img) { + if (!empty($this->excluir_Img)) { $retorno .= "  "; } - if ($this->acao) { + if (!empty($this->acao)) { $retorno .= "  "; } - if ($this->url_cancelar || $this->script_cancelar) { + if (!empty($this->url_cancelar) || !empty($this->script_cancelar)) { $retorno .= "  "; } - if ($this->url_copiar_enturmacoes) { + if (!empty($this->url_copiar_enturmacoes)) { $retorno .= "  "; } @@ -715,11 +716,11 @@ function setColor(color) $retorno .= "
\n
\n\n"; $retorno .= "\n"; - if ($this->bannerClose) { + if (!empty($this->bannerClose)) { $retorno .= ""; } - if ($this->executa_script) { + if (!empty($this->executa_script)) { $retorno .= ""; } diff --git a/ieducar/intranet/include/clsCampos.inc.php b/ieducar/intranet/include/clsCampos.inc.php index 6d243a6ac7..57ccbad003 100644 --- a/ieducar/intranet/include/clsCampos.inc.php +++ b/ieducar/intranet/include/clsCampos.inc.php @@ -1751,7 +1751,7 @@ classe = (classe == \'formmdtd\')? \'formlttd tr_\' + This.nome : \'formmdtd tr_ $retorno .= "$componente[3]{$explicacao}\n"; } else { - if ($componente[10] && ($componente[0] == 'textoDuploInv' + if (isset($componente[10]) && ($componente[0] == 'textoDuploInv' || $componente[0] == 'textoInv')) { $name = " name='tr_{$componente[10]}' "; } else { diff --git a/ieducar/intranet/include/clsListagem.inc.php b/ieducar/intranet/include/clsListagem.inc.php index e65675dd8c..b7643a0a64 100644 --- a/ieducar/intranet/include/clsListagem.inc.php +++ b/ieducar/intranet/include/clsListagem.inc.php @@ -553,31 +553,35 @@ function RenderHTML() // Lista if (empty($this->linhas)) { - $retorno .= " - - Não há informação para ser apresentada - "; + $retorno .= "Não há informação para ser apresentada"; } else { reset($this->linhas); foreach ($this->linhas as $i => $linha) { $classe = ($i % 2) ? 'formmdtd' : 'formlttd'; - $retorno .= " - "; + $retornoTmp = ''; if (is_array($linha)) { + if ( + !empty($linha['tipo']) + && !empty($linha['conteudo']) + && $linha['tipo'] === 'html-puro' + ) { + $retorno .= $linha['conteudo']; + continue; + } + reset($linha); if (!empty($this->colunas)) { - reset( $this->colunas ); + reset($this->colunas); } foreach ($linha as $i => $celula) { if (!empty( $this->colunas)) { $fmt = current($this->colunas); - } - else { + } else { $fmt = alTopLeft; } @@ -585,17 +589,13 @@ function RenderHTML() $celula = str_replace("", "", $celula); } - $retorno .= " - $celula"; + $retornoTmp .= "$celula"; } - } - else { - $retorno .= " - $linha"; + } else { + $retornoTmp .= "$linha"; } - $retorno .= " - "; + $retorno .= '' . $retornoTmp . ''; } } @@ -732,7 +732,7 @@ function RenderHTML() if(isset($this->acao_imprimir) && $this->acao_imprimir) { $botao = "   "; } - if ($this->acao && $this->show_botao_novo) { + if (!empty($this->acao) && $this->show_botao_novo) { $retorno .= " $botao diff --git a/ieducar/intranet/include/modules/clsModulesAuditoriaGeral.inc.php b/ieducar/intranet/include/modules/clsModulesAuditoriaGeral.inc.php index 275af167f7..70171e29c4 100644 --- a/ieducar/intranet/include/modules/clsModulesAuditoriaGeral.inc.php +++ b/ieducar/intranet/include/modules/clsModulesAuditoriaGeral.inc.php @@ -145,17 +145,6 @@ function keysComValuesIguais($array1, $array2) { } function insereAuditoria($operacao, $valorAntigo, $valorNovo) { - if ($operacao == self::OPERACAO_ALTERACAO) { - $keysEmComum = array_intersect_key($valorAntigo, $valorNovo); - - $valorAntigo = $this->removeKeysDiferentes($valorAntigo, $keysEmComum); - $valorNovo = $this->removeKeysDiferentes($valorNovo, $keysEmComum); - - $keysMesmoValor = $this->keysComValuesIguais($valorAntigo, $valorNovo); - - $valorAntigo = $this->removeKeysIguais($valorAntigo, $keysMesmoValor); - $valorNovo = $this->removeKeysIguais($valorNovo, $keysMesmoValor); - } if (!$valorAntigo && !$valorNovo) return; diff --git a/ieducar/intranet/include/pmieducar/clsPermissoes.inc.php b/ieducar/intranet/include/pmieducar/clsPermissoes.inc.php index 22b3c71176..f73392d02b 100644 --- a/ieducar/intranet/include/pmieducar/clsPermissoes.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPermissoes.inc.php @@ -260,10 +260,10 @@ function getEscola($int_idpes_usuario) $detalhe_usuario = $obj_usuario->detalhe(); if ($detalhe_usuario) { - return $detalhe_usuario['ref_cod_escola']; + return $detalhe_usuario['ref_cod_escola'] ?? false; } - return FALSE; + return false; } /** diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarAnoLetivoModulo.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarAnoLetivoModulo.inc.php index 06d13cd62c..e783c191dc 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarAnoLetivoModulo.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarAnoLetivoModulo.inc.php @@ -1,196 +1,151 @@ _schema = "pmieducar."; + + $this->_schema = 'pmieducar.'; $this->_tabela = "{$this->_schema}ano_letivo_modulo"; - $this->_campos_lista = $this->_todos_campos = "ref_ano, ref_ref_cod_escola, sequencial, ref_cod_modulo, data_inicio, data_fim, dias_letivos"; - - if( is_numeric( $ref_cod_modulo ) ) - { - if( class_exists( "clsPmieducarModulo" ) ) - { - $tmp_obj = new clsPmieducarModulo( $ref_cod_modulo ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { + $this->_campos_lista = $this->_todos_campos = 'ref_ano, ref_ref_cod_escola, sequencial, ref_cod_modulo, data_inicio, data_fim, dias_letivos'; + + if (is_numeric($ref_cod_modulo)) { + if (class_exists('clsPmieducarModulo')) { + $tmp_obj = new clsPmieducarModulo($ref_cod_modulo); + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { $this->ref_cod_modulo = $ref_cod_modulo; } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { + } elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { $this->ref_cod_modulo = $ref_cod_modulo; } } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.modulo WHERE cod_modulo = '{$ref_cod_modulo}'" ) ) - { + } else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.modulo WHERE cod_modulo = '{$ref_cod_modulo}'")) { $this->ref_cod_modulo = $ref_cod_modulo; } } } - if( is_numeric( $ref_ref_cod_escola ) && is_numeric( $ref_ano ) ) - { - if( class_exists( "clsPmieducarEscolaAnoLetivo" ) ) - { - $tmp_obj = new clsPmieducarEscolaAnoLetivo( $ref_ref_cod_escola, $ref_ano ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { + + if (is_numeric($ref_ref_cod_escola) && is_numeric($ref_ano)) { + if (class_exists('clsPmieducarEscolaAnoLetivo')) { + $tmp_obj = new clsPmieducarEscolaAnoLetivo($ref_ref_cod_escola, $ref_ano); + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { $this->ref_ref_cod_escola = $ref_ref_cod_escola; $this->ref_ano = $ref_ano; } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { + } elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { $this->ref_ref_cod_escola = $ref_ref_cod_escola; $this->ref_ano = $ref_ano; } } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.escola_ano_letivo WHERE ref_cod_escola = '{$ref_ref_cod_escola}' AND ano = '{$ref_ano}'" ) ) - { + } else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.escola_ano_letivo WHERE ref_cod_escola = '{$ref_ref_cod_escola}' AND ano = '{$ref_ano}'")) { $this->ref_ref_cod_escola = $ref_ref_cod_escola; $this->ref_ano = $ref_ano; } } } - - if( is_numeric( $sequencial ) ) - { + if (is_numeric($sequencial)) { $this->sequencial = $sequencial; } - if( is_string( $data_inicio ) ) - { + + if (is_string($data_inicio)) { $this->data_inicio = $data_inicio; } - if( is_string( $data_fim ) ) - { + + if (is_string($data_fim)) { $this->data_fim = $data_fim; } - if( is_numeric( $dias_letivos ) ) - { + + if (is_numeric($dias_letivos)) { $this->dias_letivos = $dias_letivos; } - } /** @@ -198,77 +153,84 @@ function __construct( $ref_ano = null, $ref_ref_cod_escola = null, $sequencial = * * @return bool */ - function cadastra() + public function cadastra() { - if( is_numeric( $this->ref_ano ) && is_numeric( $this->ref_ref_cod_escola ) && is_numeric( $this->sequencial ) && is_numeric( $this->ref_cod_modulo ) && is_string( $this->data_inicio ) && is_string( $this->data_fim) && is_numeric($this->dias_letivos) ) - { + if ( + is_numeric($this->ref_ano) + && is_numeric($this->ref_ref_cod_escola) + && is_numeric($this->sequencial) + && is_numeric($this->ref_cod_modulo) + && is_string($this->data_inicio) + && is_string($this->data_fim) + && is_numeric($this->dias_letivos) + ) { $db = new clsBanco(); - $campos = ""; - $valores = ""; - $gruda = ""; + $campos = []; + $valores = []; + + if (is_numeric($this->ref_ano)) { + $campos[] = "ref_ano"; + $valores[] = "'{$this->ref_ano}'"; + } - if( is_numeric( $this->ref_ano ) ) - { - $campos .= "{$gruda}ref_ano"; - $valores .= "{$gruda}'{$this->ref_ano}'"; - $gruda = ", "; + if (is_numeric($this->ref_ref_cod_escola)) { + $campos[] = "ref_ref_cod_escola"; + $valores[] = "'{$this->ref_ref_cod_escola}'"; } - if( is_numeric( $this->ref_ref_cod_escola ) ) - { - $campos .= "{$gruda}ref_ref_cod_escola"; - $valores .= "{$gruda}'{$this->ref_ref_cod_escola}'"; - $gruda = ", "; + + if (is_numeric($this->sequencial)) { + $campos[] = "sequencial"; + $valores[] = "'{$this->sequencial}'"; } - if( is_numeric( $this->sequencial ) ) - { - $campos .= "{$gruda}sequencial"; - $valores .= "{$gruda}'{$this->sequencial}'"; - $gruda = ", "; + + if (is_numeric($this->ref_cod_modulo)) { + $campos[] = "ref_cod_modulo"; + $valores[] = "'{$this->ref_cod_modulo}'"; } - if( is_numeric( $this->ref_cod_modulo ) ) - { - $campos .= "{$gruda}ref_cod_modulo"; - $valores .= "{$gruda}'{$this->ref_cod_modulo}'"; - $gruda = ", "; + + if (is_string($this->data_inicio)) { + $campos[] = "data_inicio"; + $valores[] = "'{$this->data_inicio}'"; } - if( is_string( $this->data_inicio ) ) - { - $campos .= "{$gruda}data_inicio"; - $valores .= "{$gruda}'{$this->data_inicio}'"; - $gruda = ", "; + + if (is_string($this->data_fim)) { + $campos[] = "data_fim"; + $valores[] = "'{$this->data_fim}'"; } - if( is_string( $this->data_fim ) ) - { - $campos .= "{$gruda}data_fim"; - $valores .= "{$gruda}'{$this->data_fim}'"; - $gruda = ", "; + + if (is_numeric($this->dias_letivos)) { + $campos[] = "dias_letivos"; + $valores[] = "'{$this->dias_letivos}'"; } - if( is_numeric( $this->dias_letivos ) ) - { - $campos .= "{$gruda}dias_letivos"; - $valores .= "{$gruda}'{$this->dias_letivos}'"; - $gruda = ", "; + + // ativa escolaAnoLetivo se estiver desativado + // (quando o escolaAnoLetivo é 'excluido' o registro não é removido) + $escolaAnoLetivo = new clsPmieducarEscolaAnoLetivo( + $this->ref_ref_cod_escola, + $this->ref_ano, + null, + $_SESSION['id_pessoa'], + null, + null, + null, + 1 + ); + + $escolaAnoLetivoDetalhe = $escolaAnoLetivo->detalhe(); + + if (isset($escolaAnoLetivoDetalhe['ativo']) and $escolaAnoLetivoDetalhe['ativo'] != '1') { + $escolaAnoLetivo->edita(); } - // ativa escolaAnoLetivo se estiver desativado - // (quando o escolaAnoLetivo é 'excluido' o registro não é removido) - $escolaAnoLetivo = new clsPmieducarEscolaAnoLetivo($this->ref_ref_cod_escola, - $this->ref_ano, - null, - $_SESSION['id_pessoa'], - null, - null, - null, - 1); - $escolaAnoLetivoDetalhe = $escolaAnoLetivo->detalhe(); - - if (isset($escolaAnoLetivoDetalhe['ativo']) and $escolaAnoLetivoDetalhe['ativo'] != '1') - $escolaAnoLetivo->edita(); - - $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" ); + $campos = join(', ', $campos); + $valores = join(', ', $valores); + + $db->Consulta("INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )"); + return true; } + return false; } @@ -277,36 +239,38 @@ function cadastra() * * @return bool */ - function edita() + public function edita() { - if( is_numeric( $this->ref_ano ) && is_numeric( $this->ref_ref_cod_escola ) && is_numeric( $this->sequencial ) && is_numeric( $this->ref_cod_modulo ) ) - { - + if ( + is_numeric($this->ref_ano) + && is_numeric($this->ref_ref_cod_escola) + && is_numeric($this->sequencial) + && is_numeric($this->ref_cod_modulo) + ) { $db = new clsBanco(); - $set = ""; + $set = []; - if( is_string( $this->data_inicio ) ) - { - $set .= "{$gruda}data_inicio = '{$this->data_inicio}'"; - $gruda = ", "; + if (is_string($this->data_inicio)) { + $set[] = "data_inicio = '{$this->data_inicio}'"; } - if( is_string( $this->data_fim ) ) - { - $set .= "{$gruda}data_fim = '{$this->data_fim}'"; - $gruda = ", "; + + if (is_string($this->data_fim)) { + $set[] = "data_fim = '{$this->data_fim}'"; } - if( is_numeric( $this->dias_letivos ) ) - { - $set .= "{$gruda}dias_letivos = '{$this->dias_letivos}'"; - $gruda = ", "; + + if (is_numeric($this->dias_letivos)) { + $set[] = "dias_letivos = '{$this->dias_letivos}'"; } - if( $set ) - { - $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE ref_ano = '{$this->ref_ano}' AND ref_ref_cod_escola = '{$this->ref_ref_cod_escola}' AND sequencial = '{$this->sequencial}' AND ref_cod_modulo = '{$this->ref_cod_modulo}'" ); + if ($set) { + $set = join(', ', $set); + + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE ref_ano = '{$this->ref_ano}' AND ref_ref_cod_escola = '{$this->ref_ref_cod_escola}' AND sequencial = '{$this->sequencial}' AND ref_cod_modulo = '{$this->ref_cod_modulo}'"); + return true; } } + return false; } @@ -315,87 +279,83 @@ function edita() * * @return array */ - function lista( $int_ref_ano = null, $int_ref_ref_cod_escola = null, $int_sequencial = null, $int_ref_cod_modulo = null, $date_data_inicio_ini = null, $date_data_inicio_fim = null, $date_data_fim_ini = null, $date_data_fim_fim = null ) - { - $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; - $filtros = ""; - - $whereAnd = " WHERE "; - - if( is_numeric( $int_ref_ano ) ) - { - $filtros .= "{$whereAnd} ref_ano = '{$int_ref_ano}'"; - $whereAnd = " AND "; + public function lista( + $int_ref_ano = null, + $int_ref_ref_cod_escola = null, + $int_sequencial = null, + $int_ref_cod_modulo = null, + $date_data_inicio_ini = null, + $date_data_inicio_fim = null, + $date_data_fim_ini = null, + $date_data_fim_fim = null + ) { + $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela} WHERE "; + $filtros = []; + + if (is_numeric($int_ref_ano)) { + $filtros[] = "ref_ano = '{$int_ref_ano}'"; } - if( is_numeric( $int_ref_ref_cod_escola ) ) - { - $filtros .= "{$whereAnd} ref_ref_cod_escola = '{$int_ref_ref_cod_escola}'"; - $whereAnd = " AND "; + + if (is_numeric($int_ref_ref_cod_escola)) { + $filtros[] = "ref_ref_cod_escola = '{$int_ref_ref_cod_escola}'"; } - if( is_numeric( $int_sequencial ) ) - { - $filtros .= "{$whereAnd} sequencial = '{$int_sequencial}'"; - $whereAnd = " AND "; + + if (is_numeric($int_sequencial)) { + $filtros[] = "sequencial = '{$int_sequencial}'"; } - if( is_numeric( $int_ref_cod_modulo ) ) - { - $filtros .= "{$whereAnd} ref_cod_modulo = '{$int_ref_cod_modulo}'"; - $whereAnd = " AND "; + + if (is_numeric($int_ref_cod_modulo)) { + $filtros[] = "ref_cod_modulo = '{$int_ref_cod_modulo}'"; } - if( is_string( $date_data_inicio_ini ) ) - { - $filtros .= "{$whereAnd} data_inicio >= '{$date_data_inicio_ini}'"; - $whereAnd = " AND "; + + if (is_string($date_data_inicio_ini)) { + $filtros[] = "data_inicio >= '{$date_data_inicio_ini}'"; } - if( is_string( $date_data_inicio_fim ) ) - { - $filtros .= "{$whereAnd} data_inicio <= '{$date_data_inicio_fim}'"; - $whereAnd = " AND "; + + if (is_string($date_data_inicio_fim)) { + $filtros[] = "data_inicio <= '{$date_data_inicio_fim}'"; } - if( is_string( $date_data_fim_ini ) ) - { - $filtros .= "{$whereAnd} data_fim >= '{$date_data_fim_ini}'"; - $whereAnd = " AND "; + + if (is_string($date_data_fim_ini)) { + $filtros[] = "data_fim >= '{$date_data_fim_ini}'"; } - if( is_string( $date_data_fim_fim ) ) - { - $filtros .= "{$whereAnd} data_fim <= '{$date_data_fim_fim}'"; - $whereAnd = " AND "; + + if (is_string($date_data_fim_fim)) { + $filtros[] = "data_fim <= '{$date_data_fim_fim}'"; } + if (empty($filtros)) { + return false; + } $db = new clsBanco(); - $countCampos = count( explode( ",", $this->_campos_lista ) ); - $resultado = array(); + $countCampos = count(explode(',', $this->_campos_lista)); + $resultado = []; + $filtros = join(' AND ', $filtros); $sql .= $filtros . $this->getOrderby() . $this->getLimite(); - $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} {$filtros}" ); + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} WHERE {$filtros}"); - $db->Consulta( $sql ); + $db->Consulta($sql); - if( $countCampos > 1 ) - { - while ( $db->ProximoRegistro() ) - { + if ($countCampos > 1) { + while ($db->ProximoRegistro()) { $tupla = $db->Tupla(); - - $tupla["_total"] = $this->_total; + $tupla['_total'] = $this->_total; $resultado[] = $tupla; } - } - else - { - while ( $db->ProximoRegistro() ) - { + } else { + while ($db->ProximoRegistro()) { $tupla = $db->Tupla(); $resultado[] = $tupla[$this->_campos_lista]; } } - if( count( $resultado ) ) - { + + if (count($resultado)) { return $resultado; } + return false; } @@ -404,16 +364,16 @@ function lista( $int_ref_ano = null, $int_ref_ref_cod_escola = null, $int_sequen * * @return array */ - function detalhe() + public function detalhe() { - if( is_numeric( $this->ref_ano ) && is_numeric( $this->ref_ref_cod_escola ) && is_numeric( $this->sequencial ) && is_numeric( $this->ref_cod_modulo ) ) - { + if (is_numeric($this->ref_ano) && is_numeric($this->ref_ref_cod_escola) && is_numeric($this->sequencial) && is_numeric($this->ref_cod_modulo)) { + $db = new clsBanco(); + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE ref_ano = '{$this->ref_ano}' AND ref_ref_cod_escola = '{$this->ref_ref_cod_escola}' AND sequencial = '{$this->sequencial}' AND ref_cod_modulo = '{$this->ref_cod_modulo}'"); + $db->ProximoRegistro(); - $db = new clsBanco(); - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE ref_ano = '{$this->ref_ano}' AND ref_ref_cod_escola = '{$this->ref_ref_cod_escola}' AND sequencial = '{$this->sequencial}' AND ref_cod_modulo = '{$this->ref_cod_modulo}'" ); - $db->ProximoRegistro(); - return $db->Tupla(); + return $db->Tupla(); } + return false; } @@ -422,51 +382,41 @@ function detalhe() * * @return array */ - function existe() + public function existe() { - if( is_numeric( $this->ref_ano ) && is_numeric( $this->ref_ref_cod_escola ) && is_numeric( $this->sequencial ) && is_numeric( $this->ref_cod_modulo ) ) - { + if (is_numeric($this->ref_ano) && is_numeric($this->ref_ref_cod_escola) && is_numeric($this->sequencial) && is_numeric($this->ref_cod_modulo)) { + $db = new clsBanco(); + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE ref_ano = '{$this->ref_ano}' AND ref_ref_cod_escola = '{$this->ref_ref_cod_escola}' AND sequencial = '{$this->sequencial}' AND ref_cod_modulo = '{$this->ref_cod_modulo}'"); + $db->ProximoRegistro(); - $db = new clsBanco(); - $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE ref_ano = '{$this->ref_ano}' AND ref_ref_cod_escola = '{$this->ref_ref_cod_escola}' AND sequencial = '{$this->sequencial}' AND ref_cod_modulo = '{$this->ref_cod_modulo}'" ); - $db->ProximoRegistro(); - return $db->Tupla(); + return $db->Tupla(); } + return false; } /** - * Exclui um registro + * Exclui um registro (mantido apenas por questão de BC) * * @return bool */ - function excluir() + public function excluir() { - if( is_numeric( $this->ref_ano ) && is_numeric( $this->ref_ref_cod_escola ) && is_numeric( $this->sequencial ) && is_numeric( $this->ref_cod_modulo ) ) - { - - /* - delete - $db = new clsBanco(); - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE ref_ano = '{$this->ref_ano}' AND ref_ref_cod_escola = '{$this->ref_ref_cod_escola}' AND sequencial = '{$this->sequencial}' AND ref_cod_modulo = '{$this->ref_cod_modulo}'" ); - return true; - */ - - - } return false; } /** * Exclui todos os registros referentes a uma escola e a um ano */ - function excluirTodos() + public function excluirTodos() { - if ( is_numeric( $this->ref_ano ) && is_numeric( $this->ref_ref_cod_escola ) ) { + if (is_numeric($this->ref_ano) && is_numeric($this->ref_ref_cod_escola)) { $db = new clsBanco(); - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE ref_ano = '{$this->ref_ano}' AND ref_ref_cod_escola = '{$this->ref_ref_cod_escola}'" ); + $db->Consulta("DELETE FROM {$this->_tabela} WHERE ref_ano = '{$this->ref_ano}' AND ref_ref_cod_escola = '{$this->ref_ref_cod_escola}'"); + return true; } + return false; } @@ -475,7 +425,7 @@ function excluirTodos() * * @return null */ - function setCamposLista( $str_campos ) + public function setCamposLista($str_campos) { $this->_campos_lista = $str_campos; } @@ -485,7 +435,7 @@ function setCamposLista( $str_campos ) * * @return null */ - function resetCamposLista() + public function resetCamposLista() { $this->_campos_lista = $this->_todos_campos; } @@ -495,7 +445,7 @@ function resetCamposLista() * * @return null */ - function setLimite( $intLimiteQtd, $intLimiteOffset = null ) + public function setLimite($intLimiteQtd, $intLimiteOffset = null) { $this->_limite_quantidade = $intLimiteQtd; $this->_limite_offset = $intLimiteOffset; @@ -506,18 +456,18 @@ function setLimite( $intLimiteQtd, $intLimiteOffset = null ) * * @return string */ - function getLimite() + public function getLimite() { - if( is_numeric( $this->_limite_quantidade ) ) - { + if (is_numeric($this->_limite_quantidade)) { $retorno = " LIMIT {$this->_limite_quantidade}"; - if( is_numeric( $this->_limite_offset ) ) - { + if (is_numeric($this->_limite_offset)) { $retorno .= " OFFSET {$this->_limite_offset} "; } + return $retorno; } - return ""; + + return ''; } /** @@ -525,13 +475,9 @@ function getLimite() * * @return null */ - function setOrderby( $strNomeCampo ) + public function setOrderby($strNomeCampo) { - // limpa a string de possiveis erros (delete, insert, etc) - //$strNomeCampo = eregi_replace(); - - if( is_string( $strNomeCampo ) && $strNomeCampo ) - { + if (is_string($strNomeCampo) && $strNomeCampo) { $this->_campo_order_by = $strNomeCampo; } } @@ -541,13 +487,13 @@ function setOrderby( $strNomeCampo ) * * @return string */ - function getOrderby() + public function getOrderby() { - if( is_string( $this->_campo_order_by ) ) - { + if (is_string($this->_campo_order_by)) { return " ORDER BY {$this->_campo_order_by} "; } - return ""; + + return ''; } /** @@ -555,20 +501,21 @@ function getOrderby() * * @return array */ - function menorData( $ref_ano, $ref_ref_cod_escola ) + public function menorData($ref_ano, $ref_ref_cod_escola) { - if( is_numeric( $ref_ano ) && is_numeric( $ref_ref_cod_escola ) ) - { + if (is_numeric($ref_ano) && is_numeric($ref_ref_cod_escola)) { $db = new clsBanco(); - $resultado = $db->CampoUnico( "SELECT - MIN( data_inicio ) - FROM - pmieducar.ano_letivo_modulo - WHERE - ref_ano = '{$ref_ano}' - AND ref_ref_cod_escola = '{$ref_ref_cod_escola}'" ); + $resultado = $db->CampoUnico("SELECT + MIN( data_inicio ) + FROM + pmieducar.ano_letivo_modulo + WHERE + ref_ano = '{$ref_ano}' + AND ref_ref_cod_escola = '{$ref_ref_cod_escola}'"); + return $resultado; } + return false; } @@ -577,20 +524,21 @@ function menorData( $ref_ano, $ref_ref_cod_escola ) * * @return array */ - function maiorData( $ref_ano, $ref_ref_cod_escola ) + public function maiorData($ref_ano, $ref_ref_cod_escola) { - if( is_numeric( $ref_ano ) && is_numeric( $ref_ref_cod_escola ) ) - { + if (is_numeric($ref_ano) && is_numeric($ref_ref_cod_escola)) { $db = new clsBanco(); - $resultado = $db->CampoUnico( "SELECT - MAX( data_fim ) - FROM - pmieducar.ano_letivo_modulo - WHERE - ref_ano = '{$ref_ano}' - AND ref_ref_cod_escola = '{$ref_ref_cod_escola}'" ); + $resultado = $db->CampoUnico("SELECT + MAX( data_fim ) + FROM + pmieducar.ano_letivo_modulo + WHERE + ref_ano = '{$ref_ano}' + AND ref_ref_cod_escola = '{$ref_ref_cod_escola}'"); + return $resultado; } + return false; } @@ -599,7 +547,8 @@ function maiorData( $ref_ano, $ref_ref_cod_escola ) * * @return string */ - function getNomeModulo() { + public function getNomeModulo() + { if (is_numeric($this->ref_ano) && is_numeric($this->ref_ref_cod_escola) && is_numeric($this->sequencial)) { $db = new clsBanco(); $resultado = $db->CampoUnico("SELECT sequencial || 'º ' || nm_tipo AS nome_modulo @@ -608,8 +557,10 @@ function getNomeModulo() { WHERE ref_ano = {$this->ref_ano} AND ref_ref_cod_escola = {$this->ref_ref_cod_escola} AND sequencial = {$this->sequencial}"); + return $resultado; } + return false; } @@ -618,7 +569,8 @@ function getNomeModulo() { * * @return array */ - function getEtapas() { + public function getEtapas() + { if (is_numeric($this->ref_ano) && is_numeric($this->ref_ref_cod_escola)) { $db = new clsBanco(); $sql = "SELECT sequencial AS id, sequencial || 'º ' || nm_tipo AS nome @@ -629,13 +581,13 @@ function getEtapas() { $db->Consulta($sql); - while ( $db->ProximoRegistro() ) - { + while ($db->ProximoRegistro()) { $resultado[] = $db->Tupla(); } + return $resultado; } + return false; } } -?> diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarCandidatoFilaUnica.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarCandidatoFilaUnica.inc.php index 546524bf74..456ca06f50 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarCandidatoFilaUnica.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarCandidatoFilaUnica.inc.php @@ -788,5 +788,37 @@ public function alteraSituacao($situacao, $motivo = null) return true; } + + /** + * Retorna um array com os códigos das escolas em que o aluno está + * aguardando na fila. + * + * @param int $cod_candidato_fila_unica + * + * @return array + * + * @throws Exception + */ + public function getOpcoesDeEscolas($cod_candidato_fila_unica) + { + $db = new clsBanco(); + + $db->Consulta( + " + SELECT ref_cod_escola + FROM pmieducar.escola_candidato_fila_unica + WHERE ref_cod_candidato_fila_unica = {$cod_candidato_fila_unica} + ORDER BY sequencial; + " + ); + + $escolas = []; + + while ($db->ProximoRegistro()) { + $escolas[] = $db->Tupla()['ref_cod_escola']; + } + + return $escolas; + } } ?> diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarDispensaDisciplina.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarDispensaDisciplina.inc.php index c88b6bed33..db7ec5d5b7 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarDispensaDisciplina.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarDispensaDisciplina.inc.php @@ -1,627 +1,638 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Prefeitura Municipal de Itajaí - * @category i-Educar - * @license @@license@@ - * @package iEd_Pmieducar - * @since Arquivo disponível desde a versão 1.0.0 - * @version $Id$ - */ - require_once 'include/pmieducar/geral.inc.php'; -/** - * clsPmieducarDispensaDisciplina class. - * - * @author Prefeitura Municipal de Itajaí - * @category i-Educar - * @license @@license@@ - * @package iEd_Pmieducar - * @since Classe disponível desde a versão 1.0.0 - * @version @@package_version@@ - */ class clsPmieducarDispensaDisciplina { - var $ref_cod_matricula; - var $ref_cod_serie; - var $ref_cod_escola; - var $ref_cod_disciplina; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_cod_tipo_dispensa; - var $data_cadastro; - var $data_exclusao; - var $ativo; - var $observacao; - var $cod_dispensa; - - /** - * Armazena o total de resultados obtidos na última chamada ao método lista(). - * @var int - */ - var $_total; - - /** - * Nome do schema. - * @var string - */ - var $_schema; - - /** - * Nome da tabela. - * @var string - */ - var $_tabela; - - /** - * Lista separada por vírgula, com os campos que devem ser selecionados na - * próxima chamado ao método lista(). - * @var string - */ - var $_campos_lista; - - /** - * Lista com todos os campos da tabela separados por vírgula, padrão para - * seleção no método lista. - * @var string - */ - var $_todos_campos; - - /** - * Valor que define a quantidade de registros a ser retornada pelo método lista(). - * @var int - */ - var $_limite_quantidade; - - /** - * Define o valor de offset no retorno dos registros no método lista(). - * @var int - */ - var $_limite_offset; - - /** - * Define o campo para ser usado como padrão de ordenação no método lista(). - * @var string - */ - var $_campo_order_by; - - /** - * Construtor. - */ - function __construct($ref_cod_matricula = NULL, - $ref_cod_serie = NULL, $ref_cod_escola = NULL, $ref_cod_disciplina = NULL, - $ref_usuario_exc = NULL, $ref_usuario_cad = NULL, $ref_cod_tipo_dispensa = NULL, - $data_cadastro = NULL, $data_exclusao = NULL, $ativo = NULL, $observacao = NULL, - $cod_dispensa = NULL) - { - $db = new clsBanco(); - $this->_schema = 'pmieducar.'; - $this->_tabela = $this->_schema . 'dispensa_disciplina'; - - $this->_campos_lista = $this->_todos_campos = 'ref_cod_matricula, ref_cod_serie, ref_cod_escola, ref_cod_disciplina, ref_usuario_exc, ref_usuario_cad, ref_cod_tipo_dispensa, data_cadastro, data_exclusao, ativo, observacao, cod_dispensa'; - - if (is_numeric($ref_usuario_exc)) { - $usuario = new clsPmieducarUsuario($ref_usuario_exc); - if ($usuario->existe()) { - $this->ref_usuario_exc = $ref_usuario_exc; - } - } - - if (is_numeric($ref_usuario_cad)) { - $usuario = new clsPmieducarUsuario($ref_usuario_cad); - if ($usuario->existe()) { - $this->ref_usuario_cad = $ref_usuario_cad; - } - } - - if (is_numeric($ref_cod_matricula)) { - $matricula = new clsPmieducarMatricula($ref_cod_matricula); - if ($matricula->existe()) { - $this->ref_cod_matricula = $ref_cod_matricula; - } - } - - if (is_numeric($ref_cod_tipo_dispensa)) { - $tipoDispensa = new clsPmieducarTipoDispensa($ref_cod_tipo_dispensa); - if ($tipoDispensa->existe()) { - $this->ref_cod_tipo_dispensa = $ref_cod_tipo_dispensa; - } - } - - if (is_numeric($ref_cod_disciplina) && is_numeric($ref_cod_escola) && - is_numeric($ref_cod_serie) + public $ref_cod_matricula; + public $ref_cod_serie; + public $ref_cod_escola; + public $ref_cod_disciplina; + public $ref_usuario_exc; + public $ref_usuario_cad; + public $ref_cod_tipo_dispensa; + public $data_cadastro; + public $data_exclusao; + public $ativo; + public $observacao; + public $cod_dispensa; + + /** + * Armazena o total de resultados obtidos na última chamada ao método lista(). + * + * @var int + */ + public $_total; + + /** + * Nome do schema. + * + * @var string + */ + public $_schema; + + /** + * Nome da tabela. + * + * @var string + */ + public $_tabela; + + /** + * Lista separada por vírgula, com os campos que devem ser selecionados na + * próxima chamado ao método lista(). + * + * @var string + */ + public $_campos_lista; + + /** + * Lista com todos os campos da tabela separados por vírgula, padrão para + * seleção no método lista. + * + * @var string + */ + public $_todos_campos; + + /** + * Valor que define a quantidade de registros a ser retornada pelo método lista(). + * + * @var int + */ + public $_limite_quantidade; + + /** + * Define o valor de offset no retorno dos registros no método lista(). + * + * @var int + */ + public $_limite_offset; + + /** + * Define o campo para ser usado como padrão de ordenação no método lista(). + * + * @var string + */ + public $_campo_order_by; + + /** + * Construtor. + */ + public function __construct( + $ref_cod_matricula = null, + $ref_cod_serie = null, + $ref_cod_escola = null, + $ref_cod_disciplina = null, + $ref_usuario_exc = null, + $ref_usuario_cad = null, + $ref_cod_tipo_dispensa = null, + $data_cadastro = null, + $data_exclusao = null, + $ativo = null, + $observacao = null, + $cod_dispensa = null ) { - require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php'; - $anoEscolarMapper = new ComponenteCurricular_Model_AnoEscolarDataMapper(); - $componenteAnos = $anoEscolarMapper->findAll(array(), array( - 'componenteCurricular' => $ref_cod_disciplina, - 'anoEscolar' => $ref_cod_serie - )); - - if (1 == count($componenteAnos)) { - $this->ref_cod_disciplina = $ref_cod_disciplina; - $this->ref_cod_serie = $ref_cod_serie; - $this->ref_cod_escola = $ref_cod_escola; - } - } - - if (is_string($data_cadastro)) { - $this->data_cadastro = $data_cadastro; - } - - if (is_string($data_exclusao)) { - $this->data_exclusao = $data_exclusao; - } - - if (is_numeric($ativo)) { - $this->ativo = $ativo; - } - - if (is_string($observacao)) { - $this->observacao = $observacao; - } - - if (is_numeric($cod_dispensa)) { - $this->cod_dispensa = $cod_dispensa; - } - } - - /** - * Cria um novo registro. - * @return bool - */ - function cadastra() - { - if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && - is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) && - is_numeric($this->ref_usuario_cad) && is_numeric($this->ref_cod_tipo_dispensa) && - is_numeric($this->cod_dispensa)) + $db = new clsBanco(); + $this->_schema = 'pmieducar.'; + $this->_tabela = $this->_schema . 'dispensa_disciplina'; + + $this->_campos_lista = $this->_todos_campos = ' + ref_cod_matricula, + ref_cod_serie, + ref_cod_escola, + ref_cod_disciplina, + ref_usuario_exc, + ref_usuario_cad, + ref_cod_tipo_dispensa, + data_cadastro, + data_exclusao, + ativo, + observacao, + cod_dispensa + '; + + if (is_numeric($ref_usuario_exc)) { + $usuario = new clsPmieducarUsuario($ref_usuario_exc); + if ($usuario->existe()) { + $this->ref_usuario_exc = $ref_usuario_exc; + } + } + + if (is_numeric($ref_usuario_cad)) { + $usuario = new clsPmieducarUsuario($ref_usuario_cad); + if ($usuario->existe()) { + $this->ref_usuario_cad = $ref_usuario_cad; + } + } + + if (is_numeric($ref_cod_matricula)) { + $matricula = new clsPmieducarMatricula($ref_cod_matricula); + if ($matricula->existe()) { + $this->ref_cod_matricula = $ref_cod_matricula; + } + } + + if (is_numeric($ref_cod_tipo_dispensa)) { + $tipoDispensa = new clsPmieducarTipoDispensa($ref_cod_tipo_dispensa); + if ($tipoDispensa->existe()) { + $this->ref_cod_tipo_dispensa = $ref_cod_tipo_dispensa; + } + } + + if (is_numeric($ref_cod_disciplina) && is_numeric($ref_cod_escola) && is_numeric($ref_cod_serie)) { + require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php'; + $anoEscolarMapper = new ComponenteCurricular_Model_AnoEscolarDataMapper(); + $componenteAnos = $anoEscolarMapper->findAll([], [ + 'componenteCurricular' => $ref_cod_disciplina, + 'anoEscolar' => $ref_cod_serie + ]); + + if (1 == count($componenteAnos)) { + $this->ref_cod_disciplina = $ref_cod_disciplina; + $this->ref_cod_serie = $ref_cod_serie; + $this->ref_cod_escola = $ref_cod_escola; + } + } + + if (is_string($data_cadastro)) { + $this->data_cadastro = $data_cadastro; + } + + if (is_string($data_exclusao)) { + $this->data_exclusao = $data_exclusao; + } + + if (is_numeric($ativo)) { + $this->ativo = $ativo; + } + + if (is_string($observacao)) { + $this->observacao = $observacao; + } + + if (is_numeric($cod_dispensa)) { + $this->cod_dispensa = $cod_dispensa; + } + } + + /** + * Cria um novo registro. + * + * @return bool + */ + public function cadastra() { - $db = new clsBanco(); - - $campos = ''; - $valores = ''; - $gruda = ''; - - if (is_numeric($this->ref_cod_matricula)) { - $campos .= "{$gruda}ref_cod_matricula"; - $valores .= "{$gruda}'{$this->ref_cod_matricula}'"; - $gruda = ', '; - } - - if (is_numeric($this->ref_cod_serie)) { - $campos .= "{$gruda}ref_cod_serie"; - $valores .= "{$gruda}'{$this->ref_cod_serie}'"; - $gruda = ', '; - } - - if (is_numeric($this->ref_cod_escola)) { - $campos .= "{$gruda}ref_cod_escola"; - $valores .= "{$gruda}'{$this->ref_cod_escola}'"; - $gruda = ', '; - } - - if (is_numeric($this->ref_cod_disciplina)) { - $campos .= "{$gruda}ref_cod_disciplina"; - $valores .= "{$gruda}'{$this->ref_cod_disciplina}'"; - $gruda = ', '; - } - - if (is_numeric($this->ref_usuario_cad)) { - $campos .= "{$gruda}ref_usuario_cad"; - $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; - $gruda = ', '; - } - - if (is_numeric($this->ref_cod_tipo_dispensa)) { - $campos .= "{$gruda}ref_cod_tipo_dispensa"; - $valores .= "{$gruda}'{$this->ref_cod_tipo_dispensa}'"; - $gruda = ', '; - } - - $campos .= "{$gruda}data_cadastro"; - $valores .= "{$gruda}NOW()"; - $gruda = ', '; - - $campos .= "{$gruda}ativo"; - $valores .= "{$gruda}'1'"; - $gruda = ', '; - - if (is_string($this->observacao)) { - $campos .= "{$gruda}observacao"; - $valores .= "{$gruda}'{$this->observacao}'"; - $gruda = ', '; - } - - if (is_numeric($this->cod_dispensa)) { - $campos .= "{$gruda}cod_dispensa"; - $valores .= "{$gruda}'{$this->cod_dispensa}'"; - $gruda = ', '; - } - - $sql = "INSERT INTO {$this->_tabela} ($campos) VALUES ($valores)"; - $db->Consulta($sql); - return TRUE; - } - - return FALSE; - } - - /** - * Edita os dados de um registro. - * @return bool - */ - function edita() - { - if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && - is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) && - is_numeric($this->ref_usuario_exc) + if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && + is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) && + is_numeric($this->ref_usuario_cad) && is_numeric($this->ref_cod_tipo_dispensa) + ) { + $db = new clsBanco(); + + $campos = ''; + $valores = ''; + $gruda = ''; + + if (is_numeric($this->ref_cod_matricula)) { + $campos .= "{$gruda}ref_cod_matricula"; + $valores .= "{$gruda}'{$this->ref_cod_matricula}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_serie)) { + $campos .= "{$gruda}ref_cod_serie"; + $valores .= "{$gruda}'{$this->ref_cod_serie}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_escola)) { + $campos .= "{$gruda}ref_cod_escola"; + $valores .= "{$gruda}'{$this->ref_cod_escola}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_disciplina)) { + $campos .= "{$gruda}ref_cod_disciplina"; + $valores .= "{$gruda}'{$this->ref_cod_disciplina}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_usuario_cad)) { + $campos .= "{$gruda}ref_usuario_cad"; + $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_tipo_dispensa)) { + $campos .= "{$gruda}ref_cod_tipo_dispensa"; + $valores .= "{$gruda}'{$this->ref_cod_tipo_dispensa}'"; + $gruda = ', '; + } + + $campos .= "{$gruda}data_cadastro"; + $valores .= "{$gruda}NOW()"; + $gruda = ', '; + + $campos .= "{$gruda}ativo"; + $valores .= "{$gruda}'1'"; + $gruda = ', '; + + if (is_string($this->observacao)) { + $campos .= "{$gruda}observacao"; + $valores .= "{$gruda}'{$this->observacao}'"; + $gruda = ', '; + } + + $sql = "INSERT INTO {$this->_tabela} ($campos) VALUES ($valores)"; + $db->Consulta($sql); + $id = $db->InsertId("{$this->_tabela}_cod_dispensa_seq"); + $this->id = $id; + $auditoria = new clsModulesAuditoriaGeral('dispensa_disciplina', $this->pessoa_logada, $id); + $auditoria->inclusao($this->detalhe()); + + return $id; + } + + return false; + } + + /** + * Edita os dados de um registro. + * + * @return bool + */ + public function edita() + { + if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && + is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) && + is_numeric($this->ref_usuario_exc)) { + $db = new clsBanco(); + $set = ''; + + if (is_numeric($this->ref_usuario_exc)) { + $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_usuario_cad)) { + $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_tipo_dispensa)) { + $set .= "{$gruda}ref_cod_tipo_dispensa = '{$this->ref_cod_tipo_dispensa}'"; + $gruda = ', '; + } + + if (is_string($this->data_cadastro)) { + $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; + $gruda = ', '; + } + + $set .= "{$gruda}data_exclusao = NOW()"; + $gruda = ', '; + + if (is_numeric($this->ativo)) { + $set .= "{$gruda}ativo = '{$this->ativo}'"; + $gruda = ', '; + } + + if (is_string($this->observacao)) { + $set .= "{$gruda}observacao = '{$this->observacao}'"; + $gruda = ', '; + } + + if ($set) { + $detalheAntigo = $this->detalhe(); + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_serie = '{$this->ref_cod_serie}' AND ref_cod_escola = '{$this->ref_cod_escola}' AND ref_cod_disciplina = '{$this->ref_cod_disciplina}'"); + $detalheAtual = $this->detalhe(); + $auditoria = new clsModulesAuditoriaGeral('dispensa_disciplina', $this->pessoa_logada, $this->id); + $auditoria->alteracao($detalheAntigo, $detalheAtual); + + return true; + } + } + + return false; + } + + /** + * Retorna uma lista de registros filtrados de acordo com os parâmetros. + * + * @return array + */ + public function lista( + $int_ref_cod_matricula = null, + $int_ref_cod_serie = null, + $int_ref_cod_escola = null, + $int_ref_cod_disciplina = null, + $int_ref_usuario_exc = null, + $int_ref_usuario_cad = null, + $int_ref_cod_tipo_dispensa = null, + $date_data_cadastro_ini = null, + $date_data_cadastro_fim = null, + $date_data_exclusao_ini = null, + $date_data_exclusao_fim = null, + $int_ativo = null, + $str_observacao = null ) { - $db = new clsBanco(); - $set = ''; - - if (is_numeric($this->ref_usuario_exc)) { - $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; - $gruda = ', '; - } - - if (is_numeric($this->ref_usuario_cad)) { - $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; - $gruda = ', '; - } - - if (is_numeric($this->ref_cod_tipo_dispensa)) { - $set .= "{$gruda}ref_cod_tipo_dispensa = '{$this->ref_cod_tipo_dispensa}'"; - $gruda = ', '; - } - - if (is_string($this->data_cadastro)) { - $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; - $gruda = ', '; - } - - $set .= "{$gruda}data_exclusao = NOW()"; - $gruda = ', '; - - if (is_numeric($this->ativo)) { - $set .= "{$gruda}ativo = '{$this->ativo}'"; - $gruda = ', '; - } - - if (is_string($this->observacao)) { - $set .= "{$gruda}observacao = '{$this->observacao}'"; - $gruda = ', '; - } - - if ($set) { - $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_serie = '{$this->ref_cod_serie}' AND ref_cod_escola = '{$this->ref_cod_escola}' AND ref_cod_disciplina = '{$this->ref_cod_disciplina}'"); - return TRUE; - } - } - - return FALSE; - } - - /** - * Retorna uma lista de registros filtrados de acordo com os parâmetros. - * @return array - */ - function lista($int_ref_cod_matricula = NULL, $int_ref_cod_serie = NULL, - $int_ref_cod_escola = NULL, $int_ref_cod_disciplina = NULL, - $int_ref_usuario_exc = NULL, $int_ref_usuario_cad = NULL, - $int_ref_cod_tipo_dispensa = NULL, $date_data_cadastro_ini = NULL, - $date_data_cadastro_fim = NULL, $date_data_exclusao_ini = NULL, - $date_data_exclusao_fim = NULL, $int_ativo = NULL, $str_observacao = NULL) - { - $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; - $filtros = ''; - - $whereAnd = ' WHERE '; - - if (is_numeric($int_ref_cod_matricula)) { - $filtros .= "{$whereAnd} ref_cod_matricula = '{$int_ref_cod_matricula}'"; - $whereAnd = ' AND '; - } - - if (is_numeric($int_ref_cod_serie)) { - $filtros .= "{$whereAnd} ref_cod_serie = '{$int_ref_cod_serie}'"; - $whereAnd = ' AND '; - } - - if (is_numeric($int_ref_cod_escola)) { - $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; - $whereAnd = ' AND '; - } - - if (is_numeric($int_ref_cod_disciplina)) { - $filtros .= "{$whereAnd} ref_cod_disciplina = '{$int_ref_cod_disciplina}'"; - $whereAnd = ' AND '; - } - - if (is_numeric($int_ref_usuario_exc)) { - $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'"; - $whereAnd = ' AND '; - } - - if (is_numeric($int_ref_usuario_cad)) { - $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'"; - $whereAnd = ' AND '; - } - - if (is_numeric($int_ref_cod_tipo_dispensa)) { - $filtros .= "{$whereAnd} ref_cod_tipo_dispensa = '{$int_ref_cod_tipo_dispensa}'"; - $whereAnd = ' AND '; - } - - if (is_string($date_data_cadastro_ini)) { - $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'"; - $whereAnd = ' AND '; - } - - if (is_string($date_data_cadastro_fim)) { - $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'"; - $whereAnd = ' AND '; - } + $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; + $filtros = ''; + + $whereAnd = ' WHERE '; + + if (is_numeric($int_ref_cod_matricula)) { + $filtros .= "{$whereAnd} ref_cod_matricula = '{$int_ref_cod_matricula}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_serie)) { + $filtros .= "{$whereAnd} ref_cod_serie = '{$int_ref_cod_serie}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_escola)) { + $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_disciplina)) { + $filtros .= "{$whereAnd} ref_cod_disciplina = '{$int_ref_cod_disciplina}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_usuario_exc)) { + $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_usuario_cad)) { + $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_tipo_dispensa)) { + $filtros .= "{$whereAnd} ref_cod_tipo_dispensa = '{$int_ref_cod_tipo_dispensa}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_cadastro_ini)) { + $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_cadastro_fim)) { + $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_exclusao_ini)) { + $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_exclusao_fim)) { + $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'"; + $whereAnd = ' AND '; + } + + if (is_null($int_ativo) || $int_ativo) { + $filtros .= "{$whereAnd} ativo = '1'"; + $whereAnd = ' AND '; + } else { + $filtros .= "{$whereAnd} ativo = '0'"; + $whereAnd = ' AND '; + } + + if (is_string($str_observacao)) { + $filtros .= "{$whereAnd} observacao LIKE '%{$str_observacao}%'"; + $whereAnd = ' AND '; + } + + $db = new clsBanco(); + $countCampos = count(explode(',', $this->_campos_lista)); + $resultado = []; + + $sql .= $filtros . $this->getOrderby() . $this->getLimite(); + + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}"); + $db->Consulta($sql); + + if ($countCampos > 1) { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + + $tupla['_total'] = $this->_total; + $resultado[] = $tupla; + } + } else { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + $resultado[] = $tupla[$this->_campos_lista]; + } + } + + if (count($resultado)) { + return $resultado; + } + + return false; + } + + public function disciplinaDispensadaEtapa( + $int_ref_cod_matricula = null, + $int_ref_cod_serie = null, + $int_ref_cod_escola = null, + $int_etapa = null + ) { + $sql = "SELECT {$this->_campos_lista}, etapa + FROM {$this->_tabela} + INNER JOIN pmieducar.dispensa_etapa ON (dispensa_etapa.ref_cod_dispensa = dispensa_disciplina.cod_dispensa)"; + $filtros = ''; - if (is_string($date_data_exclusao_ini)) { - $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'"; - $whereAnd = ' AND '; - } + $whereAnd = ' WHERE '; - if (is_string($date_data_exclusao_fim)) { - $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'"; - $whereAnd = ' AND '; - } + if (is_numeric($int_ref_cod_matricula)) { + $filtros .= "{$whereAnd} ref_cod_matricula = '{$int_ref_cod_matricula}'"; + $whereAnd = ' AND '; + } - if (is_null($int_ativo) || $int_ativo) { - $filtros .= "{$whereAnd} ativo = '1'"; - $whereAnd = ' AND '; - } - else { - $filtros .= "{$whereAnd} ativo = '0'"; - $whereAnd = ' AND '; - } + if (is_numeric($int_ref_cod_serie)) { + $filtros .= "{$whereAnd} ref_cod_serie = '{$int_ref_cod_serie}'"; + $whereAnd = ' AND '; + } - if (is_string($str_observacao)) { - $filtros .= "{$whereAnd} observacao LIKE '%{$str_observacao}%'"; - $whereAnd = ' AND '; - } + if (is_numeric($int_ref_cod_escola)) { + $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; + $whereAnd = ' AND '; + } - $db = new clsBanco(); - $countCampos = count(explode(',', $this->_campos_lista)); - $resultado = array(); + if (is_numeric($int_etapa)) { + $filtros .= "{$whereAnd} etapa = '{$int_etapa}'"; + $whereAnd = ' AND '; + } - $sql .= $filtros . $this->getOrderby() . $this->getLimite(); + $db = new clsBanco(); + $countCampos = count(explode(',', $this->_campos_lista)); + $resultado = []; - $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}"); - $db->Consulta($sql); + $sql .= $filtros . $this->getOrderby() . $this->getLimite(); - if ($countCampos > 1) { - while ($db->ProximoRegistro()) { - $tupla = $db->Tupla(); + $this->_total = $db->CampoUnico("SELECT COUNT(0) + FROM {$this->_tabela} + INNER JOIN pmieducar.dispensa_etapa ON (dispensa_etapa.ref_cod_dispensa = dispensa_disciplina.cod_dispensa) + {$filtros}"); + $db->Consulta($sql); + + if ($countCampos > 1) { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + + $tupla['_total'] = $this->_total; + $resultado[] = $tupla; + } + } else { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + $resultado[] = $tupla[$this->_campos_lista]; + } + } + + if (count($resultado)) { + return $resultado; + } + + return false; + } + /** + * Retorna um array com os dados de um registro. + * + * @return array + */ + public function detalhe() + { + if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && + is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) + ) { + $db = new clsBanco(); + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_serie = '{$this->ref_cod_serie}' AND ref_cod_escola = '{$this->ref_cod_escola}' AND ref_cod_disciplina = '{$this->ref_cod_disciplina}'"); + $db->ProximoRegistro(); - $tupla["_total"] = $this->_total; - $resultado[] = $tupla; - } - } - else { - while ($db->ProximoRegistro()) { - $tupla = $db->Tupla(); - $resultado[] = $tupla[$this->_campos_lista]; - } - } + return $db->Tupla(); + } - if (count($resultado)) { - return $resultado; + return false; } - return FALSE; - } - - - - function disciplinaDispensadaEtapa($int_ref_cod_matricula = NULL, - $int_ref_cod_serie = NULL, - $int_ref_cod_escola = NULL, - $int_etapa = NULL) - { - $sql = "SELECT {$this->_campos_lista}, etapa - FROM {$this->_tabela} - INNER JOIN pmieducar.dispensa_etapa ON (dispensa_etapa.ref_cod_dispensa = dispensa_disciplina.cod_dispensa)"; - $filtros = ''; + /** + * Retorna um array com os dados de um registro + * + * @return array + */ + public function existe() + { + if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && + is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) + ) { + $db = new clsBanco(); + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_serie = '{$this->ref_cod_serie}' AND ref_cod_escola = '{$this->ref_cod_escola}' AND ref_cod_disciplina = '{$this->ref_cod_disciplina}'"); + $db->ProximoRegistro(); - $whereAnd = ' WHERE '; + return $db->Tupla(); + } - if (is_numeric($int_ref_cod_matricula)) { - $filtros .= "{$whereAnd} ref_cod_matricula = '{$int_ref_cod_matricula}'"; - $whereAnd = ' AND '; + return false; } - if (is_numeric($int_ref_cod_serie)) { - $filtros .= "{$whereAnd} ref_cod_serie = '{$int_ref_cod_serie}'"; - $whereAnd = ' AND '; + /** + * Exclui um registro. + * + * @return bool + */ + public function excluir() + { + if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && + is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) && + is_numeric($this->ref_usuario_exc) + ) { + $detalhe = $this->detalhe(); + $db = new clsBanco(); + $db->Consulta("DELETE FROM {$this->_tabela} WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_disciplina = '{$this->ref_cod_disciplina}'"); + $auditoria = new clsModulesAuditoriaGeral('dispensa_disciplina', $this->pessoa_logada, $this->id); + $auditoria->exclusao($detalhe); + + return $this->edita(); + } + + return false; + } + + /** + * Define quais campos da tabela serão selecionados no método Lista(). + */ + public function setCamposLista($str_campos) + { + $this->_campos_lista = $str_campos; } - if (is_numeric($int_ref_cod_escola)) { - $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; - $whereAnd = ' AND '; + /** + * Define que o método Lista() deverpa retornar todos os campos da tabela. + */ + public function resetCamposLista() + { + $this->_campos_lista = $this->_todos_campos; } - if (is_numeric($int_etapa)) { - $filtros .= "{$whereAnd} etapa = '{$int_etapa}'"; - $whereAnd = ' AND '; + /** + * Define limites de retorno para o método Lista(). + */ + public function setLimite($intLimiteQtd, $intLimiteOffset = null) + { + $this->_limite_quantidade = $intLimiteQtd; + $this->_limite_offset = $intLimiteOffset; } - $db = new clsBanco(); - $countCampos = count(explode(',', $this->_campos_lista)); - $resultado = array(); - - $sql .= $filtros . $this->getOrderby() . $this->getLimite(); - // echo $sql; die; - - $this->_total = $db->CampoUnico("SELECT COUNT(0) - FROM {$this->_tabela} - INNER JOIN pmieducar.dispensa_etapa ON (dispensa_etapa.ref_cod_dispensa = dispensa_disciplina.cod_dispensa) - {$filtros}"); - $db->Consulta($sql); + /** + * Retorna a string com o trecho da query responsável pelo limite de + * registros retornados/afetados. + * + * @return string + */ + public function getLimite() + { + if (is_numeric($this->_limite_quantidade)) { + $retorno = " LIMIT {$this->_limite_quantidade}"; + if (is_numeric($this->_limite_offset)) { + $retorno .= " OFFSET {$this->_limite_offset} "; + } - if ($countCampos > 1) { - while ($db->ProximoRegistro()) { - $tupla = $db->Tupla(); + return $retorno; + } - $tupla["_total"] = $this->_total; - $resultado[] = $tupla; - } - } - else { - while ($db->ProximoRegistro()) { - $tupla = $db->Tupla(); - $resultado[] = $tupla[$this->_campos_lista]; - } + return ''; } - if (count($resultado)) { - return $resultado; - } + /** + * Define o campo para ser utilizado como ordenação no método Lista(). + */ + public function setOrderby($strNomeCampo) + { + if (is_string($strNomeCampo) && $strNomeCampo) { + $this->_campo_order_by = $strNomeCampo; + } + } + + /** + * Retorna a string com o trecho da query responsável pela Ordenação dos + * registros. + * + * @return string + */ + public function getOrderby() + { + if (is_string($this->_campo_order_by)) { + return " ORDER BY {$this->_campo_order_by} "; + } - return FALSE; - } - /** - * Retorna um array com os dados de um registro. - * @return array - */ - function detalhe() - { - if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && - is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) - ) { - $db = new clsBanco(); - $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_serie = '{$this->ref_cod_serie}' AND ref_cod_escola = '{$this->ref_cod_escola}' AND ref_cod_disciplina = '{$this->ref_cod_disciplina}'"); - $db->ProximoRegistro(); - return $db->Tupla(); - } - return FALSE; - } - - /** - * Retorna um array com os dados de um registro - * - * @return array - */ - function existe() - { - if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && - is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) - ) { - $db = new clsBanco(); - $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_serie = '{$this->ref_cod_serie}' AND ref_cod_escola = '{$this->ref_cod_escola}' AND ref_cod_disciplina = '{$this->ref_cod_disciplina}'" ); - $db->ProximoRegistro(); - return $db->Tupla(); - } - return FALSE; - } - - /** - * Exclui um registro. - * @return bool - */ - function excluir() - { - if (is_numeric($this->ref_cod_matricula) && is_numeric($this->ref_cod_serie) && - is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_disciplina) && - is_numeric($this->ref_usuario_exc) - ) { - $db = new clsBanco(); - $db->Consulta("DELETE FROM {$this->_tabela} WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_disciplina = '{$this->ref_cod_disciplina}'"); - return $this->edita(); - } - return FALSE; - } - - /** - * Define quais campos da tabela serão selecionados no método Lista(). - */ - function setCamposLista($str_campos) - { - $this->_campos_lista = $str_campos; - } - - /** - * Define que o método Lista() deverpa retornar todos os campos da tabela. - */ - function resetCamposLista() - { - $this->_campos_lista = $this->_todos_campos; - } - - /** - * Define limites de retorno para o método Lista(). - */ - function setLimite($intLimiteQtd, $intLimiteOffset = NULL) - { - $this->_limite_quantidade = $intLimiteQtd; - $this->_limite_offset = $intLimiteOffset; - } - - /** - * Retorna a string com o trecho da query responsável pelo limite de - * registros retornados/afetados. - * - * @return string - */ - function getLimite() - { - if (is_numeric($this->_limite_quantidade)) { - $retorno = " LIMIT {$this->_limite_quantidade}"; - if (is_numeric($this->_limite_offset)) { - $retorno .= " OFFSET {$this->_limite_offset} "; - } - return $retorno; - } - return ''; - } - - /** - * Define o campo para ser utilizado como ordenação no método Lista(). - */ - function setOrderby($strNomeCampo) - { - if (is_string($strNomeCampo) && $strNomeCampo ) { - $this->_campo_order_by = $strNomeCampo; - } - } - - /** - * Retorna a string com o trecho da query responsável pela Ordenação dos - * registros. - * - * @return string - */ - function getOrderby() - { - if (is_string($this->_campo_order_by)) { - return " ORDER BY {$this->_campo_order_by} "; + return ''; } - return ''; - } } \ No newline at end of file diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarDistribuicaoUniforme.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarDistribuicaoUniforme.inc.php index d1c3d61673..b051211be7 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarDistribuicaoUniforme.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarDistribuicaoUniforme.inc.php @@ -1,621 +1,687 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Lucas Schmoeller da Silva - * @category i-Educar - * @license @@license@@ - * @package Module - * @since ? - * @version $Id$ - */ require_once 'include/pmieducar/geral.inc.php'; -/** - * clsPmieducarDistribuicaoUniforme class. - * - * @author Lucas Schmoeller da Silva - * @category i-Educar - * @license @@license@@ - * @package Module - * @since ? - * @version @@package_version@@ - */ class clsPmieducarDistribuicaoUniforme { - var $cod_distribuicao_uniforme; - var $ref_cod_aluno; - var $ano; - var $kit_completo; - var $agasalho_qtd; - var $camiseta_curta_qtd; - var $camiseta_longa_qtd; - var $meias_qtd; - var $bermudas_tectels_qtd; - var $bermudas_coton_qtd; - var $tenis_qtd; - var $data; - var $agasalho_tm; - var $camiseta_curta_tm; - var $camiseta_longa_tm; - var $meias_tm; - var $bermudas_tectels_tm; - var $bermudas_coton_tm; - var $tenis_tm; - var $ref_cod_escola; - - /** - * @var int - * Armazena o total de resultados obtidos na última chamada ao método lista(). - */ - var $_total; - - /** - * Nome do schema. - * @var string - */ - var $_schema; - - /** - * Nome da tabela. - * @var string - */ - var $_tabela; - - /** - * Lista separada por vírgula, com os campos que devem ser selecionados na - * próxima chamado ao método lista(). - * @var string - */ - var $_campos_lista; - - /** - * Lista com todos os campos da tabela separados por vírgula, padrão para - * seleção no método lista. - * @var string - */ - var $_todos_campos; - - /** - * Valor que define a quantidade de registros a ser retornada pelo método lista(). - * @var int - */ - var $_limite_quantidade; - - /** - * Define o valor de offset no retorno dos registros no método lista(). - * @var int - */ - var $_limite_offset; - - /** - * Define o campo para ser usado como padrão de ordenação no método lista(). - * @var string - */ - var $_campo_order_by; - - /** - * Construtor. - */ - function __construct( $cod_distribuicao_uniforme = NULL, $ref_cod_aluno = NULL, $ano = NULL, - $kit_completo = NULL, $agasalho_qtd = NULL, $camiseta_curta_qtd = NULL, - $camiseta_longa_qtd = NULL, $meias_qtd = NULL, $bermudas_tectels_qtd = NULL, - $bermudas_coton_qtd = NULL, $tenis_qtd = NULL, $data = NULL, $agasalho_tm = NULL, $camiseta_curta_tm = NULL, - $camiseta_longa_tm = NULL, $meias_tm = NULL, $bermudas_tectels_tm = NULL, - $bermudas_coton_tm = NULL, $tenis_tm = NULL, $ref_cod_escola = NULL) - { - $db = new clsBanco(); - $this->_schema = "pmieducar."; - $this->_tabela = "{$this->_schema}distribuicao_uniforme"; - - $this->_campos_lista = $this->_todos_campos = " cod_distribuicao_uniforme, ref_cod_aluno, ano, kit_completo, agasalho_qtd, camiseta_curta_qtd, - camiseta_longa_qtd, meias_qtd, bermudas_tectels_qtd, bermudas_coton_qtd, tenis_qtd, data, - agasalho_tm, camiseta_curta_tm, camiseta_longa_tm, meias_tm, bermudas_tectels_tm, bermudas_coton_tm, tenis_tm, ref_cod_escola"; - - if (is_numeric($cod_distribuicao_uniforme)) { - $this->cod_distribuicao_uniforme = $cod_distribuicao_uniforme; - } + public $cod_distribuicao_uniforme; - if (is_numeric($ref_cod_aluno)) { - $this->ref_cod_aluno = $ref_cod_aluno; - } + public $ref_cod_aluno; - if (is_numeric($ano)) { - $this->ano = $ano; - } + public $ano; - $this->kit_completo = $kit_completo; + public $kit_completo; - if (is_numeric($agasalho_qtd)) { - $this->agasalho_qtd = $agasalho_qtd; - } + public $agasalho_qtd; - if (is_numeric($camiseta_curta_qtd)) { - $this->camiseta_curta_qtd = $camiseta_curta_qtd; - } + public $camiseta_curta_qtd; - if (is_numeric($camiseta_longa_qtd)) { - $this->camiseta_longa_qtd = $camiseta_longa_qtd; - } + public $camiseta_longa_qtd; - if (is_numeric($meias_qtd)) { - $this->meias_qtd = $meias_qtd; - } + public $meias_qtd; - if (is_numeric($bermudas_tectels_qtd)) { - $this->bermudas_tectels_qtd = $bermudas_tectels_qtd; - } + public $bermudas_tectels_qtd; - if (is_numeric($bermudas_coton_qtd)) { - $this->bermudas_coton_qtd = $bermudas_coton_qtd; - } + public $bermudas_coton_qtd; - if (is_numeric($tenis_qtd)) { - $this->tenis_qtd = $tenis_qtd; - } + public $tenis_qtd; - if (is_string($data)) { - $this->data = $data; + public $data; + + public $agasalho_tm; + + public $camiseta_curta_tm; + + public $camiseta_longa_tm; + + public $meias_tm; + + public $bermudas_tectels_tm; + + public $bermudas_coton_tm; + + public $tenis_tm; + + public $ref_cod_escola; + + public $camiseta_infantil_qtd; + + public $camiseta_infantil_tm; + + /** + * Armazena o total de resultados obtidos na última chamada ao método lista(). + * + * @var int + */ + public $_total; + + /** + * Nome do schema. + * + * @var string + */ + public $_schema; + + /** + * Nome da tabela. + * + * @var string + */ + public $_tabela; + + /** + * Lista separada por vírgula, com os campos que devem ser selecionados na + * próxima chamado ao método lista(). + * + * @var string + */ + public $_campos_lista; + + /** + * Lista com todos os campos da tabela separados por vírgula, padrão para + * seleção no método lista. + * + * @var string + */ + public $_todos_campos; + + /** + * Valor que define a quantidade de registros a ser retornada pelo método lista(). + * + * @var int + */ + public $_limite_quantidade; + + /** + * Define o valor de offset no retorno dos registros no método lista(). + * + * @var int + */ + public $_limite_offset; + + /** + * Define o campo para ser usado como padrão de ordenação no método lista(). + * + * @var string + */ + public $_campo_order_by; + + /** + * Construtor. + */ + public function __construct( + $cod_distribuicao_uniforme = null, + $ref_cod_aluno = null, + $ano = null, + $kit_completo = null, + $agasalho_qtd = null, + $camiseta_curta_qtd = null, + $camiseta_longa_qtd = null, + $meias_qtd = null, + $bermudas_tectels_qtd = null, + $bermudas_coton_qtd = null, + $tenis_qtd = null, + $data = null, + $agasalho_tm = null, + $camiseta_curta_tm = null, + $camiseta_longa_tm = null, + $meias_tm = null, + $bermudas_tectels_tm = null, + $bermudas_coton_tm = null, + $tenis_tm = null, + $ref_cod_escola = null, + $camiseta_infantil_qtd = null, + $camiseta_infantil_tm = null + ) { + $this->_schema = 'pmieducar.'; + $this->_tabela = "{$this->_schema}distribuicao_uniforme"; + + $this->_campos_lista = $this->_todos_campos = ' + cod_distribuicao_uniforme, ref_cod_aluno, ano, kit_completo, + agasalho_qtd, camiseta_curta_qtd, camiseta_longa_qtd, meias_qtd, + bermudas_tectels_qtd, bermudas_coton_qtd, tenis_qtd, data, + agasalho_tm, camiseta_curta_tm, camiseta_longa_tm, meias_tm, + bermudas_tectels_tm, bermudas_coton_tm, tenis_tm, ref_cod_escola, + camiseta_infantil_qtd, camiseta_infantil_tm + '; + + if (is_numeric($cod_distribuicao_uniforme)) { + $this->cod_distribuicao_uniforme = $cod_distribuicao_uniforme; + } + + if (is_numeric($ref_cod_aluno)) { + $this->ref_cod_aluno = $ref_cod_aluno; + } + + if (is_numeric($ano)) { + $this->ano = $ano; + } + + $this->kit_completo = $kit_completo; + + if (is_numeric($agasalho_qtd)) { + $this->agasalho_qtd = $agasalho_qtd; + } + + if (is_numeric($camiseta_curta_qtd)) { + $this->camiseta_curta_qtd = $camiseta_curta_qtd; + } + + if (is_numeric($camiseta_longa_qtd)) { + $this->camiseta_longa_qtd = $camiseta_longa_qtd; + } + + if (is_numeric($meias_qtd)) { + $this->meias_qtd = $meias_qtd; + } + + if (is_numeric($bermudas_tectels_qtd)) { + $this->bermudas_tectels_qtd = $bermudas_tectels_qtd; + } + + if (is_numeric($bermudas_coton_qtd)) { + $this->bermudas_coton_qtd = $bermudas_coton_qtd; + } + + if (is_numeric($tenis_qtd)) { + $this->tenis_qtd = $tenis_qtd; + } + + if (is_string($data)) { + $this->data = $data; + } + + if (is_numeric($camiseta_infantil_qtd)) { + $this->camiseta_infantil_qtd = $camiseta_infantil_qtd; + } + + if (is_string($camiseta_infantil_tm)) { + $this->camiseta_infantil_tm = $camiseta_infantil_tm; + } + + $this->agasalho_tm = $agasalho_tm; + $this->camiseta_curta_tm = $camiseta_curta_tm; + $this->camiseta_longa_tm = $camiseta_longa_tm; + $this->meias_tm = $meias_tm; + $this->bermudas_tectels_tm = $bermudas_tectels_tm; + $this->bermudas_coton_tm = $bermudas_coton_tm; + $this->tenis_tm = $tenis_tm; + $this->ref_cod_escola = $ref_cod_escola; } - $this->agasalho_tm = $agasalho_tm; - $this->camiseta_curta_tm = $camiseta_curta_tm; - $this->camiseta_longa_tm = $camiseta_longa_tm; - $this->meias_tm = $meias_tm; - $this->bermudas_tectels_tm = $bermudas_tectels_tm; - $this->bermudas_coton_tm = $bermudas_coton_tm; - $this->tenis_tm = $tenis_tm; - $this->ref_cod_escola = $ref_cod_escola; - - } - - /** - * Cria um novo registro. - * @return bool - */ - function cadastra() - { - if (is_numeric($this->ref_cod_aluno) && is_numeric($this->ano)) + + /** + * Cria um novo registro. + * + * @return bool + */ + public function cadastra() { - $db = new clsBanco(); - - $campos = ''; - $valores = ''; - $gruda = ''; - - $campos .= "{$gruda}ref_cod_aluno"; - $valores .= "{$gruda}{$this->ref_cod_aluno}"; - $gruda = ", "; - - $campos .= "{$gruda}ano"; - $valores .= "{$gruda}{$this->ano}"; - $gruda = ", "; - - if(dbBool($this->kit_completo)){ - $campos .= "{$gruda}kit_completo"; - $valores .= "{$gruda} TRUE "; - $gruda = ", "; - }else{ - $campos .= "{$gruda}kit_completo"; - $valores .= "{$gruda} FALSE "; - $gruda = ", "; - } - - if(is_numeric($this->agasalho_qtd)){ - $campos .= "{$gruda}agasalho_qtd"; - $valores .= "{$gruda}{$this->agasalho_qtd}"; - $gruda = ", "; - } - - if(is_numeric($this->camiseta_curta_qtd)){ - $campos .= "{$gruda}camiseta_curta_qtd"; - $valores .= "{$gruda}{$this->camiseta_curta_qtd}"; - $gruda = ", "; - } - - if(is_numeric($this->camiseta_longa_qtd)){ - $campos .= "{$gruda}camiseta_longa_qtd"; - $valores .= "{$gruda}{$this->camiseta_longa_qtd}"; - $gruda = ", "; - } - - if(is_numeric($this->meias_qtd)){ - $campos .= "{$gruda}meias_qtd"; - $valores .= "{$gruda}{$this->meias_qtd}"; - $gruda = ", "; - } - - if(is_numeric($this->bermudas_tectels_qtd)){ - $campos .= "{$gruda}bermudas_tectels_qtd"; - $valores .= "{$gruda}{$this->bermudas_tectels_qtd}"; - $gruda = ", "; - } - - if(is_numeric($this->bermudas_coton_qtd)){ - $campos .= "{$gruda}bermudas_coton_qtd"; - $valores .= "{$gruda}{$this->bermudas_coton_qtd}"; - $gruda = ", "; - } - - if(is_numeric($this->tenis_qtd)){ - $campos .= "{$gruda}tenis_qtd"; - $valores .= "{$gruda}{$this->tenis_qtd}"; - $gruda = ", "; - } - - if(is_string($this->data)){ - $campos .= "{$gruda}data"; - $valores .= "{$gruda}'{$this->data}'"; - $gruda = ", "; - } - if(is_string($this->agasalho_tm)){ - $campos .= "{$gruda}agasalho_tm"; - $valores .= "{$gruda}'{$this->agasalho_tm}'"; - $gruda = ", "; - } - - if(is_string($this->camiseta_curta_tm)){ - $campos .= "{$gruda}camiseta_curta_tm"; - $valores .= "{$gruda}'{$this->camiseta_curta_tm}'"; - $gruda = ", "; - } - - if(is_string($this->camiseta_longa_tm)){ - $campos .= "{$gruda}camiseta_longa_tm"; - $valores .= "{$gruda}'{$this->camiseta_longa_tm}'"; - $gruda = ", "; - } - - if(is_string($this->meias_tm)){ - $campos .= "{$gruda}meias_tm"; - $valores .= "{$gruda}'{$this->meias_tm}'"; - $gruda = ", "; - } - - if(is_string($this->bermudas_tectels_tm)){ - $campos .= "{$gruda}bermudas_tectels_tm"; - $valores .= "{$gruda}'{$this->bermudas_tectels_tm}'"; - $gruda = ", "; - } - - if(is_string($this->bermudas_coton_tm)){ - $campos .= "{$gruda}bermudas_coton_tm"; - $valores .= "{$gruda}'{$this->bermudas_coton_tm}'"; - $gruda = ", "; - } - - if(is_string($this->tenis_tm)){ - $campos .= "{$gruda}tenis_tm"; - $valores .= "{$gruda}'{$this->tenis_tm}'"; - $gruda = ", "; - } - - if($this->ref_cod_escola){ - $campos .= "{$gruda}ref_cod_escola"; - $valores .= "{$gruda}{$this->ref_cod_escola}"; - $gruda = ", "; - } - - $db->Consulta("INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )"); - return $db->insertId("{$this->_tabela}_seq"); - } + if (is_numeric($this->ref_cod_aluno) && is_numeric($this->ano)) { + $db = new clsBanco(); + + $campos = ''; + $valores = ''; + $gruda = ''; + + $campos .= "{$gruda}ref_cod_aluno"; + $valores .= "{$gruda}{$this->ref_cod_aluno}"; + $gruda = ', '; + + $campos .= "{$gruda}ano"; + $valores .= "{$gruda}{$this->ano}"; + $gruda = ', '; + + if (dbBool($this->kit_completo)) { + $campos .= "{$gruda}kit_completo"; + $valores .= "{$gruda} TRUE "; + $gruda = ', '; + } else { + $campos .= "{$gruda}kit_completo"; + $valores .= "{$gruda} FALSE "; + $gruda = ', '; + } + + if (is_numeric($this->agasalho_qtd)) { + $campos .= "{$gruda}agasalho_qtd"; + $valores .= "{$gruda}{$this->agasalho_qtd}"; + $gruda = ', '; + } + + if (is_numeric($this->camiseta_curta_qtd)) { + $campos .= "{$gruda}camiseta_curta_qtd"; + $valores .= "{$gruda}{$this->camiseta_curta_qtd}"; + $gruda = ', '; + } + + if (is_numeric($this->camiseta_longa_qtd)) { + $campos .= "{$gruda}camiseta_longa_qtd"; + $valores .= "{$gruda}{$this->camiseta_longa_qtd}"; + $gruda = ', '; + } + + if (is_numeric($this->meias_qtd)) { + $campos .= "{$gruda}meias_qtd"; + $valores .= "{$gruda}{$this->meias_qtd}"; + $gruda = ', '; + } + + if (is_numeric($this->bermudas_tectels_qtd)) { + $campos .= "{$gruda}bermudas_tectels_qtd"; + $valores .= "{$gruda}{$this->bermudas_tectels_qtd}"; + $gruda = ', '; + } + + if (is_numeric($this->bermudas_coton_qtd)) { + $campos .= "{$gruda}bermudas_coton_qtd"; + $valores .= "{$gruda}{$this->bermudas_coton_qtd}"; + $gruda = ', '; + } + + if (is_numeric($this->tenis_qtd)) { + $campos .= "{$gruda}tenis_qtd"; + $valores .= "{$gruda}{$this->tenis_qtd}"; + $gruda = ', '; + } + + if (is_string($this->data)) { + $campos .= "{$gruda}data"; + $valores .= "{$gruda}'{$this->data}'"; + $gruda = ', '; + } + if (is_string($this->agasalho_tm)) { + $campos .= "{$gruda}agasalho_tm"; + $valores .= "{$gruda}'{$this->agasalho_tm}'"; + $gruda = ', '; + } + + if (is_string($this->camiseta_curta_tm)) { + $campos .= "{$gruda}camiseta_curta_tm"; + $valores .= "{$gruda}'{$this->camiseta_curta_tm}'"; + $gruda = ', '; + } + + if (is_string($this->camiseta_longa_tm)) { + $campos .= "{$gruda}camiseta_longa_tm"; + $valores .= "{$gruda}'{$this->camiseta_longa_tm}'"; + $gruda = ', '; + } + + if (is_string($this->meias_tm)) { + $campos .= "{$gruda}meias_tm"; + $valores .= "{$gruda}'{$this->meias_tm}'"; + $gruda = ', '; + } + + if (is_string($this->bermudas_tectels_tm)) { + $campos .= "{$gruda}bermudas_tectels_tm"; + $valores .= "{$gruda}'{$this->bermudas_tectels_tm}'"; + $gruda = ', '; + } + + if (is_string($this->bermudas_coton_tm)) { + $campos .= "{$gruda}bermudas_coton_tm"; + $valores .= "{$gruda}'{$this->bermudas_coton_tm}'"; + $gruda = ', '; + } + + if (is_string($this->tenis_tm)) { + $campos .= "{$gruda}tenis_tm"; + $valores .= "{$gruda}'{$this->tenis_tm}'"; + $gruda = ', '; + } + + if ($this->ref_cod_escola) { + $campos .= "{$gruda}ref_cod_escola"; + $valores .= "{$gruda}{$this->ref_cod_escola}"; + $gruda = ', '; + } + + if (is_numeric($this->camiseta_infantil_qtd)) { + $campos .= "{$gruda}camiseta_infantil_qtd"; + $valores .= "{$gruda}{$this->camiseta_infantil_qtd}"; + $gruda = ', '; + } + + if (is_string($this->camiseta_infantil_tm)) { + $campos .= "{$gruda}camiseta_infantil_tm"; + $valores .= "{$gruda}'{$this->camiseta_infantil_tm}'"; + $gruda = ', '; + } + + $db->Consulta("INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )"); + + return $db->insertId("{$this->_tabela}_seq"); + } - return FALSE; - } - - /** - * Edita os dados de um registro. - * @return bool - */ - function edita() - { - if (is_numeric($this->cod_distribuicao_uniforme)) { - $db = new clsBanco(); - $set = ''; - - if (is_numeric($this->ano)) - $set .= " ano = '{$this->ano}' "; - else return false; + } - if (dbBool($this->kit_completo)) - $set .= ",kit_completo = TRUE "; - else{ - $set .= ",kit_completo = FALSE"; - } - - if (is_numeric($this->agasalho_qtd)) - $set .= ",agasalho_qtd = '{$this->agasalho_qtd}'"; - else{ - $set .= ",agasalho_qtd = NULL"; - } - - if (is_numeric($this->camiseta_curta_qtd)) - $set .= ",camiseta_curta_qtd = '{$this->camiseta_curta_qtd}'"; - else{ - $set .= ",camiseta_curta_qtd = NULL"; - } - - if (is_numeric($this->camiseta_longa_qtd)) - $set .= ",camiseta_longa_qtd = '{$this->camiseta_longa_qtd}'"; - else{ - $set .= ",camiseta_longa_qtd = NULL"; - } - - if (is_numeric($this->meias_qtd)) - $set .= ",meias_qtd = '{$this->meias_qtd}'"; - else{ - $set .= ",meias_qtd = NULL"; - } - - if (is_numeric($this->bermudas_tectels_qtd)) - $set .= ",bermudas_tectels_qtd = '{$this->bermudas_tectels_qtd}'"; - else{ - $set .= ",bermudas_tectels_qtd = NULL"; - } - - if (is_numeric($this->bermudas_coton_qtd)) - $set .= ",bermudas_coton_qtd = '{$this->bermudas_coton_qtd}'"; - else{ - $set .= ",bermudas_coton_qtd = NULL"; - } - - if (is_numeric($this->tenis_qtd)) - $set .= ",tenis_qtd = '{$this->tenis_qtd}'"; - else{ - $set .= ",tenis_qtd = NULL"; - } - - if(is_string($this->data)) - $set .= ",data = '{$this->data}'"; - - if ($this->agasalho_tm) - $set .= ",agasalho_tm = '{$this->agasalho_tm}'"; - else{ - $set .= ",agasalho_tm = NULL"; - } - - if ($this->camiseta_curta_tm) - $set .= ",camiseta_curta_tm = '{$this->camiseta_curta_tm}'"; - else{ - $set .= ",camiseta_curta_tm = NULL"; - } - - if ($this->camiseta_longa_tm) - $set .= ",camiseta_longa_tm = '{$this->camiseta_longa_tm}'"; - else{ - $set .= ",camiseta_longa_tm = NULL"; - } - - if ($this->meias_tm) - $set .= ",meias_tm = '{$this->meias_tm}'"; - else{ - $set .= ",meias_tm = NULL"; - } - - if ($this->bermudas_tectels_tm) - $set .= ",bermudas_tectels_tm = '{$this->bermudas_tectels_tm}'"; - else{ - $set .= ",bermudas_tectels_tm = NULL"; - } - - if ($this->bermudas_coton_tm) - $set .= ",bermudas_coton_tm = '{$this->bermudas_coton_tm}'"; - else{ - $set .= ",bermudas_coton_tm = NULL"; - } - - if ($this->tenis_tm) - $set .= ",tenis_tm = '{$this->tenis_tm}'"; - else{ - $set .= ",tenis_tm = NULL"; - } - if ($this->ref_cod_escola) - $set .= ",ref_cod_escola = '{$this->ref_cod_escola}'"; - else{ - $set .= ",ref_cod_escola = NULL"; - } - - if ($set) { - $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE cod_distribuicao_uniforme = '{$this->cod_distribuicao_uniforme}'"); - return TRUE; - } + /** + * Edita os dados de um registro. + * + * @return bool + */ + public function edita() + { + if (is_numeric($this->cod_distribuicao_uniforme)) { + $db = new clsBanco(); + $set = ''; + + if (is_numeric($this->ano)) { + $set .= " ano = '{$this->ano}' "; + } else { + return false; + } + + if (dbBool($this->kit_completo)) { + $set .= ',kit_completo = TRUE '; + } else { + $set .= ',kit_completo = FALSE'; + } + + if (is_numeric($this->agasalho_qtd)) { + $set .= ",agasalho_qtd = '{$this->agasalho_qtd}'"; + } else { + $set .= ',agasalho_qtd = NULL'; + } + + if (is_numeric($this->camiseta_curta_qtd)) { + $set .= ",camiseta_curta_qtd = '{$this->camiseta_curta_qtd}'"; + } else { + $set .= ',camiseta_curta_qtd = NULL'; + } + + if (is_numeric($this->camiseta_longa_qtd)) { + $set .= ",camiseta_longa_qtd = '{$this->camiseta_longa_qtd}'"; + } else { + $set .= ',camiseta_longa_qtd = NULL'; + } + + if (is_numeric($this->meias_qtd)) { + $set .= ",meias_qtd = '{$this->meias_qtd}'"; + } else { + $set .= ',meias_qtd = NULL'; + } + + if (is_numeric($this->bermudas_tectels_qtd)) { + $set .= ",bermudas_tectels_qtd = '{$this->bermudas_tectels_qtd}'"; + } else { + $set .= ',bermudas_tectels_qtd = NULL'; + } + + if (is_numeric($this->bermudas_coton_qtd)) { + $set .= ",bermudas_coton_qtd = '{$this->bermudas_coton_qtd}'"; + } else { + $set .= ',bermudas_coton_qtd = NULL'; + } + + if (is_numeric($this->tenis_qtd)) { + $set .= ",tenis_qtd = '{$this->tenis_qtd}'"; + } else { + $set .= ',tenis_qtd = NULL'; + } + + if (is_string($this->data)) { + $set .= ",data = '{$this->data}'"; + } + + if ($this->agasalho_tm) { + $set .= ",agasalho_tm = '{$this->agasalho_tm}'"; + } else { + $set .= ',agasalho_tm = NULL'; + } + + if ($this->camiseta_curta_tm) { + $set .= ",camiseta_curta_tm = '{$this->camiseta_curta_tm}'"; + } else { + $set .= ',camiseta_curta_tm = NULL'; + } + + if ($this->camiseta_longa_tm) { + $set .= ",camiseta_longa_tm = '{$this->camiseta_longa_tm}'"; + } else { + $set .= ',camiseta_longa_tm = NULL'; + } + + if ($this->meias_tm) { + $set .= ",meias_tm = '{$this->meias_tm}'"; + } else { + $set .= ',meias_tm = NULL'; + } + + if ($this->bermudas_tectels_tm) { + $set .= ",bermudas_tectels_tm = '{$this->bermudas_tectels_tm}'"; + } else { + $set .= ',bermudas_tectels_tm = NULL'; + } + + if ($this->bermudas_coton_tm) { + $set .= ",bermudas_coton_tm = '{$this->bermudas_coton_tm}'"; + } else { + $set .= ',bermudas_coton_tm = NULL'; + } + + if ($this->tenis_tm) { + $set .= ",tenis_tm = '{$this->tenis_tm}'"; + } else { + $set .= ',tenis_tm = NULL'; + } + if ($this->ref_cod_escola) { + $set .= ",ref_cod_escola = '{$this->ref_cod_escola}'"; + } else { + $set .= ',ref_cod_escola = NULL'; + } + + if ($this->camiseta_infantil_qtd) { + $set .= ",camiseta_infantil_qtd = '{$this->camiseta_infantil_qtd}'"; + } else { + $set .= ',camiseta_infantil_qtd = NULL'; + } + + if ($this->camiseta_infantil_tm) { + $set .= ",camiseta_infantil_tm = '{$this->camiseta_infantil_tm}'"; + } else { + $set .= ',camiseta_infantil_tm = NULL'; + } + + if ($set) { + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE cod_distribuicao_uniforme = '{$this->cod_distribuicao_uniforme}'"); + + return true; + } + } + + return false; } - return FALSE; - } + /** + * Retorna uma lista de registros filtrados de acordo com os parâmetros. + * + * @return array + */ + public function lista($ref_cod_aluno = null, $ano = null) + { + $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; + $filtros = ' WHERE TRUE '; - /** - * Retorna uma lista de registros filtrados de acordo com os parâmetros. - * @return array - */ - function lista($ref_cod_aluno = NULL, $ano = NULL) - { - $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; - $filtros = " WHERE TRUE "; - // implementar + if (is_numeric($ref_cod_aluno)) { + $filtros .= " AND ref_cod_aluno = {$ref_cod_aluno} "; + } - if(is_numeric($ref_cod_aluno)) - $filtros .= " AND ref_cod_aluno = {$ref_cod_aluno} "; + if (is_numeric($ano)) { + $filtros .= " AND ano = {$ano} "; + } - if(is_numeric($ano)) - $filtros .= " AND ano = {$ano} "; + $db = new clsBanco(); + $countCampos = count(explode(',', $this->_campos_lista)) + 2; + $resultado = []; - $db = new clsBanco(); - $countCampos = count(explode(',', $this->_campos_lista))+2; - $resultado = array(); + $sql .= $filtros . $this->getOrderby() . $this->getLimite(); - $sql .= $filtros . $this->getOrderby() . $this->getLimite(); + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}"); - $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}"); + $db->Consulta($sql); - $db->Consulta($sql); + if ($countCampos > 1) { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + $tupla['_total'] = $this->_total; + $resultado[] = $tupla; + } + } else { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + $resultado[] = $tupla[$this->_campos_lista]; + } + } - if ($countCampos > 1) { - while ($db->ProximoRegistro()) { - $tupla = $db->Tupla(); - $tupla["_total"] = $this->_total; - $resultado[] = $tupla; - } + if (count($resultado)) { + return $resultado; + } + + return false; } - else { - while ($db->ProximoRegistro()) { - $tupla = $db->Tupla(); - $resultado[] = $tupla[$this->_campos_lista]; - } + + /** + * Retorna um array com os dados de um registro. + * + * @return array + */ + public function detalhe() + { + if (is_numeric($this->cod_distribuicao_uniforme)) { + $db = new clsBanco(); + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_distribuicao_uniforme = '{$this->cod_distribuicao_uniforme}'"); + $db->ProximoRegistro(); + + return $db->Tupla(); + } + + return false; } - if (count($resultado)) { - return $resultado; + + /** + * Retorna um array com os dados de um registro. + * + * @return array + */ + public function detalhePorAlunoAno() + { + if (is_numeric($this->ref_cod_aluno) && is_numeric($this->ano)) { + $db = new clsBanco(); + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE ano = '{$this->ano}' AND ref_cod_aluno = '{$this->ref_cod_aluno}'"); + $db->ProximoRegistro(); + + return $db->Tupla(); + } + + return false; } - return FALSE; - } - - /** - * Retorna um array com os dados de um registro. - * @return array - */ - function detalhe() - { - if (is_numeric($this->cod_distribuicao_uniforme)) { - $db = new clsBanco(); - $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_distribuicao_uniforme = '{$this->cod_distribuicao_uniforme}'"); - $db->ProximoRegistro(); - return $db->Tupla(); + /** + * Retorna um array com os dados de um registro. + * + * @return array + */ + public function existe() + { + if (is_numeric($this->cod_distribuicao_uniforme)) { + $db = new clsBanco(); + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_distribuicao_uniforme = '{$this->cod_distribuicao_uniforme}'"); + $db->ProximoRegistro(); + + return $db->Tupla(); + } + + return false; } - return FALSE; - } - - /** - * Retorna um array com os dados de um registro. - * @return array - */ - function detalhePorAlunoAno() - { - if (is_numeric($this->ref_cod_aluno) && is_numeric($this->ano)) { - $db = new clsBanco(); - $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE ano = '{$this->ano}' AND ref_cod_aluno = '{$this->ref_cod_aluno}'"); - $db->ProximoRegistro(); - return $db->Tupla(); + /** + * Exclui um registro. + * + * @return bool + */ + public function excluir() + { + if (is_numeric($this->cod_distribuicao_uniforme)) { + $sql = "DELETE FROM {$this->_tabela} WHERE cod_distribuicao_uniforme = '{$this->cod_distribuicao_uniforme}'"; + $db = new clsBanco(); + $db->Consulta($sql); + + return true; + } + + return false; } - return FALSE; - } - - /** - * Retorna um array com os dados de um registro. - * @return array - */ - function existe() - { - if (is_numeric($this->cod_distribuicao_uniforme)) { - $db = new clsBanco(); - $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_distribuicao_uniforme = '{$this->cod_distribuicao_uniforme}'"); - $db->ProximoRegistro(); - return $db->Tupla(); + /** + * Define quais campos da tabela serão selecionados no método Lista(). + */ + public function setCamposLista($str_campos) + { + $this->_campos_lista = $str_campos; } - return FALSE; - } - - /** - * Exclui um registro. - * @return bool - */ - function excluir() - { - if (is_numeric($this->cod_distribuicao_uniforme)) { - $sql = "DELETE FROM {$this->_tabela} WHERE cod_distribuicao_uniforme = '{$this->cod_distribuicao_uniforme}'"; - $db = new clsBanco(); - $db->Consulta($sql); - return true; + /** + * Define que o método Lista() deverpa retornar todos os campos da tabela. + */ + public function resetCamposLista() + { + $this->_campos_lista = $this->_todos_campos; } - return FALSE; - } - - /** - * Define quais campos da tabela serão selecionados no método Lista(). - */ - function setCamposLista($str_campos) - { - $this->_campos_lista = $str_campos; - } - - /** - * Define que o método Lista() deverpa retornar todos os campos da tabela. - */ - function resetCamposLista() - { - $this->_campos_lista = $this->_todos_campos; - } - - /** - * Define limites de retorno para o método Lista(). - */ - function setLimite($intLimiteQtd, $intLimiteOffset = NULL) - { - $this->_limite_quantidade = $intLimiteQtd; - $this->_limite_offset = $intLimiteOffset; - } - - /** - * Retorna a string com o trecho da query responsável pelo limite de - * registros retornados/afetados. - * - * @return string - */ - function getLimite() - { - if (is_numeric($this->_limite_quantidade)) { - $retorno = " LIMIT {$this->_limite_quantidade}"; - if (is_numeric($this->_limite_offset)) { - $retorno .= " OFFSET {$this->_limite_offset} "; - } - return $retorno; + /** + * Define limites de retorno para o método Lista(). + */ + public function setLimite($intLimiteQtd, $intLimiteOffset = null) + { + $this->_limite_quantidade = $intLimiteQtd; + $this->_limite_offset = $intLimiteOffset; + } + + /** + * Retorna a string com o trecho da query responsável pelo limite de + * registros retornados/afetados. + * + * @return string + */ + public function getLimite() + { + if (is_numeric($this->_limite_quantidade)) { + $retorno = " LIMIT {$this->_limite_quantidade}"; + + if (is_numeric($this->_limite_offset)) { + $retorno .= " OFFSET {$this->_limite_offset} "; + } + + return $retorno; + } + + return ''; } - return ''; - } - - /** - * Define o campo para ser utilizado como ordenação no método Lista(). - */ - function setOrderby($strNomeCampo) - { - if (is_string($strNomeCampo) && $strNomeCampo ) { - $this->_campo_order_by = $strNomeCampo; + + /** + * Define o campo para ser utilizado como ordenação no método Lista(). + */ + public function setOrderby($strNomeCampo) + { + if (is_string($strNomeCampo) && $strNomeCampo) { + $this->_campo_order_by = $strNomeCampo; + } } - } - - /** - * Retorna a string com o trecho da query responsável pela Ordenação dos - * registros. - * - * @return string - */ - function getOrderby() - { - if (is_string($this->_campo_order_by)) { - return " ORDER BY {$this->_campo_order_by} "; + + /** + * Retorna a string com o trecho da query responsável pela Ordenação dos + * registros. + * + * @return string + */ + public function getOrderby() + { + if (is_string($this->_campo_order_by)) { + return " ORDER BY {$this->_campo_order_by} "; + } + + return ''; } - return ''; - } -} \ No newline at end of file +} diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarInstituicao.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarInstituicao.inc.php index 6ab282c29c..c896d0040e 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarInstituicao.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarInstituicao.inc.php @@ -4,103 +4,112 @@ class clsPmieducarInstituicao { - var $cod_instituicao; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_idtlog; - var $ref_sigla_uf; - var $cep; - var $cidade; - var $bairro; - var $logradouro; - var $numero; - var $complemento; - var $nm_responsavel; - var $ddd_telefone; - var $telefone; - var $data_cadastro; - var $data_exclusao; - var $ativo; - var $nm_instituicao; - var $data_base_remanejamento; - var $data_base_transferencia; - var $exigir_vinculo_turma_professor; - var $controlar_espaco_utilizacao_aluno; - var $percentagem_maxima_ocupacao_salas; - var $quantidade_alunos_metro_quadrado; - var $gerar_historico_transferencia; - var $controlar_posicao_historicos; - var $restringir_multiplas_enturmacoes; - var $permissao_filtro_abandono_transferencia; - var $data_base_matricula; - var $multiplas_reserva_vaga; - var $permitir_carga_horaria; - var $reserva_integral_somente_com_renda; - var $data_expiracao_reserva_vaga; - var $componente_curricular_turma; - var $reprova_dependencia_ano_concluinte; - var $data_educacenso; - var $exigir_dados_socioeconomicos; - var $altera_atestado_para_declaracao; - var $obrigar_campos_censo; - var $obrigar_documento_pessoa; - var $orgao_regional; - var $exigir_lancamentos_anteriores; + public $cod_instituicao; + public $ref_usuario_exc; + public $ref_usuario_cad; + public $ref_idtlog; + public $ref_sigla_uf; + public $cep; + public $cidade; + public $bairro; + public $logradouro; + public $numero; + public $complemento; + public $nm_responsavel; + public $ddd_telefone; + public $telefone; + public $data_cadastro; + public $data_exclusao; + public $ativo; + public $nm_instituicao; + public $data_base_remanejamento; + public $data_base_transferencia; + public $exigir_vinculo_turma_professor; + public $controlar_espaco_utilizacao_aluno; + public $percentagem_maxima_ocupacao_salas; + public $quantidade_alunos_metro_quadrado; + public $gerar_historico_transferencia; + public $controlar_posicao_historicos; + public $restringir_multiplas_enturmacoes; + public $permissao_filtro_abandono_transferencia; + public $data_base_matricula; + public $multiplas_reserva_vaga; + public $permitir_carga_horaria; + public $reserva_integral_somente_com_renda; + public $data_expiracao_reserva_vaga; + public $componente_curricular_turma; + public $reprova_dependencia_ano_concluinte; + public $data_educacenso; + public $exigir_dados_socioeconomicos; + public $altera_atestado_para_declaracao; + public $obrigar_campos_censo; + public $obrigar_documento_pessoa; + public $orgao_regional; + public $exigir_lancamentos_anteriores; + public $exibir_apenas_professores_alocados; /** * Armazena o total de resultados obtidos na última chamada ao método lista(). + * * @var int */ - var $_total; + public $_total; /** * Nome do schema. + * * @var string */ - var $_schema; + public $_schema; /** * Nome da tabela. + * * @var string */ - var $_tabela; + public $_tabela; /** * Lista separada por vírgula, com os campos que devem ser selecionados na * próxima chamado ao método lista(). + * * @var string */ - var $_campos_lista; + public $_campos_lista; /** * Lista com todos os campos da tabela separados por vírgula, padrão para * seleção no método lista. + * * @var string */ - var $_todos_campos; + public $_todos_campos; /** * Valor que define a quantidade de registros a ser retornada pelo método lista(). + * * @var int */ - var $_limite_quantidade; + public $_limite_quantidade; /** * Define o valor de offset no retorno dos registros no método lista(). + * * @var int */ - var $_limite_offset; + public $_limite_offset; /** * Define o campo para ser usado como padrão de ordenação no método lista(). + * * @var string */ - var $_campo_order_by; + public $_campo_order_by; /** * Construtor. */ - function __construct( + public function __construct( $cod_instituicao = null, $ref_usuario_exc = null, $ref_usuario_cad = null, @@ -124,61 +133,64 @@ function __construct( $quantidade_alunos_metro_quadrado = null, $exigir_dados_socioeconomicos = null, $altera_atestado_para_declaracao = null, - $obrigar_campos_censo = NULL, - $obrigar_documento_pessoa = NULL, - $exigir_lancamentos_anteriores = NULL - ) - { + $obrigar_campos_censo = null, + $obrigar_documento_pessoa = null, + $exigir_lancamentos_anteriores = null, + $exibir_apenas_professores_alocados = null + ) { $db = new clsBanco(); - $this->_schema = "pmieducar."; + $this->_schema = 'pmieducar.'; $this->_tabela = "{$this->_schema}instituicao"; - $this->_campos_lista = $this->_todos_campos = "cod_instituicao, - ref_usuario_exc, - ref_usuario_cad, - ref_idtlog, - ref_sigla_uf, - cep, - cidade, - bairro, - logradouro, - numero, - complemento, - nm_responsavel, - ddd_telefone, - telefone, - data_cadastro, - data_exclusao, - ativo, - nm_instituicao, - data_base_transferencia, - data_base_remanejamento, - controlar_espaco_utilizacao_aluno, - percentagem_maxima_ocupacao_salas, - quantidade_alunos_metro_quadrado, - exigir_vinculo_turma_professor, - gerar_historico_transferencia, - matricula_apenas_bairro_escola, - restringir_historico_escolar, - coordenador_transporte, - restringir_multiplas_enturmacoes, - permissao_filtro_abandono_transferencia, - data_base_matricula, - multiplas_reserva_vaga, - reserva_integral_somente_com_renda, - data_expiracao_reserva_vaga, - data_fechamento, - componente_curricular_turma, - controlar_posicao_historicos, - reprova_dependencia_ano_concluinte, - data_educacenso, - bloqueia_matricula_serie_nao_seguinte, - permitir_carga_horaria, - exigir_dados_socioeconomicos, - altera_atestado_para_declaracao, - obrigar_campos_censo, - obrigar_documento_pessoa, - orgao_regional, - exigir_lancamentos_anteriores"; + $this->_campos_lista = $this->_todos_campos = ' + cod_instituicao, + ref_usuario_exc, + ref_usuario_cad, + ref_idtlog, + ref_sigla_uf, + cep, + cidade, + bairro, + logradouro, + numero, + complemento, + nm_responsavel, + ddd_telefone, + telefone, + data_cadastro, + data_exclusao, + ativo, + nm_instituicao, + data_base_transferencia, + data_base_remanejamento, + controlar_espaco_utilizacao_aluno, + percentagem_maxima_ocupacao_salas, + quantidade_alunos_metro_quadrado, + exigir_vinculo_turma_professor, + gerar_historico_transferencia, + matricula_apenas_bairro_escola, + restringir_historico_escolar, + coordenador_transporte, + restringir_multiplas_enturmacoes, + permissao_filtro_abandono_transferencia, + data_base_matricula, + multiplas_reserva_vaga, + reserva_integral_somente_com_renda, + data_expiracao_reserva_vaga, + data_fechamento, + componente_curricular_turma, + controlar_posicao_historicos, + reprova_dependencia_ano_concluinte, + data_educacenso, + bloqueia_matricula_serie_nao_seguinte, + permitir_carga_horaria, + exigir_dados_socioeconomicos, + altera_atestado_para_declaracao, + obrigar_campos_censo, + obrigar_documento_pessoa, + orgao_regional, + exigir_lancamentos_anteriores, + exibir_apenas_professores_alocados + '; if (is_numeric($ref_usuario_cad)) { if (class_exists('clsPmieducarUsuario')) { @@ -323,9 +335,13 @@ function __construct( if (is_bool($exigir_lancamentos_anteriores)) { $this->exigir_lancamentos_anteriores = $exigir_lancamentos_anteriores; } + + if (is_bool($exibir_apenas_professores_alocados)) { + $this->exibir_apenas_professores_alocados = $exibir_apenas_professores_alocados; + } } - function canRegister() + public function canRegister() { return is_numeric($this->ref_usuario_cad) && is_string($this->ref_idtlog) && is_string($this->ref_sigla_uf) && is_numeric($this->cep) && @@ -336,9 +352,10 @@ function canRegister() /** * Cria um novo registro. + * * @return bool */ - function cadastra() + public function cadastra() { if ($this->canRegister()) { $db = new clsBanco(); @@ -350,174 +367,174 @@ function cadastra() if (is_numeric($this->ref_usuario_exc)) { $campos .= "{$gruda}ref_usuario_exc"; $valores .= "{$gruda}'{$this->ref_usuario_exc}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->ref_usuario_cad)) { $campos .= "{$gruda}ref_usuario_cad"; $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->ref_idtlog)) { $campos .= "{$gruda}ref_idtlog"; $valores .= "{$gruda}'{$this->ref_idtlog}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->ref_sigla_uf)) { $campos .= "{$gruda}ref_sigla_uf"; $valores .= "{$gruda}'{$this->ref_sigla_uf}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->cep)) { $campos .= "{$gruda}cep"; $valores .= "{$gruda}'{$this->cep}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->cidade)) { $campos .= "{$gruda}cidade"; $valores .= "{$gruda}'{$this->cidade}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->bairro)) { $campos .= "{$gruda}bairro"; $valores .= "{$gruda}'{$this->bairro}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->logradouro)) { $campos .= "{$gruda}logradouro"; $valores .= "{$gruda}'{$this->logradouro}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->numero)) { $campos .= "{$gruda}numero"; $valores .= "{$gruda}'{$this->numero}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->complemento)) { $campos .= "{$gruda}complemento"; $valores .= "{$gruda}'{$this->complemento}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->nm_responsavel)) { $campos .= "{$gruda}nm_responsavel"; $valores .= "{$gruda}'{$this->nm_responsavel}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->ddd_telefone)) { $campos .= "{$gruda}ddd_telefone"; $valores .= "{$gruda}'{$this->ddd_telefone}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->telefone)) { $campos .= "{$gruda}telefone"; $valores .= "{$gruda}'{$this->telefone}'"; - $gruda = ", "; + $gruda = ', '; } $campos .= "{$gruda}data_cadastro"; $valores .= "{$gruda}NOW()"; - $gruda = ", "; + $gruda = ', '; if (is_numeric($this->ativo)) { $campos .= "{$gruda}ativo"; $valores .= "{$gruda}'{$this->ativo}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->nm_instituicao)) { $campos .= "{$gruda}nm_instituicao"; $valores .= "{$gruda}'{$this->nm_instituicao}'"; - $gruda = ", "; + $gruda = ', '; } - if ((is_string($this->data_base_remanejamento)) AND !empty($this->data_base_remanejamento)) { + if ((is_string($this->data_base_remanejamento)) and !empty($this->data_base_remanejamento)) { $campos .= "{$gruda}data_base_remanejamento"; $valores .= "{$gruda}'{$this->data_base_remanejamento}'"; - $gruda = ", "; + $gruda = ', '; } - if ((is_string($this->data_base_transferencia)) AND !empty($this->data_base_transferencia)) { + if ((is_string($this->data_base_transferencia)) and !empty($this->data_base_transferencia)) { $campos .= "{$gruda}data_base_transferencia"; $valores .= "{$gruda}'{$this->data_base_transferencia}'"; - $gruda = ", "; + $gruda = ', '; } - if ((is_string($this->data_expiracao_reserva_vaga)) AND !empty($this->data_expiracao_reserva_vaga)) { + if ((is_string($this->data_expiracao_reserva_vaga)) and !empty($this->data_expiracao_reserva_vaga)) { $campos .= "{$gruda}data_expiracao_reserva_vaga"; $valores .= "{$gruda}'{$this->data_expiracao_reserva_vaga}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->exigir_vinculo_turma_professor)) { $campos .= "{$gruda}exigir_vinculo_turma_professor"; $valores .= "{$gruda}'{$this->exigir_vinculo_turma_professor}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->controlar_espaco_utilizacao_aluno)) { $campos .= "{$gruda}controlar_espaco_utilizacao_aluno"; $valores .= "{$gruda}'{$this->controlar_espaco_utilizacao_aluno}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->percentagem_maxima_ocupacao_salas)) { $campos .= "{$gruda}percentagem_maxima_ocupacao_salas"; $valores .= "{$gruda}'{$this->percentagem_maxima_ocupacao_salas}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->quantidade_alunos_metro_quadrado)) { $campos .= "{$gruda}quantidade_alunos_metro_quadrado"; $valores .= "{$gruda}'{$this->quantidade_alunos_metro_quadrado}'"; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->gerar_historico_transferencia)) { $campos .= "{$gruda}gerar_historico_transferencia"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}gerar_historico_transferencia"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->controlar_posicao_historicos)) { $campos .= "{$gruda}controlar_posicao_historicos"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}controlar_posicao_historicos"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->matricula_apenas_bairro_escola)) { $campos .= "{$gruda}matricula_apenas_bairro_escola"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}matricula_apenas_bairro_escola"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->restringir_historico_escolar)) { $campos .= "{$gruda}restringir_historico_escolar"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}restringir_historico_escolar"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (strripos($this->coordenador_transporte, '-') and strripos($this->coordenador_transporte, '(')) { @@ -527,164 +544,175 @@ function cadastra() if (is_string($this->coordenador_transporte)) { $campos .= "{$gruda}coordenador_transporte"; $valores .= "{$gruda}'{$this->coordenador_transporte}'"; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->restringir_multiplas_enturmacoes)) { $campos .= "{$gruda}restringir_multiplas_enturmacoes"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}restringir_multiplas_enturmacoes"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->permissao_filtro_abandono_transferencia)) { $campos .= "{$gruda}permissao_filtro_abandono_transferencia"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}permissao_filtro_abandono_transferencia"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->multiplas_reserva_vaga)) { $campos .= "{$gruda}multiplas_reserva_vaga"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}multiplas_reserva_vaga"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->permitir_carga_horaria)) { $campos .= "{$gruda}permitir_carga_horaria"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}permitir_carga_horaria"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->componente_curricular_turma)) { $campos .= "{$gruda}componente_curricular_turma"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}componente_curricular_turma"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->reprova_dependencia_ano_concluinte)) { $campos .= "{$gruda}reprova_dependencia_ano_concluinte"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}reprova_dependencia_ano_concluinte"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->reserva_integral_somente_com_renda)) { $campos .= "{$gruda}reserva_integral_somente_com_renda"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}reserva_integral_somente_com_renda"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->bloqueia_matricula_serie_nao_seguinte)) { $campos .= "{$gruda}bloqueia_matricula_serie_nao_seguinte"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}bloqueia_matricula_serie_nao_seguinte"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } - if ((is_string($this->data_base_matricula)) AND !empty($this->data_base_matricula)) { + if ((is_string($this->data_base_matricula)) and !empty($this->data_base_matricula)) { $campos .= "{$gruda}data_base_matricula"; $valores .= "{$gruda}'{$this->data_base_matricula}'"; - $gruda = ", "; + $gruda = ', '; } - if ((is_string($this->data_fechamento)) AND !empty($this->data_fechamento)) { + if ((is_string($this->data_fechamento)) and !empty($this->data_fechamento)) { $campos .= "{$gruda}data_fechamento"; $valores .= "{$gruda}'{$this->data_fechamento}'"; - $gruda = ", "; + $gruda = ', '; } - if ((is_string($this->data_educacenso)) AND !empty($this->data_educacenso)) { + if ((is_string($this->data_educacenso)) and !empty($this->data_educacenso)) { $campos .= "{$gruda}data_educacenso"; $valores .= "{$gruda}'{$this->data_educacenso}'"; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->exigir_dados_socieconomicos)) { $campos .= "{$gruda}exigir_dados_socioeconomicos"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}exigir_dados_socioeconomicos"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->altera_atestado_para_declaracao)) { $campos .= "{$gruda}altera_atestado_para_declaracao"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}altera_atestado_para_declaracao"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->obrigar_campos_censo)) { $campos .= "{$gruda}obrigar_campos_censo"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}obrigar_campos_censo"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->obrigar_documento_pessoa)) { $campos .= "{$gruda}obrigar_documento_pessoa"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}obrigar_documento_pessoa"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->exigir_lancamentos_anteriores)) { $campos .= "{$gruda}exigir_lancamentos_anteriores"; $valores .= "{$gruda} true "; - $gruda = ", "; + $gruda = ', '; } else { $campos .= "{$gruda}exigir_lancamentos_anteriores"; $valores .= "{$gruda} false "; - $gruda = ", "; + $gruda = ', '; + } + + if (dbBool($this->exibir_apenas_professores_alocados)) { + $campos .= "{$gruda}exibir_apenas_professores_alocados"; + $valores .= "{$gruda} true "; + $gruda = ', '; + } else { + $campos .= "{$gruda}exibir_apenas_professores_alocados"; + $valores .= "{$gruda} false "; + $gruda = ', '; } - if (is_string($this->orgao_regional) AND !empty($this->orgao_regional)) { + if (is_string($this->orgao_regional) and !empty($this->orgao_regional)) { $campos .= "{$gruda}orgao_regional"; $valores .= "{$gruda}'{$this->orgao_regional}'"; - $gruda = ", "; + $gruda = ', '; } $db->Consulta("INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )"); + return $db->InsertId("{$this->_tabela}_cod_instituicao_seq"); } @@ -693,9 +721,10 @@ function cadastra() /** * Edita os dados de um registro. + * * @return bool */ - function edita() + public function edita() { if (is_numeric($this->cod_instituicao)) { $db = new clsBanco(); @@ -703,151 +732,151 @@ function edita() if (is_numeric($this->ref_usuario_exc)) { $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->ref_usuario_cad)) { $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->ref_idtlog)) { $set .= "{$gruda}ref_idtlog = '{$this->ref_idtlog}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->ref_sigla_uf)) { $set .= "{$gruda}ref_sigla_uf = '{$this->ref_sigla_uf}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->cep)) { $set .= "{$gruda}cep = '{$this->cep}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->cidade)) { $set .= "{$gruda}cidade = '{$this->cidade}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->bairro)) { $set .= "{$gruda}bairro = '{$this->bairro}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->logradouro)) { $set .= "{$gruda}logradouro = '{$this->logradouro}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->numero)) { $set .= "{$gruda}numero = '{$this->numero}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->complemento)) { $set .= "{$gruda}complemento = '{$this->complemento}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->nm_responsavel)) { $set .= "{$gruda}nm_responsavel = '{$this->nm_responsavel}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->ddd_telefone)) { $set .= "{$gruda}ddd_telefone = '{$this->ddd_telefone}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->telefone)) { $set .= "{$gruda}telefone = '{$this->telefone}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->data_cadastro)) { $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; - $gruda = ", "; + $gruda = ', '; } $set .= "{$gruda}data_exclusao = NOW()"; - $gruda = ", "; + $gruda = ', '; if (is_numeric($this->ativo)) { $set .= "{$gruda}ativo = '{$this->ativo}'"; - $gruda = ", "; + $gruda = ', '; } if (is_string($this->nm_instituicao)) { $set .= "{$gruda}nm_instituicao = '{$this->nm_instituicao}'"; - $gruda = ", "; + $gruda = ', '; } - if (is_string($this->data_base_transferencia) AND !empty($this->data_base_transferencia)) { + if (is_string($this->data_base_transferencia) and !empty($this->data_base_transferencia)) { $set .= "{$gruda}data_base_transferencia = '{$this->data_base_transferencia}'"; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}data_base_transferencia = null "; - $gruda = ", "; + $gruda = ', '; } - if (is_string($this->data_expiracao_reserva_vaga) AND !empty($this->data_expiracao_reserva_vaga)) { + if (is_string($this->data_expiracao_reserva_vaga) and !empty($this->data_expiracao_reserva_vaga)) { $set .= "{$gruda}data_expiracao_reserva_vaga = '{$this->data_expiracao_reserva_vaga}'"; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}data_expiracao_reserva_vaga = null "; - $gruda = ", "; + $gruda = ', '; } - if (is_string($this->data_base_remanejamento) AND !empty($this->data_base_remanejamento)) { + if (is_string($this->data_base_remanejamento) and !empty($this->data_base_remanejamento)) { $set .= "{$gruda}data_base_remanejamento = '{$this->data_base_remanejamento}'"; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}data_base_remanejamento = null "; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->controlar_espaco_utilizacao_aluno)) { $set .= "{$gruda}controlar_espaco_utilizacao_aluno = '{$this->controlar_espaco_utilizacao_aluno}'"; - $gruda = ", "; + $gruda = ', '; } if (is_numeric($this->exigir_vinculo_turma_professor)) { $set .= "{$gruda}exigir_vinculo_turma_professor = '{$this->exigir_vinculo_turma_professor}'"; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->gerar_historico_transferencia)) { $set .= "{$gruda}gerar_historico_transferencia = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}gerar_historico_transferencia = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->controlar_posicao_historicos)) { $set .= "{$gruda}controlar_posicao_historicos = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}controlar_posicao_historicos = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->matricula_apenas_bairro_escola)) { $set .= "{$gruda}matricula_apenas_bairro_escola = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}matricula_apenas_bairro_escola = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->restringir_historico_escolar)) { $set .= "{$gruda}restringir_historico_escolar = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}restringir_historico_escolar = false "; - $gruda = ", "; + $gruda = ', '; } if (strripos($this->coordenador_transporte, '-') and strripos($this->coordenador_transporte, '(')) { $this->coordenador_transporte = $this->parteString($this->coordenador_transporte, '-', '('); @@ -855,164 +884,173 @@ function edita() if (is_string($this->coordenador_transporte)) { $set .= "{$gruda}coordenador_transporte = '{$this->coordenador_transporte}'"; - $gruda = ", "; + $gruda = ', '; } - if (is_numeric($this->percentagem_maxima_ocupacao_salas) AND !empty($this->percentagem_maxima_ocupacao_salas)) { + if (is_numeric($this->percentagem_maxima_ocupacao_salas) and !empty($this->percentagem_maxima_ocupacao_salas)) { $set .= "{$gruda}percentagem_maxima_ocupacao_salas = '{$this->percentagem_maxima_ocupacao_salas}'"; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}percentagem_maxima_ocupacao_salas = null"; - $gruda = ", "; + $gruda = ', '; } - if (is_numeric($this->quantidade_alunos_metro_quadrado) AND !empty($this->quantidade_alunos_metro_quadrado)) { + if (is_numeric($this->quantidade_alunos_metro_quadrado) and !empty($this->quantidade_alunos_metro_quadrado)) { $set .= "{$gruda}quantidade_alunos_metro_quadrado = '{$this->quantidade_alunos_metro_quadrado}'"; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}quantidade_alunos_metro_quadrado = null"; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->restringir_multiplas_enturmacoes)) { $set .= "{$gruda}restringir_multiplas_enturmacoes = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}restringir_multiplas_enturmacoes = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->permissao_filtro_abandono_transferencia)) { $set .= "{$gruda}permissao_filtro_abandono_transferencia = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}permissao_filtro_abandono_transferencia = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->multiplas_reserva_vaga)) { $set .= "{$gruda}multiplas_reserva_vaga = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}multiplas_reserva_vaga = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->permitir_carga_horaria)) { $set .= "{$gruda}permitir_carga_horaria = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}permitir_carga_horaria = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->reserva_integral_somente_com_renda)) { $set .= "{$gruda}reserva_integral_somente_com_renda = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}reserva_integral_somente_com_renda = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->componente_curricular_turma)) { $set .= "{$gruda}componente_curricular_turma = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}componente_curricular_turma = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->reprova_dependencia_ano_concluinte)) { $set .= "{$gruda}reprova_dependencia_ano_concluinte = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}reprova_dependencia_ano_concluinte = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->bloqueia_matricula_serie_nao_seguinte)) { $set .= "{$gruda}bloqueia_matricula_serie_nao_seguinte = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}bloqueia_matricula_serie_nao_seguinte = false "; - $gruda = ", "; + $gruda = ', '; } - if (is_string($this->data_base_matricula) AND !empty($this->data_base_matricula)) { + if (is_string($this->data_base_matricula) and !empty($this->data_base_matricula)) { $set .= "{$gruda}data_base_matricula = '{$this->data_base_matricula}'"; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}data_base_matricula = null "; - $gruda = ", "; + $gruda = ', '; } - if (is_string($this->data_fechamento) AND !empty($this->data_fechamento)) { + if (is_string($this->data_fechamento) and !empty($this->data_fechamento)) { $set .= "{$gruda}data_fechamento = '{$this->data_fechamento}'"; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}data_fechamento = null "; - $gruda = ", "; + $gruda = ', '; } - if (is_string($this->data_educacenso) AND !empty($this->data_educacenso)) { + if (is_string($this->data_educacenso) and !empty($this->data_educacenso)) { $data_educacenso_pg = Portabilis_Date_Utils::brToPgSQL($this->data_educacenso); $set .= "{$gruda}data_educacenso = '{$data_educacenso_pg}'"; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}data_educacenso = null "; - $gruda = ", "; + $gruda = ', '; } - if (is_string($this->orgao_regional) AND !empty($this->orgao_regional)) { + if (is_string($this->orgao_regional) and !empty($this->orgao_regional)) { $set .= "{$gruda}orgao_regional = '{$this->orgao_regional}'"; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}orgao_regional = null "; - $gruda = ", "; + $gruda = ', '; } if ($this->exigir_dados_socioeconomicos) { $set .= "{$gruda}exigir_dados_socioeconomicos = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}exigir_dados_socioeconomicos = false "; - $gruda = ", "; + $gruda = ', '; } if ($this->altera_atestado_para_declaracao) { $set .= "{$gruda}altera_atestado_para_declaracao = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}altera_atestado_para_declaracao = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->obrigar_campos_censo)) { $set .= "{$gruda}obrigar_campos_censo = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}obrigar_campos_censo = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->obrigar_documento_pessoa)) { $set .= "{$gruda}obrigar_documento_pessoa = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}obrigar_documento_pessoa = false "; - $gruda = ", "; + $gruda = ', '; } if (dbBool($this->exigir_lancamentos_anteriores)) { $set .= "{$gruda}exigir_lancamentos_anteriores = true "; - $gruda = ", "; + $gruda = ', '; } else { $set .= "{$gruda}exigir_lancamentos_anteriores = false "; - $gruda = ", "; + $gruda = ', '; + } + + if (dbBool($this->exibir_apenas_professores_alocados)) { + $set .= "{$gruda}exibir_apenas_professores_alocados = true "; + $gruda = ', '; + } else { + $set .= "{$gruda}exibir_apenas_professores_alocados = false "; + $gruda = ', '; } if ($set) { $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE cod_instituicao = '{$this->cod_instituicao}'"); + return true; } } @@ -1020,7 +1058,7 @@ function edita() return false; } - function parteString($string, $ponto_inicio, $ponto_final) + public function parteString($string, $ponto_inicio, $ponto_final) { $num = 1; if ($string and $ponto_inicio) { @@ -1030,14 +1068,16 @@ function parteString($string, $ponto_inicio, $ponto_final) $num = 0; $registro = explode($ponto_final, $registro[1]); } + return $registro[$num]; } /** * Retorna uma lista de registros filtrados de acordo com os parâmetros. + * * @return array */ - function lista( + public function lista( $int_cod_instituicao = null, $str_ref_sigla_uf = null, $int_cep = null, @@ -1055,81 +1095,81 @@ function lista( $str_nm_instituicao = null ) { $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; - $filtros = ""; + $filtros = ''; - $whereAnd = " WHERE "; + $whereAnd = ' WHERE '; if (is_numeric($int_cod_instituicao)) { $filtros .= "{$whereAnd} cod_instituicao = '{$int_cod_instituicao}'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_string($str_ref_sigla_uf)) { $filtros .= "{$whereAnd} ref_sigla_uf LIKE '%{$str_ref_sigla_uf}%'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_numeric($int_cep)) { $filtros .= "{$whereAnd} cep = '{$int_cep}'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_string($str_cidade)) { $filtros .= "{$whereAnd} cidade LIKE '%{$str_cidade}%'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_string($str_bairro)) { $filtros .= "{$whereAnd} bairro LIKE '%{$str_bairro}%'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_string($str_logradouro)) { $filtros .= "{$whereAnd} logradouro LIKE '%{$str_logradouro}%'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_numeric($int_numero)) { $filtros .= "{$whereAnd} numero = '{$int_numero}'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_string($str_complemento)) { $filtros .= "{$whereAnd} complemento LIKE '%{$str_complemento}%'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_string($str_nm_responsavel)) { $filtros .= "{$whereAnd} nm_responsavel LIKE '%{$str_nm_responsavel}%'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_numeric($int_ddd_telefone)) { $filtros .= "{$whereAnd} ddd_telefone = '{$int_ddd_telefone}'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_numeric($int_telefone)) { $filtros .= "{$whereAnd} telefone = '{$int_telefone}'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_null($int_ativo) || $int_ativo) { $filtros .= "{$whereAnd} ativo = '1'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } else { $filtros .= "{$whereAnd} ativo = '0'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } if (is_string($str_nm_instituicao)) { $filtros .= "{$whereAnd} nm_instituicao LIKE '%{$str_nm_instituicao}%'"; - $whereAnd = " AND "; + $whereAnd = ' AND '; } $db = new clsBanco(); $countCampos = count(explode(',', $this->_campos_lista)); - $resultado = array(); + $resultado = []; $sql .= $filtros . $this->getOrderby() . $this->getLimite(); @@ -1140,7 +1180,7 @@ function lista( if ($countCampos > 1) { while ($db->ProximoRegistro()) { $tupla = $db->Tupla(); - $tupla["_total"] = $this->_total; + $tupla['_total'] = $this->_total; $resultado[] = $tupla; } } else { @@ -1158,22 +1198,38 @@ function lista( public function primeiraAtiva() { - $instituicoes = $this->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, TRUE); - return COUNT($instituicoes) ? $instituicoes[0] : NULL; + $instituicoes = $this->lista( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + true + ); + + return COUNT($instituicoes) ? $instituicoes[0] : null; } - /** * Retorna um array com os dados de um registro. + * * @return array */ - function detalhe() + public function detalhe() { if (is_numeric($this->cod_instituicao)) { $db = new clsBanco(); $db->Consulta("SELECT {$this->_todos_campos},fcn_upper_nrm(nm_instituicao) as nm_instituicao_upper FROM {$this->_tabela} WHERE cod_instituicao = '{$this->cod_instituicao}'"); $db->ProximoRegistro(); + return $db->Tupla(); } @@ -1182,14 +1238,16 @@ function detalhe() /** * Retorna um array com os dados de um registro. + * * @return array */ - function existe() + public function existe() { if (is_numeric($this->cod_instituicao)) { $db = new clsBanco(); $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_instituicao = '{$this->cod_instituicao}'"); $db->ProximoRegistro(); + return $db->Tupla(); } @@ -1198,12 +1256,14 @@ function existe() /** * Exclui um registro. + * * @return bool */ - function excluir() + public function excluir() { if (is_numeric($this->cod_instituicao)) { $this->ativo = 0; + return $this->edita(); } @@ -1213,7 +1273,7 @@ function excluir() /** * Define quais campos da tabela serão selecionados no método Lista(). */ - function setCamposLista($str_campos) + public function setCamposLista($str_campos) { $this->_campos_lista = $str_campos; } @@ -1221,7 +1281,7 @@ function setCamposLista($str_campos) /** * Define que o método Lista() deverpa retornar todos os campos da tabela. */ - function resetCamposLista() + public function resetCamposLista() { $this->_campos_lista = $this->_todos_campos; } @@ -1229,7 +1289,7 @@ function resetCamposLista() /** * Define limites de retorno para o método Lista(). */ - function setLimite($intLimiteQtd, $intLimiteOffset = null) + public function setLimite($intLimiteQtd, $intLimiteOffset = null) { $this->_limite_quantidade = $intLimiteQtd; $this->_limite_offset = $intLimiteOffset; @@ -1241,22 +1301,24 @@ function setLimite($intLimiteQtd, $intLimiteOffset = null) * * @return string */ - function getLimite() + public function getLimite() { if (is_numeric($this->_limite_quantidade)) { $retorno = " LIMIT {$this->_limite_quantidade}"; if (is_numeric($this->_limite_offset)) { $retorno .= " OFFSET {$this->_limite_offset} "; } + return $retorno; } + return ''; } /** * Define o campo para ser utilizado como ordenação no método Lista(). */ - function setOrderby($strNomeCampo) + public function setOrderby($strNomeCampo) { if (is_string($strNomeCampo) && $strNomeCampo) { $this->_campo_order_by = $strNomeCampo; @@ -1269,11 +1331,12 @@ function setOrderby($strNomeCampo) * * @return string */ - function getOrderby() + public function getOrderby() { if (is_string($this->_campo_order_by)) { return " ORDER BY {$this->_campo_order_by} "; } + return ''; } } diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarModulo.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarModulo.inc.php index 5ea3a0cd55..6ac2b6a531 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarModulo.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarModulo.inc.php @@ -1,50 +1,32 @@ _schema = "pmieducar."; + $this->_schema = 'pmieducar.'; $this->_tabela = "{$this->_schema}modulo"; - $this->_campos_lista = $this->_todos_campos = "cod_modulo, ref_usuario_exc, ref_usuario_cad, nm_tipo, descricao, num_meses, num_semanas, data_cadastro, data_exclusao, ativo, ref_cod_instituicao"; - - if( is_numeric( $ref_cod_instituicao ) ) - { - if( class_exists( "clsPmieducarInstituicao" ) ) - { - $tmp_obj = new clsPmieducarInstituicao( $ref_cod_instituicao ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { + $this->_campos_lista = $this->_todos_campos = 'cod_modulo, ref_usuario_exc, ref_usuario_cad, nm_tipo, descricao, num_meses, num_semanas, data_cadastro, data_exclusao, ativo, ref_cod_instituicao, num_etapas'; + + if (is_numeric($ref_cod_instituicao)) { + if (class_exists('clsPmieducarInstituicao')) { + $tmp_obj = new clsPmieducarInstituicao($ref_cod_instituicao); + + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { $this->ref_cod_instituicao = $ref_cod_instituicao; } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { + } elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { $this->ref_cod_instituicao = $ref_cod_instituicao; } } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.instituicao WHERE cod_instituicao = '{$ref_cod_instituicao}'" ) ) - { + } else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.instituicao WHERE cod_instituicao = '{$ref_cod_instituicao}'")) { $this->ref_cod_instituicao = $ref_cod_instituicao; } } } - if( is_numeric( $ref_usuario_exc ) ) - { - if( class_exists( "clsPmieducarUsuario" ) ) - { - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_exc ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { + + if (is_numeric($ref_usuario_exc)) { + if (class_exists('clsPmieducarUsuario')) { + $tmp_obj = new clsPmieducarUsuario($ref_usuario_exc); + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { $this->ref_usuario_exc = $ref_usuario_exc; } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { + } elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { $this->ref_usuario_exc = $ref_usuario_exc; } } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'" ) ) - { + } else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'")) { $this->ref_usuario_exc = $ref_usuario_exc; } } } - if( is_numeric( $ref_usuario_cad ) ) - { - if( class_exists( "clsPmieducarUsuario" ) ) - { - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_cad ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { + + if (is_numeric($ref_usuario_cad)) { + if (class_exists('clsPmieducarUsuario')) { + $tmp_obj = new clsPmieducarUsuario($ref_usuario_cad); + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { $this->ref_usuario_cad = $ref_usuario_cad; } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { + } elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { $this->ref_usuario_cad = $ref_usuario_cad; } } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'" ) ) - { + } else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'")) { $this->ref_usuario_cad = $ref_usuario_cad; } } } - - if( is_numeric( $cod_modulo ) ) - { + if (is_numeric($cod_modulo)) { $this->cod_modulo = $cod_modulo; } - if( is_string( $nm_tipo ) ) - { + + if (is_string($nm_tipo)) { $this->nm_tipo = $nm_tipo; } - if( is_string( $descricao ) ) - { + + if (is_string($descricao)) { $this->descricao = $descricao; } - if( is_numeric( $num_meses ) ) - { + + if (is_numeric($num_meses)) { $this->num_meses = $num_meses; } - if( is_numeric( $num_semanas ) ) - { + + if (is_numeric($num_semanas)) { $this->num_semanas = $num_semanas; } - if( is_string( $data_cadastro ) ) - { + + if (is_string($data_cadastro)) { $this->data_cadastro = $data_cadastro; } - if( is_string( $data_exclusao ) ) - { + + if (is_string($data_exclusao)) { $this->data_exclusao = $data_exclusao; } - if( is_numeric( $ativo ) ) - { + + if (is_numeric($ativo)) { $this->ativo = $ativo; } + if (is_numeric($num_etapas)) { + $this->num_etapas = $num_etapas; + } } /** @@ -244,63 +211,67 @@ function __construct( $cod_modulo = null, $ref_usuario_exc = null, $ref_usuario_ * * @return bool */ - function cadastra() + public function cadastra() { - if( is_numeric( $this->ref_usuario_cad ) && is_string( $this->nm_tipo ) && is_numeric( $this->num_meses ) && is_numeric( $this->num_semanas ) && is_numeric( $this->ref_cod_instituicao ) ) - { + if ( + is_numeric($this->ref_usuario_cad) + && is_string($this->nm_tipo) + && is_numeric($this->ref_cod_instituicao) + && is_numeric($this->num_etapas) + ) { $db = new clsBanco(); - $campos = ""; - $valores = ""; - $gruda = ""; + $campos = []; + $valores = []; + + if (is_numeric($this->ref_usuario_cad)) { + $campos[] = "ref_usuario_cad"; + $valores[] = "'{$this->ref_usuario_cad}'"; + } - if( is_numeric( $this->ref_usuario_cad ) ) - { - $campos .= "{$gruda}ref_usuario_cad"; - $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; - $gruda = ", "; + if (is_string($this->nm_tipo)) { + $campos[] = "nm_tipo"; + $valores[] = "'{$this->nm_tipo}'"; } - if( is_string( $this->nm_tipo ) ) - { - $campos .= "{$gruda}nm_tipo"; - $valores .= "{$gruda}'{$this->nm_tipo}'"; - $gruda = ", "; + + if (is_string($this->descricao)) { + $campos[] = "descricao"; + $valores[] = "'{$this->descricao}'"; } - if( is_string( $this->descricao ) ) - { - $campos .= "{$gruda}descricao"; - $valores .= "{$gruda}'{$this->descricao}'"; - $gruda = ", "; + if (is_numeric($this->num_meses)) { + $campos[] = "num_meses"; + $valores[] = "'{$this->num_meses}'"; } - if( is_numeric( $this->num_meses ) ) - { - $campos .= "{$gruda}num_meses"; - $valores .= "{$gruda}'{$this->num_meses}'"; - $gruda = ", "; + + if (is_numeric($this->num_semanas)) { + $campos[] = "num_semanas"; + $valores[] = "'{$this->num_semanas}'"; } - if( is_numeric( $this->num_semanas ) ) - { - $campos .= "{$gruda}num_semanas"; - $valores .= "{$gruda}'{$this->num_semanas}'"; - $gruda = ", "; + + if (is_numeric($this->num_etapas)) { + $campos[] = "num_etapas"; + $valores[] = "'{$this->num_etapas}'"; } - $campos .= "{$gruda}data_cadastro"; - $valores .= "{$gruda}NOW()"; - $gruda = ", "; - $campos .= "{$gruda}ativo"; - $valores .= "{$gruda}'1'"; - $gruda = ", "; - if( is_numeric( $this->ref_cod_instituicao ) ) - { - $campos .= "{$gruda}ref_cod_instituicao"; - $valores .= "{$gruda}'{$this->ref_cod_instituicao}'"; - $gruda = ", "; + + $campos[] = "data_cadastro"; + $valores[] = "NOW()"; + + $campos[] = "ativo"; + $valores[] = "'1'"; + + if (is_numeric($this->ref_cod_instituicao)) { + $campos[] = "ref_cod_instituicao"; + $valores[] = "'{$this->ref_cod_instituicao}'"; } + $campos = join(', ', $campos); + $valores = join(', ', $valores); - $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" ); - return $db->InsertId( "{$this->_tabela}_cod_modulo_seq"); + $db->Consulta("INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )"); + + return $db->InsertId("{$this->_tabela}_cod_modulo_seq"); } + return false; } @@ -309,69 +280,69 @@ function cadastra() * * @return bool */ - function edita() + public function edita() { - if( is_numeric( $this->cod_modulo ) && is_numeric( $this->ref_usuario_exc ) ) - { - + if (is_numeric($this->cod_modulo) && is_numeric($this->ref_usuario_exc)) { $db = new clsBanco(); - $set = ""; + $set = []; - if( is_numeric( $this->ref_usuario_exc ) ) - { - $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; - $gruda = ", "; + if (is_numeric($this->ref_usuario_exc)) { + $set[] = "ref_usuario_exc = '{$this->ref_usuario_exc}'"; } - if( is_numeric( $this->ref_usuario_cad ) ) - { - $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; - $gruda = ", "; + + if (is_numeric($this->ref_usuario_cad)) { + $set[] = "ref_usuario_cad = '{$this->ref_usuario_cad}'"; } - if( is_string( $this->nm_tipo ) ) - { - $set .= "{$gruda}nm_tipo = '{$this->nm_tipo}'"; - $gruda = ", "; + + if (is_string($this->nm_tipo)) { + $set[] = "nm_tipo = '{$this->nm_tipo}'"; } - if( is_string( $this->descricao ) ) - { - $set .= "{$gruda}descricao = '{$this->descricao}'"; - $gruda = ", "; + + if (is_string($this->descricao)) { + $set[] = "descricao = '{$this->descricao}'"; } - if( is_numeric( $this->num_meses ) ) - { - $set .= "{$gruda}num_meses = '{$this->num_meses}'"; - $gruda = ", "; + + if (is_numeric($this->num_meses)) { + $set[] = "num_meses = '{$this->num_meses}'"; + } else { + $set[] = "num_meses = NULL"; } - if( is_numeric( $this->num_semanas ) ) - { - $set .= "{$gruda}num_semanas = '{$this->num_semanas}'"; - $gruda = ", "; + + if (is_numeric($this->num_semanas)) { + $set[] = "num_semanas = '{$this->num_semanas}'"; + } else { + $set[] = "num_semanas = NULL"; } - if( is_string( $this->data_cadastro ) ) - { - $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; - $gruda = ", "; + + if (is_string($this->data_cadastro)) { + $set[] = "data_cadastro = '{$this->data_cadastro}'"; } - $set .= "{$gruda}data_exclusao = NOW()"; - $gruda = ", "; - if( is_numeric( $this->ativo ) ) - { - $set .= "{$gruda}ativo = '{$this->ativo}'"; - $gruda = ", "; + + if (is_numeric($this->ativo)) { + $set[] = "ativo = '{$this->ativo}'"; + + if ((bool)$this->ativo === false) { + $set[] = "data_exclusao = NOW()"; + } } - if( is_numeric( $this->ref_cod_instituicao ) ) - { - $set .= "{$gruda}ref_cod_instituicao = '{$this->ref_cod_instituicao}'"; - $gruda = ", "; + + if (is_numeric($this->ref_cod_instituicao)) { + $set[] = "ref_cod_instituicao = '{$this->ref_cod_instituicao}'"; } + if (is_string($this->num_etapas)) { + $set[] = "num_etapas = '{$this->num_etapas}'"; + } + + if (!empty($set)) { + $set = join(', ', $set); + + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE cod_modulo = '{$this->cod_modulo}'"); - if( $set ) - { - $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE cod_modulo = '{$this->cod_modulo}'" ); return true; } } + return false; } @@ -380,118 +351,113 @@ function edita() * * @return array */ - function lista( $int_cod_modulo = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $str_nm_tipo = null, $str_descricao = null, $int_num_meses = null, $int_num_semanas = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null, $int_ref_cod_instituicao = null ) - { - $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela} "; - $filtros = ""; - - $whereAnd = " WHERE "; - - if( is_numeric( $int_cod_modulo ) ) - { - $filtros .= "{$whereAnd} cod_modulo = '{$int_cod_modulo}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_usuario_exc ) ) - { - $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_usuario_cad ) ) - { - $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'"; - $whereAnd = " AND "; - } - if( is_string( $str_nm_tipo ) ) - { - $filtros .= "{$whereAnd} nm_tipo LIKE '%{$str_nm_tipo}%'"; - $whereAnd = " AND "; - } - if( is_string( $str_descricao ) ) - { - $filtros .= "{$whereAnd} descricao LIKE '%{$str_descricao}%'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_num_meses ) ) - { - $filtros .= "{$whereAnd} num_meses = '{$int_num_meses}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_num_semanas ) ) - { - $filtros .= "{$whereAnd} num_semanas = '{$int_num_semanas}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_cadastro_ini ) ) - { - $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_cadastro_fim ) ) - { - $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_exclusao_ini ) ) - { - $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_exclusao_fim ) ) - { - $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'"; - $whereAnd = " AND "; - } - if( is_null( $int_ativo ) || $int_ativo ) - { - $filtros .= "{$whereAnd} ativo = '1'"; - $whereAnd = " AND "; - } - else - { - $filtros .= "{$whereAnd} ativo = '0'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_cod_instituicao ) ) - { - $filtros .= "{$whereAnd} ref_cod_instituicao = '{$int_ref_cod_instituicao}'"; - $whereAnd = " AND "; + public function lista( + $int_cod_modulo = null, + $int_ref_usuario_exc = null, + $int_ref_usuario_cad = null, + $str_nm_tipo = null, + $str_descricao = null, + $int_num_meses = null, + $int_num_semanas = null, + $date_data_cadastro_ini = null, + $date_data_cadastro_fim = null, + $date_data_exclusao_ini = null, + $date_data_exclusao_fim = null, + $int_ativo = null, + $int_ref_cod_instituicao = null, + $num_etapas = null + ) { + $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela} WHERE "; + $filtros = []; + + if (is_numeric($int_cod_modulo)) { + $filtros[] = "cod_modulo = '{$int_cod_modulo}'"; + } + + if (is_numeric($int_ref_usuario_exc)) { + $filtros[] = "ref_usuario_exc = '{$int_ref_usuario_exc}'"; + } + + if (is_numeric($int_ref_usuario_cad)) { + $filtros[] = "ref_usuario_cad = '{$int_ref_usuario_cad}'"; + } + + if (is_string($str_nm_tipo)) { + $filtros[] = "nm_tipo LIKE '%{$str_nm_tipo}%'"; + } + + if (is_string($str_descricao)) { + $filtros[] = "descricao LIKE '%{$str_descricao}%'"; } + if (is_numeric($int_num_meses)) { + $filtros[] = "num_meses = '{$int_num_meses}'"; + } + + if (is_numeric($int_num_semanas)) { + $filtros[] = "num_semanas = '{$int_num_semanas}'"; + } + + if (is_string($date_data_cadastro_ini)) { + $filtros[] = "data_cadastro >= '{$date_data_cadastro_ini}'"; + } + + if (is_string($date_data_cadastro_fim)) { + $filtros[] = "data_cadastro <= '{$date_data_cadastro_fim}'"; + } + + if (is_string($date_data_exclusao_ini)) { + $filtros[] = "data_exclusao >= '{$date_data_exclusao_ini}'"; + } + + if (is_string($date_data_exclusao_fim)) { + $filtros[] = "data_exclusao <= '{$date_data_exclusao_fim}'"; + } + + if (is_null($int_ativo) || $int_ativo) { + $filtros[] = "ativo = '1'"; + } else { + $filtros[] = "ativo = '0'"; + } + + if (is_numeric($int_ref_cod_instituicao)) { + $filtros[] = "ref_cod_instituicao = '{$int_ref_cod_instituicao}'"; + } + + if (is_numeric($num_etapas)) { + $filtros[] = "$num_etapas = '{$num_etapas}'"; + } + + if (empty($filtros)) { + return false; + } $db = new clsBanco(); - $countCampos = count( explode( ",", $this->_campos_lista ) ); - $resultado = array(); + $countCampos = count(explode(',', $this->_campos_lista)); + $resultado = []; + $filtros = join(' AND ', $filtros); $sql .= $filtros . $this->getOrderby() . $this->getLimite(); - $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} {$filtros}" ); + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} WHERE {$filtros}"); - $db->Consulta( $sql ); + $db->Consulta($sql); - if( $countCampos > 1 ) - { - while ( $db->ProximoRegistro() ) - { + if ($countCampos > 1) { + while ($db->ProximoRegistro()) { $tupla = $db->Tupla(); - $tupla["_total"] = $this->_total; + $tupla['_total'] = $this->_total; $resultado[] = $tupla; } - } - else - { - while ( $db->ProximoRegistro() ) - { + } else { + while ($db->ProximoRegistro()) { $tupla = $db->Tupla(); $resultado[] = $tupla[$this->_campos_lista]; } } - if( count( $resultado ) ) - { - return $resultado; - } - return false; + + return !empty($resultado) ? $resultado : false; } /** @@ -499,15 +465,16 @@ function lista( $int_cod_modulo = null, $int_ref_usuario_exc = null, $int_ref_us * * @return array */ - function detalhe() + public function detalhe() { - if( is_numeric( $this->cod_modulo ) ) - { + if (is_numeric($this->cod_modulo)) { $db = new clsBanco(); - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_modulo = '{$this->cod_modulo}'" ); + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_modulo = '{$this->cod_modulo}'"); $db->ProximoRegistro(); + return $db->Tupla(); } + return false; } @@ -516,16 +483,16 @@ function detalhe() * * @return array */ - function existe() + public function existe() { - if( is_numeric( $this->cod_modulo ) ) - { + if (is_numeric($this->cod_modulo)) { + $db = new clsBanco(); + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_modulo = '{$this->cod_modulo}'"); + $db->ProximoRegistro(); - $db = new clsBanco(); - $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE cod_modulo = '{$this->cod_modulo}'" ); - $db->ProximoRegistro(); - return $db->Tupla(); + return $db->Tupla(); } + return false; } @@ -534,21 +501,14 @@ function existe() * * @return bool */ - function excluir() + public function excluir() { - if( is_numeric( $this->cod_modulo ) && is_numeric( $this->ref_usuario_exc ) ) - { + if (is_numeric($this->cod_modulo) && is_numeric($this->ref_usuario_exc)) { + $this->ativo = 0; - /* - delete - $db = new clsBanco(); - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE cod_modulo = '{$this->cod_modulo}'" ); - return true; - */ - - $this->ativo = 0; return $this->edita(); } + return false; } @@ -557,7 +517,7 @@ function excluir() * * @return null */ - function setCamposLista( $str_campos ) + public function setCamposLista($str_campos) { $this->_campos_lista = $str_campos; } @@ -567,7 +527,7 @@ function setCamposLista( $str_campos ) * * @return null */ - function resetCamposLista() + public function resetCamposLista() { $this->_campos_lista = $this->_todos_campos; } @@ -577,7 +537,7 @@ function resetCamposLista() * * @return null */ - function setLimite( $intLimiteQtd, $intLimiteOffset = null ) + public function setLimite($intLimiteQtd, $intLimiteOffset = null) { $this->_limite_quantidade = $intLimiteQtd; $this->_limite_offset = $intLimiteOffset; @@ -588,18 +548,19 @@ function setLimite( $intLimiteQtd, $intLimiteOffset = null ) * * @return string */ - function getLimite() + public function getLimite() { - if( is_numeric( $this->_limite_quantidade ) ) - { + if (is_numeric($this->_limite_quantidade)) { $retorno = " LIMIT {$this->_limite_quantidade}"; - if( is_numeric( $this->_limite_offset ) ) - { + + if (is_numeric($this->_limite_offset)) { $retorno .= " OFFSET {$this->_limite_offset} "; } + return $retorno; } - return ""; + + return ''; } /** @@ -607,13 +568,9 @@ function getLimite() * * @return null */ - function setOrderby( $strNomeCampo ) + public function setOrderby($strNomeCampo) { - // limpa a string de possiveis erros (delete, insert, etc) - //$strNomeCampo = eregi_replace(); - - if( is_string( $strNomeCampo ) && $strNomeCampo ) - { + if (is_string($strNomeCampo) && $strNomeCampo) { $this->_campo_order_by = $strNomeCampo; } } @@ -623,14 +580,12 @@ function setOrderby( $strNomeCampo ) * * @return string */ - function getOrderby() + public function getOrderby() { - if( is_string( $this->_campo_order_by ) ) - { + if (is_string($this->_campo_order_by)) { return " ORDER BY {$this->_campo_order_by} "; } - return ""; - } + return ''; + } } -?> \ No newline at end of file diff --git a/ieducar/intranet/s3_config.php b/ieducar/intranet/s3_config.php index dbbba7130d..af4c139532 100644 --- a/ieducar/intranet/s3_config.php +++ b/ieducar/intranet/s3_config.php @@ -1,17 +1,16 @@ app->aws->bucketname; -$directory=$GLOBALS['coreExt']['Config']->app->database->dbname.'/'; +require_once __DIR__ . '/../includes/bootstrap.php'; + +$bucket = $GLOBALS['coreExt']['Config']->app->aws->bucketname; +$directory = $GLOBALS['coreExt']['Config']->app->database->dbname . '/'; $key = $GLOBALS['coreExt']['Config']->app->aws->awsacesskey; $secretKey = $GLOBALS['coreExt']['Config']->app->aws->awssecretkey; -if (!class_exists('S3')) +if (!class_exists('S3')) { require_once 'S3.php'; +} -//instantiate the class $s3 = new S3($key, $secretKey); $s3->putBucket($bucket, S3::ACL_PUBLIC_READ); -?> \ No newline at end of file diff --git a/ieducar/intranet/scripts/consulta_movimentos.js b/ieducar/intranet/scripts/consulta_movimentos.js new file mode 100644 index 0000000000..e738b5de97 --- /dev/null +++ b/ieducar/intranet/scripts/consulta_movimentos.js @@ -0,0 +1,111 @@ +$j(function () { + let consulta = { + links: $j('.mostra-consulta'), + dialogContainer: $j('#dialog-container'), + dialog: undefined, + createDialog: function() { + if (this.dialogContainer.length < 1) { + $j('body').append( + '
' + + '
' + + '
' + + '
' + ); + + this.dialogContainer = $j('#dialog-container'); + } + + this.dialog = this.dialogContainer.dialog({ + autoOpen: false, + closeOnEscape: true, + draggable: false, + width: 520, + modal: true, + resizable: true, + title: 'Alunos' + }); + }, + makeTable: function (data) { + let dialog = this.dialogContainer; + let tableContainer = dialog.find('.table'); + let msgContainer = dialog.find('.msg'); + + tableContainer + .empty() + .hide(); + + msgContainer.hide(); + + let html = ''; + + html += ''; + + $j.each(data, function (i, v) { + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + }); + + html += '
 NomeTurma
' + (i + 1) + '' + v.nome + '' + v.nm_turma + '
'; + + tableContainer + .html(html) + .show(); + + this.dialog.dialog('option', 'position', {my: 'center', at:'center', of: window}); + }, + showMsg: function (msg) { + let dialog = this.dialogContainer; + let tableContainer = dialog.find('.table'); + let msgContainer = dialog.find('.msg'); + + tableContainer.hide(); + msgContainer.html(msg).show(); + }, + bind: function () { + let that = this; + + this.links.on('click', function (e) { + e.preventDefault(); + + let $this = $j(this); + let api = $this.data('api'); + let params = $this.data('params'); + + params.tipo = $this.data('tipo'); + params.resource = 'alunos'; + params.oper = 'get'; + + that.request(api, params); + + return false; + }); + }, + request: function (api, params) { + let url = '/module/Api/' + api; + let that = this; + + if (!this.dialogContainer.dialog('isOpen')) { + this.dialogContainer.dialog('open'); + } + + this.showMsg('Aguarde'); + + $j.getJSON(url, params, function (d) { + if (d.alunos.length < 1) { + that.showMsg('Nenhum dado retornado.'); + } else { + that.makeTable(d.alunos); + } + }); + }, + init: function () { + this.createDialog(); + this.bind(); + } + }; + + consulta.init(); +}); diff --git a/ieducar/intranet/scripts/etapas.js b/ieducar/intranet/scripts/etapas.js new file mode 100644 index 0000000000..fa6ca1746f --- /dev/null +++ b/ieducar/intranet/scripts/etapas.js @@ -0,0 +1,299 @@ +$j(function () { + var etapasHandler = { + env: 'ano', + module: 0, + selectors: { + 'ano': { + 'stepsRows': 'tr[id^="tr_modulos_ano_letivo["]', + 'year': '#ref_ano_' + }, + 'turma': { + 'stepsRows': 'tr[id^="tr_turma_modulo["]', + 'year': '#ano_letivo' + } + }, + init: function () { + this.setupEnv(); + this.removeTableCellsAndRows(); + this.setCurrentModule(); + this.setupModule(); + this.selectModule(); + }, + getSelector: function (key) { + return this.selectors[this.env][key] || undefined; + }, + setCurrentModule: function () { + var val = $j('#ref_cod_modulo').val(); + + if (val === '') { + val = 0; + } + + this.module = parseInt(val, 10); + + return this.module; + }, + setupEnv: function () { + if ($j('tr[id^="tr_turma_modulo["]').length > 0) { + this.env = 'turma'; + } + }, + submit: function () { + var that = this; + + $j('#btn_enviar').click(function (e) { + if (parseInt($j('#padrao_ano_escolar').val(), 10) === 1) { + window.acao(); + + return; + } + + e.preventDefault(); + + that.resetErrors(); + + if (!that.validateDates()) { + alert('Ocorreram erros na validação dos campos. Verifique as mensagens e tente novamente.'); + + return false; + } + + var validations = [ + 'validateStartDates', + 'validateEndDates' + ]; + + var valid = true; + + $j.each(validations, function (i, validation) { + if (!that[validation]()) { + valid = false; + } + }); + + if (valid) { + if (typeof window.valida !== "undefined") { + // reproduzindo função encontrada em modules/Cadastro/Assets/Javascripts/Turma.js:332 + if (validationUtils.validatesFields(true)) { + window.valida(); + } + } else { + window.acao(); + } + } else { + alert('Ocorreram erros na validação dos campos. Verifique as mensagens e tente novamente.'); + } + + return false; + }); + }, + addError: function (elm, msg) { + messageUtils.error(msg, elm); + }, + resetErrors: function () { + $j('input.error').removeClass('error'); + }, + validateDates: function () { + var that = this, + fields = $j('[id^=data_inicio], [id^=data_fim]'), + valid = true; + + fields.each(function (i, elm) { + if (!validationUtils.validatesDateFieldAlt(elm)) { + valid = false; + } + }); + + return valid; + }, + validateEndDates: function () { + var that = this, + currentYear = this.getYear(), + nextYear = currentYear + 1, + fields = $j('[id^="data_fim["]'), + valid = true; + + fields.each(function (i, elm) { + var $elm = $j(elm), + val = $elm.val(), + dateParts = that.getDateParts(val), + ts = that.makeTimestamp(dateParts), + parentLine = $elm.closest('tr'), + nextLine = parentLine.next(that.getSelector('stepsRows')), + startDateElm = parentLine.find('[id^="data_inicio["]'), + startDateTs = that.makeTimestamp(that.getDateParts(startDateElm.val())); + + if (nextLine.length < 1) { + var validYears = [currentYear, nextYear]; + + if (validYears.indexOf(dateParts.year) === -1) { + valid = false; + that.addError(elm, 'O ano "' + dateParts.year + '" não é válido. Utilize o ano especificado ou próximo.'); + + return; + } + } else { + if (dateParts.year !== currentYear) { + valid = false; + that.addError(elm, 'O ano "' + dateParts.year + '" não é válido. Utilize o ano especificado.'); + + return; + } + } + + if (ts <= startDateTs) { + valid = false; + that.addError(elm, 'A data final precisa ser maior que a data inicial desta etapa.'); + + return; + } + }); + + return valid; + }, + validateStartDates: function () { + var that = this, + currentYear = this.getYear(), + previousYear = currentYear - 1, + fields = $j('[id^="data_inicio["]'), + valid = true; + + fields.each(function (i, elm) { + var $elm = $j(elm), + val = $elm.val(), + dateParts = that.getDateParts(val), + ts = that.makeTimestamp(dateParts), + parentLine = $elm.closest('tr'), + previousLine = parentLine.prev(that.getSelector('stepsRows')); + + if (previousLine.length < 1) { + var validYears = [currentYear, previousYear]; + + if (validYears.indexOf(dateParts.year) === -1) { + valid = false; + that.addError(elm, 'O ano "' + dateParts.year + '" não é válido. Utilize o ano especificado ou anterior.'); + + return; + } + } else { + if (dateParts.year !== currentYear) { + valid = false; + that.addError(elm, 'O ano "' + dateParts.year + '" não é válido. Utilize o ano especificado.'); + + return; + } + + var previousDate = previousLine.find('[id^="data_fim["]'), + previousTs = that.makeTimestamp(that.getDateParts(previousDate.val())); + + if (ts <= previousTs) { + valid = false; + that.addError(elm, 'A data inicial precisa ser maior que a data final da etapa anterior.'); + + return; + } + } + }); + + return valid; + }, + makeTimestamp: function (parts) { + var date = new Date(parts.year, parts.month - 1, parts.day); + + return Math.floor(+date / 1000); + }, + getDateParts: function (date) { + var parts = date.split('/'); + + return { + day: parseInt(parts[0], 10), + month: parseInt(parts[1], 10), + year: parseInt(parts[2], 10) + } + }, + removeTableCellsAndRows: function () { + var removeLinks = $j('[id^=link_remove'), + addLink = $j('[id^=btn_add]'), + sendBtn = $j('#btn_enviar'); + + $j('td#td_acao').hide(); + $j('[id^=link_remove').parent().hide(); + $j('#adicionar_linha').hide(); + + removeLinks.removeAttr('onclick'); + addLink.removeAttr('onclick'); + sendBtn.removeAttr('onclick'); + sendBtn.unbind('click'); + this.submit(); + }, + setupModule: function () { + var $select = $j('#ref_cod_modulo'), + val = $select.val(), + availableModules = window.modulosDisponiveis || [], + moduleInfo = availableModules[val] || {}, + etapas = moduleInfo.etapas || undefined, + rows = this.countRows(); + + val = (val === '') ? 0 : parseInt(val, 10); + + if (val && Boolean(etapas) === false) { + alert("Este módulo não possui o número de etapas definido.\nRealize esta alteração no seguinte caminho:\nCadastros > Tipos > Escolas > Tipos de etapas"); + + $select.val((this.module === 0) ? '' : this.module); + + return; + } + + this.setCurrentModule(); + + if (etapas > rows) { + var diff = etapas - rows; + + this.addRows(diff); + } + + if (etapas < rows) { + var diff = rows - etapas; + + this.removeRows(diff); + } + }, + addRows: function (qtt) { + for (var i = 0; i < qtt; i++) { + tab_add_1.addRow(); + this.removeTableCellsAndRows(); + } + }, + removeRows: function (qtt) { + var rows = $j(this.getSelector('stepsRows')).get().reverse(), + count = 0; + + rows.each(function (elm) { + if (count < qtt) { + tab_add_1.removeRow(elm); + count++; + } + }); + }, + selectModule: function () { + var that = this, + $select = $j('#ref_cod_modulo'); + + $select.focus(function () { + that.setCurrentModule(); + }).change(function () { + that.setupModule(); + }) + }, + countRows: function () { + var rows = $j(this.getSelector('stepsRows')); + + return rows.length; + }, + getYear: function () { + return parseInt($j(this.getSelector('year')).val(), 10); + } + }; + + etapasHandler.init(); +}); diff --git a/ieducar/intranet/styles/localizacaoSistema.css b/ieducar/intranet/styles/localizacaoSistema.css index 2758a2b7e9..4fd676c0e0 100644 --- a/ieducar/intranet/styles/localizacaoSistema.css +++ b/ieducar/intranet/styles/localizacaoSistema.css @@ -49,7 +49,8 @@ #localizacao .pagina_atual { color: #000; - cursor: text; + cursor: text; + margin-left: 5px; } #localizacao .pagina_atual:hover{ color: #000; diff --git a/ieducar/intranet/suspenso.php b/ieducar/intranet/suspenso.php index f517dd4f30..51ff0ee82b 100644 --- a/ieducar/intranet/suspenso.php +++ b/ieducar/intranet/suspenso.php @@ -1,36 +1,5 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -/** - * Mostra mensagem de erro de conexão com o banco de dados. - * - * @author Eriksen Costa Paixão - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Core - * @since Arquivo disponível desde a versão 1.0.1 - * @version $Id$ - */ - require_once __DIR__ . '/../includes/bootstrap.php'; require_once 'include/pmieducar/clsPmieducarConfiguracoesGerais.inc.php'; diff --git a/ieducar/lib/App/Model/IedFinder.php b/ieducar/lib/App/Model/IedFinder.php index 3fb3ce97e6..51aa70c947 100644 --- a/ieducar/lib/App/Model/IedFinder.php +++ b/ieducar/lib/App/Model/IedFinder.php @@ -625,6 +625,7 @@ public static function getMatricula($codMatricula) AND rasa.serie_id = s.cod_serie WHERE m.cod_matricula = $1 AND a.ativo = 1 + AND t.ativo = 1 AND (mt.ativo = 1 OR (mt.transferido OR mt.remanejado @@ -1286,7 +1287,7 @@ public static function getEtapasDaTurma($turma) $sql = " select * from ( - + select t.cod_turma, anm.sequencial, @@ -1294,31 +1295,31 @@ public static function getEtapasDaTurma($turma) anm.data_inicio, anm.data_fim, anm.dias_letivos - from pmieducar.turma as t - inner join pmieducar.curso as c + from pmieducar.turma as t + inner join pmieducar.curso as c on t.ref_cod_curso = c.cod_curso inner join pmieducar.ano_letivo_modulo as anm on anm.ref_ref_cod_escola = t.ref_ref_cod_escola and anm.ref_ano = t.ano where c.padrao_ano_escolar = 1 - + union all - - select + + select t.cod_turma, tm.sequencial, tm.ref_cod_modulo as cod_modulo, tm.data_inicio, tm.data_fim, tm.dias_letivos - from pmieducar.turma as t - inner join pmieducar.curso as c + from pmieducar.turma as t + inner join pmieducar.curso as c on t.ref_cod_curso = c.cod_curso inner join pmieducar.turma_modulo as tm on tm.ref_cod_turma = t.cod_turma where c.padrao_ano_escolar = 0 ) as etapas - + where cod_turma = $1; "; diff --git a/ieducar/lib/Core/Controller/Page/Abstract.php b/ieducar/lib/Core/Controller/Page/Abstract.php index 23d2d293ff..f81dd4c482 100644 --- a/ieducar/lib/Core/Controller/Page/Abstract.php +++ b/ieducar/lib/Core/Controller/Page/Abstract.php @@ -439,7 +439,20 @@ public function generate(CoreExt_Controller_Page_Interface $instance) public function getQueryString($name, $default = null) { - return $_GET[$name] ?? $default; + if (!isset($_GET[$name])) { + return $default; + } + + switch ($_GET[$name]) { + case '': + case null: + $value = $default; + break; + default: + $value = $_GET[$name]; + } + + return $value; } public function breadcrumb($currentPage, $breadcrumbs = []) diff --git a/ieducar/lib/CoreExt/Controller/Abstract.php b/ieducar/lib/CoreExt/Controller/Abstract.php index b0a96fde2c..38615c3ceb 100644 --- a/ieducar/lib/CoreExt/Controller/Abstract.php +++ b/ieducar/lib/CoreExt/Controller/Abstract.php @@ -211,6 +211,35 @@ public function redirect($url) header(sprintf('Location: %s', $url)); } + /** + * Função de redirecionamento simples que leva em consideração + * o status code. + * + * @param string $url + * @param int $code + * + * @return void + */ + public function simpleRedirect(string $url, int $code = 302) + { + $codes = [ + 301 => 'HTTP/1.1 301 Moved Permanently', + 302 => 'HTTP/1.1 302 Found', + 303 => 'HTTP/1.1 303 See Other', + 304 => 'HTTP/1.1 304 Not Modified', + 305 => 'HTTP/1.1 305 Use Proxy' + ]; + + if (empty($codes[$code])) { + $code = 302; + } + + header($codes[$code]); + header('Location: ' . $url); + + die(); + } + /** * Faz redirecionamento caso condição seja válida e encerra aplicação * diff --git a/ieducar/lib/CoreExt/Controller/Request.php b/ieducar/lib/CoreExt/Controller/Request.php index 33399e843c..cfee4f5691 100644 --- a/ieducar/lib/CoreExt/Controller/Request.php +++ b/ieducar/lib/CoreExt/Controller/Request.php @@ -1,192 +1,174 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Eriksen Costa Paixão - * @category i-Educar - * @license @@license@@ - * @package CoreExt_Controller - * @since Arquivo disponível desde a versão 1.1.0 - * @version $Id$ - */ - require_once 'CoreExt/Controller/Request/Interface.php'; -/** - * CoreExt_Controller_Request class. - * - * Classe de gerenciamento de dados de uma requisição HTTP. - * - * @author Eriksen Costa Paixão - * @category i-Educar - * @license @@license@@ - * @package CoreExt_Controller - * @since Classe disponível desde a versão 1.1.0 - * @version @@package_version@@ - */ class CoreExt_Controller_Request implements CoreExt_Controller_Request_Interface { - /** - * Opções de configuração geral da classe. - * @var array - */ - protected $_options = array( - 'baseurl' => NULL - ); - - /** - * Construtor. - * @param array $options - */ - public function __construct(array $options = array()) - { - $this->setOptions($options); - } - - /** - * @see CoreExt_Configurable#setOptions($options) - */ - public function setOptions(array $options = array()) - { - $defaultOptions = array_keys($this->getOptions()); - $passedOptions = array_keys($options); - - if (0 < count(array_diff($passedOptions, $defaultOptions))) { - throw new InvalidArgumentException( - sprintf('A classe %s não suporta as opções: %s.', get_class($this), implode(', ', $passedOptions)) - ); + protected $_options = [ + 'baseurl' => null + ]; + + protected $_data = []; + + /** + * Construtor. + * + * @param array $options + */ + public function __construct(array $options = []) + { + if (isset($options['data'])) { + $this->_data = $options['data']; + unset($options['data']); + } + + $this->setOptions($options); + } + + /** + * @see CoreExt_Configurable#setOptions($options) + */ + public function setOptions(array $options = []) + { + $defaultOptions = array_keys($this->getOptions()); + $passedOptions = array_keys($options); + + if (0 < count(array_diff($passedOptions, $defaultOptions))) { + throw new InvalidArgumentException( + sprintf('A classe %s não suporta as opções: %s.', get_class($this), implode(', ', $passedOptions)) + ); + } + + $this->_options = array_merge($this->getOptions(), $options); + + return $this; + } + + /** + * @see CoreExt_Configurable#getOptions() + */ + public function getOptions() + { + return $this->_options; + } + + /** + * Verifica se uma opção está setada. + * + * @param string $key + * + * @return bool + */ + protected function _hasOption($key) + { + return array_key_exists($key, $this->_options); + } + + /** + * Retorna um valor de opção de configuração ou NULL caso a opção não esteja + * setada. + * + * @param string $key + * + * @return mixed|NULL + */ + protected function _getOption($key) + { + return $this->_hasOption($key) ? $this->_options[$key] : null; + } + + /** + * Implementação do método mágico __get(). + * + * @param string $key + * + * @return mixed + */ + public function __get($key) + { + return $this->get($key); + } + + /** + * Getter para as variáveis de requisição. + * + * @param string $key + * + * @return mixed + */ + public function get($key) + { + switch (true) { + case isset($this->_data[$key]): + return $this->_data[$key]; + case isset($_GET[$key]): + return $_GET[$key]; + case isset($_POST[$key]): + return $_POST[$key]; + case isset($_COOKIE[$key]): + return $_COOKIE[$key]; + case isset($_SERVER[$key]): + return $_SERVER[$key]; + default: + break; + } + + return null; + } + + /** + * Implementação do método mágico __isset(). + * + * @link http://php.net/manual/en/language.oop5.overloading.php + * + * @param string $key + * + * @return bool + */ + public function __isset($key) + { + $val = $this->$key; + + return isset($val); } - $this->_options = array_merge($this->getOptions(), $options); - return $this; - } - - /** - * @see CoreExt_Configurable#getOptions() - */ - public function getOptions() - { - return $this->_options; - } - - /** - * Verifica se uma opção está setada. - * - * @param string $key - * @return bool - */ - protected function _hasOption($key) - { - return array_key_exists($key, $this->_options); - } - - /** - * Retorna um valor de opção de configuração ou NULL caso a opção não esteja - * setada. - * - * @param string $key - * @return mixed|NULL - */ - protected function _getOption($key) - { - return $this->_hasOption($key) ? $this->_options[$key] : NULL; - } - - /** - * Implementação do método mágico __get(). - * - * @param string $key - * @return mixed - */ - public function __get($key) - { - switch (true) { - case isset($_GET[$key]): - return $_GET[$key]; - case isset($_POST[$key]): - return $_POST[$key]; - case isset($_COOKIE[$key]): - return $_COOKIE[$key]; - case isset($_SERVER[$key]): - return $_SERVER[$key]; - default: - break; + /** + * Setter para a opção de configuração baseurl. + * + * @param string $url + * + * @return CoreExt_Controller_Request_Interface Provê interface fluída + */ + public function setBaseurl($url) + { + $this->setOptions(['baseurl' => $url]); + + return $this; } - return NULL; - } - - /** - * Getter para as variáveis de requisição. - * @param string $key - * @return mixed - */ - public function get($key) - { - return $this->__get($key); - } - - /** - * Implementação do método mágico __isset(). - * - * @link http://php.net/manual/en/language.oop5.overloading.php - * @param string $key - * @return bool - */ - public function __isset($key) - { - $val = $this->$key; - return isset($val); - } - - /** - * Setter para a opção de configuração baseurl. - * @param string $url - * @return CoreExt_Controller_Request_Interface Provê interface fluída - */ - public function setBaseurl($url) - { - $this->setOptions(array('baseurl' => $url)); - return $this; - } - - /** - * Getter para a opção de configuração baseurl. - * - * Caso a opção não esteja configurada, determina um valor baseado na - * variável $_SERVER['REQUEST_URI'] da requisição, usando apenas os - * componentes scheme e path da URL. Veja {@link http://php.net/parse_url} - * para mais informações sobre os componentes de uma URL. - * - * @return string - */ - public function getBaseurl() - { - if (is_null($this->_getOption('baseurl'))) { - require_once 'CoreExt/View/Helper/UrlHelper.php'; - $url = CoreExt_View_Helper_UrlHelper::url( - $this->get('REQUEST_URI'), - array('absolute' => TRUE, 'components' => CoreExt_View_Helper_UrlHelper::URL_HOST) - ); - $this->setBaseurl($url); + + /** + * Getter para a opção de configuração baseurl. + * + * Caso a opção não esteja configurada, determina um valor baseado na + * variável $_SERVER['REQUEST_URI'] da requisição, usando apenas os + * componentes scheme e path da URL. Veja {@link http://php.net/parse_url} + * para mais informações sobre os componentes de uma URL. + * + * @return string + */ + public function getBaseurl() + { + if (is_null($this->_getOption('baseurl'))) { + require_once 'CoreExt/View/Helper/UrlHelper.php'; + + $url = CoreExt_View_Helper_UrlHelper::url( + $this->get('REQUEST_URI'), + ['absolute' => true, 'components' => CoreExt_View_Helper_UrlHelper::URL_HOST] + ); + + $this->setBaseurl($url); + } + + return $this->_getOption('baseurl'); } - return $this->_getOption('baseurl'); - } } diff --git a/ieducar/lib/CoreExt/Validate/Abstract.php b/ieducar/lib/CoreExt/Validate/Abstract.php index 526a1a7fe3..f6f2989210 100644 --- a/ieducar/lib/CoreExt/Validate/Abstract.php +++ b/ieducar/lib/CoreExt/Validate/Abstract.php @@ -161,7 +161,7 @@ public function isValid($value) $this->_value = $value; $value = $this->_sanitize($value); - if (TRUE == $this->getOption('trim')) { + if (TRUE == $this->getOption('trim') && is_string($value)) { $value = trim($value); } @@ -286,4 +286,4 @@ public function getSanitizedValue() { return $this->_sanitized; } -} \ No newline at end of file +} diff --git a/ieducar/lib/Portabilis/Business/Professor.php b/ieducar/lib/Portabilis/Business/Professor.php index 321dc6548c..ac518ce607 100644 --- a/ieducar/lib/Portabilis/Business/Professor.php +++ b/ieducar/lib/Portabilis/Business/Professor.php @@ -117,6 +117,10 @@ public static function cursosAlocado($instituicaoId, $escolaId, $userId){ } public static function seriesAlocado($instituicaoId, $escolaId, $cursoId, $userId) { + $instituicaoId = $instituicaoId ?: 0; + $escolaId = $escolaId ?: 0; + $cursoId = $cursoId ?: 0; + if (self::canLoadSeriesAlocado($instituicaoId)){ $sql = "SELECT s.cod_serie as id, s.nm_serie as nome FROM pmieducar.quadro_horario qh diff --git a/ieducar/lib/Portabilis/Controller/ApiCoreController.php b/ieducar/lib/Portabilis/Controller/ApiCoreController.php index abb073ad73..b3d42e8a09 100644 --- a/ieducar/lib/Portabilis/Controller/ApiCoreController.php +++ b/ieducar/lib/Portabilis/Controller/ApiCoreController.php @@ -320,7 +320,8 @@ protected function validatesPresenceOf($requiredParamNames) { $valid = true; foreach($requiredParamNames as $param) { - if (! $this->validator->validatesPresenceOf($this->getRequest()->$param, $param) and $valid) { + $value = $this->getRequest()->$param; + if (! $this->validator->validatesPresenceOf($value, $param) and $valid) { $valid = false; } } diff --git a/ieducar/lib/Portabilis/View/Helper/DynamicInput/Curso.php b/ieducar/lib/Portabilis/View/Helper/DynamicInput/Curso.php index 8a1ca8c2ed..25ca90435d 100644 --- a/ieducar/lib/Portabilis/View/Helper/DynamicInput/Curso.php +++ b/ieducar/lib/Portabilis/View/Helper/DynamicInput/Curso.php @@ -50,8 +50,8 @@ protected function inputName() { protected function inputOptions($options) { $resources = $options['resources']; - $instituicaoId = $this->getInstituicaoId($options['instituicaoId']); - $escolaId = $this->getEscolaId($options['escolaId']); + $instituicaoId = $this->getInstituicaoId($options['instituicaoId'] ?? null); + $escolaId = $this->getEscolaId($options['escolaId'] ?? null); $userId = $this->getCurrentUserId(); $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); @@ -68,4 +68,4 @@ protected function inputOptions($options) { public function curso($options = array()) { parent::select($options); } -} \ No newline at end of file +} diff --git a/ieducar/lib/Portabilis/View/Helper/DynamicInput/DataFinal.php b/ieducar/lib/Portabilis/View/Helper/DynamicInput/DataFinal.php index a17299765f..38ba0e2455 100644 --- a/ieducar/lib/Portabilis/View/Helper/DynamicInput/DataFinal.php +++ b/ieducar/lib/Portabilis/View/Helper/DynamicInput/DataFinal.php @@ -1,71 +1,41 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Lucas D'Avila - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since Arquivo disponível desde a versão 1.1.0 - * @version $Id$ - */ require_once 'lib/Portabilis/View/Helper/DynamicInput/Core.php'; +class Portabilis_View_Helper_DynamicInput_DataFinal extends Portabilis_View_Helper_DynamicInput_Core +{ + protected function inputValue($value = null) + { + if (!is_null($value)) { + return $value; + } -/** - * Portabilis_View_Helper_DynamicInput_DataFinal class. - * - * @author Lucas D'Avila - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since Classe disponível desde a versão 1.1.0 - * @version @@package_version@@ - */ -class Portabilis_View_Helper_DynamicInput_DataFinal extends Portabilis_View_Helper_DynamicInput_Core { - protected function inputValue($value = null) { - if (! $value && $this->viewInstance->data_final) - $value = $this->viewInstance->data_final; - else - $value = date('t/m/Y'); + if (!empty($this->viewInstance->data_final)) { + return $this->viewInstance->data_final; + } - return $value; - } + return date('t/m/Y'); + } - public function dataFinal($options = array()) { - $defaultOptions = array('options' => array()); - $options = $this->mergeOptions($options, $defaultOptions); + public function dataFinal($options = []) + { + $defaultOptions = ['options' => []]; + $options = $this->mergeOptions($options, $defaultOptions); + $value = $options['options']['value'] ?? null; - $defaultInputOptions = array('id' => 'data_final', - 'label' => 'Data final', - 'value' => $this->inputValue($options['options']['value']), - 'required' => true, - 'label_hint' => '', - 'inline' => false, - 'callback' => false, - 'disabled' => false); + $defaultInputOptions = [ + 'id' => 'data_final', + 'label' => 'Data final', + 'value' => $this->inputValue($value), + 'required' => true, + 'label_hint' => '', + 'inline' => false, + 'callback' => false, + 'disabled' => false + ]; - $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); - call_user_func_array(array($this->viewInstance, 'campoData'), $inputOptions); - } -} \ No newline at end of file + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); + + call_user_func_array([$this->viewInstance, 'campoData'], $inputOptions); + } +} diff --git a/ieducar/lib/Portabilis/View/Helper/DynamicInput/DataInicial.php b/ieducar/lib/Portabilis/View/Helper/DynamicInput/DataInicial.php index e362a05d62..e8f34d2fa2 100644 --- a/ieducar/lib/Portabilis/View/Helper/DynamicInput/DataInicial.php +++ b/ieducar/lib/Portabilis/View/Helper/DynamicInput/DataInicial.php @@ -1,71 +1,41 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Lucas D'Avila - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since Arquivo disponível desde a versão 1.1.0 - * @version $Id$ - */ require_once 'lib/Portabilis/View/Helper/DynamicInput/Core.php'; +class Portabilis_View_Helper_DynamicInput_DataInicial extends Portabilis_View_Helper_DynamicInput_Core +{ + protected function inputValue($value = null) + { + if (!is_null($value)) { + return $value; + } -/** - * Portabilis_View_Helper_DynamicInput_DataInicial class. - * - * @author Lucas D'Avila - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since Classe disponível desde a versão 1.1.0 - * @version @@package_version@@ - */ -class Portabilis_View_Helper_DynamicInput_DataInicial extends Portabilis_View_Helper_DynamicInput_Core { - protected function inputValue($value = null) { - if (! $value && $this->viewInstance->data_inicial) - $value = $this->viewInstance->data_inicial; - else - $value = date('01/m/Y'); + if (!empty($this->viewInstance->data_inicial)) { + return $this->viewInstance->data_inicial; + } - return $value; - } + return date('01/m/Y'); + } - public function dataInicial($options = array()) { - $defaultOptions = array('options' => array()); - $options = $this->mergeOptions($options, $defaultOptions); + public function dataInicial($options = []) + { + $defaultOptions = ['options' => []]; + $options = $this->mergeOptions($options, $defaultOptions); + $value = $options['options']['value'] ?? null; - $defaultInputOptions = array('id' => 'data_inicial', - 'label' => 'Data inicial', - 'value' => $this->inputValue($options['options']['value']), - 'required' => true, - 'label_hint' => '', - 'inline' => false, - 'callback' => false, - 'disabled' => false); + $defaultInputOptions = [ + 'id' => 'data_inicial', + 'label' => 'Data inicial', + 'value' => $this->inputValue($value), + 'required' => true, + 'label_hint' => '', + 'inline' => false, + 'callback' => false, + 'disabled' => false + ]; - $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); - call_user_func_array(array($this->viewInstance, 'campoData'), $inputOptions); - } -} \ No newline at end of file + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); + + call_user_func_array([$this->viewInstance, 'campoData'], $inputOptions); + } +} diff --git a/ieducar/lib/Portabilis/View/Helper/DynamicInput/Escola.php b/ieducar/lib/Portabilis/View/Helper/DynamicInput/Escola.php index 0da8fb06bc..1f419c424f 100644 --- a/ieducar/lib/Portabilis/View/Helper/DynamicInput/Escola.php +++ b/ieducar/lib/Portabilis/View/Helper/DynamicInput/Escola.php @@ -55,7 +55,7 @@ protected function inputName() { protected function inputOptions($options) { $resources = $options['resources']; - $instituicaoId = $this->getInstituicaoId($options['instituicaoId']); + $instituicaoId = $this->getInstituicaoId($options['instituicaoId'] ?? null); $userId = $this->getCurrentUserId(); if ($instituicaoId and empty($resources)) { diff --git a/ieducar/lib/Portabilis/View/Helper/DynamicInput/EtapaEscola.php b/ieducar/lib/Portabilis/View/Helper/DynamicInput/EtapaEscola.php index cd56c480c7..b5376fba76 100644 --- a/ieducar/lib/Portabilis/View/Helper/DynamicInput/EtapaEscola.php +++ b/ieducar/lib/Portabilis/View/Helper/DynamicInput/EtapaEscola.php @@ -51,8 +51,8 @@ protected function inputName() { protected function inputOptions($options) { $resources = $options['resources']; - $instituicaoId = $this->getInstituicaoId($options['instituicaoId']); - $escolaId = $this->getEscolaId($options['escolaId']); + $instituicaoId = $this->getInstituicaoId($options['instituicaoId'] ?? null); + $escolaId = $this->getEscolaId($options['escolaId'] ?? null); $ano = $this->viewInstance->ano; $userId = $this->getCurrentUserId(); @@ -66,4 +66,4 @@ protected function inputOptions($options) { public function etapaEscola($options = array()) { parent::select($options); } -} \ No newline at end of file +} diff --git a/ieducar/lib/Portabilis/View/Helper/DynamicInput/Serie.php b/ieducar/lib/Portabilis/View/Helper/DynamicInput/Serie.php index 55c4d0326d..4aa0c38611 100644 --- a/ieducar/lib/Portabilis/View/Helper/DynamicInput/Serie.php +++ b/ieducar/lib/Portabilis/View/Helper/DynamicInput/Serie.php @@ -50,13 +50,13 @@ protected function inputName() { protected function inputOptions($options) { $resources = $options['resources']; - $instituicaoId = $this->getInstituicaoId($options['instituicaoId']); - $escolaId = $this->getEscolaId($options['escolaId']); - $cursoId = $this->getCursoId($options['cursoId']); + $instituicaoId = $this->getInstituicaoId($options['instituicaoId'] ?? null); + $escolaId = $this->getEscolaId($options['escolaId'] ?? null); + $cursoId = $this->getCursoId($options['cursoId'] ?? null); $userId = $this->getCurrentUserId(); $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); - if ($isProfessor && Portabilis_Business_Professor::canLoadSeriesAlocado($instituicaoId)){ + if ($isProfessor && Portabilis_Business_Professor::canLoadSeriesAlocado($instituicaoId)){ $series = Portabilis_Business_Professor::seriesAlocado($instituicaoId, $escolaId, $serieId, $userId); //$resources = Portabilis_Array_Utils::setAsIdValue($series, 'id', 'nome'); } @@ -73,4 +73,4 @@ protected function defaultOptions(){ public function serie($options = array()) { parent::select($options); } -} \ No newline at end of file +} diff --git a/ieducar/lib/Portabilis/View/Helper/DynamicInput/Turma.php b/ieducar/lib/Portabilis/View/Helper/DynamicInput/Turma.php index c9f6e82694..c17b017e5d 100644 --- a/ieducar/lib/Portabilis/View/Helper/DynamicInput/Turma.php +++ b/ieducar/lib/Portabilis/View/Helper/DynamicInput/Turma.php @@ -50,11 +50,11 @@ protected function inputName() { protected function inputOptions($options) { $resources = $options['resources']; - $instituicaoId = $this->getInstituicaoId($options['instituicaoId']); - $escolaId = $this->getEscolaId($options['escolaId']); - $serieId = $this->getSerieId($options['serieId']); - $ano = $this->viewInstance->ano; - $naoFiltrarAno = $this->viewInstance->nao_filtrar_ano; + $instituicaoId = $this->getInstituicaoId($options['instituicaoId'] ?? null); + $escolaId = $this->getEscolaId($options['escolaId'] ?? null); + $serieId = $this->getSerieId($options['serieId'] ?? null); + $ano = isset($this->viewInstance->ano) ? $this->viewInstance->ano : null; + $naoFiltrarAno = isset($this->viewInstance->nao_filtrar_ano) ? $this->viewInstance->nao_filtrar_ano : null; $userId = $this->getCurrentUserId(); $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); @@ -94,4 +94,4 @@ protected function turmasPorAno($escolaId, $ano) { public function turma($options = array()) { parent::select($options); } -} \ No newline at end of file +} diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Ano.php b/ieducar/lib/Portabilis/View/Helper/Input/Ano.php index f3e817496d..b0099e6044 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Ano.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Ano.php @@ -1,75 +1,45 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Lucas D'Avila - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since Arquivo disponível desde a versão 1.1.0 - * @version $Id$ - */ require_once 'lib/Portabilis/View/Helper/Input/Core.php'; +class Portabilis_View_Helper_Input_Ano extends Portabilis_View_Helper_Input_Core +{ + protected function inputValue($value = null) + { + if (!is_null($value) && is_numeric($value)) { + return $value; + } -/** - * Portabilis_View_Helper_DynamicInput_Ano class. - * - * @author Lucas D'Avila - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since Classe disponível desde a versão 1.1.0 - * @version @@package_version@@ - */ -class Portabilis_View_Helper_Input_Ano extends Portabilis_View_Helper_Input_Core { - protected function inputValue($value = null) { - if (! $value && $this->viewInstance->ano) - $value = $this->viewInstance->ano; - else - $value = date('Y'); + if (isset($this->viewInstance->ano) && is_numeric($this->viewInstance->ano)) { + return $this->viewInstance->ano; + } - return $value; - } + return date('Y'); + } + + public function ano($options = array()) + { + $defaultOptions = array('options' => array()); + $options = $this->mergeOptions($options, $defaultOptions); + $value = $options['options']['value'] ?? null; - public function ano($options = array()) { - $defaultOptions = array('options' => array()); - $options = $this->mergeOptions($options, $defaultOptions); + $defaultInputOptions = [ + 'id' => 'ano', + 'label' => 'Ano', + 'value' => $this->inputValue($value), + 'size' => 4, + 'max_length' => 4, + 'required' => true, + 'label_hint' => '', + 'input_hint' => '', + 'script' => false, + 'callback' => false, + 'inline' => false, + 'disabled' => false + ]; - $defaultInputOptions = array('id' => 'ano', - 'label' => 'Ano', - 'value' => $this->inputValue($options['options']['value']), - 'size' => 4, - 'max_length' => 4, - 'required' => true, - 'label_hint' => '', - 'input_hint' => '', - 'script' => false, - 'callback' => false, - 'inline' => false, - 'disabled' => false); + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); - $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); - call_user_func_array(array($this->viewInstance, 'campoNumero'), $inputOptions); + call_user_func_array(array($this->viewInstance, 'campoNumero'), $inputOptions); } } diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Core.php b/ieducar/lib/Portabilis/View/Helper/Input/Core.php index 8febcae077..fa5cf961cc 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Core.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Core.php @@ -1,33 +1,4 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Lucas D'Avila - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since Arquivo disponível desde a versão 1.1.0 - * @version $Id$ - */ require_once 'include/pmieducar/clsPermissoes.inc.php'; require_once 'App/Model/IedFinder.php'; @@ -37,186 +8,218 @@ require_once 'lib/Portabilis/Object/Utils.php'; require_once 'lib/Portabilis/DataMapper/Utils.php'; -/** - * Portabilis_View_Helper_Input_Core class. - * - * @author Lucas D'Avila - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since Classe disponível desde a versão 1.1.0 - * @version @@package_version@@ - */ -class Portabilis_View_Helper_Input_Core { +class Portabilis_View_Helper_Input_Core +{ + public function __construct($viewInstance, $inputsHelper) + { + $this->viewInstance = $viewInstance; + $this->_inputsHelper = $inputsHelper; - public function __construct($viewInstance, $inputsHelper) { - $this->viewInstance = $viewInstance; - $this->_inputsHelper = $inputsHelper; - - $this->loadCoreAssets(); - $this->loadAssets(); - } + $this->loadCoreAssets(); + $this->loadAssets(); + } + protected function inputsHelper() + { + return $this->_inputsHelper; + } - protected function inputsHelper() { - return $this->_inputsHelper; - } + protected function helperName() + { + $arrayClassName = explode('_', get_class($this)); + return end($arrayClassName); + } - protected function helperName() - { - $arrayClassName = explode('_', get_class($this)); - return end($arrayClassName); - } + protected function inputName() + { + return Portabilis_String_Utils::underscore($this->helperName()); + } + protected function inputValue($value = null) + { + if (!is_null($value)) { + return $value; + } - protected function inputName() { - return Portabilis_String_Utils::underscore($this->helperName()); - } + if (isset($this->viewInstance->{$this->inputName()})) { + return $this->viewInstance->{$this->inputName()}; + } + return null; + } - protected function inputValue($value = null) { - if (! $value && $this->viewInstance->{$this->inputName()}) - $value = $this->viewInstance->{$this->inputName()}; + protected function inputPlaceholder($inputOptions) + { + return $inputOptions['placeholder'] ?? $inputOptions['label'] ?? null; + } - return $value; - } + protected function fixupPlaceholder($inputOptions) + { + $id = $inputOptions['id']; + $placeholder = $this->inputPlaceholder($inputOptions); - protected function inputPlaceholder($inputOptions) { - return isset($inputOptions['placeholder']) ? $inputOptions['placeholder'] : $inputOptions['label']; - } + $script = ' + var $input = $j(\'#' . $id . '\'); + if ($input.is(\':enabled\')) { + $input.attr(\'placeholder\', \'' . $placeholder . '\'); + } + '; - protected function fixupPlaceholder($inputOptions) { - $id = $inputOptions['id']; - $placeholder = $this->inputPlaceholder($inputOptions); + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $script, $afterReady = true); + } - $script = " - var \$input = \$j('#" . $id . "'); - if (\$input.is(':enabled')) - \$input.attr('placeholder', '" . $placeholder . "'); - "; - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $script, $afterReady = true); - } + protected function loadCoreAssets() + { + // carrega estilo para feedback messages, devido algumas validações de inuts + // adicionarem mensagens + $style = '/modules/Portabilis/Assets/Stylesheets/Frontend.css'; - protected function loadCoreAssets() { - // carrega estilo para feedback messages, devido algumas validações de inuts - // adicionarem mensagens + Portabilis_View_Helper_Application::loadStylesheet($this->viewInstance, $style); - $style = "/modules/Portabilis/Assets/Stylesheets/Frontend.css"; - Portabilis_View_Helper_Application::loadStylesheet($this->viewInstance, $style); + $dependencies = [ + '/modules/Portabilis/Assets/Javascripts/Utils.js', + '/modules/Portabilis/Assets/Javascripts/ClientApi.js', + '/modules/Portabilis/Assets/Javascripts/Validator.js' + ]; + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $dependencies); + } - $dependencies = array('/modules/Portabilis/Assets/Javascripts/Utils.js', - '/modules/Portabilis/Assets/Javascripts/ClientApi.js', - '/modules/Portabilis/Assets/Javascripts/Validator.js'); + protected function loadAssets() + { + $rootPath = dirname(dirname(dirname(dirname(dirname(__DIR__))))); + $style = "/modules/DynamicInput/Assets/Stylesheets/{$this->helperName()}.css"; + $script = "/modules/DynamicInput/Assets/Javascripts/{$this->helperName()}.js"; - Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $dependencies); - } + if (file_exists($rootPath . $style)) { + Portabilis_View_Helper_Application::loadStylesheet($this->viewInstance, $style); + } + if (file_exists($rootPath . $script)) { + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $script); + } + } - protected function loadAssets() { - $rootPath = $_SERVER['DOCUMENT_ROOT']; - $style = "/modules/DynamicInput/Assets/Stylesheets/{$this->helperName()}.css"; - $script = "/modules/DynamicInput/Assets/Javascripts/{$this->helperName()}.js"; + // wrappers - if (file_exists($rootPath . $style)) - Portabilis_View_Helper_Application::loadStylesheet($this->viewInstance, $style); + protected function getCurrentUserId() + { + return Portabilis_Utils_User::currentUserId(); + } - if (file_exists($rootPath . $script)) - Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $script); - } + protected function getPermissoes() + { + return Portabilis_Utils_User::getClsPermissoes(); + } - // wrappers + protected function hasNivelAcesso($nivelAcessoType) + { + return Portabilis_Utils_User::hasNivelAcesso($nivelAcessoType); + } - protected function getCurrentUserId() { - return Portabilis_Utils_User::currentUserId(); - } + protected function getDataMapperFor($packageName, $modelName) + { + return Portabilis_DataMapper_Utils::getDataMapperFor($packageName, $modelName); + } - protected function getPermissoes() { - return Portabilis_Utils_User::getClsPermissoes(); - } + protected static function mergeOptions($options, $defaultOptions) + { + return Portabilis_Array_Utils::merge($options, $defaultOptions); + } - protected function hasNivelAcesso($nivelAcessoType) { - return Portabilis_Utils_User::hasNivelAcesso($nivelAcessoType); - } + protected static function insertOption($key, $value, $array) + { + return Portabilis_Array_Utils::insertIn($key, $value, $array); + } - protected function getDataMapperFor($packageName, $modelName){ - return Portabilis_DataMapper_Utils::getDataMapperFor($packageName, $modelName); - } + // ieducar helpers - protected static function mergeOptions($options, $defaultOptions) { - return Portabilis_Array_Utils::merge($options, $defaultOptions); - } + protected function getInstituicaoId($instituicaoId = null) + { + if (!is_null($instituicaoId) && is_numeric($instituicaoId)) { + return $instituicaoId; + } - protected static function insertOption($key, $value, $array) { - return Portabilis_Array_Utils::insertIn($key, $value, $array); - } + if (isset($this->viewInstance->ref_cod_instituicao) && is_numeric($this->viewInstance->ref_cod_instituicao)) { + return $this->viewInstance->ref_cod_instituicao; + } - // ieducar helpers + if (isset($this->viewInstance->ref_cod_escola) && is_numeric($this->viewInstance->ref_cod_escola)) { + return $this->viewInstance->ref_cod_escola; + } - protected function getInstituicaoId($instituicaoId = null) { - if (! $instituicaoId && is_numeric($this->viewInstance->ref_cod_instituicao)) - $instituicaoId = $this->viewInstance->ref_cod_instituicao; + if (isset($this->viewInstance->ref_cod_biblioteca) && is_numeric($this->viewInstance->ref_cod_biblioteca)) { + $biblioteca = App_Model_IedFinder::getBiblioteca($this->viewInstance->ref_cod_biblioteca); - elseif (! $instituicaoId && is_numeric($this->viewInstance->ref_cod_escola)) { - $escola = App_Model_IedFinder::getEscola($this->viewInstance->ref_cod_escola); - $instituicaoId = $escola['ref_cod_instituicao']; - } + return $biblioteca['ref_cod_instituicao']; + } - elseif (! $instituicaoId && is_numeric($this->viewInstance->ref_cod_biblioteca)) { - $biblioteca = App_Model_IedFinder::getBiblioteca($this->viewInstance->ref_cod_biblioteca); - $instituicaoId = $biblioteca['ref_cod_instituicao']; + return $this->getPermissoes()->getInstituicao($this->getCurrentUserId()); } - elseif (! $instituicaoId) - $instituicaoId = $this->getPermissoes()->getInstituicao($this->getCurrentUserId()); + protected function getEscolaId($escolaId = null) + { + if (!is_null($escolaId) && is_numeric($escolaId)) { + return $escolaId; + } - return $instituicaoId; - } + if (isset($this->viewInstance->ref_cod_escola) && is_numeric($this->viewInstance->ref_cod_escola)) { + return $this->viewInstance->ref_cod_escola; + } + if (isset($this->viewInstance->ref_cod_biblioteca) && is_numeric($this->viewInstance->ref_cod_biblioteca)) { + $biblioteca = App_Model_IedFinder::getBiblioteca($this->viewInstance->ref_cod_biblioteca); - protected function getEscolaId($escolaId = null) { - if (! $escolaId && $this->viewInstance->ref_cod_escola) - $escolaId = $this->viewInstance->ref_cod_escola; + return $biblioteca['ref_cod_escola']; + } - elseif (! $escolaId && is_numeric($this->viewInstance->ref_cod_biblioteca)) { - $biblioteca = App_Model_IedFinder::getBiblioteca($this->viewInstance->ref_cod_biblioteca); - $escolaId = $biblioteca['ref_cod_escola']; + return $this->getPermissoes()->getEscola($this->getCurrentUserId()); } - elseif (! $escolaId) - $escolaId = $this->getPermissoes()->getEscola($this->getCurrentUserId()); + protected function getBibliotecaId($bibliotecaId = null) + { + if (!is_null($bibliotecaId) && is_numeric($bibliotecaId)) { + return $bibliotecaId; + } - return $escolaId; - } + if (isset($this->viewInstance->ref_cod_biblioteca) && is_numeric($this->viewInstance->ref_cod_biblioteca)) { + return $this->viewInstance->ref_cod_biblioteca; + } + $biblioteca = $this->getPermissoes()->getBiblioteca($this->getCurrentUserId()); - protected function getBibliotecaId($bibliotecaId = null) { - if (! $bibliotecaId && ! $this->viewInstance->ref_cod_biblioteca) { - $biblioteca = $this->getPermissoes()->getBiblioteca($this->getCurrentUserId()); + if (is_array($biblioteca) && count($biblioteca) > 0) { + return $biblioteca[0]['ref_cod_biblioteca']; + } - if (is_array($biblioteca) && count($biblioteca) > 0) - $bibliotecaId = $biblioteca[0]['ref_cod_biblioteca']; + return null; } - elseif (! $bibliotecaId) - $bibliotecaId = $this->viewInstance->ref_cod_biblioteca; + protected function getCursoId($cursoId = null) + { + if (!is_null($cursoId) && is_numeric($cursoId)) { + return $cursoId; + } - return $bibliotecaId; - } + if (isset($this->viewInstance->ref_cod_curso) && is_numeric($this->viewInstance->ref_cod_curso)) { + return $this->viewInstance->ref_cod_curso; + } - protected function getCursoId($cursoId = null) { - if (! $cursoId && $this->viewInstance->ref_cod_curso) - $cursoId = $this->viewInstance->ref_cod_curso; + return null; + } - return $cursoId; - } + protected function getSerieId($serieId = null) + { + if (!is_null($serieId) && is_numeric($serieId)) { + return $serieId; + } - protected function getSerieId($serieId = null) { - if (! $serieId && $this->viewInstance->ref_cod_serie) - $serieId = $this->viewInstance->ref_cod_serie; + if (isset($this->viewInstance->ref_cod_serie) && is_numeric($this->viewInstance->ref_cod_serie)) { + return $this->viewInstance->ref_cod_serie; + } - return $serieId; - } -} \ No newline at end of file + return null; + } +} diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchComponenteCurricular.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchComponenteCurricular.php index 5e8e3710ca..f410294056 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchComponenteCurricular.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchComponenteCurricular.php @@ -1,86 +1,54 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Lucas Schmoeller da Silva - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since ? - * @version $Id$ - */ - require_once 'lib/Portabilis/View/Helper/Input/MultipleSearch.php'; require_once 'lib/Portabilis/Utils/Database.php'; require_once 'lib/Portabilis/String/Utils.php'; -/** - * Portabilis_View_Helper_Input_MultipleSearchComponenteCurricular class. - * - * @author Lucas Schmoeller da Silva - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since ? - * @version @@package_version@@ - */ -class Portabilis_View_Helper_Input_Resource_MultipleSearchComponenteCurricular extends Portabilis_View_Helper_Input_MultipleSearch { - - protected function getOptions($resources) { +class Portabilis_View_Helper_Input_Resource_MultipleSearchComponenteCurricular extends Portabilis_View_Helper_Input_MultipleSearch +{ + protected function getOptions($resources) + { + if (empty($resources)) { + $resources = Portabilis_Utils_Database::fetchPreparedQuery('SELECT id, nome FROM modules.componente_curricular'); + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'id', 'nome'); + } - if (empty($resources)) { - $resources = Portabilis_Utils_Database::fetchPreparedQuery('SELECT id, nome FROM modules.componente_curricular'); - $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'id', 'nome'); + return $this->insertOption(null, '', $resources); } - return $this->insertOption(null, '', $resources); - } - - public function multipleSearchComponenteCurricular($attrName, $options = array()) { - $defaultOptions = array('objectName' => 'componentecurricular', - 'apiController' => 'ComponenteCurricular', - 'apiResource' => 'componentecurricular-search'); + public function multipleSearchComponenteCurricular($attrName, $options = []) + { + $defaultOptions = [ + 'objectName' => 'componentecurricular', + 'apiController' => 'ComponenteCurricular', + 'apiResource' => 'componentecurricular-search', + 'searchForArea' => false + ]; - $options = $this->mergeOptions($options, $defaultOptions); - $options['options']['resources'] = $this->getOptions($options['options']['resources']); + $options = $this->mergeOptions($options, $defaultOptions); + $options['options']['resources'] = $this->getOptions($options['options']['resources']); - $this->placeholderJs($options); + $this->placeholderJs($options); - parent::multipleSearch($options['objectName'], $attrName, $options); - } + parent::multipleSearch($options['objectName'], $attrName, $options); + } - protected function placeholderJs($options) { - $optionsVarName = "multipleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; - $optionsVarName.placeholder = safeUtf8Decode('Selecione os componentes');"; + protected function placeholderJs($options) + { + $optionsVarName = 'multipleSearch' . Portabilis_String_Utils::camelize($options['objectName']) . 'Options'; + $searchForArea = $options['searchForArea'] ? "true" : "false"; + $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; + $optionsVarName.placeholder = safeUtf8Decode('Selecione os componentes');"; + $js .= "var searchForArea = {$searchForArea}"; - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); - } + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = false); + } - protected function loadAssets() { - Portabilis_View_Helper_Application::loadChosenLib($this->viewInstance); - $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/MultipleSearch.js'; - Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); - $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/MultipleSearchComponenteCurricular.js'; - Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); - } -} \ No newline at end of file + protected function loadAssets() + { + Portabilis_View_Helper_Application::loadChosenLib($this->viewInstance); + $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/MultipleSearch.js'; + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); + $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/MultipleSearchComponenteCurricular.js'; + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); + } +} diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchCurso.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchCurso.php index b541deaea1..4d82abcacb 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchCurso.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchCurso.php @@ -1,83 +1,50 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Lucas Schmoeller da Silva - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since ? - * @version $Id$ - */ require_once 'lib/Portabilis/View/Helper/Input/MultipleSearch.php'; require_once 'lib/Portabilis/Utils/Database.php'; require_once 'lib/Portabilis/String/Utils.php'; -/** - * Portabilis_View_Helper_Input_MultipleSearchCurso class. - * - * @author Paula Bonot - * @category i-Educar - * @license @@license@@ - * @package Portabilis - * @since ? - * @version @@package_version@@ - */ -class Portabilis_View_Helper_Input_Resource_MultipleSearchCurso extends Portabilis_View_Helper_Input_MultipleSearch { - - protected function getOptions($resources) { - - // if (empty($resources)) { - // $resources = Portabilis_Utils_Database::fetchPreparedQuery('SELECT cod_escola, nome FROM pmieducar.escola INNER JOIN cadastro.pessoa ON (ref_idpes = idpes) WHERE escola.ativo = 1'); - // $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_escola', 'nome'); - // } - - return $this->insertOption(null, '', $resources); - } - - public function multipleSearchCurso($attrName, $options = array()) { - $defaultOptions = array('objectName' => 'curso', 'max_selected_options' => 3); - - $options = $this->mergeOptions($options, $defaultOptions); - $options['options']['resources'] = $this->getOptions($options['options']['resources']); - - $this->placeholderJs($options); - - parent::multipleSearch($options['objectName'], $attrName, $options); - } - - protected function placeholderJs($options) { - $optionsVarName = "multipleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; - $optionsVarName.placeholder = safeUtf8Decode('Selecione os cursos');"; - - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); - } - protected function loadAssets() { - Portabilis_View_Helper_Application::loadChosenLib($this->viewInstance); - $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/MultipleSearch.js'; - Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); - $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/MultipleSearchCurso.js'; - Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); - } -} \ No newline at end of file +class Portabilis_View_Helper_Input_Resource_MultipleSearchCurso extends Portabilis_View_Helper_Input_MultipleSearch +{ + protected function getOptions($resources) + { + return $this->insertOption(null, '', $resources); + } + + public function multipleSearchCurso($attrName, $options = []) + { + $defaultOptions = [ + 'objectName' => 'curso', + 'max_selected_options' => 3 + ]; + + $options = $this->mergeOptions($options, $defaultOptions); + $options['options']['resources'] = $options['options']['resources'] ?? []; + $options['options']['resources'] = $this->getOptions($options['options']['resources']); + + $this->placeholderJs($options); + + parent::multipleSearch($options['objectName'], $attrName, $options); + } + + protected function placeholderJs($options) + { + $optionsVarName = 'multipleSearch' . Portabilis_String_Utils::camelize($options['objectName']) . 'Options'; + + $js = " + if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; + $optionsVarName.placeholder = safeUtf8Decode('Selecione os cursos'); + "; + + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); + } + + protected function loadAssets() + { + Portabilis_View_Helper_Application::loadChosenLib($this->viewInstance); + $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/MultipleSearch.js'; + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); + $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/MultipleSearchCurso.js'; + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); + } +} diff --git a/ieducar/lib/Utils/FileStream.class.php b/ieducar/lib/Utils/FileStream.class.php index 03bbbdea67..5c279c1f0c 100644 --- a/ieducar/lib/Utils/FileStream.class.php +++ b/ieducar/lib/Utils/FileStream.class.php @@ -1,155 +1,128 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -/** - * FileStream class. - * - * Classe para stream de arquivos implementando checagens de segurança como - * diretórios permitidos e tipo de arquivo. - * - * @author Eriksen Costa Paixão - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Core - * @since Classe disponível desde a versão 1.1.0 - * @version $Id$ - */ class FileStream { - /** * Instância da classe Mimetype - * @var Mimetype - */ - protected $Mimetype = NULL; - - /** - * Caminho do arquivo para stream - * @var string - */ - protected $filepath = NULL; - - /** - * Array de diretórios permitidos para stream de arquivos. - * @var array - */ - protected $allowedDirs = array(); - - - /** - * Construtor. - * - * @param Mimetype $mimetype Objeto Mimetype - * @param array $allowedDirs Diretórios permitidos para stream - */ - public function __construct(Mimetype $mimetype, array $allowedDirs = array()) { - $this->Mimetype = $mimetype; - $this->setAllowedDirectories((array) $allowedDirs); - } - - /** - * Configura o nome do arquivo, verificando se o mesmo encontra-se em um - * diretório de acesso permitido e se é legível. - * - * @param string $filepath O caminho completo ou relativo do arquivo - * @throws Exception - */ - public function setFilepath($filepath) { - $this->isReadable($filepath); - $this->filepath = $filepath; - } - - /** - * Configura os diretórios permitidos para stream de arquivos. - * - * @param array $v - */ - protected function setAllowedDirectories($v) { - $this->allowedDirs = $v; - } - - /** - * Verifica se o arquivo é legível e se está em um diretório permitido - * para stream de arquivos. * - * @param string $filepath O caminho completo ou relativo ao arquivo - * @throws Exception + * @var Mimetype */ - protected function isReadable($filepath) - { - $fileinfo = pathinfo($filepath); - - if (! $this->isDirectoryAllowed($fileinfo['dirname'])) { - throw new Exception('Acesso ao diretório negado.'); + protected $mimetype = null; + + /** + * Caminho do arquivo para stream + * + * @var string + */ + protected $filepath = null; + + /** + * Array de diretórios permitidos para stream de arquivos. + * + * @var array + */ + protected $allowedDirs = []; + + /** + * Construtor. + * + * @param Mimetype $mimetype Objeto Mimetype + * @param array $allowedDirs Diretórios permitidos para stream + */ + public function __construct(Mimetype $mimetype, array $allowedDirs = []) + { + $this->mimetype = $mimetype; + $this->setAllowedDirectories((array) $allowedDirs); } - if (! is_readable($filepath)) { - throw new Exception('Arquivo não existe.'); + /** + * Configura o nome do arquivo, verificando se o mesmo encontra-se em um + * diretório de acesso permitido e se é legível. + * + * @param string $filepath O caminho completo ou relativo do arquivo + * + * @throws Exception + */ + public function setFilepath($filepath) + { + $this->isReadable($filepath); + $this->filepath = $filepath; } - } - /** - * Verifica se o diretório está na lista de diretórios permitidos para - * stream de arquivos. - * - * @param string $directory - * @return bool Retorna TRUE se o diretório é permitido - */ - public function isDirectoryAllowed($directory) - { - if (FALSE === array_search($directory, $this->allowedDirs)) { - return FALSE; + /** + * Configura os diretórios permitidos para stream de arquivos. + * + * @param array $v + */ + protected function setAllowedDirectories($v) + { + $this->allowedDirs = $v; } - return TRUE; - } - - /** - * Faz o stream do arquivo. - * - * @throws Exception - */ - public function streamFile() - { - $mimetype = $this->Mimetype->getType($this->filepath); - - if (FALSE === $mimetype) { - throw new Exception('Extensão não suportada.'); + /** + * Verifica se o arquivo é legível e se está em um diretório permitido + * para stream de arquivos. + * + * @param string $filepath O caminho completo ou relativo ao arquivo + * + * @throws Exception + */ + protected function isReadable($filepath) + { + $fileinfo = pathinfo($filepath); + + if (! $this->isDirectoryAllowed($fileinfo['dirname'])) { + throw new Exception('Acesso ao diretório negado.'); + } + + if (! is_readable($filepath)) { + throw new Exception('Arquivo não existe.'); + } } - // Headers para stream de arquivo - header('Content-Description: File Transfer'); - header('Content-Type: ' . $mimetype); - header('Content-Disposition: attachment;'); - header('Content-Transfer-Encoding: binary'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - header('Content-Length: ' . filesize($this->filepath)); - ob_clean(); - flush(); - - // Lê o arquivo para stream buffer - readfile($this->filepath); - } + /** + * Verifica se o diretório está na lista de diretórios permitidos para + * stream de arquivos. + * + * @param string $directory + * + * @return bool Retorna TRUE se o diretório é permitido + */ + public function isDirectoryAllowed($directory) + { + if (false === array_search($directory, $this->allowedDirs)) { + return false; + } + + return true; + } + /** + * Faz o stream do arquivo. + * + * @throws Exception + */ + public function streamFile() + { + $mimetype = $this->mimetype->getType($this->filepath); + + if (false === $mimetype) { + throw new Exception('Extensão não suportada.'); + } + + // Headers para stream de arquivo + header('Content-Description: File Transfer'); + header('Content-Type: ' . $mimetype); + header('Content-Disposition: attachment;'); + header('Content-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: ' . filesize($this->filepath)); + ob_clean(); + flush(); + + // Lê o arquivo para stream buffer + readfile($this->filepath); + } } diff --git a/ieducar/lib/Utils/Mimetype.class.php b/ieducar/lib/Utils/Mimetype.class.php index a30b510382..26ce90b1ac 100644 --- a/ieducar/lib/Utils/Mimetype.class.php +++ b/ieducar/lib/Utils/Mimetype.class.php @@ -1,114 +1,35 @@ - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -/* - * Copyright (C) 2002 Jason Sheets . - * All rights reserved. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/** - * mimetype class. - * - * Essa classe é uma modificação da classe mimetype de Jason Sheets. A classe - * original é distribuída sobre uma licença BSD. Essa classe estava modificada - * dentro do arquivo intranet/download.php mas para melhorar a testabilidade, - * foi refatorada para a sua própria classe novamente. - * - * Essa classe poderá a vir ser depreciada em favor do uso da extensão PECL - * {@link http://php.net/fileinfo fileinfo} do PHP 5.2 (no core na versão 5.3). - * No entanto, essa dependência só deverá ser implantada quando um instalador - * ou processo de verificação de dependência estiver disponível. - * - * @author Eriksen Costa Paixão - * @author Jason Sheets - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @license http://opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpclasses.org/browse/file/2743.html Código fonte original - * @package Core - * @since Classe disponível desde a versão 1.1.0 - * @todo Verificar dual-licensing do arquivo - * @todo Substituir por fileinfo e adicionar dependência na aplicação - * @version $Id$ - */ class Mimetype { + public function getType($filename) + { + $filename = basename($filename); + $filename = explode('.', $filename); + $filename = $filename[count($filename)-1]; - public function getType($filename) - { - $filename = basename($filename); - $filename = explode('.', $filename); - $filename = $filename[count($filename)-1]; + return $this->privFindType($filename); + } - return $this->privFindType($filename); - } + protected function privFindType($ext) + { + $mimetypes = $this->privBuildMimeArray(); - protected function privFindType($ext) - { - $mimetypes = $this->privBuildMimeArray(); + if (isset($mimetypes[$ext])) { + return $mimetypes[$ext]; + } - if (isset($mimetypes[$ext])) { - return $mimetypes[$ext]; + return false; } - else { - return FALSE; - } - } - protected function privBuildMimeArray() { - return array( - 'doc' => 'application/msword', - 'odt' => 'application/vnd.oasis.opendocument.text', - 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - 'pdf' => 'application/pdf', - 'xls' => 'application/vnd.ms-excel', - ); - } -} \ No newline at end of file + protected function privBuildMimeArray() + { + return [ + 'doc' => 'application/msword', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'pdf' => 'application/pdf', + 'xls' => 'application/vnd.ms-excel', + ]; + } +} diff --git a/ieducar/lib/Utils/SafeJson.php b/ieducar/lib/Utils/SafeJson.php index 2840bbe4aa..8f14262f9f 100644 --- a/ieducar/lib/Utils/SafeJson.php +++ b/ieducar/lib/Utils/SafeJson.php @@ -1,7 +1,7 @@ execute('ALTER TABLE pmieducar.modulo ADD COLUMN num_etapas numeric(2,0) NOT NULL DEFAULT 0;'); + } +} diff --git a/ieducar/misc/database/migrations/20180615201121_altera_nomes_do_menu_modulo_para_etapa.php b/ieducar/misc/database/migrations/20180615201121_altera_nomes_do_menu_modulo_para_etapa.php new file mode 100644 index 0000000000..c2e22f8c52 --- /dev/null +++ b/ieducar/misc/database/migrations/20180615201121_altera_nomes_do_menu_modulo_para_etapa.php @@ -0,0 +1,13 @@ +execute('update pmicontrolesis.menu set tt_menu = \'Tipos de etapas\' where cod_menu = 21159;'); + $this->execute('update menu_submenu set nm_submenu = \'Tipos de etapas da escola\' where cod_menu_submenu = 584;'); + } +} diff --git a/ieducar/misc/database/migrations/20180801183745_ajusta_etapas_dos_modulos.php b/ieducar/misc/database/migrations/20180801183745_ajusta_etapas_dos_modulos.php new file mode 100644 index 0000000000..c243d0ebb7 --- /dev/null +++ b/ieducar/misc/database/migrations/20180801183745_ajusta_etapas_dos_modulos.php @@ -0,0 +1,101 @@ +execute(" + update pmieducar.modulo set num_etapas = 4 where trim(lower(nm_tipo)) in ('bimestre', 'bimestral'); + update pmieducar.modulo set num_etapas = 3 where trim(lower(nm_tipo)) in ('trimestre', 'trimestral'); + update pmieducar.modulo set num_etapas = 2 where trim(lower(nm_tipo)) in ('semestre', 'semestral'); + update pmieducar.modulo set num_etapas = 1 where trim(lower(nm_tipo)) in ('anual'); + "); + + $modules = $this->fetchAll('select cod_modulo from pmieducar.modulo where num_etapas = 0 order by cod_modulo asc;'); + + if (!empty($modules)) { + $query = " + select + etapas.total AS etapas + from + pmieducar.modulo + inner join + ( + select + ref_cod_modulo, + total, + count(*) AS count + from + ( + select + ref_cod_modulo, + count(*) AS total + from + pmieducar.ano_letivo_modulo + inner join pmieducar.escola_ano_letivo on true + and escola_ano_letivo.ano = ano_letivo_modulo.ref_ano + and escola_ano_letivo.ref_cod_escola = ano_letivo_modulo.ref_ref_cod_escola + and escola_ano_letivo.ativo = 1 + group by + ref_ano, + ref_ref_cod_escola, + ref_cod_modulo + order by + ref_cod_modulo + ) AS etapas_count + group by + ref_cod_modulo, + total + order by + ref_cod_modulo asc, + total desc + ) as etapas on true + and etapas.ref_cod_modulo = modulo.cod_modulo + where true + and modulo.cod_modulo = %d + order by + modulo.cod_modulo asc, + etapas.count desc + limit 1 + "; + + foreach ($modules as $module) { + $q = sprintf($query, $module['cod_modulo']); + $results = $this->fetchRow($q); + + if (empty($results)) { + continue; + } + + $this->execute(sprintf( + "update pmieducar.modulo set num_etapas = %d where cod_modulo = %d;", + $results['etapas'], + $module['cod_modulo'] + )); + } + } + } +} diff --git a/ieducar/misc/database/migrations/20180801191005_ajusta_modulos_de_anos.php b/ieducar/misc/database/migrations/20180801191005_ajusta_modulos_de_anos.php new file mode 100644 index 0000000000..513df15c52 --- /dev/null +++ b/ieducar/misc/database/migrations/20180801191005_ajusta_modulos_de_anos.php @@ -0,0 +1,135 @@ +execute("SELECT SETVAL('pmieducar.modulo_cod_modulo_seq', (SELECT MAX(cod_modulo) + 1 FROM pmieducar.modulo));"); + + $query = " + select + ref_ano, + ref_ref_cod_escola AS ref_cod_escola, + count(*) AS etapas + from + pmieducar.ano_letivo_modulo + inner join pmieducar.escola_ano_letivo on true + and escola_ano_letivo.ref_cod_escola = ano_letivo_modulo.ref_ref_cod_escola + and escola_ano_letivo.ano = ano_letivo_modulo.ref_ano + where true + and escola_ano_letivo.ativo = 1 + group by + ref_ano, + ref_ref_cod_escola + order by + ref_ano, + ref_cod_escola + "; + + $records = $this->fetchAll($query); + + foreach ($records as $record) { + $steps = $this->fetchAll(sprintf( + 'select * from pmieducar.ano_letivo_modulo where ref_ano = %d and ref_ref_cod_escola = %d', + $record['ref_ano'], + $record['ref_cod_escola'] + )); + + $modules = []; + $module = 0; + + foreach ($steps as $step) { + $modules[] = $step['ref_cod_modulo']; + } + + $modules = array_unique($modules); + + foreach ($modules as $mod) { + $m = $this->fetchRow(sprintf('select * from pmieducar.modulo where cod_modulo = %d', $mod)); + + if ((int)$m['num_etapas'] === (int)$record['etapas']) { + $module = (int)$mod; + break; + } + } + + if ($module === 0) { + $m = $this->fetchRow(sprintf('select * from pmieducar.modulo where num_etapas = %d limit 1', $record['etapas'])); + + if ($m) { + if ((bool)$m['ativo'] === false) { + $this->execute(sprintf('update pmieducar.modulo set ativo = 1 where cod_modulo = %d;', (int)$m['cod_modulo'])); + } + + $module = (int)$m['cod_modulo']; + } + } + + if ($module === 0) { + $module = $this->createModule((int)$record['etapas']); + } + + $query = sprintf( + 'UPDATE pmieducar.ano_letivo_modulo SET ref_cod_modulo = %d WHERE ref_ano = %d AND ref_ref_cod_escola = %d', + $module, + $record['ref_ano'], + $record['ref_cod_escola'] + ); + + $this->execute($query); + } + } + + private function createModule(int $steps) { + $map = [ + 1 => 'Anual', + 2 => 'Semestral', + 3 => 'Trimestral', + 4 => 'Bimestral', + ]; + + $data = [ + 'ref_usuario_cad' => "'1'", + 'nm_tipo' => !empty($map[$steps]) ? "'$map[$steps]'" : sprintf("'Módulo %d etapas'", $steps), + 'num_meses' => "'1'", + 'num_semanas' => "'1'", + 'data_cadastro' => 'NOW()', + 'ativo' => "'1'", + 'ref_cod_instituicao' => "'1'", + 'num_etapas' => "'$steps'" + ]; + + $query = sprintf( + 'INSERT INTO pmieducar.modulo (%s) VALUES (%s) RETURNING cod_modulo', + join(', ', array_keys($data)), + join(', ', $data) + ); + + $result = $this->fetchRow($query); + + return (int)$result['cod_modulo']; + } +} diff --git a/ieducar/misc/database/migrations/20180801210413_ajusta_modulos_de_turmas.php b/ieducar/misc/database/migrations/20180801210413_ajusta_modulos_de_turmas.php new file mode 100644 index 0000000000..fba029ba91 --- /dev/null +++ b/ieducar/misc/database/migrations/20180801210413_ajusta_modulos_de_turmas.php @@ -0,0 +1,146 @@ +execute("SELECT SETVAL('pmieducar.modulo_cod_modulo_seq', (SELECT MAX(cod_modulo) + 1 FROM pmieducar.modulo));"); + + $generator = function () { + $id = 0; + + do { + $query = sprintf( + " + select + turma_modulo.ref_cod_turma, + count(*) as etapas + from + pmieducar.turma_modulo + inner join pmieducar.turma on true + and turma.cod_turma = turma_modulo.ref_cod_turma + where true + and turma.ativo = 1 + and turma.cod_turma > %d + group by + turma_modulo.ref_cod_turma + order by + turma_modulo.ref_cod_turma + limit 1 + ", + $id + ); + + $result = $this->fetchRow($query); + + if ($result) { + yield $result; + + $id = $result['ref_cod_turma']; + } + } while ($result); + }; + + foreach ($generator() as $record) { + $steps = $this->fetchAll(sprintf( + 'select * from pmieducar.turma_modulo where ref_cod_turma = %d', + $record['ref_cod_turma'] + )); + + $modules = []; + $module = 0; + + foreach ($steps as $step) { + $modules[] = $step['ref_cod_modulo']; + } + + $modules = array_unique($modules); + + foreach ($modules as $mod) { + $m = $this->fetchRow(sprintf('select * from pmieducar.modulo where cod_modulo = %d', $mod)); + + if ((int)$m['num_etapas'] === (int)$record['etapas']) { + $module = (int)$mod; + break; + } + } + + if ($module === 0) { + $m = $this->fetchRow(sprintf('select * from pmieducar.modulo where num_etapas = %d limit 1', $record['etapas'])); + + if ($m) { + if ((bool)$m['ativo'] === false) { + $this->execute(sprintf('update pmieducar.modulo set ativo = 1 where cod_modulo = %d;', (int)$m['cod_modulo'])); + } + + $module = (int)$m['cod_modulo']; + } + } + + if ($module === 0) { + $module = $this->createModule((int)$record['etapas']); + } + + $query = sprintf( + 'UPDATE pmieducar.turma_modulo SET ref_cod_modulo = %d WHERE ref_cod_turma = %d', + $module, + $record['ref_cod_turma'] + ); + + $this->execute($query); + } + } + + private function createModule(int $steps) { + $map = [ + 1 => 'Anual', + 2 => 'Semestral', + 3 => 'Trimestral', + 4 => 'Bimestral', + ]; + + $data = [ + 'ref_usuario_cad' => "'1'", + 'nm_tipo' => !empty($map[$steps]) ? "'$map[$steps]'" : sprintf("'Módulo %d etapas'", $steps), + 'num_meses' => "'1'", + 'num_semanas' => "'1'", + 'data_cadastro' => 'NOW()', + 'ativo' => "'1'", + 'ref_cod_instituicao' => "'1'", + 'num_etapas' => "'$steps'" + ]; + + $query = sprintf( + 'INSERT INTO pmieducar.modulo (%s) VALUES (%s) RETURNING cod_modulo', + join(', ', array_keys($data)), + join(', ', $data) + ); + + $result = $this->fetchRow($query); + + return (int)$result['cod_modulo']; + } +} diff --git a/ieducar/misc/database/migrations/20180823181003_remove_not_null_da_coluna_nun_semanas_da_tabela_modulos.php b/ieducar/misc/database/migrations/20180823181003_remove_not_null_da_coluna_nun_semanas_da_tabela_modulos.php new file mode 100644 index 0000000000..3e61b2e5e6 --- /dev/null +++ b/ieducar/misc/database/migrations/20180823181003_remove_not_null_da_coluna_nun_semanas_da_tabela_modulos.php @@ -0,0 +1,20 @@ +execute($sql); + + } +} diff --git a/ieducar/misc/database/migrations/20180823181019_remove_not_null_da_coluna_nun_meses_da_tabela_modulos.php b/ieducar/misc/database/migrations/20180823181019_remove_not_null_da_coluna_nun_meses_da_tabela_modulos.php new file mode 100644 index 0000000000..816420e716 --- /dev/null +++ b/ieducar/misc/database/migrations/20180823181019_remove_not_null_da_coluna_nun_meses_da_tabela_modulos.php @@ -0,0 +1,20 @@ +execute($sql); + } +} diff --git a/ieducar/misc/database/migrations/20180823210652_consultas.php b/ieducar/misc/database/migrations/20180823210652_consultas.php new file mode 100644 index 0000000000..4b90ee6b06 --- /dev/null +++ b/ieducar/misc/database/migrations/20180823210652_consultas.php @@ -0,0 +1,33 @@ +execute(' + insert into pmicontrolesis.menu values(9998890, null, 999926, \'Consultas\', 1, null, \'_self\', 1, 15, null, null); + insert into portal.menu_submenu values(9998900, 55, 2, \'Consulta de movimento geral\', \'educar_consulta_movimento_geral.php\', null, 3); + insert into pmicontrolesis.menu values(9998900, 9998900, 9998890, \'Consulta de movimento geral\', 0, \'educar_consulta_movimento_geral.php\', \'_self\', 1, 15, 1, null); + insert into portal.menu_submenu values(9998910, 55, 2, \'Consulta de movimento mensal\', \'educar_consulta_movimento_mensal.php\', null, 3); + insert into pmicontrolesis.menu values(9998910, 9998910, 9998890, \'Consulta de movimento mensal\', 0, \'educar_consulta_movimento_mensal.php\', \'_self\', 1, 15, 1, null); + insert into pmieducar.menu_tipo_usuario VALUES (1, 9998900, 1, 1, 1); + insert into pmieducar.menu_tipo_usuario VALUES (1, 9998910, 1, 1, 1); + + '); + } + + public function down() + { + $this->execute(' + delete from pmieducar.menu_tipo_usuario where ref_cod_menu_submenu = 9998910; + delete from pmieducar.menu_tipo_usuario where ref_cod_menu_submenu = 9998900; + delete from pmicontrolesis.menu where cod_menu = 9998910; + delete from portal.menu_submenu where cod_menu_submenu = 9998910; + delete from pmicontrolesis.menu where cod_menu = 9998900; + delete from portal.menu_submenu where cod_menu_submenu = 9998900; + delete from pmicontrolesis.menu where cod_menu = 9998890; + '); + } +} diff --git a/ieducar/misc/database/migrations/20180827173740_altera_colunas_para_permitir_null.php b/ieducar/misc/database/migrations/20180827173740_altera_colunas_para_permitir_null.php new file mode 100644 index 0000000000..0d3d41cc57 --- /dev/null +++ b/ieducar/misc/database/migrations/20180827173740_altera_colunas_para_permitir_null.php @@ -0,0 +1,22 @@ +execute($sql); + } +} diff --git a/ieducar/misc/database/migrations/20180831175718_atualiza_situacao_nota_componente.php b/ieducar/misc/database/migrations/20180831175718_atualiza_situacao_nota_componente.php new file mode 100644 index 0000000000..45b5c9c782 --- /dev/null +++ b/ieducar/misc/database/migrations/20180831175718_atualiza_situacao_nota_componente.php @@ -0,0 +1,63 @@ +execute($query); + + $query = <<<'SQL' + update + nota_componente_curricular_media + set + situacao = matricula.aprovado + from + modules.nota_aluno, + pmieducar.matricula + where true + and nota_aluno.id = nota_componente_curricular_media.nota_aluno_id + and nota_aluno.matricula_id = matricula.cod_matricula + and nota_componente_curricular_media.situacao is null; +SQL; + + $this->execute($query); + } +} diff --git a/ieducar/misc/database/migrations/20180903170004_cria_sequencial_para_dispensa.php b/ieducar/misc/database/migrations/20180903170004_cria_sequencial_para_dispensa.php new file mode 100644 index 0000000000..a2fcb18c09 --- /dev/null +++ b/ieducar/misc/database/migrations/20180903170004_cria_sequencial_para_dispensa.php @@ -0,0 +1,19 @@ +execute("CREATE SEQUENCE pmieducar.dispensa_disciplina_cod_dispensa_seq;"); + $this->execute("ALTER TABLE pmieducar.dispensa_disciplina ALTER COLUMN cod_dispensa SET DEFAULT nextval('pmieducar.dispensa_disciplina_cod_dispensa_seq');"); + $this->execute("SELECT SETVAL('pmieducar.dispensa_disciplina_cod_dispensa_seq', (SELECT COALESCE(MAX(cod_dispensa) + 1, 1) FROM pmieducar.dispensa_disciplina));"); + } + + public function down() + { + $this->execute("ALTER TABLE pmieducar.dispensa_disciplina ALTER COLUMN cod_dispensa SET DEFAULT NULL;"); + $this->execute("DROP SEQUENCE pmieducar.dispensa_disciplina_cod_dispensa_seq;"); + } +} \ No newline at end of file diff --git a/ieducar/misc/database/migrations/20180905184020_adiciona_coluna_camiseta_infantil.php b/ieducar/misc/database/migrations/20180905184020_adiciona_coluna_camiseta_infantil.php new file mode 100644 index 0000000000..e9a9af63d1 --- /dev/null +++ b/ieducar/misc/database/migrations/20180905184020_adiciona_coluna_camiseta_infantil.php @@ -0,0 +1,26 @@ +execute( + ' + ALTER TABLE pmieducar.distribuicao_uniforme ADD camiseta_infantil_qtd int2 NULL; + ALTER TABLE pmieducar.distribuicao_uniforme ADD camiseta_infantil_tm varchar(20) NULL; + ' + ); + } + + public function down() + { + $this->execute( + ' + ALTER TABLE pmieducar.distribuicao_uniforme DROP COLUMN camiseta_infantil_qtd; + ALTER TABLE pmieducar.distribuicao_uniforme DROP COLUMN camiseta_infantil_tm; + ' + ); + } +} diff --git a/ieducar/misc/database/migrations/20180910201540_altera_trigger_auditoria_falta_geral.php b/ieducar/misc/database/migrations/20180910201540_altera_trigger_auditoria_falta_geral.php new file mode 100644 index 0000000000..cd26382bd0 --- /dev/null +++ b/ieducar/misc/database/migrations/20180910201540_altera_trigger_auditoria_falta_geral.php @@ -0,0 +1,33 @@ +execute($sql); + + } +} diff --git a/ieducar/misc/database/migrations/20180928193631_adiciona_coluna_para_exibir_professores_alocados.php b/ieducar/misc/database/migrations/20180928193631_adiciona_coluna_para_exibir_professores_alocados.php new file mode 100644 index 0000000000..fa723175b0 --- /dev/null +++ b/ieducar/misc/database/migrations/20180928193631_adiciona_coluna_para_exibir_professores_alocados.php @@ -0,0 +1,17 @@ +execute("ALTER TABLE pmieducar.instituicao ADD COLUMN exibir_apenas_professores_alocados BOOLEAN DEFAULT false;"); + $this->execute("COMMENT ON COLUMN pmieducar.instituicao.exibir_apenas_professores_alocados IS 'Para filtros de emissão de relatórios'"); + } + + public function down() + { + $this->execute("ALTER TABLE pmieducar.instituicao DROP COLUMN exibir_apenas_professores_alocados;"); + } +} diff --git a/ieducar/module/index.php b/ieducar/module/index.php index 84d6e5a4e4..b9eba315b9 100644 --- a/ieducar/module/index.php +++ b/ieducar/module/index.php @@ -43,8 +43,6 @@ require_once 'CoreExt/Controller/Front.php'; require_once 'CoreExt/DataMapper.php'; -require_once 'modules/Error/Mailers/NotificationMailer.php'; - try { // Objeto de requisição @@ -96,7 +94,6 @@ } error_log("Erro inesperado (pego em /module/index.php): " . $e->getMessage()); - (new NotificationMailer)->unexpectedError($e->getMessage()); die(""); } diff --git a/ieducar/modules/Api/Views/AlunoController.php b/ieducar/modules/Api/Views/AlunoController.php index 68c72e2c48..88b3e3d973 100644 --- a/ieducar/modules/Api/Views/AlunoController.php +++ b/ieducar/modules/Api/Views/AlunoController.php @@ -1034,6 +1034,13 @@ protected function get() $aluno['projetos'] = $this->loadProjetos($id); $aluno['historico_altura_peso'] = $this->loadHistoricoAlturaPeso($id); + $objFoto = new clsCadastroFisicaFoto($aluno['pessoa_id']); + $detalheFoto = $objFoto->detalhe(); + + if ($detalheFoto) { + $aluno['url_foto_aluno'] = $detalheFoto['caminho']; + } + return $aluno; } } @@ -1046,12 +1053,13 @@ protected function getTodosAlunos() p.nome as nome_aluno, f.data_nasc as data_nascimento, ff.caminho as foto_aluno, - EXISTS(SELECT 1 - FROM cadastro.fisica_deficiencia fd - JOIN cadastro.deficiencia d - ON d.cod_deficiencia = fd.ref_cod_deficiencia - WHERE fd.ref_idpes = p.idpes - AND d.nm_deficiencia NOT ILIKE \'nenhuma\') as utiliza_regra_diferenciada + COALESCE((SELECT NOT d.desconsidera_regra_diferenciada + FROM cadastro.fisica_deficiencia fd + JOIN cadastro.deficiencia d ON (d.cod_deficiencia = fd.ref_cod_deficiencia) + WHERE fd.ref_idpes = p.idpes AND + d.nm_deficiencia NOT ILIKE \'nenhuma\' + ORDER BY d.desconsidera_regra_diferenciada + LIMIT 1), false) as utiliza_regra_diferenciada FROM pmieducar.aluno a INNER JOIN cadastro.pessoa p ON p.idpes = a.ref_idpes INNER JOIN cadastro.fisica f ON f.idpes = p.idpes diff --git a/ieducar/modules/Api/Views/ConsultaBaseController.php b/ieducar/modules/Api/Views/ConsultaBaseController.php new file mode 100644 index 0000000000..d436ac225b --- /dev/null +++ b/ieducar/modules/Api/Views/ConsultaBaseController.php @@ -0,0 +1,58 @@ +pdo)) { + $base = new clsBanco(); + $base->FraseConexao(); + $connectionString = 'pgsql:' . $base->getFraseConexao(); + + $this->pdo = new \PDO($connectionString); + } + + return $this->pdo; + } + + protected function getAlunos() { + if (!$this->canGetAlunos()) { + return null; + } + + return $this->getData(); + } + + protected function getData() { + return []; + } + + protected function getMethodName($type) + { + $name = 'getData'; + $type = str_replace('_', ' ', $type); + $type = ucwords($type); + $type = str_replace(' ', '', $type); + + return $name . $type; + } + + public function Gerar() + { + if ($this->isRequestFor('get', 'alunos')) { + $this->appendResponse($this->getAlunos()); + } else { + $this->notImplementedOperationError(); + } + } +} diff --git a/ieducar/modules/Api/Views/ConsultaMovimentoGeralController.php b/ieducar/modules/Api/Views/ConsultaMovimentoGeralController.php new file mode 100644 index 0000000000..009a740a42 --- /dev/null +++ b/ieducar/modules/Api/Views/ConsultaMovimentoGeralController.php @@ -0,0 +1,176 @@ +validatesPresenceOf('escola') && + $this->validatesPresenceOf('tipo') && + $this->validatesPresenceOf('data_inicial') && + $this->validatesPresenceOf('data_final') && + $this->validatesPresenceOf('ano') + ); + } + + protected function getData() + { + $type = $this->getRequest()->tipo; + $params = []; + + $params['escola'] = $this->getRequest()->escola; + $params['data_inicial'] = $this->getRequest()->data_inicial; + $params['data_final'] = $this->getRequest()->data_final; + $params['ano'] = $this->getRequest()->ano; + $params['curso'] = !empty($this->getRequest()->curso) ? $this->getRequest()->curso : 0; + + if ($params['curso'] !== 0) { + $params['curso'] = explode(',', $params['curso']); + $params['seleciona_curso'] = 1; + } else { + unset($params['curso']); + } + + $method = $this->getMethodName($type); + + return $this->{$method}($params); + } + + protected function getDataObito($params) + { + $queryFactory = new MovimentoGeralAlunosObitoQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataRecla($params) + { + $queryFactory = new MovimentoGeralAlunosReclaQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataRem($params) + { + $queryFactory = new MovimentoGeralAlunosRemQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataTransf($params) + { + $queryFactory = new MovimentoGeralAlunosTransferidosQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataAband($params) + { + $queryFactory = new MovimentoGeralAlunosAbandonosQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataAdmitidos($params) + { + $queryFactory = new MovimentoGeralAlunosAdmitidosQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataEdInfInt($params) + { + $queryFactory = new MovimentoGeralAlunosEdInfIntQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataEdInfParc($params) + { + $queryFactory = new MovimentoGeralAlunosEdInfParcQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataAnos($params) + { + $queryFactory = new MovimentoGeralAlunosAnosQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataAno1($params) + { + $params['ano_coluna'] = 1; + + return $this->getDataAnos($params); + } + + protected function getDataAno2($params) + { + $params['ano_coluna'] = 2; + + return $this->getDataAnos($params); + } + + protected function getDataAno3($params) + { + $params['ano_coluna'] = 3; + + return $this->getDataAnos($params); + } + + protected function getDataAno4($params) + { + $params['ano_coluna'] = 4; + + return $this->getDataAnos($params); + } + + protected function getDataAno5($params) + { + $params['ano_coluna'] = 5; + + return $this->getDataAnos($params); + } + + protected function getDataAno6($params) + { + $params['ano_coluna'] = 6; + + return $this->getDataAnos($params); + } + + protected function getDataAno7($params) + { + $params['ano_coluna'] = 7; + + return $this->getDataAnos($params); + } + + protected function getDataAno8($params) + { + $params['ano_coluna'] = 8; + + return $this->getDataAnos($params); + } + + protected function getDataAno9($params) + { + $params['ano_coluna'] = 9; + + return $this->getDataAnos($params); + } +} diff --git a/ieducar/modules/Api/Views/ConsultaMovimentoMensalController.php b/ieducar/modules/Api/Views/ConsultaMovimentoMensalController.php new file mode 100644 index 0000000000..173c84b8d6 --- /dev/null +++ b/ieducar/modules/Api/Views/ConsultaMovimentoMensalController.php @@ -0,0 +1,173 @@ +validatesPresenceOf('ano') && + $this->validatesPresenceOf('instituicao') && + $this->validatesPresenceOf('escola') && + $this->validatesPresenceOf('data_inicial') && + $this->validatesPresenceOf('data_final') + ); + } + + protected function getData() + { + $type = $this->getRequest()->tipo; + $params = []; + + $params['ano'] = $this->getRequest()->ano; + $params['instituicao'] = $this->getRequest()->instituicao; + $params['escola'] = $this->getRequest()->escola; + $params['data_inicial'] = $this->getRequest()->data_inicial; + $params['data_final'] = $this->getRequest()->data_final; + $params['curso'] = !empty($this->getRequest()->curso) ? $this->getRequest()->curso : 0; + $params['serie'] = !empty($this->getRequest()->serie) ? $this->getRequest()->serie : 0; + $params['turma'] = !empty($this->getRequest()->turma) ? $this->getRequest()->turma : 0; + + $method = $this->getMethodName($type); + + return $this->{$method}($params); + } + + protected function getDataMatIniM($params) + { + $params['sexo'] = 'M'; + $queryFactory = new MovimentoMensalMatIniQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatIniF($params) + { + $params['sexo'] = 'F'; + $queryFactory = new MovimentoMensalMatIniQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatTransfM($params) + { + $params['sexo'] = 'M'; + $queryFactory = new MovimentoMensalMatTransfQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatTransfF($params) + { + $params['sexo'] = 'F'; + $queryFactory = new MovimentoMensalMatTransfQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatAbandM($params) + { + $params['sexo'] = 'M'; + $queryFactory = new MovimentoMensalMatAbandQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatAbandF($params) + { + $params['sexo'] = 'F'; + $queryFactory = new MovimentoMensalMatAbandQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatAdmitM($params) + { + $params['sexo'] = 'M'; + $queryFactory = new MovimentoMensalMatAdmitQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatAdmitF($params) + { + $params['sexo'] = 'F'; + $queryFactory = new MovimentoMensalMatAdmitQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatFalecidoM($params) + { + $params['sexo'] = 'M'; + $queryFactory = new MovimentoMensalMatFalecidoQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatFalecidoF($params) + { + $params['sexo'] = 'F'; + $queryFactory = new MovimentoMensalMatFalecidoQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatReclassificadosM($params) + { + $params['sexo'] = 'M'; + $queryFactory = new MovimentoMensalMatReclassificadosQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatReclassificadosF($params) + { + $params['sexo'] = 'F'; + $queryFactory = new MovimentoMensalMatReclassificadosQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatTrocaeM($params) + { + $params['sexo'] = 'M'; + $queryFactory = new MovimentoMensalMatTrocaeQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatTrocaeF($params) + { + $params['sexo'] = 'F'; + $queryFactory = new MovimentoMensalMatTrocaeQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatTrocasM($params) + { + $params['sexo'] = 'M'; + $queryFactory = new MovimentoMensalMatTrocasQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } + + protected function getDataMatTrocasF($params) + { + $params['sexo'] = 'F'; + $queryFactory = new MovimentoMensalMatTrocasQueryFactory($this->getPDO(), $params); + + return ['alunos' => $queryFactory->getData()]; + } +} diff --git a/ieducar/modules/Api/Views/DeficienciaController.php b/ieducar/modules/Api/Views/DeficienciaController.php index 058608403b..ca68151459 100644 --- a/ieducar/modules/Api/Views/DeficienciaController.php +++ b/ieducar/modules/Api/Views/DeficienciaController.php @@ -20,8 +20,9 @@ protected function formatResourceValue($resource) protected function getDeficiencias() { - $sql = ' SELECT cod_deficiencia, nm_deficiencia - FROM cadastro.deficiencia '; + $sql = " SELECT cod_deficiencia, nm_deficiencia + FROM cadastro.deficiencia + WHERE desconsidera_regra_diferenciada = 'FALSE'"; $deficiencias = $this->fetchPreparedQuery($sql); diff --git a/ieducar/modules/Api/Views/MatriculaController.php b/ieducar/modules/Api/Views/MatriculaController.php index cdfcb8fc44..73c5ccabec 100644 --- a/ieducar/modules/Api/Views/MatriculaController.php +++ b/ieducar/modules/Api/Views/MatriculaController.php @@ -7,6 +7,10 @@ require_once 'intranet/include/clsBanco.inc.php'; require_once 'include/pmieducar/geral.inc.php'; require_once 'Portabilis/Date/Utils.php'; +require_once 'modules/Avaliacao/Model/NotaAlunoDataMapper.php'; +require_once 'modules/Avaliacao/Model/NotaComponenteMediaDataMapper.php'; +require_once 'modules/Avaliacao/Views/PromocaoApiController.php'; +require_once 'lib/CoreExt/Controller/Request.php'; class MatriculaController extends ApiCoreController { @@ -262,22 +266,31 @@ protected function getMovimentacaoEnturmacao() WHEN matricula.aprovado = 3 AND matricula_turma.remanejado = TRUE THEN TRUE ELSE FALSE - END) AS apresentar_fora_da_data + END) AS apresentar_fora_da_data, + (CASE + WHEN instituicao.data_base_remanejamento IS NULL THEN COALESCE(matricula_turma.remanejado, FALSE) = FALSE + ELSE TRUE + END) AS mostrar_enturmacao FROM matricula INNER JOIN pmieducar.escola ON (escola.cod_escola = matricula.ref_ref_cod_escola) INNER JOIN pmieducar.instituicao ON (instituicao.cod_instituicao = escola.ref_cod_instituicao) LEFT JOIN matricula_turma ON matricula_turma.ref_cod_matricula = matricula.cod_matricula - WHERE cod_matricula = $1 - AND CASE - WHEN instituicao.data_base_remanejamento IS NULL THEN COALESCE(matricula_turma.remanejado, false) = false - ELSE true - END'; + WHERE cod_matricula = $1'; $params = [$matriculas[$key]['matricula_id']]; $enturmacoes = $this->fetchPreparedQuery($sql, $params, false); if (is_array($enturmacoes) && count($enturmacoes) > 0) { - $attrs = ['turma_id', 'sequencial', 'sequencial_fechamento', 'data_entrada', 'data_saida', 'data_atualizacao', 'apresentar_fora_da_data']; + $attrs = [ + 'turma_id', + 'sequencial', + 'sequencial_fechamento', + 'data_entrada', + 'data_saida', + 'data_atualizacao', + 'apresentar_fora_da_data', + 'mostrar_enturmacao' + ]; $enturmacoes = Portabilis_Array_Utils::filterSet($enturmacoes, $attrs); $matriculas[$key]['enturmacoes'] = $enturmacoes; } @@ -345,6 +358,20 @@ protected function deleteAbandono() $params = [$sequencial, $matriculaId]; $this->fetchPreparedQuery($sql, $params); + $instituicaoId = (new clsBanco)->unicoCampo("select cod_instituicao from pmieducar.instituicao where ativo = 1 order by cod_instituicao asc limit 1;"); + + $fakeRequest = new CoreExt_Controller_Request(['data' => [ + 'oper' => 'post', + 'resource' => 'promocao', + 'instituicao_id' => $instituicaoId, + 'matricula_id' => $matriculaId + ]]); + + $promocaoApi = new PromocaoApiController(); + + $promocaoApi->setRequest($fakeRequest); + $promocaoApi->Gerar(); + $this->messenger->append('Abandono desfeito.', 'success'); } } @@ -496,6 +523,12 @@ protected function postSituacao() } } } + + $notaAlunoId = (new Avaliacao_Model_NotaAlunoDataMapper()) + ->findAll(['id'], ['matricula_id' => $matricula->cod_matricula])[0]->get('id'); + + (new Avaliacao_Model_NotaComponenteMediaDataMapper()) + ->updateSituation($notaAlunoId, $situacaoNova); } elseif ($situacaoNova == App_Model_MatriculaSituacao::APROVADO || $situacaoNova == App_Model_MatriculaSituacao::EM_ANDAMENTO || $situacaoNova == App_Model_MatriculaSituacao::REPROVADO) { if ($enturmacoes) { $params = [$matriculaId]; diff --git a/ieducar/modules/Api/Views/RegraController.php b/ieducar/modules/Api/Views/RegraController.php index 14f0933108..be5c280b66 100644 --- a/ieducar/modules/Api/Views/RegraController.php +++ b/ieducar/modules/Api/Views/RegraController.php @@ -162,7 +162,7 @@ protected function getRegras() $__regras[$regra['id']]['media_recuperacao_paralela'] = $regra['media_recuperacao_paralela']; $__regras[$regra['id']]['nota_maxima_geral'] = $regra['nota_maxima_geral']; $__regras[$regra['id']]['nota_maxima_exame'] = $regra['nota_maxima_exame']; - $__regras[$regra['id']]['turmas'] || $__regras[$regra['id']]['turmas'] = []; + $__regras[$regra['id']]['turmas'] = []; if ($regra['turma_id']) { $__regras[$regra['id']]['turmas'][] = [ diff --git a/ieducar/modules/Avaliacao/Model/NotaAlunoDataMapper.php b/ieducar/modules/Avaliacao/Model/NotaAlunoDataMapper.php index ef3a33278d..1758e43c72 100644 --- a/ieducar/modules/Avaliacao/Model/NotaAlunoDataMapper.php +++ b/ieducar/modules/Avaliacao/Model/NotaAlunoDataMapper.php @@ -3,25 +3,14 @@ require_once 'CoreExt/DataMapper.php'; require_once 'Avaliacao/Model/NotaAluno.php'; -/** - * Avaliacao_Model_NotaAluno class. - * - * @author Eriksen Costa Paixão - * @category i-Educar - * @license @@license@@ - * @package Avaliacao - * @subpackage Modules - * @since Classe disponível desde a versão 1.1.0 - * @version @@package_version@@ - */ class Avaliacao_Model_NotaAlunoDataMapper extends CoreExt_DataMapper { protected $_entityClass = 'Avaliacao_Model_NotaAluno'; - protected $_tableName = 'nota_aluno'; + protected $_tableName = 'nota_aluno'; protected $_tableSchema = 'modules'; - protected $_attributeMap = array( - 'id' => 'id', + protected $_attributeMap = [ + 'id' => 'id', 'matricula' => 'matricula_id' - ); + ]; } diff --git a/ieducar/modules/Avaliacao/Model/NotaComponenteMediaDataMapper.php b/ieducar/modules/Avaliacao/Model/NotaComponenteMediaDataMapper.php index b7a9cb5ba3..72acb7e416 100644 --- a/ieducar/modules/Avaliacao/Model/NotaComponenteMediaDataMapper.php +++ b/ieducar/modules/Avaliacao/Model/NotaComponenteMediaDataMapper.php @@ -3,31 +3,36 @@ require_once 'CoreExt/DataMapper.php'; require_once 'Avaliacao/Model/NotaComponenteMedia.php'; -/** - * Avaliacao_Model_NotaComponenteMediaDataMapper class. - * - * @author Eriksen Costa Paixão - * @category i-Educar - * @license @@license@@ - * @package Avaliacao - * @subpackage Modules - * @since Classe disponível desde a versão 1.1.0 - * @version @@package_version@@ - */ class Avaliacao_Model_NotaComponenteMediaDataMapper extends CoreExt_DataMapper { - protected $_entityClass = 'Avaliacao_Model_NotaComponenteMedia'; - protected $_tableName = 'nota_componente_curricular_media'; - protected $_tableSchema = 'modules'; - - protected $_attributeMap = array( - 'notaAluno' => 'nota_aluno_id', - 'componenteCurricular' => 'componente_curricular_id', - 'mediaArredondada' => 'media_arredondada' - ); - - protected $_primaryKey = array( - 'notaAluno' => 'nota_aluno_id', - 'componenteCurricular' => 'componente_curricular_id' - ); + protected $_entityClass = 'Avaliacao_Model_NotaComponenteMedia'; + protected $_tableName = 'nota_componente_curricular_media'; + protected $_tableSchema = 'modules'; + + protected $_attributeMap = [ + 'notaAluno' => 'nota_aluno_id', + 'componenteCurricular' => 'componente_curricular_id', + 'mediaArredondada' => 'media_arredondada' + ]; + + protected $_primaryKey = [ + 'notaAluno' => 'nota_aluno_id', + 'componenteCurricular' => 'componente_curricular_id' + ]; + + public function updateSituation($notaAlunoId, $situacao) + { + $entities = $this->findAll([], ['nota_aluno_id' => $notaAlunoId]); + + if (empty($entities)) { + return true; + } + + foreach ($entities as $entity) { + $entity->situacao = $situacao; + $this->save($entity); + } + + return true; + } } diff --git a/ieducar/modules/Avaliacao/Service/Boletim.php b/ieducar/modules/Avaliacao/Service/Boletim.php index d702fe8b2e..806618f2ce 100644 --- a/ieducar/modules/Avaliacao/Service/Boletim.php +++ b/ieducar/modules/Avaliacao/Service/Boletim.php @@ -3132,7 +3132,7 @@ protected function _updateNotaComponenteMedia() $this->_loadNotas(FALSE); $regra = $this->getRegra(); - if(is_null($etapa)) {$etapa = 1;} + $etapa = 1; if($regra->get('notaGeralPorEtapa') == "1"){ $notasGerais = array('Se' => 0, 'Et' => $this->getOption('etapas')); @@ -3199,12 +3199,17 @@ protected function _updateNotaComponenteMedia() } $verificaDispensa = App_Model_IedFinder::validaDispensaPorMatricula($matriculaId, $serieId, $escolaId, $id); + $consideraEtapas = []; + + for ($i = 1; $i <= $qtdeEtapas; $i++) { + $consideraEtapas['C' . $i] = in_array($i, $verificaDispensa) ? 0 : 1; + } if ($verificaDispensa) { $qtdeEtapas = $qtdeEtapas - count($verificaDispensa); } - $notas = array('Se' => 0, 'Et' => $qtdeEtapas); + $notas = array_merge(['Se' => 0, 'Et' => $qtdeEtapas], $consideraEtapas); // Cria o array formatado para o cálculo da fórmula da média foreach ($etapasNotas as $etapa => $nota) { diff --git a/ieducar/modules/Cadastro/Assets/Javascripts/DocumentacaoPadrao.js b/ieducar/modules/Cadastro/Assets/Javascripts/DocumentacaoPadrao.js new file mode 100644 index 0000000000..56a52df552 --- /dev/null +++ b/ieducar/modules/Cadastro/Assets/Javascripts/DocumentacaoPadrao.js @@ -0,0 +1,156 @@ +var $arrayDocumento = []; + +function inserirDocumento(url) { + var searchPath = '../module/Api/InstituicaoDocumentacao?oper=get&resource=insertDocuments'; + var ref_cod_escola; + if($j('#ref_cod_escola').val() == ''){ + var ref_cod_escola = 'null'; + }else{ + var ref_cod_escola = $j('#ref_cod_escola').val(); + } + var params = {instituicao_id : $j('#cod_instituicao').val(), titulo_documento : $j('#titulo_documento').val(), url_documento : url, ref_usuario_cad : $j('#pessoa_logada').val(), ref_cod_escola : ref_cod_escola} + console.log(params); + + $j.get(searchPath, params, function(idDocumento){ + addDocumento(idDocumento.id, $j('#titulo_documento').val(), url, "inline"); + $j('#titulo_documento').val(''); + }); +} + +function getDocumento() { +var searchPath = '../module/Api/InstituicaoDocumentacao?oper=get&resource=getDocuments'; + var params = {instituicao_id : $j('#cod_instituicao').val()} + var id = ''; + var titulo = ''; + var url = ''; + + $j.get(searchPath, params, function(data){ + + var documentos = data.documentos; + var escola = $j('#ref_cod_escola').val(); + console.log(escola); + + for (var i = documentos.length - 1; i >= 0; i--) { + if (escola == documentos[i].ref_cod_escola || escola == '') { + addDocumento(documentos[i].id, documentos[i].titulo_documento, documentos[i].url_documento, "inline"); + }else{ + addDocumento(documentos[i].id, documentos[i].titulo_documento, documentos[i].url_documento, "none"); + } + } + }); +} + +function excluirDocumento(event){ + var searchPath = '../module/Api/InstituicaoDocumentacao?oper=get&resource=deleteDocuments'; + var params = {id : event.data['id']} + if(confirm("Deseja realmente excluir este documento?")){ + $j.get(searchPath, params, function(deleteID){ + $j('#'+event.data['id']).hide(); + }); + } +} + +getDocumento(); + +function addDocumento(id, titulo, url, display){ + console.log(display); + $arrayDocumento[$arrayDocumento.length] = $j('
').attr('id', id).append($j('
').html(stringUtils.toUtf8(titulo + ':')) + .css({ "text-align" : "right", "float" : "left"})) + .append($j('').append($j('').html(stringUtils.toUtf8('Excluir')) + .addClass('decorated') + .attr('id','link_excluir_documento_'+id) + .css({ "cursor": "pointer", "color" : "#B22222", "display" : display}) + .css('margin-left','10px') + .click({id: id}, excluirDocumento))) + .append($j('').append($j('').html(stringUtils.toUtf8('Visualizar')) + .addClass('decorated') + .attr('id','link_visualizar_documento_'+id) + .attr('target','_blank') + .attr('href',url) + .css({ "cursor": "pointer", "color" : "#556B2F"}) + .css('margin-left','10px'))) + .insertAfter($j('#aviso_formato')); + +} + +var $loadingDocumento = $j('').attr('src', 'imagens/indicator.gif') + .css('margin-top', '3px') + .hide() + .insertAfter($j('#aviso_formato')); + +// when page is ready + +(function($) { + $(document).ready(function() { + + $('#btn_enviar').hide(); + + var titulo = $j('#titulo_documento').val(); + $j('#documento').on('change', prepareUploadDocumento); + + function prepareUploadDocumento(event) + { + $j('#documento').removeClass('error'); + uploadFilesDocumento(event.target.files); + } + + + function uploadFilesDocumento(files) + { + if ($j('#titulo_documento').val() !== '' ){ + if (files && files.length>0){ + $j('#documento').attr('disabled', 'disabled'); + $j('#btn_enviar').attr('disabled', 'disabled').val('Aguarde...'); + $loadingDocumento.show(); + messageUtils.notice('Carregando documento...'); + + var data = new FormData(); + $j.each(files, function(key, value) + { + data.append(key, value); + }); + + $j.ajax({ + url: '/intranet/upload_just_pdf.php?files', + type: 'POST', + data: data, + cache: false, + dataType: 'json', + processData: false, + contentType: false, + success: function(dataResponse) + { + if (dataResponse.error){ + $j('#documento').val("").addClass('error'); + messageUtils.error(dataResponse.error); + }else{ + messageUtils.success('Documento carregado com sucesso'); + $j('#documento').addClass('success'); + inserirDocumento(dataResponse.file_url); + } + + }, + error: function() + { + $j('#documento').val("").addClass('error'); + messageUtils.error('Não foi possível enviar o arquivo'); + }, + complete: function() + { + $j('#documento').removeAttr('disabled'); + $loadingDocumento.hide(); + $j('#btn_enviar').removeAttr('disabled').val('Gravar'); + } + }); + } + }else{ + alert('Favor, inserir um t\u00edtulo para este documento.'); + $j('#documento').val('').clone(true); + } + } + + + }); // ready + + //gambiarra sinistra que funciona +})(jQuery); \ No newline at end of file diff --git a/ieducar/modules/Cadastro/Assets/Javascripts/Instituicao.js b/ieducar/modules/Cadastro/Assets/Javascripts/Instituicao.js index 56a52df552..6311baa645 100644 --- a/ieducar/modules/Cadastro/Assets/Javascripts/Instituicao.js +++ b/ieducar/modules/Cadastro/Assets/Javascripts/Instituicao.js @@ -1,156 +1,108 @@ -var $arrayDocumento = []; - -function inserirDocumento(url) { - var searchPath = '../module/Api/InstituicaoDocumentacao?oper=get&resource=insertDocuments'; - var ref_cod_escola; - if($j('#ref_cod_escola').val() == ''){ - var ref_cod_escola = 'null'; - }else{ - var ref_cod_escola = $j('#ref_cod_escola').val(); +// Abas +$j('td .formdktd').append(` +
+
    +
  • +
    + Dados gerais +
    +
  • +
  • +
    + Parâmetros +
    +
  • +
+
`); +$j('td .formdktd b').remove(); +$j('.tablecadastro td .formdktd div').remove(); +$j('#tab1').addClass('instituicaoTab-active').removeClass('instituicaoTab'); + +// Atribui um id a linha, para identificar até onde/a partir de onde esconder os campos +$j('#orgao_regional').closest('tr').attr('id','tr_orgao_regional'); + +// Adiciona um ID à linha que termina o formulário para parar de esconder os campos +$j('.tableDetalheLinhaSeparador').closest('tr').attr('id','stop'); + +// Pega o número dessa linha +linha_inicial_tipo = $j('#tr_orgao_regional').index(); + +// hide nos campos das outras abas (deixando só os campos da primeira aba) +$j('.tablecadastro >tbody > tr').each(function(index, row) { + if (index>=linha_inicial_tipo){ + if (row.id!='stop') + row.hide(); + else{ + return false; + } } - var params = {instituicao_id : $j('#cod_instituicao').val(), titulo_documento : $j('#titulo_documento').val(), url_documento : url, ref_usuario_cad : $j('#pessoa_logada').val(), ref_cod_escola : ref_cod_escola} - console.log(params); - - $j.get(searchPath, params, function(idDocumento){ - addDocumento(idDocumento.id, $j('#titulo_documento').val(), url, "inline"); - $j('#titulo_documento').val(''); +}); + +// Aba dados gerais +$j('#tab1').click( +function(){ + $j('.instituicaoTab-active').toggleClass('instituicaoTab-active instituicaoTab'); + $j('#tab1').toggleClass('instituicaoTab instituicaoTab-active') + $j('.tablecadastro >tbody > tr').each(function(index, row) { + if (index>=linha_inicial_tipo){ + if (row.id!='stop') + row.hide(); + else + return false; + }else{ + row.show(); + } }); } +); + +// Aba parametros +$j('#tab2').click( +function(){ + $j('.instituicaoTab-active').toggleClass('instituicaoTab-active instituicaoTab'); + $j('#tab2').toggleClass('instituicaoTab instituicaoTab-active') + $j('.tablecadastro >tbody > tr').each(function(index, row) { + if (row.id!='stop'){ + if (index>=linha_inicial_tipo){ + if ((index - linha_inicial_tipo) % 2 == 0){ + $j('#'+row.id).find('td').removeClass('formlttd'); + $j('#'+row.id).find('td').addClass('formmdtd'); + }else{ + $j('#'+row.id).find('td').removeClass('formmdtd'); + $j('#'+row.id).find('td').addClass('formlttd'); -function getDocumento() { -var searchPath = '../module/Api/InstituicaoDocumentacao?oper=get&resource=getDocuments'; - var params = {instituicao_id : $j('#cod_instituicao').val()} - var id = ''; - var titulo = ''; - var url = ''; - - $j.get(searchPath, params, function(data){ - - var documentos = data.documentos; - var escola = $j('#ref_cod_escola').val(); - console.log(escola); + } - for (var i = documentos.length - 1; i >= 0; i--) { - if (escola == documentos[i].ref_cod_escola || escola == '') { - addDocumento(documentos[i].id, documentos[i].titulo_documento, documentos[i].url_documento, "inline"); - }else{ - addDocumento(documentos[i].id, documentos[i].titulo_documento, documentos[i].url_documento, "none"); + row.show(); + }else if (index>0){ + row.hide(); } - } + }else + return false; }); -} + $j('#controlar_espaco_utilizacao_aluno').click(onControlarEspacoUtilizadoClick); -function excluirDocumento(event){ - var searchPath = '../module/Api/InstituicaoDocumentacao?oper=get&resource=deleteDocuments'; - var params = {id : event.data['id']} - if(confirm("Deseja realmente excluir este documento?")){ - $j.get(searchPath, params, function(deleteID){ - $j('#'+event.data['id']).hide(); - }); + if (!$j('#controlar_espaco_utilizacao_aluno').prop('checked')) { + $j('#percentagem_maxima_ocupacao_salas').closest('tr').hide(); + $j('#quantidade_alunos_metro_quadrado').closest('tr').hide(); } -} - -getDocumento(); - -function addDocumento(id, titulo, url, display){ - console.log(display); - $arrayDocumento[$arrayDocumento.length] = $j('
').attr('id', id).append($j('
').html(stringUtils.toUtf8(titulo + ':')) - .css({ "text-align" : "right", "float" : "left"})) - .append($j('').append($j('').html(stringUtils.toUtf8('Excluir')) - .addClass('decorated') - .attr('id','link_excluir_documento_'+id) - .css({ "cursor": "pointer", "color" : "#B22222", "display" : display}) - .css('margin-left','10px') - .click({id: id}, excluirDocumento))) - .append($j('').append($j('').html(stringUtils.toUtf8('Visualizar')) - .addClass('decorated') - .attr('id','link_visualizar_documento_'+id) - .attr('target','_blank') - .attr('href',url) - .css({ "cursor": "pointer", "color" : "#556B2F"}) - .css('margin-left','10px'))) - .insertAfter($j('#aviso_formato')); - -} - -var $loadingDocumento = $j('').attr('src', 'imagens/indicator.gif') - .css('margin-top', '3px') - .hide() - .insertAfter($j('#aviso_formato')); - -// when page is ready - -(function($) { - $(document).ready(function() { +}); - $('#btn_enviar').hide(); - - var titulo = $j('#titulo_documento').val(); - $j('#documento').on('change', prepareUploadDocumento); - - function prepareUploadDocumento(event) - { - $j('#documento').removeClass('error'); - uploadFilesDocumento(event.target.files); - } - - - function uploadFilesDocumento(files) - { - if ($j('#titulo_documento').val() !== '' ){ - if (files && files.length>0){ - $j('#documento').attr('disabled', 'disabled'); - $j('#btn_enviar').attr('disabled', 'disabled').val('Aguarde...'); - $loadingDocumento.show(); - messageUtils.notice('Carregando documento...'); - - var data = new FormData(); - $j.each(files, function(key, value) - { - data.append(key, value); - }); - - $j.ajax({ - url: '/intranet/upload_just_pdf.php?files', - type: 'POST', - data: data, - cache: false, - dataType: 'json', - processData: false, - contentType: false, - success: function(dataResponse) - { - if (dataResponse.error){ - $j('#documento').val("").addClass('error'); - messageUtils.error(dataResponse.error); - }else{ - messageUtils.success('Documento carregado com sucesso'); - $j('#documento').addClass('success'); - inserirDocumento(dataResponse.file_url); - } - - }, - error: function() - { - $j('#documento').val("").addClass('error'); - messageUtils.error('Não foi possível enviar o arquivo'); - }, - complete: function() - { - $j('#documento').removeAttr('disabled'); - $loadingDocumento.hide(); - $j('#btn_enviar').removeAttr('disabled').val('Gravar'); - } - }); - } - }else{ - alert('Favor, inserir um t\u00edtulo para este documento.'); - $j('#documento').val('').clone(true); - } - } - - - }); // ready - - //gambiarra sinistra que funciona -})(jQuery); \ No newline at end of file +// fix checkboxs +$j('.tablecadastro >tbody > tr').each(function(index, row) { + if (index>=linha_inicial_tipo){ + $j('#'+row.id).find('input:checked').val('on'); + } +}); + +function onControlarEspacoUtilizadoClick() { + if (!$j('#controlar_espaco_utilizacao_aluno').prop('checked')) { + $j('#percentagem_maxima_ocupacao_salas').val(''); + $j('#quantidade_alunos_metro_quadrado').val(''); + $j('#percentagem_maxima_ocupacao_salas').closest('tr').hide(); + $j('#quantidade_alunos_metro_quadrado').closest('tr').hide(); + } else { + $j('#percentagem_maxima_ocupacao_salas').closest('tr').show(); + $j('#quantidade_alunos_metro_quadrado').closest('tr').show(); + } +} \ No newline at end of file diff --git a/ieducar/modules/Cadastro/Assets/Javascripts/ServidorVinculoTurma.js b/ieducar/modules/Cadastro/Assets/Javascripts/ServidorVinculoTurma.js index 751b283654..209d4c48c6 100644 --- a/ieducar/modules/Cadastro/Assets/Javascripts/ServidorVinculoTurma.js +++ b/ieducar/modules/Cadastro/Assets/Javascripts/ServidorVinculoTurma.js @@ -1,119 +1,7 @@ $j(document).ready(function() { - var $turmaField = getElementFor('turma'); - var $anoField = getElementFor('ano'); - var $instituicaoField = getElementFor('instituicao'); - let obrigarCamposCenso = $j('#obrigar_campos_censo').val() == '1'; - var handleGetComponentesArea = function(response){ - let componentes = Object.keys(response['options']||{}); - $j('#componentecurricular').val(componentes.concat($j('#componentecurricular').val()||[])).trigger('chosen:updated'); - $j("#dialog_area_conhecimento").dialog("close"); - } - - var preenchePorAreaConhecimento = function(){ - let areaConhecimento = $j('#area_conhecimento').val(); - if (!areaConhecimento) { - alert('Área de conhecimento deve ser preenchida'); - return false; - } - urlForGetAreaConhecimento = getResourceUrlBuilder.buildUrl('/module/Api/ComponenteCurricular', 'componentes-curriculares-for-multiple-search', { - turma_id: $turmaField.val(), - ano: $anoField.val(), - instituicao_id: $instituicaoField.val(), - area_conhecimento_id: areaConhecimento - }); - - var options = { - url: urlForGetAreaConhecimento, - dataType: 'json', - success: handleGetComponentesArea - }; - - getResources(options); - } - - $j('body').append(htmlFormModal()); - - $j('#area_conhecimento').chosen({ - width: '231px', - placeholder_text_multiple: "Selecione as opções", - }); - - $j("#dialog_area_conhecimento").dialog({ - autoOpen: false, - height: 'auto', - width: 'auto', - modal: true, - zIndex: 500, - resizable: false, - draggable: false, - title: 'Selecionar por área de conhecimento', - buttons: { - "Preencher": preenchePorAreaConhecimento, - "Cancelar": function(){ - $j(this).dialog("close"); - } - }, - create: function () { - $j(this) - .closest(".ui-dialog") - .find(".ui-button-text:first") - .addClass("btn-green"); - }, - close: function () { - $j('#area_conhecimento').val(""); - } - }); - - - var handleGetAreaConhecimento = function(response) { - $j('#area_conhecimento').html('').val(''); - var selectOptions = response['options']; - for(let key in selectOptions){ - if (selectOptions.hasOwnProperty(key)) { - $j('#area_conhecimento').append($j('').attr('href','#').text('Selecionar por área de conhecimento').on('click', modalOpen); + + if (searchForArea) { + $j('#tr_componentecurricular td:last-child').append($linkModalArea); + } + // bind onchange event $turmaField.change(updateComponenteCurricular); diff --git a/ieducar/modules/Portabilis/Assets/Javascripts/Validator.js b/ieducar/modules/Portabilis/Assets/Javascripts/Validator.js index 008bda51aa..48f336f494 100644 --- a/ieducar/modules/Portabilis/Assets/Javascripts/Validator.js +++ b/ieducar/modules/Portabilis/Assets/Javascripts/Validator.js @@ -6,9 +6,90 @@ var validationUtils = { return /(^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$)/.test(date); }, + validatesLeapYear: function (year) { + return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0); + }, + + validatesDateFieldAlt: function (elm) { + var $elm = $j(elm), + val = $elm.val(), + regex = /[0-3]{1}[0-9]{1}\/[0-1]{1}[0-9]{1}\/[0-9]{4}/, + match = val.match(regex); + + if (match === null) { + messageUtils.error('Adicione uma data no seguinte formato: dd/mm/aaaa.', elm); + return false; + } + + var parts = val.split('/'), + dateParts = { + day: parseInt(parts[0], 10), + month: parseInt(parts[1], 10), + year: parseInt(parts[2], 10) + }, + isLeapYear = this.validatesLeapYear(dateParts.year); + + if (dateParts.month > 12) { + messageUtils.error('O mês "' + dateParts.month + '" informado não é valido.', elm); + + return false; + } + + if (dateParts.day > 31) { + messageUtils.error('O dia "' + dateParts.day + '" não é válido.', elm); + + return false; + } + + if ( + dateParts.month === 2 + && dateParts.day > 29 + && isLeapYear === true + ) { + messageUtils.error('O dia "' + dateParts.day + '" não é válido.', elm); + + return false; + } + + if ( + dateParts.month === 2 + && dateParts.day > 28 + && isLeapYear === false + ) { + messageUtils.error('O dia "' + dateParts.day + '" não é válido em anos não bissextos.', elm); + + return false; + } + + var module = dateParts.month % 2; + + if ( + dateParts.month <= 7 + && dateParts.month !== 2 + && dateParts.day > 30 + && module === 0 + ) { + messageUtils.error('O dia "' + dateParts.day + '" não é válido.', elm); + + return false; + } + + if ( + dateParts.month >= 8 + && dateParts.day > 30 + && module !== 0 + ) { + messageUtils.error('O dia "' + dateParts.day + '" não é válido.', elm); + + return false; + } + + return true; + }, + validatesDateFields : function() { var allValid = true; - var fields = $j("input[id^='data_'][value!=''], input[id^='dt_'][value!='']"); + var fields = $j("input[id^='data_'][value!=''], input[id^='dt_'][value!='']"); $j.each(fields, function(index, field) { if (! validationUtils.validatesDate(field.value)) { diff --git a/ieducar/modules/Portabilis/Assets/Version.php b/ieducar/modules/Portabilis/Assets/Version.php index 95f812315d..91c2a35009 100644 --- a/ieducar/modules/Portabilis/Assets/Version.php +++ b/ieducar/modules/Portabilis/Assets/Version.php @@ -2,7 +2,5 @@ class Portabilis_Assets_Version { - - const VERSION = '20180731-100699'; - + const VERSION = '20181003-112900'; } diff --git a/ieducar/phpunit.xml b/ieducar/phpunit.xml index 0028c49c8e..332ce56433 100644 --- a/ieducar/phpunit.xml +++ b/ieducar/phpunit.xml @@ -6,7 +6,7 @@ convertNoticesToExceptions="false" convertWarningsToExceptions="false" processIsolation="false" - stopOnFailure="false"> + stopOnFailure="true"> diff --git a/ieducar/tests/SuiteTestCase/TestCase.php b/ieducar/tests/SuiteTestCase/TestCase.php index c4c7bc01ce..3d968b4b61 100644 --- a/ieducar/tests/SuiteTestCase/TestCase.php +++ b/ieducar/tests/SuiteTestCase/TestCase.php @@ -79,4 +79,9 @@ public function getHtmlCodeFromFile($fileName) { return file_get_contents(__DIR__ . '/../Unit/assets/' . $fileName); } + + public function getPdoConection() + { + return $this->getConnection()->getConnection(); + } } diff --git a/ieducar/tests/Unit/Api/RegraTest.php b/ieducar/tests/Unit/Api/RegraTest.php index ab7041380d..56477c65ef 100644 --- a/ieducar/tests/Unit/Api/RegraTest.php +++ b/ieducar/tests/Unit/Api/RegraTest.php @@ -5,6 +5,8 @@ use PHPUnit\DbUnit\DataSet\DefaultDataSet; use Tests\SuiteTestCase\ApiTestCase; use Tests\SuiteTestCase\TestCase; +use PHPUnit\Framework\Constraint\JsonMatches; +use PHPUnit\Util\Json; require_once __DIR__ . '/../../../modules/Api/Views/RegraController.php'; @@ -18,8 +20,8 @@ public function getDataSet() public function testRegression() { - $this->markTestSkipped('must be revisited.'); $responseBody = $this->doAuthenticatedRequest('regras', ['instituicao_id' => 1, 'ano' => '2018']); + $this->assertJsonStringEqualsJsonFile($this->getJsonFile('regra_json_valid.json'), $responseBody); } } diff --git a/ieducar/tests/Unit/App/Model/MatriculaTest.php b/ieducar/tests/Unit/App/Model/MatriculaTest.php index a3b5142166..20f15d43ab 100644 --- a/ieducar/tests/Unit/App/Model/MatriculaTest.php +++ b/ieducar/tests/Unit/App/Model/MatriculaTest.php @@ -43,11 +43,10 @@ * @since Classe disponível desde a versão 1.1.0 * @version @@package_version@@ */ -class App_Model_MatriculaTest extends PHPUnit\Framework\TestCase +class App_Model_MatriculaTest extends UnitBaseTest { public function testAtualizaMatricula() { - $this->markTestSkipped('must be revisited.'); $matricula = $this->getCleanMock('clsPmieducarMatricula'); $matricula->expects($this->once()) ->method('edita') diff --git a/ieducar/tests/Unit/CoreExt/Validate/ValidateTest.php b/ieducar/tests/Unit/CoreExt/Validate/ValidateTest.php index e8d3ccb1d0..406bc38fd5 100644 --- a/ieducar/tests/Unit/CoreExt/Validate/ValidateTest.php +++ b/ieducar/tests/Unit/CoreExt/Validate/ValidateTest.php @@ -92,7 +92,6 @@ public function testValorNuloLancaExcecao() */ public function testValorArrayVazioLancaExcecao() { - $this->markTestSkipped('must be revisited.'); $this->assertTrue($this->_validator->isValid(array())); } diff --git a/ieducar/tests/Unit/Modules/FormulaMedia/Model/FormulaTest.php b/ieducar/tests/Unit/Modules/FormulaMedia/Model/FormulaTest.php new file mode 100644 index 0000000000..0aa21ea34a --- /dev/null +++ b/ieducar/tests/Unit/Modules/FormulaMedia/Model/FormulaTest.php @@ -0,0 +1,148 @@ +formula = new FormulaMedia_Model_Formula(); + } + + /** + * @see FormulaMedia_Model_Formula::getTokens() + * + * @return void + */ + public function testGetTokensMethod() + { + $this->assertCount(63, $this->formula->getTokens()); + } + + /** + * @see FormulaMedia_Model_Formula::isNumericToken() + * + * @return void + */ + public function testIsNumericTokenMethod() + { + $this->assertTrue( + $this->formula->isNumericToken('E1') + ); + + $this->assertFalse( + $this->formula->isNumericToken('*') + ); + } + + /** + * @see FormulaMedia_Model_Formula::replaceTokens() + * + * @return void + */ + public function testReplaceTokensMethod() + { + $formula = $this->formula->replaceTokens('Se / Et', [ + 'Et' => 4, + 'Se' => 20, + ]); + + $this->assertEquals('20 / 4', $formula); + } + + /** + * @see FormulaMedia_Model_Formula::replaceAliasTokens() + * + * @return void + */ + public function testReplaceAliasTokensMethod() + { + $formula = '(1x2)'; + $expected = ' ( 1*2 ) '; + $replaced = $this->formula->replaceAliasTokens($formula); + + $this->assertEquals($expected, $replaced); + } + + /** + * @see FormulaMedia_Model_Formula::execFormulaMedia() + * + * @return void + */ + public function testExecFormulaMediaMethod() + { + $this->formula->formulaMedia = '(E1 + E2 + E3 + E4) / Et'; + $average = $this->formula->execFormulaMedia([ + 'E1' => 10, + 'E2' => 8, + 'E3' => 7, + 'E4' => 7, + 'Et' => 4, + ]); + + $this->formula->formulaMedia = '((Se / Et * 0.6) + (Rc * 0.4))'; + $recuperation = $this->formula->execFormulaMedia([ + 'Et' => 4, + 'Se' => 20, + 'Rc' => 7 + ]); + + $this->assertEquals(8, $average); + $this->assertEquals(5.8, $recuperation); + } + + /** + * @see FormulaMedia_Model_Formula::getDefaultValidatorCollection() + * + * @return void + */ + public function testGetDefaultValidatorCollectionMethod() + { + // Este método tem muitas dependências e deverá ser refatorado. + + $this->assertTrue(true); + } + + /** + * Este teste está relacionado à dispensa de etapas dos alunos quando a + * média ponderada é utilizada para o cálculo da nota. Ou seja, cada etapa + * tem um peso diferente. + * + * Como a fórmula de cálculo da média ponderada é fixa, dependendo a etapa + * em que o aluno é dispensado, o cálculo da média fica incorreto, pois o + * aluno não possui nota devido ter a etapa dispensada. + * + * @return void + */ + public function testConsideringDispensedStages() + { + $this->formula->formulaMedia = '((C1*E1*1) + (C2*E2*2) + (C3*E3*3) + (C4*E4*4)) / ((C1*1) + (C2*2) + (C3*3) + (C4*4))'; + $average = $this->formula->execFormulaMedia([ + 'E1' => 9, + 'E2' => 0, + 'E3' => 9, + 'E4' => 7, + 'C1' => 1, + 'C2' => 0, + 'C3' => 1, + 'C4' => 1, + ]); + + $this->assertEquals(8, $average); + } +} diff --git a/ieducar/tests/Unit/Modules/Service/FaltaAlunoTest.php b/ieducar/tests/Unit/Modules/Service/FaltaAlunoTest.php index fbc4b2aa94..7a5a9288db 100644 --- a/ieducar/tests/Unit/Modules/Service/FaltaAlunoTest.php +++ b/ieducar/tests/Unit/Modules/Service/FaltaAlunoTest.php @@ -46,7 +46,6 @@ class Avaliacao_Service_FaltaAlunoTest extends Avaliacao_Service_TestCommon { public function testCriaNovaInstanciaDeFaltaAluno() { - $this->markTestSkipped('must be revisited.'); $faltaAluno = $this->_getConfigOption('faltaAluno', 'instance'); $faltaSave = clone $faltaAluno; diff --git a/ieducar/tests/Unit/assets/regra_json_valid.json b/ieducar/tests/Unit/assets/regra_json_valid.json index d22778cdba..aa7dab4ba2 100644 --- a/ieducar/tests/Unit/assets/regra_json_valid.json +++ b/ieducar/tests/Unit/assets/regra_json_valid.json @@ -1,389 +1,106 @@ { + "any_error_msg": false, + "msgs": [], + "oper": "get", "regras": [ { "id": "2", + "media_recuperacao_paralela": null, + "nota_maxima_exame": "10", + "nota_maxima_geral": "10", + "parecer_descritivo": "0", "regra_diferenciada_id": null, "tabela_arredondamento_id": "2", "tabela_arredondamento_id_conceitual": null, "tipo_nota": "2", "tipo_presenca": "2", - "parecer_descritivo": "0", "tipo_recuperacao": "0", - "media_recuperacao_paralela": null, - "nota_maxima_geral": "10", - "nota_maxima_exame": "10", "turmas": [] }, { "id": "3", + "media_recuperacao_paralela": null, + "nota_maxima_exame": "10", + "nota_maxima_geral": "10", + "parecer_descritivo": "6", "regra_diferenciada_id": null, "tabela_arredondamento_id": "4", "tabela_arredondamento_id_conceitual": null, "tipo_nota": "1", "tipo_presenca": "1", - "parecer_descritivo": "6", "tipo_recuperacao": "0", - "media_recuperacao_paralela": null, - "nota_maxima_geral": "10", - "nota_maxima_exame": "10", "turmas": [] }, { "id": "4", + "media_recuperacao_paralela": null, + "nota_maxima_exame": "10", + "nota_maxima_geral": "10", + "parecer_descritivo": "3", "regra_diferenciada_id": null, "tabela_arredondamento_id": "6", "tabela_arredondamento_id_conceitual": null, "tipo_nota": "1", "tipo_presenca": "1", - "parecer_descritivo": "3", "tipo_recuperacao": "0", - "media_recuperacao_paralela": null, - "nota_maxima_geral": "10", - "nota_maxima_exame": "10", - "turmas": [ - { - "turma_id": "701" - }, - { - "turma_id": "702" - }, - { - "turma_id": "703" - }, - { - "turma_id": "720" - }, - { - "turma_id": "721" - }, - { - "turma_id": "723" - }, - { - "turma_id": "724" - }, - { - "turma_id": "725" - }, - { - "turma_id": "733" - }, - { - "turma_id": "769" - }, - { - "turma_id": "771" - }, - { - "turma_id": "772" - }, - { - "turma_id": "775" - }, - { - "turma_id": "776" - }, - { - "turma_id": "779" - } - ] + "turmas": [] }, { "id": "5", + "media_recuperacao_paralela": null, + "nota_maxima_exame": "10", + "nota_maxima_geral": "10", + "parecer_descritivo": "3", "regra_diferenciada_id": null, "tabela_arredondamento_id": "3", "tabela_arredondamento_id_conceitual": null, "tipo_nota": "2", "tipo_presenca": "1", - "parecer_descritivo": "3", "tipo_recuperacao": "0", - "media_recuperacao_paralela": null, - "nota_maxima_geral": "10", - "nota_maxima_exame": "10", - "turmas": [ - { - "turma_id": "689" - }, - { - "turma_id": "690" - }, - { - "turma_id": "691" - }, - { - "turma_id": "693" - }, - { - "turma_id": "694" - }, - { - "turma_id": "695" - }, - { - "turma_id": "696" - }, - { - "turma_id": "697" - }, - { - "turma_id": "699" - }, - { - "turma_id": "705" - }, - { - "turma_id": "706" - }, - { - "turma_id": "707" - }, - { - "turma_id": "708" - }, - { - "turma_id": "710" - }, - { - "turma_id": "711" - }, - { - "turma_id": "712" - }, - { - "turma_id": "713" - }, - { - "turma_id": "714" - }, - { - "turma_id": "715" - }, - { - "turma_id": "738" - }, - { - "turma_id": "739" - }, - { - "turma_id": "740" - }, - { - "turma_id": "741" - }, - { - "turma_id": "742" - }, - { - "turma_id": "743" - }, - { - "turma_id": "744" - }, - { - "turma_id": "745" - }, - { - "turma_id": "746" - }, - { - "turma_id": "747" - }, - { - "turma_id": "748" - }, - { - "turma_id": "750" - }, - { - "turma_id": "751" - }, - { - "turma_id": "752" - }, - { - "turma_id": "753" - }, - { - "turma_id": "755" - }, - { - "turma_id": "756" - }, - { - "turma_id": "757" - }, - { - "turma_id": "758" - }, - { - "turma_id": "759" - }, - { - "turma_id": "760" - }, - { - "turma_id": "761" - }, - { - "turma_id": "762" - }, - { - "turma_id": "763" - }, - { - "turma_id": "764" - }, - { - "turma_id": "787" - }, - { - "turma_id": "788" - } - ] + "turmas": [] }, { "id": "6", + "media_recuperacao_paralela": null, + "nota_maxima_exame": "10", + "nota_maxima_geral": "10", + "parecer_descritivo": "0", "regra_diferenciada_id": "1", "tabela_arredondamento_id": "1", "tabela_arredondamento_id_conceitual": "5", "tipo_nota": "3", "tipo_presenca": "1", - "parecer_descritivo": "0", "tipo_recuperacao": "0", - "media_recuperacao_paralela": null, - "nota_maxima_geral": "10", - "nota_maxima_exame": "10", - "turmas": [ - { - "turma_id": "700" - }, - { - "turma_id": "704" - }, - { - "turma_id": "729" - }, - { - "turma_id": "730" - }, - { - "turma_id": "731" - }, - { - "turma_id": "732" - }, - { - "turma_id": "781" - }, - { - "turma_id": "782" - }, - { - "turma_id": "783" - }, - { - "turma_id": "784" - }, - { - "turma_id": "789" - } - ] + "turmas": [] }, { "id": "7", + "media_recuperacao_paralela": null, + "nota_maxima_exame": "5", + "nota_maxima_geral": "5", + "parecer_descritivo": "0", "regra_diferenciada_id": "1", "tabela_arredondamento_id": "1", "tabela_arredondamento_id_conceitual": null, "tipo_nota": "1", "tipo_presenca": "1", - "parecer_descritivo": "0", "tipo_recuperacao": "0", - "media_recuperacao_paralela": null, - "nota_maxima_geral": "5", - "nota_maxima_exame": "5", "turmas": [] }, { "id": "1", + "media_recuperacao_paralela": null, + "nota_maxima_exame": "10", + "nota_maxima_geral": "10", + "parecer_descritivo": "0", "regra_diferenciada_id": "5", "tabela_arredondamento_id": "6", "tabela_arredondamento_id_conceitual": null, "tipo_nota": "1", "tipo_presenca": "2", - "parecer_descritivo": "0", "tipo_recuperacao": "0", - "media_recuperacao_paralela": null, - "nota_maxima_geral": "10", - "nota_maxima_exame": "10", - "turmas": [ - { - "turma_id": "717" - }, - { - "turma_id": "718" - }, - { - "turma_id": "719" - }, - { - "turma_id": "722" - }, - { - "turma_id": "726" - }, - { - "turma_id": "727" - }, - { - "turma_id": "728" - }, - { - "turma_id": "734" - }, - { - "turma_id": "735" - }, - { - "turma_id": "736" - }, - { - "turma_id": "766" - }, - { - "turma_id": "767" - }, - { - "turma_id": "768" - }, - { - "turma_id": "770" - }, - { - "turma_id": "773" - }, - { - "turma_id": "774" - }, - { - "turma_id": "777" - }, - { - "turma_id": "778" - }, - { - "turma_id": "780" - }, - { - "turma_id": "785" - }, - { - "turma_id": "786" - } - ] + "turmas": [] } ], - "oper": "get", - "resource": "regras", - "msgs": [], - "any_error_msg": false -} \ No newline at end of file + "resource": "regras" +} diff --git a/ieducar/tests/unit/Reports/QueryFactoryTest.php b/ieducar/tests/unit/Reports/QueryFactoryTest.php new file mode 100644 index 0000000000..422bdf12a6 --- /dev/null +++ b/ieducar/tests/unit/Reports/QueryFactoryTest.php @@ -0,0 +1,47 @@ +getPdoConection(); + + $fakeClass = new class($pdo, []) extends QueryFactory{ + protected $keys = ['fake_key']; + }; + + $this->expectException(\InvalidArgumentException::class); + $fakeClass->getData(); + } + + public function testArrayValue() + { + $this->setupDump('fakeusers.sql'); + + $pdo = $this->getPdoConection(); + + $fakeClass = new class($pdo, []) extends QueryFactory{ + protected $keys = ['usuarios']; + protected $query = 'SELECT * FROM pmieducar.usuario WHERE cod_usuario IN (:usuarios)'; + }; + $fakeClass->setParams(['usuarios' => [1,2]]); + $this->assertCount(2, $fakeClass->getData()); + } + + public function testSingleValue() + { + $pdo = $this->getPdoConection(); + + $fakeClass = new class($pdo, []) extends QueryFactory{ + protected $keys = ['usuario']; + protected $query = 'SELECT * FROM pmieducar.usuario WHERE cod_usuario = :usuario'; + }; + $fakeClass->setParams(['usuario' => 1]); + $this->assertEquals(1, $fakeClass->getData()[0]['cod_usuario']); + } +} diff --git a/ieducar/tests/unit/dumps/fakeusers.sql b/ieducar/tests/unit/dumps/fakeusers.sql new file mode 100644 index 0000000000..7105090385 --- /dev/null +++ b/ieducar/tests/unit/dumps/fakeusers.sql @@ -0,0 +1,2 @@ +DELETE FROM pmieducar.usuario; +INSERT INTO pmieducar.usuario (cod_usuario, ref_cod_instituicao, ref_funcionario_cad, data_cadastro, ativo) VALUES (1, 1, 1, NOW(), 1), (2, 1, 1, NOW(), 1); \ No newline at end of file diff --git a/readme.md b/readme.md index 8f169d005c..8c69816f02 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,7 @@ -[![Latest Release](https://img.shields.io/github/release/portabilis/i-educar.svg?label=latest%20release)](https://github.com/portabilis/i-educar/releases) ![](https://scrutinizer-ci.com/g/portabilis/i-educar/badges/quality-score.png?b=master) ![](https://scrutinizer-ci.com/g/portabilis/i-educar/badges/coverage.png?b=master) ![](https://scrutinizer-ci.com/g/portabilis/i-educar/badges/build.png?b=master) ![](https://scrutinizer-ci.com/g/portabilis/i-educar/badges/code-intelligence.svg?b=master) +[![Latest Release](https://img.shields.io/github/release/portabilis/i-educar.svg?label=latest%20release)](https://github.com/portabilis/i-educar/releases) +![](https://scrutinizer-ci.com/g/portabilis/i-educar/badges/quality-score.png?b=master) +![](https://scrutinizer-ci.com/g/portabilis/i-educar/badges/build.png?b=master) +![](https://scrutinizer-ci.com/g/portabilis/i-educar/badges/code-intelligence.svg?b=master) [![Coverage Status](https://coveralls.io/repos/github/portabilis/i-educar/badge.svg?branch=master)](https://coveralls.io/github/portabilis/i-educar?branch=master) # i-Educar @@ -96,45 +99,71 @@ Para executar o projeto é necessário a utilização de alguns softwares para f Para instalar o projeto clone o repositório: -``` +```bash git clone https://github.com/portabilis/i-educar.git && cd i-educar ``` Em seguida, clone o repositório de relatórios: -``` +```bash git clone https://github.com/portabilis/i-educar-reports-package.git ieducar/modules/Reports ``` Será necessário criar os arquivos de configuração do seu ambiente, modifique-os se necessário: -``` +```bash cp docker-compose.yml.example docker-compose.yml cp .env.example .env cp ieducar/configuration/ieducar.ini.example ieducar/configuration/ieducar.ini cp phinx.php.example phinx.php ``` -Faça o build das imagens Docker utilizadas no projeto (pode levar alguns minutos): +Altere também o arquivo `phinx.php`, para adicionar as migrations dos relatórios: + +```php +... + +$configuration = array( + "paths" => array( + "migrations" => array( + "ieducar/misc/database/migrations", + "ieducar/modules/Reports/database/migrations", // <<<<< ADICIONAR ESTA LINHA + ), + "seeds" => array( + "ieducar/misc/database/seeds", + "ieducar/modules/Reports/database/seeds", // <<<<< ADICIONAR ESTA LINHA + ), + ), + "environments" => $environments, +); +... ``` + +Faça o build das imagens Docker utilizadas no projeto (pode levar alguns minutos): + +```bash docker-compose build ``` Então, inicie os containers da aplicação: -``` +```bash docker-compose up -d ``` Faça instalação das dependências do projeto execute apenas um dos comandos abaixo: -``` # Caso você tenha o Composer instalado localmente + +```bash composer install +``` # Senão, execute + +```bash docker run -it -v $(pwd):/app composer install ``` @@ -153,23 +182,18 @@ chmod +x vendor/cossou/jasperphp/src/JasperStarter/bin/jasperstarter php artisan key:generate php artisan legacy:link -vendor/bin/phinx seed:run -s StartingSeed -s StartingForeignKeysSeed +vendor/bin/phinx seed:run -s StartingSeed -s StartingForeignKeysSeed -s StartingReportsSeed vendor/bin/phinx migrate exit ``` -### Instalando outras dependências - -O i-Educar usa o [Composer](https://getcomposer.org/) para gerenciar suas -dependências. O Composer já é executado automaticamente para quem utilizar -docker-compose, basta executar o comando `docker-compose up`. - -Caso queira adicionar novas dependências ao projeto ou executar algum outro -comando do composer, execute na raiz do projeto: +### Compilando arquivos do JasperReports ```bash -docker run -it -v $(pwd):/app composer +docker-compose exec php bash +cd ieducar/modules/Reports/ReportSources +for line in $(ls -a | sort | grep .jrxml | sed -e "s/\.jrxml//"); do $(../../../vendor/cossou/jasperphp/src/JasperStarter/bin/jasperstarter cp $line.jrxml -o $line); done ``` ### Primeiro acesso @@ -195,7 +219,7 @@ configurá-la, modifique os valores das variáveis `XDEBUG_*` no arquivo Para ambiente de desenvolvimento edite o arquivo ieducar/phpunit.xml e removaou comente a linha que segue: ```xml - + ``` Esta linha acima é apenas para gerar o xml de coverage para a badge do @@ -207,7 +231,7 @@ projeto. Para rodar os testes, execute o comando que segue: ```bash -docker-compose exec ieducar_1604 ieducar/vendor/bin/phpunit -c /home/portabilis/ieducar/ieducar/phpunit.xml +docker-compose exec php vendor/bin/phpunit -c /application/ieducar/phpunit.xml ``` #### Visualizar report de coverage diff --git a/src/Modules/ErrorTracking/EmailTracker.php b/src/Modules/ErrorTracking/EmailTracker.php new file mode 100644 index 0000000000..1ad58f1e3d --- /dev/null +++ b/src/Modules/ErrorTracking/EmailTracker.php @@ -0,0 +1,60 @@ +getStringMessage($exception, $data); + $subject = '[Erro inesperado] i-Educar - ' . $this->getHost(); + $to = $this->getRecipient(); + + (new \Portabilis_Mailer())->sendMail($to, $subject, $message); + } + + private function getStringMessage(Throwable $exception, array $data) + { + $data = $this->getStringData($data); + $trace = $this->getStringTrace(); + + return "Olá!\n\n" . + "Ocorreu um erro inesperado no banco de dados, detalhes abaixo:\n\n" . + " ERRO: ' {$exception->getMessage()}\n" . + " LINHA {$exception->getLine()} em {$exception->getFile()}\n" . + " DADOS: {$data}\n" . + " TRACE: \n{$trace}\n" . + "\n\n-\n\n" . + 'Você recebeu este email pois seu email foi configurado para receber ' . + 'notificações de erros.'; + } + + private function getStringTrace() + { + return json_encode(debug_backtrace()); + } + + private function getStringData($data) + { + return json_encode($data); + } + + protected function getHost() + { + return $_SERVER['HTTP_HOST'] ?? null; + } + + private function getRecipient() + { + $recipient = $GLOBALS['coreExt']['Config']->modules->error->email_recipient; + + if (empty($recipient)) { + throw new Exception('Parâmetro modules.error.email_recipient não encontrado'); + } + + return $recipient; + } +} \ No newline at end of file diff --git a/src/Modules/ErrorTracking/HoneyBadgerTracker.php b/src/Modules/ErrorTracking/HoneyBadgerTracker.php index 0440c1209c..49b6a3ec47 100644 --- a/src/Modules/ErrorTracking/HoneyBadgerTracker.php +++ b/src/Modules/ErrorTracking/HoneyBadgerTracker.php @@ -6,14 +6,18 @@ class HoneyBadgerTracker implements Tracker { - public function notify(Throwable $exception) + public function notify(Throwable $exception, $data = []) { \Honeybadger\Honeybadger::$config->values(array( 'api_key' => $GLOBALS['coreExt']['Config']->modules->error->honeybadger_key, 'environment_name' => $_SERVER['HTTP_HOST'], )); - \Honeybadger\Honeybadger::context($_REQUEST); + \Honeybadger\Honeybadger::context($data); + if (empty($data)) { + \Honeybadger\Honeybadger::context($_REQUEST); + } + \Honeybadger\Honeybadger::notify($exception); } } \ No newline at end of file diff --git a/src/Modules/ErrorTracking/TrackerFactory.php b/src/Modules/ErrorTracking/TrackerFactory.php index 918d6ceb01..2d212f55b2 100644 --- a/src/Modules/ErrorTracking/TrackerFactory.php +++ b/src/Modules/ErrorTracking/TrackerFactory.php @@ -12,6 +12,10 @@ public static function getTracker($trackerName) return new HoneyBadgerTracker(); } + if ($trackerName == 'EMAIL') { + return new EmailTracker(); + } + throw new Exception('Invalid error tracker'); } } \ No newline at end of file diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosAbandonosQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosAbandonosQueryFactory.php new file mode 100644 index 0000000000..285735a9f1 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosAbandonosQueryFactory.php @@ -0,0 +1,61 @@ + 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + turma.nm_turma + from + pmieducar.matricula m + inner join + pmieducar.aluno + on aluno.cod_aluno = m.ref_cod_aluno + inner join + cadastro.pessoa + on pessoa.idpes = aluno.ref_idpes + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_matricula = m.cod_matricula + inner join + pmieducar.turma + on turma.cod_turma = mt.ref_cod_turma + where true + and m.ref_ref_cod_escola = :escola + and m.ano = :ano + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and m.aprovado = 6 + and mt.abandono = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosAdmitidosQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosAdmitidosQueryFactory.php new file mode 100644 index 0000000000..41134efd2d --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosAdmitidosQueryFactory.php @@ -0,0 +1,60 @@ + 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + turma.nm_turma + from + pmieducar.matricula m + inner join pmieducar.aluno + on aluno.cod_aluno = m.ref_cod_aluno + inner join cadastro.pessoa + on pessoa.idpes = aluno.ref_idpes + inner join pmieducar.matricula_turma mt + on mt.ref_cod_matricula = m.cod_matricula + inner join pmieducar.turma + on turma.cod_turma = mt.ref_cod_turma + where true + and m.ref_ref_cod_escola = :escola + and m.ano = :ano + and m.ativo = 1 + and m.ref_ref_cod_serie in ( + select + ref_cod_serie + from + modules.config_movimento_geral + inner join pmieducar.serie + on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and mt.sequencial = 1 + and coalesce(mt.data_enturmacao, m.data_cadastro) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosAnosQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosAnosQueryFactory.php new file mode 100644 index 0000000000..f186320c4e --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosAnosQueryFactory.php @@ -0,0 +1,64 @@ + 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + turma.nm_turma + from + pmieducar.matricula_turma mt + inner join + pmieducar.turma + on turma.cod_turma = mt.ref_cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.pessoa + on pessoa.idpes = a.ref_idpes + where true + and m.ref_ref_cod_escola = :escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = :ano_coluna + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosEdInfIntQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosEdInfIntQueryFactory.php new file mode 100644 index 0000000000..c5351c8ca9 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosEdInfIntQueryFactory.php @@ -0,0 +1,63 @@ + 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + turma.nm_turma + from + pmieducar.matricula_turma mt + inner join + pmieducar.turma + on turma.cod_turma = mt.ref_cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.pessoa + on pessoa.idpes = a.ref_idpes + where true + and m.ref_ref_cod_escola = :escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and turma.turma_turno_id = 4 + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 0 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula, m.data_cadastro)) < :data_inicial::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosEdInfParcQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosEdInfParcQueryFactory.php new file mode 100644 index 0000000000..5f7392bf61 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosEdInfParcQueryFactory.php @@ -0,0 +1,64 @@ + 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + turma.nm_turma + from + pmieducar.matricula_turma mt + inner join + pmieducar.turma + on turma.cod_turma = mt.ref_cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.pessoa + on pessoa.idpes = a.ref_idpes + where true + and m.ref_ref_cod_escola = :escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and turma.turma_turno_id <> 4 + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 0 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosObitoQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosObitoQueryFactory.php new file mode 100644 index 0000000000..ec37562ba4 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosObitoQueryFactory.php @@ -0,0 +1,60 @@ + 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + turma.nm_turma + from + pmieducar.matricula m + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_matricula = m.cod_matricula + inner join + pmieducar.aluno + on aluno.cod_aluno = m.ref_cod_aluno + inner join + cadastro.pessoa + on pessoa.idpes = aluno.ref_idpes + inner join + pmieducar.turma + on turma.cod_turma = mt.ref_cod_turma + where true + and m.ref_ref_cod_escola = :escola + and m.ano = :ano + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and m.aprovado = 15 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosReclaQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosReclaQueryFactory.php new file mode 100644 index 0000000000..4a35fd50ec --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosReclaQueryFactory.php @@ -0,0 +1,62 @@ + 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + turma.nm_turma + from + pmieducar.matricula_turma mt + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.turma + on turma.cod_turma = mt.ref_cod_turma + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.pessoa + on pessoa.idpes = a.ref_idpes + where true + and m.ref_ref_cod_escola = :escola + and m.ativo = 1 + and m.ano = :ano + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and m.aprovado = 5 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosRemQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosRemQueryFactory.php new file mode 100644 index 0000000000..7ffe466d7f --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosRemQueryFactory.php @@ -0,0 +1,67 @@ + 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + turma.nm_turma + from + pmieducar.matricula_turma mt + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.turma + on turma.cod_turma = mt.ref_cod_turma + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.pessoa + on pessoa.idpes = a.ref_idpes + where true + and m.ref_ref_cod_escola = :escola + and m.ativo = 1 + and m.ano = :ano + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and mt.ativo = 0 + and mt.sequencial < ( + select max(sequencial) + from pmieducar.matricula_turma + where matricula_turma.ref_cod_matricula = mt.ref_cod_matricula + ) + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosTransferidosQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosTransferidosQueryFactory.php new file mode 100644 index 0000000000..ee44608b49 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralAlunosTransferidosQueryFactory.php @@ -0,0 +1,61 @@ + 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + turma.nm_turma + from + pmieducar.matricula m + inner join + pmieducar.aluno + on aluno.cod_aluno = m.ref_cod_aluno + inner join + cadastro.pessoa + on pessoa.idpes = aluno.ref_idpes + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_matricula = m.cod_matricula + inner join + pmieducar.turma + on turma.cod_turma = mt.ref_cod_turma + where true + and m.ref_ref_cod_escola = :escola + and m.ano = :ano + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and m.aprovado = 4 + and mt.transferido = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoGeralQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoGeralQueryFactory.php new file mode 100644 index 0000000000..40a4cb6523 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoGeralQueryFactory.php @@ -0,0 +1,510 @@ + 1, + 'seleciona_curso' => 0, + 'curso' => 0 + ]; + + protected $query = <<<'SQL' + select + escola.cod_escola, + juridica.fantasia as escola, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.turma on turma.cod_turma = mt.ref_cod_turma + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo =1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and turma.turma_turno_id = 4 + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 0 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula, m.data_cadastro)) < :data_inicial::date + ) as ed_inf_int, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.turma on turma.cod_turma = mt.ref_cod_turma + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and turma.turma_turno_id <> 4 + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 0 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ed_inf_parc, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 1 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ano_1, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 2 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ano_2, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 3 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ano_3, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 4 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ano_4, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 5 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ano_5, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 6 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ano_6, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 7 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ano_7, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 8 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ano_8, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.aprovado not in (4, 6, 15) + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and coluna = 9 + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and date(coalesce(mt.data_exclusao, m.data_cancel)) is null + ) as ano_9, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on mt.ref_cod_matricula = m.cod_matricula + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ano = :ano + and m.ativo = 1 + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and mt.sequencial = 1 + and coalesce(mt.data_enturmacao, m.data_cadastro) between :data_inicial::date and :data_final::date + ) as admitidos, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on mt.ref_cod_matricula = m.cod_matricula + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ano = :ano + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and m.aprovado = 4 + and mt.transferido = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as transf, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on mt.ref_cod_matricula = m.cod_matricula + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ano = :ano + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and m.aprovado = 6 + and mt.abandono = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as aband, + ( + select count(m.cod_matricula) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo = 1 + and m.ano = :ano + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and mt.ativo = 0 + and mt.sequencial < ( + select max(sequencial) + from pmieducar.matricula_turma + where matricula_turma.ref_cod_matricula = mt.ref_cod_matricula + ) + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as rem, + ( + select count(m.cod_matricula) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ativo =1 + and m.ano = :ano + and m.dependencia not in (true) + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and m.aprovado = 5 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as recla, + ( + select count(m.cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on mt.ref_cod_matricula = m.cod_matricula + where true + and m.ref_ref_cod_escola = escola.cod_escola + and m.ano = :ano + and m.ref_ref_cod_serie in ( + select ref_cod_serie + from modules.config_movimento_geral + inner join pmieducar.serie on serie.cod_serie = config_movimento_geral.ref_cod_serie + where true + and (case + when :seleciona_curso = 0 then + true + else + serie.ref_cod_curso in (:curso) + end) + ) + and m.aprovado = 15 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as obito, + (case + when coalesce(fundamental_ciclo, 0) = 0 then + '' + else + '**' + end) as ciclo, + (case + when coalesce(atendimento_aee, 0) <= 0 then + '' + else + '*' + end) as aee, + (case + when escola.zona_localizacao = 2 then + 'Rural' + else + 'Urbana' + end) as localizacao + from pmieducar.escola + inner join cadastro.juridica on juridica.idpes = escola.ref_idpes + where true + and escola.ativo = 1 + and escola.ref_cod_instituicao = :instituicao + and (case + when :seleciona_curso = 0 then + true + else + exists( + select 1 + from pmieducar.escola_curso + where true + and escola_curso.ref_cod_curso in (:curso) + and escola.cod_escola = escola_curso.ref_cod_escola + ) + end) + order by + juridica.fantasia asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoMensalMatAbandQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoMensalMatAbandQueryFactory.php new file mode 100644 index 0000000000..17bfde37c3 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoMensalMatAbandQueryFactory.php @@ -0,0 +1,81 @@ + 1, + 'curso' => 0, + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + t.nm_turma + from + pmieducar.serie s + inner join + pmieducar.escola_serie es + on s.cod_serie = es.ref_cod_serie + inner join + pmieducar.escola e + on e.cod_escola = es.ref_cod_escola + inner join + pmieducar.turma t + on t.ref_ref_cod_serie = s.cod_serie + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_turma = t.cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.fisica f + on f.idpes = a.ref_idpes + inner join + cadastro.pessoa + on pessoa.idpes = f.idpes + where true + and e.ref_cod_instituicao = :instituicao + and e.cod_escola = :escola + and t.ref_ref_cod_escola = :escola + and t.ativo = 1 + and t.ano = :ano + and t.cod_turma = :turma + and s.cod_serie = :serie + and (case + when :curso = 0 then + true + else + s.ref_cod_curso = :curso + end) + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = :sexo + and m.aprovado = 6 + and mt.abandono = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoMensalMatAdmitQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoMensalMatAdmitQueryFactory.php new file mode 100644 index 0000000000..2436e4aeb0 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoMensalMatAdmitQueryFactory.php @@ -0,0 +1,83 @@ + 1, + 'curso' => 0, + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + t.nm_turma + from + pmieducar.serie s + inner join + pmieducar.escola_serie es + on s.cod_serie = es.ref_cod_serie + inner join + pmieducar.escola e + on e.cod_escola = es.ref_cod_escola + inner join + pmieducar.turma t + on t.ref_ref_cod_serie = s.cod_serie + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_turma = t.cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.fisica f + on f.idpes = a.ref_idpes + inner join + cadastro.pessoa + on pessoa.idpes = f.idpes + where true + and e.ref_cod_instituicao = :instituicao + and e.cod_escola = :escola + and t.ref_ref_cod_escola = :escola + and t.ativo = 1 + and t.ano = :ano + and t.cod_turma = :turma + and s.cod_serie = :serie + and ( + select case + when :curso = 0 then + true + else + s.ref_cod_curso = :curso + end + ) + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ativo = 1 + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and mt.sequencial = 1 + and f.sexo = :sexo + and coalesce(mt.data_enturmacao, m.data_cadastro) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoMensalMatFalecidoQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoMensalMatFalecidoQueryFactory.php new file mode 100644 index 0000000000..19c53fde0c --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoMensalMatFalecidoQueryFactory.php @@ -0,0 +1,80 @@ + 1, + 'curso' => 0, + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + t.nm_turma + from + pmieducar.serie s + inner join + pmieducar.escola_serie es + on s.cod_serie = es.ref_cod_serie + inner join + pmieducar.escola e + on e.cod_escola = es.ref_cod_escola + inner join + pmieducar.turma t + on t.ref_ref_cod_serie = s.cod_serie + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_turma = t.cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.fisica f + on f.idpes = a.ref_idpes + inner join + cadastro.pessoa + on pessoa.idpes = f.idpes + where true + and e.ref_cod_instituicao = :instituicao + and e.cod_escola = :escola + and t.ref_ref_cod_escola = :escola + and t.ativo = 1 + and t.ano = :ano + and t.cod_turma = :turma + and s.cod_serie = :serie + and (case + when :curso = 0 then + true + else + s.ref_cod_curso = :curso + end) + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = :sexo + and m.aprovado = 15 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoMensalMatIniQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoMensalMatIniQueryFactory.php new file mode 100644 index 0000000000..f5f1466854 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoMensalMatIniQueryFactory.php @@ -0,0 +1,82 @@ + 1, + 'curso' => 0, + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + t.nm_turma + from + pmieducar.serie s + inner join + pmieducar.escola_serie es + on s.cod_serie = es.ref_cod_serie + inner join + pmieducar.escola e + on e.cod_escola = es.ref_cod_escola + inner join + pmieducar.turma t + on t.ref_ref_cod_serie = s.cod_serie + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_turma = t.cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.fisica f + on f.idpes = a.ref_idpes + inner join + cadastro.pessoa + on pessoa.idpes = f.idpes + where true + and e.ref_cod_instituicao = :instituicao + and e.cod_escola = :escola + and t.ref_ref_cod_escola = :escola + and t.ativo = 1 + and t.ano = :ano + and m.ativo = 1 + and f.sexo = :sexo + and m.ano = t.ano + and m.dependencia not in (true) + and s.cod_serie = :serie + and t.cod_turma = :turma + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and (case + when date(coalesce(date(mt.data_exclusao), date(m.data_cancel))) is not null then + date(coalesce(date(mt.data_exclusao),date(m.data_cancel))) >= :data_inicial::date + else + true + end) + and (case + when :curso = 0 then + true + else + s.ref_cod_curso = :curso + end) + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoMensalMatReclassificadosQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoMensalMatReclassificadosQueryFactory.php new file mode 100644 index 0000000000..5c698aebce --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoMensalMatReclassificadosQueryFactory.php @@ -0,0 +1,80 @@ + 1, + 'curso' => 0, + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + t.nm_turma + from + pmieducar.serie s + inner join + pmieducar.escola_serie es + on s.cod_serie = es.ref_cod_serie + inner join + pmieducar.escola e + on e.cod_escola = es.ref_cod_escola + inner join + pmieducar.turma t + on t.ref_ref_cod_serie = s.cod_serie + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_turma = t.cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.fisica f + on f.idpes = a.ref_idpes + inner join + cadastro.pessoa + on pessoa.idpes = f.idpes + where true + and e.ref_cod_instituicao = :instituicao + and e.cod_escola = :escola + and t.ref_ref_cod_escola = :escola + and t.ativo = 1 + and t.ano = :ano + and t.cod_turma = :turma + and s.cod_serie = :serie + and (case + when :curso = 0 then + true + else + s.ref_cod_curso = :curso + end) + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = :sexo + and m.aprovado = 5 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoMensalMatTransfQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoMensalMatTransfQueryFactory.php new file mode 100644 index 0000000000..368ddbd67a --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoMensalMatTransfQueryFactory.php @@ -0,0 +1,81 @@ + 1, + 'curso' => 0, + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + t.nm_turma + from + pmieducar.serie s + inner join + pmieducar.escola_serie es + on s.cod_serie = es.ref_cod_serie + inner join + pmieducar.escola e + on e.cod_escola = es.ref_cod_escola + inner join + pmieducar.turma t + on t.ref_ref_cod_serie = s.cod_serie + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_turma = t.cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.fisica f + on f.idpes = a.ref_idpes + inner join + cadastro.pessoa + on pessoa.idpes = f.idpes + where true + and e.ref_cod_instituicao = :instituicao + and e.cod_escola = :escola + and t.ref_ref_cod_escola = :escola + and t.ativo = 1 + and t.ano = :ano + and t.cod_turma = :turma + and s.cod_serie = :serie + and (case + when :curso = 0 then + true + else + s.ref_cod_curso = :curso + end) + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = :sexo + and m.aprovado = 4 + and mt.transferido = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoMensalMatTrocaeQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoMensalMatTrocaeQueryFactory.php new file mode 100644 index 0000000000..786288ad27 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoMensalMatTrocaeQueryFactory.php @@ -0,0 +1,81 @@ + 1, + 'curso' => 0, + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + t.nm_turma + from + pmieducar.serie s + inner join + pmieducar.escola_serie es + on s.cod_serie = es.ref_cod_serie + inner join + pmieducar.escola e + on e.cod_escola = es.ref_cod_escola + inner join + pmieducar.turma t + on t.ref_ref_cod_serie = s.cod_serie + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_turma = t.cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.fisica f + on f.idpes = a.ref_idpes + inner join + cadastro.pessoa + on pessoa.idpes = f.idpes + where true + and e.ref_cod_instituicao = :instituicao + and e.cod_escola = :escola + and t.ref_ref_cod_escola = :escola + and t.ativo = 1 + and t.ano = :ano + and t.cod_turma = :turma + and s.cod_serie = :serie + and (case + when :curso = 0 then + true + else + s.ref_cod_curso = :curso + end) + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = :sexo + and m.ativo = 1 + and coalesce(mt.data_enturmacao, m.data_cadastro) between :data_inicial::date and :data_final::date + and mt.sequencial > 1 + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoMensalMatTrocasQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoMensalMatTrocasQueryFactory.php new file mode 100644 index 0000000000..45a2277b83 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoMensalMatTrocasQueryFactory.php @@ -0,0 +1,85 @@ + 1, + 'curso' => 0, + ]; + + protected $query = <<<'SQL' + select + m.cod_matricula, + pessoa.nome, + t.nm_turma + from + pmieducar.serie s + inner join + pmieducar.escola_serie es + on s.cod_serie = es.ref_cod_serie + inner join + pmieducar.escola e + on e.cod_escola = es.ref_cod_escola + inner join + pmieducar.turma t + on t.ref_ref_cod_serie = s.cod_serie + inner join + pmieducar.matricula_turma mt + on mt.ref_cod_turma = t.cod_turma + inner join + pmieducar.matricula m + on m.cod_matricula = mt.ref_cod_matricula + inner join + pmieducar.aluno a + on a.cod_aluno = m.ref_cod_aluno + inner join + cadastro.fisica f + on f.idpes = a.ref_idpes + inner join + cadastro.pessoa + on pessoa.idpes = f.idpes + where true + and e.ref_cod_instituicao = :instituicao + and e.cod_escola = :escola + and t.ref_ref_cod_escola = :escola + and t.ativo = 1 + and t.ano = :ano + and t.cod_turma = :turma + and s.cod_serie = :serie + and (case + when :curso = 0 then + true + else + s.ref_cod_curso = :curso + end) + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = :sexo + and m.ativo = 1 + and coalesce(mt.data_enturmacao, m.data_cadastro) between :data_inicial::date and :data_final::date + and mt.sequencial < ( + select max(sequencial) + from pmieducar.matricula_turma + where matricula_turma.ref_cod_matricula = mt.ref_cod_matricula + ) + order by + pessoa.nome asc +SQL; +} diff --git a/src/Modules/Reports/QueryFactory/MovimentoMensalQueryFactory.php b/src/Modules/Reports/QueryFactory/MovimentoMensalQueryFactory.php new file mode 100644 index 0000000000..6b315ab943 --- /dev/null +++ b/src/Modules/Reports/QueryFactory/MovimentoMensalQueryFactory.php @@ -0,0 +1,375 @@ + 1, + 'curso' => 0, + 'turma' => 0, + 'serie' => 0, + ]; + + protected $query = <<<'SQL' + select * + from + ( + select + s.cod_serie, + s.nm_serie, + t.cod_turma, + t.nm_turma, + ( + select nome + from pmieducar.turma_turno + where id = t.turma_turno_id + ) as turno, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + inner join cadastro.fisica f on f.idpes = a.ref_idpes + where true + and mt.ref_cod_turma = t.cod_turma + and m.ativo = 1 + and f.sexo = 'M' + and m.ano = t.ano + and m.dependencia not in (true) + and date(coalesce(mt.data_enturmacao, m.data_matricula,m.data_cadastro)) < :data_inicial::date + and (case + when date(coalesce(date(mt.data_exclusao), date(m.data_cancel))) is not null then + date(coalesce(date(mt.data_exclusao),date(m.data_cancel))) >= :data_inicial::date + else + true + end) + ) as mat_ini_m, + ( + select count(distinct(m.cod_matricula)) + from pmieducar.matricula_turma mt + inner join pmieducar.matricula m on m.cod_matricula = mt.ref_cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + inner join cadastro.fisica f on f.idpes = a.ref_idpes + where true + and mt.ref_cod_turma = t.cod_turma + and m.ativo = 1 + and f.sexo = 'F' + and m.ano = t.ano + and m.dependencia not in (true) + and date(coalesce(mt.data_enturmacao, m.data_matricula, m.data_cadastro)) < :data_inicial::date + and (case + when date(coalesce(date(mt.data_exclusao), date(m.data_cancel))) is not null then + date(coalesce(date(mt.data_exclusao), date(m.data_cancel))) >= :data_inicial::date + else + true + end) + ) as mat_ini_f, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on mt.ref_cod_matricula = m.cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + inner join cadastro.fisica f on f.idpes = a.ref_idpes + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'M' + and m.ativo = 1 + and coalesce(mt.data_enturmacao, m.data_cadastro) between :data_inicial::date and :data_final::date + and mt.sequencial > 1 + ) as mat_trocae_m, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on mt.ref_cod_matricula = m.cod_matricula + inner join pmieducar.aluno a on a.cod_aluno = m.ref_cod_aluno + inner join cadastro.fisica f on f.idpes = a.ref_idpes + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'F' + and m.ativo = 1 + and coalesce(mt.data_enturmacao, m.data_cadastro) between :data_inicial::date and :data_final::date + and mt.sequencial > 1 + ) as mat_trocae_f, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'M' + and m.ativo = 1 + and mt.ativo = 0 + and mt.sequencial < ( + select max(sequencial) + from pmieducar.matricula_turma + where matricula_turma.ref_cod_matricula = mt.ref_cod_matricula + ) + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_trocas_m, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'F' + and m.ativo = 1 + and mt.ativo = 0 + and mt.sequencial < ( + select max(sequencial) + from pmieducar.matricula_turma + where matricula_turma.ref_cod_matricula = mt.ref_cod_matricula + ) + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_trocas_f, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ativo = 1 + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and mt.sequencial = 1 + and f.sexo = 'M' + and coalesce(mt.data_enturmacao, m.data_cadastro) between :data_inicial::date and :data_final::date + ) as mat_admit_m, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ativo = 1 + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and mt.sequencial = 1 + and f.sexo = 'F' + and coalesce(mt.data_enturmacao, m.data_cadastro) between :data_inicial::date and :data_final::date + ) as mat_admit_f, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'M' + and m.aprovado = 5 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_reclassificados_m, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'F' + and m.aprovado = 5 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_reclassificados_f, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'M' + and m.aprovado = 4 + and mt.transferido = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_transf_m, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'F' + and m.aprovado = 4 + and mt.transferido = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_transf_f, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'M' + and m.aprovado = 6 + and mt.abandono = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_aband_m, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'F' + and m.aprovado = 6 + and mt.abandono = 't' + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_aband_f, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'M' + and m.aprovado = 15 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_falecido_m, + ( + select count(cod_matricula) + from pmieducar.matricula m + inner join pmieducar.matricula_turma mt on (mt.ref_cod_matricula = m.cod_matricula) + inner join pmieducar.aluno a on (a.cod_aluno = m.ref_cod_aluno) + inner join cadastro.fisica f on (f.idpes = a.ref_idpes) + where true + and m.ref_ref_cod_escola = e.cod_escola + and m.ano = t.ano + and m.ref_cod_curso = s.ref_cod_curso + and m.ref_ref_cod_serie = s.cod_serie + and mt.ref_cod_turma = t.cod_turma + and f.sexo = 'F' + and m.aprovado = 15 + and coalesce(mt.data_exclusao, m.data_cancel) between :data_inicial::date and :data_final::date + ) as mat_falecido_f + from pmieducar.serie s + inner join pmieducar.escola_serie es on (s.cod_serie = es.ref_cod_serie) + inner join pmieducar.escola e on (e.cod_escola = es.ref_cod_escola) + inner join pmieducar.turma t on (t.ref_ref_cod_serie = s.cod_serie) + where true + and e.ref_cod_instituicao = :instituicao + and e.cod_escola = :escola + and t.ref_ref_cod_escola = :escola + and t.ativo = 1 + and t.ano = :ano + and ( + select case + when :curso = 0 then + true + else + s.ref_cod_curso = :curso + end + ) + and ( + select case + when :turma = 0 then + true + else + t.cod_turma = :turma + end + ) + and ( + select case + when :serie = 0 then + true + else + s.cod_serie = :serie + end + ) + ) as movimento + order by + nm_serie, + nm_turma +SQL; + + public function getData(){ + $data = parent::getData(); + + foreach ($data as $k => $v) { + $data[$k]['mat_ini_t'] = $v['mat_ini_m'] + $v['mat_ini_f']; + $data[$k]['mat_final_m'] = ($v['mat_ini_m'] + $v['mat_admit_m'] + $v['mat_trocae_m']) - ($v['mat_transf_m'] + $v['mat_aband_m'] + $v['mat_falecido_m'] + $v['mat_trocas_m'] + $v['mat_reclassificados_m']); + $data[$k]['mat_final_f'] = ($v['mat_ini_f'] + $v['mat_admit_f'] + $v['mat_trocae_f']) - ($v['mat_transf_f'] + $v['mat_aband_f'] + $v['mat_falecido_f'] + $v['mat_trocas_f'] + $v['mat_reclassificados_f']); + $data[$k]['mat_final_t'] = $data[$k]['mat_final_m'] + $data[$k]['mat_final_f']; + } + + return $data; + } +} diff --git a/src/Modules/Reports/QueryFactory/QueryFactory.php b/src/Modules/Reports/QueryFactory/QueryFactory.php new file mode 100644 index 0000000000..e3321085fb --- /dev/null +++ b/src/Modules/Reports/QueryFactory/QueryFactory.php @@ -0,0 +1,63 @@ +params = $params; + $this->pdo = $connection; + } + + public function getData() + { + $query = $this->query; + $values = []; + + foreach ($this->keys as $key) { + $value = $this->params[$key] ?? $this->defaults[$key] ?? null; + + if (is_null($value)) { + throw new \InvalidArgumentException( + sprintf('O parâmetro "%s" não está presente ou não possui um valor padrão definido.', $key) + ); + } + + if (is_array($value)) { + $tmpValues = []; + + foreach ($value as $k => $v) { + $tmpValues[':' . $key . '_' . $k] = $v; + } + + $query = str_replace(':' . $key, join(', ', array_keys($tmpValues)), $query); + + $values += $tmpValues; + } else { + $values[':' . $key] = $value; + } + } + + $statement = $this->pdo->prepare($query); + + $statement->execute($values); + + return $statement->fetchAll(\PDO::FETCH_ASSOC); + } + + public function setParams($params) + { + $this->params = $params; + } +} diff --git a/website/blog/2018-10-05-lancamento-de-pacote-de-relatorios-para-comunidade.md b/website/blog/2018-10-05-lancamento-de-pacote-de-relatorios-para-comunidade.md new file mode 100644 index 0000000000..dd8713fae7 --- /dev/null +++ b/website/blog/2018-10-05-lancamento-de-pacote-de-relatorios-para-comunidade.md @@ -0,0 +1,66 @@ +--- +author: Tiago de Faveri Giusti +authorURL: https://www.linkedin.com/in/giustin +title: Lançamento de pacote de relatórios na Comunidade i-Educar +--- + + +![pelicula-live-comunidade](https://user-images.githubusercontent.com/42675992/46549245-b5cced80-c8a7-11e8-9ca1-205c90f251ce.jpg) +###### Imagem do lançamento de pacote de relatórios para a Comunidade i-Educar + + +Vamos ajudar a educação a decolar com os melhores relatórios para a Comunidade? + +A [Portabilis](http://portabilis.com.br) fez o lançamento oficial de um pacote com seus melhores relatórios para a Comunidade i-Educar, para garantir o compromisso que temos com a Comunidade e, principalmente, com a educação do nosso País. + +[Este lançamento](https://www.youtube.com/watch?v=6-Uzv5hLsLE&t=352s) de evoluções se trata de um **pacote com dezenas de relatórios e documentos** , os melhores que desenvolvemos junto aos nossos clientes, que facilitarão o uso dos dados gerados pelo software, apoiando as escolas de todo o Brasil a superarem a falta de informação e tecnologia necessários para tomadas mais inteligentes de decisão na gestão da educação. + +Aqui você vai descobrir como esses relatórios na Comunidade vão contribuir com a vida de todos os profissionais de educação do Brasil! Vamos lá? + +### Como chegamos até aqui? + +No [final do ano de](http://ieducar.org/blog/2017/12/28/em-2018-queremos-o-i-educar-por-todo-o-brasil.html) [2017](http://ieducar.org/blog/2017/12/28/em-2018-queremos-o-i-educar-por-todo-o-brasil.html), firmamos nosso compromisso de levar o i-Educar **#PorTodasAsEscolasDoBrasil** e fazer dele o maior software livre e público de todo o País! + +Desde então, a Portabilis vem contribuindo o máximo para o fortalecimento da **Comunidade i-Educar** , contando com a colaboração de todos que fazem parte deste projeto. + +Em junho deste ano, lançamos os avanços do i-Educar para todo o Brasil, com o [lançamento oficial do i-Educar 2.0](https://www.youtube.com/watch?v=1C3473KxIeM&t=2420s) para a Comunidade, fortalecendo nosso papel com o projeto. Nessa transmissão ao vivo, disponibilizamos novos recursos, melhorias nos módulos, na interface e muitas outras! + +Com isso, o i-Educar se tornou o **1º software livre do Brasil** integrado com o maior levantamento estatístico da educação no País, o [Censo Escolar](https://www.youtube.com/watch?v=AzU8ltLF8Ig&t=17s) **.** + +Agora, buscando fortalecer mais ainda a nossa Comunidade, lançamos um pacote com mais de **40 modelos de relatórios** para facilitar a extração de dados e melhorar a tomada de decisão dos gestores usuários do i-Educar, contribuindo para o desenvolvimento colaborativo do i-Educar e, principalmente, possibilitando que **milhares de municípios** superem a falta de tecnologia e informação, impactando de verdade nos objetivos da educação do nosso País! + +Neste pacote, você encontrará diversos tipos de relatórios como listagens, fichas, boletins, indicadores e histórico escolar. Assista a [live de lançamento](https://www.youtube.com/watch?v=6-Uzv5hLsLE&t=352s) e fique por dentro de tudo! + +### Mas e os relatórios de antes? + +Antes deste lançamento, a Comunidade i-Educar possuía apenas **8 relatórios com diversos problemas e bugs,** com falhas na emissão dos dados e outras dificuldades. Agora, temos mais de 40 relatórios funcionais e padronizados a fim de melhorar a experiência dos usuários do sistema! + +A metodologia de desenvolvimento anterior também incluía regras de negócio e design fortemente acoplados, o que dificultava a manutenção. Agora, com uma nova abordagem em camadas, conseguimos garantir mais integridade e confiabilidade dos dados gerados, pois permitirá, por exemplo, a implementação de testes automatizados nos dados dos relatórios. + +Se você deseja saber um pouco mais sobre estas e outras questões mais avançadas, no dia **19 de outubro** faremos uma transmissão ao vivo de uma **live técnica sobre relatórios** , que vai detalhar com mais profundidade estes avanços e os próximos passos. + +Se você quiser ler mais sobre o assunto técnico antes da **live técnica de relatórios** , pode acessar [aqui](https://github.com/portabilis/i-educar/pull/409) o pull request detalhado. + +### Seja um promotor do movimento do i-Educar por todo o Brasil! + +A [Fundação Lemann](https://fundacaolemann.org.br) ajudou a Comunidade i-Educar a ter acesso ao **Discourse** , ferramenta adotada para o Fórum da Comunidade, pelo período de **1 ano**. Depois disso, precisaremos de 2 mil estrelas para garantir o serviço gratuito para a Comunidade! + +Você pode ajudar ativamente e fazer a diferença pela educação pública do Brasil! Dê uma estrela para o projeto e nos ajude a manter essas conquistas! + +Você já ajudou o projeto com uma **estrelinha ⭐** no [github do i-Educar](https://github.com/portabilis/i-educar)? + +Divulgue o máximo que você conseguir este post e todas as novidades, para que mais redes se conectem com a comunidade e nos ajude a tornar o i-Educar o maior software livre de educação do Brasil! + +### Gostou da novidade? + +Você pode rever o lançamento [aqui](https://www.youtube.com/watch?v=6-Uzv5hLsLE&t=352s). + +Para as próximas novidades, fique ligado nos lançamentos que anunciamos na transmissão, o lançamento de abertura de código do Portabilis Diário e App para a Comunidade e, é claro, **a live técnica de relatórios do i-Educar** , que vai acontecer dia **19 de outubro**! + +Enquanto isso, nos acompanhe no [Fórum](http://forum.ieducar.org), [Twitter](http://twitter.com/portabilis) e [Facebook](http://facebook.com/ieducar) e saiba mais sobre todos os próximos lançamentos e movimentos da Comunidade i-Educar! ❤️ + +#### Eu sou Tiago Giusti, CEO da Portabilis e Coordenador da Comunidade i-Educar. + +#### Junto com o #TimePortabilis e a Comunidade, acredito que podemos mudar o nosso país através da educação, tecnologia e dados. + +#### Junte-se a nós no movimento do **#iEducar #PorTodasAsEscolasDoBrasil**!