Commit a19c816639e8edb3819d350960d79399cd559145

Authored by Eder Soares
2 parents 24321bf3 79a7e414
Exists in 2.9 and in 2 other branches 2.7, 2.8

Merge branch 'main' into community-patch-2022-07-10

app/Http/Kernel.php
@@ -40,6 +40,7 @@ class Kernel extends HttpKernel @@ -40,6 +40,7 @@ class Kernel extends HttpKernel
40 ], 40 ],
41 41
42 'api' => [ 42 'api' => [
  43 + \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
43 'bindings', 44 'bindings',
44 'throttle:60,1', 45 'throttle:60,1',
45 ], 46 ],
app/Http/Middleware/SkipMiddleware.php 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Middleware;
  4 +
  5 +use Closure;
  6 +use Illuminate\Http\Request;
  7 +
  8 +class SkipMiddleware
  9 +{
  10 + public function handle(Request $request, Closure $next): mixed
  11 + {
  12 + return $next($request);
  13 + }
  14 +}
app/Models/LegacyMenuUserType.php 0 → 100644
@@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use App\Menu;
  6 +use Illuminate\Database\Eloquent\Factories\HasFactory;
  7 +use Illuminate\Database\Eloquent\Model;
  8 +
  9 +class LegacyMenuUserType extends Model
  10 +{
  11 + use HasFactory;
  12 +
  13 + protected $table = 'pmieducar.menu_tipo_usuario';
  14 +
  15 + public $timestamps = false;
  16 + public $primaryKey = null;
  17 + public $incrementing = false;
  18 +
  19 + protected $fillable = [
  20 + 'ref_cod_tipo_usuario',
  21 + 'menu_id',
  22 + 'cadastra',
  23 + 'visualiza',
  24 + 'exclui',
  25 + ];
  26 +
  27 + public function menus()
  28 + {
  29 + return $this->belongsTo(Menu::class);
  30 + }
  31 +}
app/Models/LegacyUser.php
@@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
2 2
3 namespace App\Models; 3 namespace App\Models;
4 4
5 -use Illuminate\Database\Eloquent\Model; 5 +use App\User as DefaultUser;
6 use Illuminate\Database\Eloquent\Relations\BelongsTo; 6 use Illuminate\Database\Eloquent\Relations\BelongsTo;
7 7
8 -class LegacyUser extends Model 8 +class LegacyUser extends DefaultUser
9 { 9 {
10 /** 10 /**
11 * @var string 11 * @var string
app/Repositories/EducacensoRepository.php
@@ -556,7 +556,7 @@ SQL; @@ -556,7 +556,7 @@ SQL;
556 SELECT ARRAY_REMOVE(ARRAY_AGG(educacenso_curso_superior.curso_id), NULL) course_id, 556 SELECT ARRAY_REMOVE(ARRAY_AGG(educacenso_curso_superior.curso_id), NULL) course_id,
557 ARRAY_REMOVE(ARRAY_AGG(completion_year), NULL) completion_year, 557 ARRAY_REMOVE(ARRAY_AGG(completion_year), NULL) completion_year,
558 ARRAY_REMOVE(ARRAY_AGG(educacenso_ies.ies_id), NULL) college_id, 558 ARRAY_REMOVE(ARRAY_AGG(educacenso_ies.ies_id), NULL) college_id,
559 - ARRAY_REMOVE(ARRAY_AGG(discipline_id), NULL) discipline_id 559 + ARRAY_REMOVE(ARRAY_AGG(coalesce(discipline_id, 0)), NULL) discipline_id
560 FROM employee_graduations 560 FROM employee_graduations
561 JOIN modules.educacenso_curso_superior ON educacenso_curso_superior.id = employee_graduations.course_id 561 JOIN modules.educacenso_curso_superior ON educacenso_curso_superior.id = employee_graduations.course_id
562 JOIN modules.educacenso_ies ON educacenso_ies.id = employee_graduations.college_id 562 JOIN modules.educacenso_ies ON educacenso_ies.id = employee_graduations.college_id
@@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany; @@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
12 use Illuminate\Foundation\Auth\User as Authenticatable; 12 use Illuminate\Foundation\Auth\User as Authenticatable;
13 use Illuminate\Notifications\Notifiable; 13 use Illuminate\Notifications\Notifiable;
14 use Illuminate\Support\Carbon; 14 use Illuminate\Support\Carbon;
  15 +use Laravel\Sanctum\HasApiTokens;
15 16
16 /** 17 /**
17 * @property int $id 18 * @property int $id
@@ -26,6 +27,7 @@ use Illuminate\Support\Carbon; @@ -26,6 +27,7 @@ use Illuminate\Support\Carbon;
26 */ 27 */
27 class User extends Authenticatable 28 class User extends Authenticatable
28 { 29 {
  30 + use HasApiTokens;
29 use Notifiable; 31 use Notifiable;
30 32
31 /** 33 /**
@@ -114,16 +114,16 @@ @@ -114,16 +114,16 @@
114 }, 114 },
115 { 115 {
116 "name": "aws/aws-sdk-php", 116 "name": "aws/aws-sdk-php",
117 - "version": "3.229.2", 117 + "version": "3.231.2",
118 "source": { 118 "source": {
119 "type": "git", 119 "type": "git",
120 "url": "https://github.com/aws/aws-sdk-php.git", 120 "url": "https://github.com/aws/aws-sdk-php.git",
121 - "reference": "142a872fd7172bf5d067f4e30e4f89593296fc8f" 121 + "reference": "9a7c2a8c4b7f95074749e1a7b575e6b4486bdcab"
122 }, 122 },
123 "dist": { 123 "dist": {
124 "type": "zip", 124 "type": "zip",
125 - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/142a872fd7172bf5d067f4e30e4f89593296fc8f",  
126 - "reference": "142a872fd7172bf5d067f4e30e4f89593296fc8f", 125 + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/9a7c2a8c4b7f95074749e1a7b575e6b4486bdcab",
  126 + "reference": "9a7c2a8c4b7f95074749e1a7b575e6b4486bdcab",
127 "shasum": "" 127 "shasum": ""
128 }, 128 },
129 "require": { 129 "require": {
@@ -141,6 +141,7 @@ @@ -141,6 +141,7 @@
141 "andrewsville/php-token-reflection": "^1.4", 141 "andrewsville/php-token-reflection": "^1.4",
142 "aws/aws-php-sns-message-validator": "~1.0", 142 "aws/aws-php-sns-message-validator": "~1.0",
143 "behat/behat": "~3.0", 143 "behat/behat": "~3.0",
  144 + "composer/composer": "^1.10.22",
144 "doctrine/cache": "~1.4", 145 "doctrine/cache": "~1.4",
145 "ext-dom": "*", 146 "ext-dom": "*",
146 "ext-openssl": "*", 147 "ext-openssl": "*",
@@ -199,9 +200,9 @@ @@ -199,9 +200,9 @@
199 "support": { 200 "support": {
200 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", 201 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
201 "issues": "https://github.com/aws/aws-sdk-php/issues", 202 "issues": "https://github.com/aws/aws-sdk-php/issues",
202 - "source": "https://github.com/aws/aws-sdk-php/tree/3.229.2" 203 + "source": "https://github.com/aws/aws-sdk-php/tree/3.231.2"
203 }, 204 },
204 - "time": "2022-07-01T18:16:42+00:00" 205 + "time": "2022-07-08T18:16:11+00:00"
205 }, 206 },
206 { 207 {
207 "name": "aws/aws-sdk-php-laravel", 208 "name": "aws/aws-sdk-php-laravel",
@@ -4206,16 +4207,16 @@ @@ -4206,16 +4207,16 @@
4206 }, 4207 },
4207 { 4208 {
4208 "name": "nuwave/lighthouse", 4209 "name": "nuwave/lighthouse",
4209 - "version": "v5.55.1", 4210 + "version": "v5.57.0",
4210 "source": { 4211 "source": {
4211 "type": "git", 4212 "type": "git",
4212 "url": "https://github.com/nuwave/lighthouse.git", 4213 "url": "https://github.com/nuwave/lighthouse.git",
4213 - "reference": "4676619e2ddc1b516715885bb32142bd0658b6bd" 4214 + "reference": "77fb645de4d58622a515b5ff7575c3df96e768f1"
4214 }, 4215 },
4215 "dist": { 4216 "dist": {
4216 "type": "zip", 4217 "type": "zip",
4217 - "url": "https://api.github.com/repos/nuwave/lighthouse/zipball/4676619e2ddc1b516715885bb32142bd0658b6bd",  
4218 - "reference": "4676619e2ddc1b516715885bb32142bd0658b6bd", 4218 + "url": "https://api.github.com/repos/nuwave/lighthouse/zipball/77fb645de4d58622a515b5ff7575c3df96e768f1",
  4219 + "reference": "77fb645de4d58622a515b5ff7575c3df96e768f1",
4219 "shasum": "" 4220 "shasum": ""
4220 }, 4221 },
4221 "require": { 4222 "require": {
@@ -4333,7 +4334,7 @@ @@ -4333,7 +4334,7 @@
4333 "type": "tidelift" 4334 "type": "tidelift"
4334 } 4335 }
4335 ], 4336 ],
4336 - "time": "2022-06-22T13:21:15+00:00" 4337 + "time": "2022-07-08T08:50:28+00:00"
4337 }, 4338 },
4338 { 4339 {
4339 "name": "paragonie/constant_time_encoding", 4340 "name": "paragonie/constant_time_encoding",
@@ -4454,16 +4455,16 @@ @@ -4454,16 +4455,16 @@
4454 }, 4455 },
4455 { 4456 {
4456 "name": "phpoffice/phpspreadsheet", 4457 "name": "phpoffice/phpspreadsheet",
4457 - "version": "1.23.0", 4458 + "version": "1.24.0",
4458 "source": { 4459 "source": {
4459 "type": "git", 4460 "type": "git",
4460 "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", 4461 "url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
4461 - "reference": "21e4cf62699eebf007db28775f7d1554e612ed9e" 4462 + "reference": "ebe8745c92a7cac4514d040758393b5399633b83"
4462 }, 4463 },
4463 "dist": { 4464 "dist": {
4464 "type": "zip", 4465 "type": "zip",
4465 - "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/21e4cf62699eebf007db28775f7d1554e612ed9e",  
4466 - "reference": "21e4cf62699eebf007db28775f7d1554e612ed9e", 4466 + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/ebe8745c92a7cac4514d040758393b5399633b83",
  4467 + "reference": "ebe8745c92a7cac4514d040758393b5399633b83",
4467 "shasum": "" 4468 "shasum": ""
4468 }, 4469 },
4469 "require": { 4470 "require": {
@@ -4491,15 +4492,15 @@ @@ -4491,15 +4492,15 @@
4491 }, 4492 },
4492 "require-dev": { 4493 "require-dev": {
4493 "dealerdirect/phpcodesniffer-composer-installer": "dev-master", 4494 "dealerdirect/phpcodesniffer-composer-installer": "dev-master",
4494 - "dompdf/dompdf": "^1.0", 4495 + "dompdf/dompdf": "^1.0 || ^2.0",
4495 "friendsofphp/php-cs-fixer": "^3.2", 4496 "friendsofphp/php-cs-fixer": "^3.2",
4496 "jpgraph/jpgraph": "^4.0", 4497 "jpgraph/jpgraph": "^4.0",
4497 - "mpdf/mpdf": "8.0.17", 4498 + "mpdf/mpdf": "8.1.1",
4498 "phpcompatibility/php-compatibility": "^9.3", 4499 "phpcompatibility/php-compatibility": "^9.3",
4499 "phpstan/phpstan": "^1.1", 4500 "phpstan/phpstan": "^1.1",
4500 "phpstan/phpstan-phpunit": "^1.0", 4501 "phpstan/phpstan-phpunit": "^1.0",
4501 "phpunit/phpunit": "^8.5 || ^9.0", 4502 "phpunit/phpunit": "^8.5 || ^9.0",
4502 - "squizlabs/php_codesniffer": "^3.6", 4503 + "squizlabs/php_codesniffer": "^3.7",
4503 "tecnickcom/tcpdf": "^6.4" 4504 "tecnickcom/tcpdf": "^6.4"
4504 }, 4505 },
4505 "suggest": { 4506 "suggest": {
@@ -4552,9 +4553,9 @@ @@ -4552,9 +4553,9 @@
4552 ], 4553 ],
4553 "support": { 4554 "support": {
4554 "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", 4555 "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
4555 - "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.23.0" 4556 + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.24.0"
4556 }, 4557 },
4557 - "time": "2022-04-24T13:53:10+00:00" 4558 + "time": "2022-07-09T13:49:09+00:00"
4558 }, 4559 },
4559 { 4560 {
4560 "name": "phpoption/phpoption", 4561 "name": "phpoption/phpoption",
@@ -5168,16 +5169,16 @@ @@ -5168,16 +5169,16 @@
5168 }, 5169 },
5169 { 5170 {
5170 "name": "psy/psysh", 5171 "name": "psy/psysh",
5171 - "version": "v0.11.6", 5172 + "version": "v0.11.7",
5172 "source": { 5173 "source": {
5173 "type": "git", 5174 "type": "git",
5174 "url": "https://github.com/bobthecow/psysh.git", 5175 "url": "https://github.com/bobthecow/psysh.git",
5175 - "reference": "3f5b5f8aaa979fbd0d1783173f4c82ad529fe621" 5176 + "reference": "77fc7270031fbc28f9a7bea31385da5c4855cb7a"
5176 }, 5177 },
5177 "dist": { 5178 "dist": {
5178 "type": "zip", 5179 "type": "zip",
5179 - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/3f5b5f8aaa979fbd0d1783173f4c82ad529fe621",  
5180 - "reference": "3f5b5f8aaa979fbd0d1783173f4c82ad529fe621", 5180 + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/77fc7270031fbc28f9a7bea31385da5c4855cb7a",
  5181 + "reference": "77fc7270031fbc28f9a7bea31385da5c4855cb7a",
5181 "shasum": "" 5182 "shasum": ""
5182 }, 5183 },
5183 "require": { 5184 "require": {
@@ -5238,9 +5239,9 @@ @@ -5238,9 +5239,9 @@
5238 ], 5239 ],
5239 "support": { 5240 "support": {
5240 "issues": "https://github.com/bobthecow/psysh/issues", 5241 "issues": "https://github.com/bobthecow/psysh/issues",
5241 - "source": "https://github.com/bobthecow/psysh/tree/v0.11.6" 5242 + "source": "https://github.com/bobthecow/psysh/tree/v0.11.7"
5242 }, 5243 },
5243 - "time": "2022-07-03T16:40:23+00:00" 5244 + "time": "2022-07-07T13:49:11+00:00"
5244 }, 5245 },
5245 { 5246 {
5246 "name": "ralouphie/getallheaders", 5247 "name": "ralouphie/getallheaders",
config/sanctum.php
@@ -60,8 +60,8 @@ return [ @@ -60,8 +60,8 @@ return [
60 */ 60 */
61 61
62 'middleware' => [ 62 'middleware' => [
63 - 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,  
64 - 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 63 + 'verify_csrf_token' => App\Http\Middleware\SkipMiddleware::class,
  64 + 'encrypt_cookies' => App\Http\Middleware\SkipMiddleware::class,
65 ], 65 ],
66 66
67 ]; 67 ];
database/factories/LegacyMenuUserTypeFactory.php 0 → 100644
@@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
  1 +<?php
  2 +
  3 +namespace Database\Factories;
  4 +
  5 +use App\Models\LegacyMenuUserType;
  6 +use App_Model_NivelTipoUsuario;
  7 +use Illuminate\Database\Eloquent\Factories\Factory;
  8 +
  9 +class LegacyMenuUserTypeFactory extends Factory
  10 +{
  11 + protected $model = LegacyMenuUserType::class;
  12 +
  13 + /**
  14 + * Define the model's default state.
  15 + *
  16 + * @return array<string, mixed>
  17 + */
  18 + public function definition()
  19 + {
  20 + return [
  21 + 'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
  22 + [
  23 + 'nivel' => $this->faker->randomElement([
  24 + App_Model_NivelTipoUsuario::POLI_INSTITUCIONAL,
  25 + App_Model_NivelTipoUsuario::INSTITUCIONAL,
  26 + App_Model_NivelTipoUsuario::ESCOLA,
  27 + App_Model_NivelTipoUsuario::BIBLIOTECA
  28 + ]),
  29 + ]
  30 + ),
  31 + 'menu_id' => MenuFactory::new()->create()->getKey(),
  32 + 'cadastra' => 1,
  33 + 'visualiza' => 1,
  34 + 'exclui' => 1,
  35 + ];
  36 + }
  37 +
  38 + public function admin()
  39 + {
  40 + return $this->state(
  41 + [
  42 + 'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
  43 + ['nivel' => App_Model_NivelTipoUsuario::POLI_INSTITUCIONAL]
  44 + )
  45 + ]
  46 + );
  47 + }
  48 +
  49 + public function institutional()
  50 + {
  51 + return $this->state(
  52 + [
  53 + 'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
  54 + ['nivel' => App_Model_NivelTipoUsuario::INSTITUCIONAL]
  55 + )
  56 + ]
  57 + );
  58 + }
  59 +
  60 + public function school()
  61 + {
  62 + return $this->state(
  63 + [
  64 + 'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
  65 + ['nivel' => App_Model_NivelTipoUsuario::ESCOLA]
  66 + )
  67 + ]
  68 + );
  69 + }
  70 +
  71 + public function library()
  72 + {
  73 + return $this->state(
  74 + [
  75 + 'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
  76 + ['nivel' => App_Model_NivelTipoUsuario::ESCOLA]
  77 + )
  78 + ]
  79 + );
  80 + }
  81 +}
database/factories/LegacyUserFactory.php
@@ -37,6 +37,17 @@ class LegacyUserFactory extends Factory @@ -37,6 +37,17 @@ class LegacyUserFactory extends Factory
37 ]; 37 ];
38 } 38 }
39 39
  40 + public function admin(): static
  41 + {
  42 + return $this->state([
  43 + 'ref_cod_tipo_usuario' => function () {
  44 + return LegacyUserTypeFactory::new()->create([
  45 + 'nivel' => 1,
  46 + ]);
  47 + },
  48 + ]);
  49 + }
  50 +
40 public function unique() 51 public function unique()
41 { 52 {
42 return $this->state(function () { 53 return $this->state(function () {
@@ -53,4 +64,20 @@ class LegacyUserFactory extends Factory @@ -53,4 +64,20 @@ class LegacyUserFactory extends Factory
53 ]; 64 ];
54 }); 65 });
55 } 66 }
  67 +
  68 + public function withAccess($process, $view = true, $modify = true, $remove = true): static
  69 + {
  70 + return $this->afterCreating(function (LegacyUser $user) use ($process, $view, $modify, $remove) {
  71 + $menu = MenuFactory::new()->create(
  72 + ['process' => $process]
  73 + );
  74 + LegacyMenuUserTypeFactory::new()->create([
  75 + 'menu_id' => $menu,
  76 + 'ref_cod_tipo_usuario' => $user->type,
  77 + 'cadastra' => $modify,
  78 + 'visualiza' => $view,
  79 + 'exclui' => $remove,
  80 + ]);
  81 + });
  82 + }
56 } 83 }
database/factories/MenuFactory.php 0 → 100644
@@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
  1 +<?php
  2 +
  3 +namespace Database\Factories;
  4 +
  5 +use App\Menu;
  6 +use Illuminate\Database\Eloquent\Factories\Factory;
  7 +
  8 +class MenuFactory extends Factory
  9 +{
  10 + protected $model = Menu::class;
  11 +
  12 + /**
  13 + * Define the model's default state.
  14 + *
  15 + * @return array<string, mixed>
  16 + */
  17 + public function definition()
  18 + {
  19 + return [
  20 + 'parent_id' => null,
  21 + 'title' => $this->faker->colorName(),
  22 + 'description' => $this->faker->name(),
  23 + 'link' => $this->faker->filePath(),
  24 + 'icon' => $this->faker->imageUrl(),
  25 + 'order'=> $this->faker->randomDigitNotZero(),
  26 + 'type' => $this->faker->randomDigitNotZero(),
  27 + 'parent_old' => null,
  28 + 'old' => null,
  29 + 'process' => $this->faker->randomDigitNotZero(),
  30 + 'active' => true,
  31 + ];
  32 + }
  33 +}
database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php 0 → 100644
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
  1 +<?php
  2 +
  3 +use Illuminate\Database\Migrations\Migration;
  4 +use Illuminate\Database\Schema\Blueprint;
  5 +use Illuminate\Support\Facades\Schema;
  6 +
  7 +class CreatePersonalAccessTokensTable extends Migration
  8 +{
  9 + /**
  10 + * Run the migrations.
  11 + *
  12 + * @return void
  13 + */
  14 + public function up()
  15 + {
  16 + Schema::create('personal_access_tokens', function (Blueprint $table) {
  17 + $table->bigIncrements('id');
  18 + $table->morphs('tokenable');
  19 + $table->string('name');
  20 + $table->string('token', 64)->unique();
  21 + $table->text('abilities')->nullable();
  22 + $table->timestamp('last_used_at')->nullable();
  23 + $table->timestamps();
  24 + });
  25 + }
  26 +
  27 + /**
  28 + * Reverse the migrations.
  29 + *
  30 + * @return void
  31 + */
  32 + public function down()
  33 + {
  34 + Schema::dropIfExists('personal_access_tokens');
  35 + }
  36 +}
database/migrations/2022_06_29_133818_update_cities.php 0 → 100644
@@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
  1 +<?php
  2 +
  3 +use App\Models\City;
  4 +use App\Models\State;
  5 +use Illuminate\Database\Migrations\Migration;
  6 +
  7 +return new class () extends Migration {
  8 + public function up()
  9 + {
  10 + //Comparação realizada com o seeder original
  11 +
  12 + //Atualização. Não possuem ibge_code e os nomes estão diferentes.
  13 + $this->createOrUpdate('MA', 'Pindaré-Mirim', '2108504', 'Pindare Mirim');
  14 + $this->createOrUpdate('PI', 'Aroeiras do Itaim', '2200954', 'Aroeira do Itaim');
  15 + $this->createOrUpdate('PE', 'Belém do São Francisco', '2601607', 'Belem de Sao Francisco');
  16 + $this->createOrUpdate('PE', 'Lagoa de Itaenga', '2608503', 'Lagoa do Itaenga');
  17 + $this->createOrUpdate('MG', 'Brazópolis', '3108909', 'Brasopolis');
  18 + $this->createOrUpdate('MG', 'Pingo-d\'Água', '3150539', 'Pingo D Agua');
  19 + $this->createOrUpdate('MG', 'Sem-Peixe', '3165560', 'Sem Peixe');
  20 + $this->createOrUpdate('MG', 'Tocos do Moji', '3169059', 'Tocos do Mogi');
  21 + $this->createOrUpdate('RJ', 'Paraty', '3303807', 'Parati');
  22 + $this->createOrUpdate('RJ', 'Trajano de Moraes', '3305901', 'Trajano de Morais');
  23 + $this->createOrUpdate('PR', 'Bela Vista da Caroba', '4102752', 'Bela Vista do Caroba');
  24 + $this->createOrUpdate('MS', 'Batayporã', '5002001', 'Bataipora');
  25 +
  26 + //Novos
  27 + $this->createOrUpdate('AM', 'Itacoatiara', '1301902');
  28 + $this->createOrUpdate('BA', 'Barro Preto', '2903300');
  29 + $this->createOrUpdate('CE', 'Itapajé', '2306306');
  30 + $this->createOrUpdate('MS', 'Paraíso das Águas', '5006275');
  31 + $this->createOrUpdate('MT', 'Curvelândia', '5103437');
  32 + $this->createOrUpdate('PA', 'Mojuí dos Campos', '1504752');
  33 + $this->createOrUpdate('PA', 'Santa Izabel do Pará', '1506500');
  34 + $this->createOrUpdate('PB', 'Joca Claudino', '2513653');
  35 + $this->createOrUpdate('PB', 'São Domingos', '2513968');
  36 + $this->createOrUpdate('PB', 'Tacima', '2516409');
  37 + $this->createOrUpdate('PE', 'Ilha de Itamaracá', '2607604');
  38 + $this->createOrUpdate('PR', 'Goioerê', '4108601');
  39 + $this->createOrUpdate('RN', 'Serra Caiada', '2410306');
  40 + $this->createOrUpdate('RS', 'Pinto Bandeira', '4314548');
  41 + $this->createOrUpdate('SC', 'Garopaba', '4205704');
  42 + $this->createOrUpdate('SC', 'Pescaria Brava', '4212650');
  43 + $this->createOrUpdate('SC', 'Balneário Rincão', '4220000');
  44 + $this->createOrUpdate('SP', 'Embu das Artes', '3515004');
  45 + $this->createOrUpdate('TO', 'Couto Magalhães', '1706001');
  46 + $this->createOrUpdate('TO', 'São Valério', '1720499');
  47 + }
  48 +
  49 + public function createOrUpdate($state_abbreviation, $name, $ibge_code, $old_name = null)
  50 + {
  51 + //verifica se o codigo ibge já existe
  52 + if (City::where('ibge_code', $ibge_code)->exists()) {
  53 + return;
  54 + }
  55 +
  56 + //atualiza ibge_code e nome, se a cidade estiver cadastrada sem o ibge_code
  57 + $city = City::whereRaw('unaccent(name) ILIKE unaccent(?)', $old_name ?? $name)->whereHas('state', fn ($q) => $q->where('abbreviation', $state_abbreviation))->whereNull('ibge_code')->first();
  58 +
  59 + if ($city) {
  60 + $city->update(['ibge_code' => $ibge_code, 'name' => $name]);
  61 +
  62 + return;
  63 + }
  64 +
  65 + //cria a cidade
  66 + if ($state_id = State::where('abbreviation', $state_abbreviation)->value('id')) {
  67 + City::create(compact('state_id', 'name', 'ibge_code'));
  68 + }
  69 + }
  70 +
  71 + public function down()
  72 + {
  73 + }
  74 +};
database/migrations/2022_07_06_102852_change_orgao_regional_column_type.php 0 → 100755
@@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
  1 +<?php
  2 +
  3 +use Illuminate\Database\Migrations\Migration;
  4 +use Illuminate\Database\Schema\Blueprint;
  5 +use Illuminate\Support\Facades\Schema;
  6 +
  7 +return new class () extends Migration {
  8 + /**
  9 + * Run the migrations.
  10 + *
  11 + * @return void
  12 + */
  13 + public function up()
  14 + {
  15 + Schema::table('pmieducar.instituicao', function (Blueprint $table) {
  16 + $table->string('orgao_regional', 5)->change();
  17 + });
  18 + }
  19 +
  20 + /**
  21 + * Reverse the migrations.
  22 + *
  23 + * @return void
  24 + */
  25 + public function down()
  26 + {
  27 + Schema::table('pmieducar.instituicao', function (Blueprint $table) {
  28 + $table->integer('orgao_regional')->change();
  29 + });
  30 + }
  31 +};
ieducar/intranet/educar_escola_cad.php
@@ -8,24 +8,25 @@ use App\Rules\SchoolManagerAtLeastOneChief; @@ -8,24 +8,25 @@ use App\Rules\SchoolManagerAtLeastOneChief;
8 use App\Rules\SchoolManagerUniqueIndividuals; 8 use App\Rules\SchoolManagerUniqueIndividuals;
9 use App\Services\SchoolManagerService; 9 use App\Services\SchoolManagerService;
10 use iEducar\Modules\Addressing\LegacyAddressingFields; 10 use iEducar\Modules\Addressing\LegacyAddressingFields;
  11 +use iEducar\Modules\Educacenso\Model\AbastecimentoAgua;
11 use iEducar\Modules\Educacenso\Model\AreasExternas; 12 use iEducar\Modules\Educacenso\Model\AreasExternas;
12 use iEducar\Modules\Educacenso\Model\Banheiros; 13 use iEducar\Modules\Educacenso\Model\Banheiros;
13 use iEducar\Modules\Educacenso\Model\DependenciaAdministrativaEscola; 14 use iEducar\Modules\Educacenso\Model\DependenciaAdministrativaEscola;
14 use iEducar\Modules\Educacenso\Model\Dormitorios; 15 use iEducar\Modules\Educacenso\Model\Dormitorios;
15 use iEducar\Modules\Educacenso\Model\Equipamentos; 16 use iEducar\Modules\Educacenso\Model\Equipamentos;
16 use iEducar\Modules\Educacenso\Model\EquipamentosAcessoInternet; 17 use iEducar\Modules\Educacenso\Model\EquipamentosAcessoInternet;
17 -use iEducar\Modules\Educacenso\Model\EsferaAdministrativa; 18 +use iEducar\Modules\Educacenso\Model\EsgotamentoSanitario;
  19 +use iEducar\Modules\Educacenso\Model\FonteEnergia;
18 use iEducar\Modules\Educacenso\Model\InstrumentosPedagogicos; 20 use iEducar\Modules\Educacenso\Model\InstrumentosPedagogicos;
19 use iEducar\Modules\Educacenso\Model\Laboratorios; 21 use iEducar\Modules\Educacenso\Model\Laboratorios;
20 use iEducar\Modules\Educacenso\Model\LocalFuncionamento; 22 use iEducar\Modules\Educacenso\Model\LocalFuncionamento;
21 use iEducar\Modules\Educacenso\Model\LocalizacaoDiferenciadaEscola; 23 use iEducar\Modules\Educacenso\Model\LocalizacaoDiferenciadaEscola;
22 use iEducar\Modules\Educacenso\Model\MantenedoraDaEscolaPrivada; 24 use iEducar\Modules\Educacenso\Model\MantenedoraDaEscolaPrivada;
23 -use iEducar\Modules\Educacenso\Model\OrganizacaoEnsino;  
24 use iEducar\Modules\Educacenso\Model\OrgaosColegiados; 25 use iEducar\Modules\Educacenso\Model\OrgaosColegiados;
25 use iEducar\Modules\Educacenso\Model\OrgaoVinculadoEscola; 26 use iEducar\Modules\Educacenso\Model\OrgaoVinculadoEscola;
  27 +use iEducar\Modules\Educacenso\Model\PoderPublicoConveniado;
26 use iEducar\Modules\Educacenso\Model\RecursosAcessibilidade; 28 use iEducar\Modules\Educacenso\Model\RecursosAcessibilidade;
27 use iEducar\Modules\Educacenso\Model\RedeLocal; 29 use iEducar\Modules\Educacenso\Model\RedeLocal;
28 -use iEducar\Modules\Educacenso\Model\Regulamentacao;  
29 use iEducar\Modules\Educacenso\Model\ReservaVagasCotas; 30 use iEducar\Modules\Educacenso\Model\ReservaVagasCotas;
30 use iEducar\Modules\Educacenso\Model\SalasAtividades; 31 use iEducar\Modules\Educacenso\Model\SalasAtividades;
31 use iEducar\Modules\Educacenso\Model\SalasFuncionais; 32 use iEducar\Modules\Educacenso\Model\SalasFuncionais;
@@ -1542,8 +1543,6 @@ return new class extends clsCadastro { @@ -1542,8 +1543,6 @@ return new class extends clsCadastro {
1542 $obj_permissoes->permissao_cadastra(561, $this->pessoa_logada, 3, 'educar_escola_lst.php'); 1543 $obj_permissoes->permissao_cadastra(561, $this->pessoa_logada, 3, 'educar_escola_lst.php');
1543 $this->pesquisaPessoaJuridica = false; 1544 $this->pesquisaPessoaJuridica = false;
1544 1545
1545 - $this->preparaDados();  
1546 -  
1547 if (!$this->validaCnpjMantenedora()) { 1546 if (!$this->validaCnpjMantenedora()) {
1548 return false; 1547 return false;
1549 } 1548 }
@@ -1579,14 +1578,6 @@ return new class extends clsCadastro { @@ -1579,14 +1578,6 @@ return new class extends clsCadastro {
1579 return false; 1578 return false;
1580 } 1579 }
1581 1580
1582 - if (!$this->validaCampoEquipamentos()) {  
1583 - return false;  
1584 - }  
1585 -  
1586 - if (!$this->validaInstrumentosPedagogicos()) {  
1587 - return false;  
1588 - }  
1589 -  
1590 if (! isset($this->pessoaj_id_oculto) || 1581 if (! isset($this->pessoaj_id_oculto) ||
1591 ! is_int((int)$this->pessoaj_id_oculto) 1582 ! is_int((int)$this->pessoaj_id_oculto)
1592 ) { 1583 ) {
@@ -1594,6 +1585,8 @@ return new class extends clsCadastro { @@ -1594,6 +1585,8 @@ return new class extends clsCadastro {
1594 return false; 1585 return false;
1595 } 1586 }
1596 1587
  1588 + $this->preparaDados();
  1589 +
1597 $pessoaJuridica = (new clsJuridica((int)$this->pessoaj_id_oculto))->detalhe(); 1590 $pessoaJuridica = (new clsJuridica((int)$this->pessoaj_id_oculto))->detalhe();
1598 1591
1599 if ($pessoaJuridica === false) { 1592 if ($pessoaJuridica === false) {
@@ -1857,8 +1850,6 @@ return new class extends clsCadastro { @@ -1857,8 +1850,6 @@ return new class extends clsCadastro {
1857 $obj_permissoes->permissao_cadastra(561, $this->pessoa_logada, 7, 'educar_escola_lst.php'); 1850 $obj_permissoes->permissao_cadastra(561, $this->pessoa_logada, 7, 'educar_escola_lst.php');
1858 $this->pesquisaPessoaJuridica = false; 1851 $this->pesquisaPessoaJuridica = false;
1859 1852
1860 - $this->preparaDados();  
1861 -  
1862 if (!$this->validaCnpjMantenedora()) { 1853 if (!$this->validaCnpjMantenedora()) {
1863 return false; 1854 return false;
1864 } 1855 }
@@ -1894,13 +1885,7 @@ return new class extends clsCadastro { @@ -1894,13 +1885,7 @@ return new class extends clsCadastro {
1894 return false; 1885 return false;
1895 } 1886 }
1896 1887
1897 - if (!$this->validaCampoEquipamentos()) {  
1898 - return false;  
1899 - }  
1900 -  
1901 - if (!$this->validaInstrumentosPedagogicos()) {  
1902 - return false;  
1903 - } 1888 + $this->preparaDados();
1904 1889
1905 $this->bloquear_lancamento_diario_anos_letivos_encerrados = is_null($this->bloquear_lancamento_diario_anos_letivos_encerrados) ? 0 : 1; 1890 $this->bloquear_lancamento_diario_anos_letivos_encerrados = is_null($this->bloquear_lancamento_diario_anos_letivos_encerrados) ? 0 : 1;
1906 $this->utiliza_regra_diferenciada = !is_null($this->utiliza_regra_diferenciada); 1891 $this->utiliza_regra_diferenciada = !is_null($this->utiliza_regra_diferenciada);
@@ -1962,17 +1947,6 @@ return new class extends clsCadastro { @@ -1962,17 +1947,6 @@ return new class extends clsCadastro {
1962 ); 1947 );
1963 } 1948 }
1964 1949
1965 - protected function validaCampoEquipamentos()  
1966 - {  
1967 - $dadosEquipamentos = transformStringFromDBInArray($this->equipamentos);  
1968 -  
1969 - if (is_array($dadosEquipamentos) && count($dadosEquipamentos) > 1 && in_array(Equipamentos::NENHUM_EQUIPAMENTO_LISTADO, $dadosEquipamentos)) {  
1970 - $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Equipamentos da escola</b>, quando a opção: <b>Nenhum dos equipamentos listados</b> estiver selecionada.';  
1971 - return false;  
1972 - }  
1973 - return true;  
1974 - }  
1975 -  
1976 protected function inputTelefone($type, $typeLabel = '') 1950 protected function inputTelefone($type, $typeLabel = '')
1977 { 1951 {
1978 if (!$typeLabel) { 1952 if (!$typeLabel) {
@@ -2024,16 +1998,14 @@ return new class extends clsCadastro { @@ -2024,16 +1998,14 @@ return new class extends clsCadastro {
2024 $this->validaQuantidadeComputadoresAlunos() && 1998 $this->validaQuantidadeComputadoresAlunos() &&
2025 $this->validaQuantidadeEquipamentosEnsino() && 1999 $this->validaQuantidadeEquipamentosEnsino() &&
2026 $this->validaLinguasIndigenas() && 2000 $this->validaLinguasIndigenas() &&
2027 - $this->validaPoderPublicoParceriaConvenio() &&  
2028 $this->validaFormasDeContratacaoEntreAdministracaoPublicaEOutrasInstituicoes() && 2001 $this->validaFormasDeContratacaoEntreAdministracaoPublicaEOutrasInstituicoes() &&
2029 - $this->validaMatriculasAtendidasPorConvenio() &&  
2030 - $this->validaLinguasIndigenas() 2002 + $this->validaMatriculasAtendidasPorConvenio()
2031 ; 2003 ;
2032 } 2004 }
2033 2005
2034 protected function validaFormasDeContratacaoEntreAdministracaoPublicaEOutrasInstituicoes(): bool 2006 protected function validaFormasDeContratacaoEntreAdministracaoPublicaEOutrasInstituicoes(): bool
2035 { 2007 {
2036 - $formasDeContratacao = transformStringFromDBInArray($this->formas_contratacao_adm_publica_e_outras_instituicoes); 2008 + $formasDeContratacao = $this->formas_contratacao_adm_publica_e_outras_instituicoes;
2037 2009
2038 $acceptDependenciaAdministrativa = [DependenciaAdministrativaEscola::FEDERAL, DependenciaAdministrativaEscola::ESTADUAL, DependenciaAdministrativaEscola::MUNICIPAL]; 2010 $acceptDependenciaAdministrativa = [DependenciaAdministrativaEscola::FEDERAL, DependenciaAdministrativaEscola::ESTADUAL, DependenciaAdministrativaEscola::MUNICIPAL];
2039 $notAcceptFormasDeContratoInDependenciaAdministrativa = [1, 2, 3, 4]; 2011 $notAcceptFormasDeContratoInDependenciaAdministrativa = [1, 2, 3, 4];
@@ -2079,20 +2051,6 @@ return new class extends clsCadastro { @@ -2079,20 +2051,6 @@ return new class extends clsCadastro {
2079 return true; 2051 return true;
2080 } 2052 }
2081 2053
2082 - protected function validaInstrumentosPedagogicos()  
2083 - {  
2084 - $dadosInstrumentosPedagogicos = transformStringFromDBInArray($this->instrumentos_pedagogicos);  
2085 -  
2086 - if (is_array($dadosInstrumentosPedagogicos) &&  
2087 - count($dadosInstrumentosPedagogicos) > 1 &&  
2088 - in_array(InstrumentosPedagogicos::NENHUM_DOS_INSTRUMENTOS_LISTADOS, $dadosInstrumentosPedagogicos)) {  
2089 - $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Instrumentos, materiais socioculturais e/ou pedagógicos em uso na escola para o desenvolvimento de atividades de ensino aprendizagem</b>, quando a opção: <b>Nenhum dos instrumentos listados</b> estiver selecionada.';  
2090 - return false;  
2091 - }  
2092 -  
2093 - return true;  
2094 - }  
2095 -  
2096 protected function validaOcupacaoPredio() 2054 protected function validaOcupacaoPredio()
2097 { 2055 {
2098 if (is_array($this->local_funcionamento) && in_array(LocalFuncionamento::PREDIO_ESCOLAR, $this->local_funcionamento) && empty($this->condicao)) { 2056 if (is_array($this->local_funcionamento) && in_array(LocalFuncionamento::PREDIO_ESCOLAR, $this->local_funcionamento) && empty($this->condicao)) {
@@ -2587,19 +2545,25 @@ return new class extends clsCadastro { @@ -2587,19 +2545,25 @@ return new class extends clsCadastro {
2587 2545
2588 protected function validaOpcoesUnicasMultipleSearch() 2546 protected function validaOpcoesUnicasMultipleSearch()
2589 { 2547 {
2590 - if (is_array($this->abastecimento_agua) && in_array(5, $this->abastecimento_agua) && count($this->abastecimento_agua) > 1) { 2548 + if (is_array($this->poder_publico_parceria_convenio) && in_array(PoderPublicoConveniado::NAO_POSSUI, $this->poder_publico_parceria_convenio) && count($this->poder_publico_parceria_convenio) > 1) {
  2549 + $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Poder público responsável pela parceria ou convênio entre a Administração Pública e outras instituições</b>, quando a opção: <b>Não possui parceria ou convênio</b> estiver selecionada.';
  2550 +
  2551 + return false;
  2552 + }
  2553 +
  2554 + if (is_array($this->abastecimento_agua) && in_array(AbastecimentoAgua::INEXISTENTE, $this->abastecimento_agua) && count($this->abastecimento_agua) > 1) {
2591 $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Abastecimento de água</b>, quando a opção: <b>Não há abastecimento de água</b> estiver selecionada.'; 2555 $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Abastecimento de água</b>, quando a opção: <b>Não há abastecimento de água</b> estiver selecionada.';
2592 2556
2593 return false; 2557 return false;
2594 } 2558 }
2595 2559
2596 - if (is_array($this->abastecimento_energia) && in_array(4, $this->abastecimento_energia) && count($this->abastecimento_energia) > 1) { 2560 + if (is_array($this->abastecimento_energia) && in_array(FonteEnergia::INEXISTENTE, $this->abastecimento_energia) && count($this->abastecimento_energia) > 1) {
2597 $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Fonte de energia elétrica</b>, quando a opção: <b>Não há energia elétrica</b> estiver selecionada.'; 2561 $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Fonte de energia elétrica</b>, quando a opção: <b>Não há energia elétrica</b> estiver selecionada.';
2598 2562
2599 return false; 2563 return false;
2600 } 2564 }
2601 2565
2602 - if (is_array($this->esgoto_sanitario) && in_array(3, $this->esgoto_sanitario) && count($this->esgoto_sanitario) > 1) { 2566 + if (is_array($this->esgoto_sanitario) && in_array(EsgotamentoSanitario::INEXISTENTE, $this->esgoto_sanitario) && count($this->esgoto_sanitario) > 1) {
2603 $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Esgotamento sanitário</b>, quando a opção: <b>Não há esgotamento sanitário</b> estiver selecionada.'; 2567 $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Esgotamento sanitário</b>, quando a opção: <b>Não há esgotamento sanitário</b> estiver selecionada.';
2604 2568
2605 return false; 2569 return false;
@@ -2617,37 +2581,14 @@ return new class extends clsCadastro { @@ -2617,37 +2581,14 @@ return new class extends clsCadastro {
2617 return false; 2581 return false;
2618 } 2582 }
2619 2583
2620 - if (is_array($this->uso_internet) && in_array(UsoInternet::NAO_POSSUI, $this->uso_internet) && count($this->uso_internet) > 1) {  
2621 - $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Acesso à internet</b>, quando a opção: <b>Não possui acesso à internet</b> estiver selecionada.';  
2622 -  
2623 - return false;  
2624 - }  
2625 - if (is_array($this->abastecimento_agua) && in_array(5, $this->abastecimento_agua) && count($this->abastecimento_agua) > 1) {  
2626 - $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Abastecimento de água</b>, quando a opção: <b>Não há abastecimento de água</b> estiver selecionada.';  
2627 -  
2628 - return false;  
2629 - }  
2630 -  
2631 - if (is_array($this->abastecimento_energia) && in_array(4, $this->abastecimento_energia) && count($this->abastecimento_energia) > 1) {  
2632 - $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Fonte de energia elétrica</b>, quando a opção: <b>Não há energia elétrica</b> estiver selecionada.';  
2633 -  
2634 - return false;  
2635 - }  
2636 -  
2637 - if (is_array($this->esgoto_sanitario) && in_array(3, $this->esgoto_sanitario) && count($this->esgoto_sanitario) > 1) {  
2638 - $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Esgotamento sanitário</b>, quando a opção: <b>Não há esgotamento sanitário</b> estiver selecionada.';  
2639 -  
2640 - return false;  
2641 - }  
2642 -  
2643 - if (is_array($this->tratamento_lixo) && in_array(TratamentoLixo::NAO_FAZ, $this->tratamento_lixo) && count($this->tratamento_lixo) > 1) {  
2644 - $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Tratamento do lixo/resíduos que a escola realiza</b>, quando a opção: <b>Não faz tratamento</b> estiver selecionada'; 2584 + if (is_array($this->equipamentos) && in_array(Equipamentos::NENHUM_EQUIPAMENTO_LISTADO, $this->equipamentos) && count($this->equipamentos) > 1) {
  2585 + $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Equipamentos da escola</b>, quando a opção: <b>Nenhum dos equipamentos listados</b> estiver selecionada.';
2645 2586
2646 return false; 2587 return false;
2647 } 2588 }
2648 2589
2649 - if (is_array($this->recursos_acessibilidade) && in_array(RecursosAcessibilidade::NENHUM, $this->recursos_acessibilidade) && count($this->recursos_acessibilidade) > 1) {  
2650 - $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Recursos de acessibilidade</b>, quando a opção: <b>Nenhum dos recursos de acessibilidade</b> estiver selecionada.'; 2590 + if (is_array($this->rede_local) && in_array(RedeLocal::NENHUMA, $this->rede_local) && count($this->rede_local) > 1) {
  2591 + $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Rede local de interligação de computadores</b>, quando a opção: <b>Não há rede local interligando computadores</b> estiver selecionada.';
2651 2592
2652 return false; 2593 return false;
2653 } 2594 }
@@ -2671,13 +2612,21 @@ return new class extends clsCadastro { @@ -2671,13 +2612,21 @@ return new class extends clsCadastro {
2671 return false; 2612 return false;
2672 } 2613 }
2673 2614
  2615 + if (is_array($this->instrumentos_pedagogicos) && in_array(InstrumentosPedagogicos::NENHUM_DOS_INSTRUMENTOS_LISTADOS, $this->instrumentos_pedagogicos) && count($this->instrumentos_pedagogicos) > 1) {
  2616 + $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Instrumentos, materiais socioculturais e/ou pedagógicos em uso na escola para o desenvolvimento de atividades de ensino aprendizagem</b>, quando a opção: <b>Nenhum dos instrumentos listados</b> estiver selecionada.';
  2617 +
  2618 + return false;
  2619 + }
  2620 +
2674 return true; 2621 return true;
2675 } 2622 }
2676 2623
2677 protected function validaEquipamentosAcessoInternet() 2624 protected function validaEquipamentosAcessoInternet()
2678 { 2625 {
2679 - if (!is_array($this->equipamentos_acesso_internet) && !is_array($this->rede_local)) {  
2680 - return true; 2626 + if (is_array($this->equipamentos_acesso_internet) && in_array(2, $this->equipamentos_acesso_internet) &&
  2627 + is_array($this->rede_local) && !in_array(3, $this->rede_local)) {
  2628 + $this->mensagem = "O campo: <b>Equipamentos que os aluno(a)s usam para acessar a internet da escola</b> não deve ser preenchido com a opção: <b>Dispositivos pessoais (computadores portáteis, celulares, tablets, etc.)</b> quando o campo: <b>Rede local de interligação de computadores</b> não possuir a opção: <b>Wireless</b> selecionada.";
  2629 + return false;
2681 } 2630 }
2682 2631
2683 return true; 2632 return true;
@@ -2709,13 +2658,11 @@ return new class extends clsCadastro { @@ -2709,13 +2658,11 @@ return new class extends clsCadastro {
2709 2658
2710 protected function validaMatriculasAtendidasPorConvenio() 2659 protected function validaMatriculasAtendidasPorConvenio()
2711 { 2660 {
2712 - $poderPulicoParceriaConvenio = transformStringFromDBInArray($this->poder_publico_parceria_convenio);  
2713 -  
2714 - if ($poderPulicoParceriaConvenio === null) { 2661 + if ($this->poder_publico_parceria_convenio === null) {
2715 return true; 2662 return true;
2716 } 2663 }
2717 2664
2718 - if (!in_array(1, $poderPulicoParceriaConvenio) && !in_array(2, $poderPulicoParceriaConvenio)){ 2665 + if (!in_array(1, $this->poder_publico_parceria_convenio) && !in_array(2, $this->poder_publico_parceria_convenio)){
2719 return true; 2666 return true;
2720 } 2667 }
2721 2668
@@ -2839,23 +2786,6 @@ return new class extends clsCadastro { @@ -2839,23 +2786,6 @@ return new class extends clsCadastro {
2839 return true; 2786 return true;
2840 } 2787 }
2841 2788
2842 - private function validaPoderPublicoParceriaConvenio()  
2843 - {  
2844 - $values = transformStringFromDBInArray($this->poder_publico_parceria_convenio);  
2845 -  
2846 - if ($values === null) {  
2847 - return true;  
2848 - }  
2849 -  
2850 - if (count($values) > 1 && in_array(3, $values)) {  
2851 - $this->mensagem = 'Não é possível informar mais de uma opção no campo: <b>Poder público responsável pela parceria ou convênio entre a Administração Pública e outras instituições</b>, quando a opção: <b>Não possui parceria ou convênio</b> estiver selecionada.';  
2852 -  
2853 - return false;  
2854 - }  
2855 -  
2856 - return true;  
2857 - }  
2858 -  
2859 public function Formular() 2789 public function Formular()
2860 { 2790 {
2861 $this->title = 'Escola'; 2791 $this->title = 'Escola';
ieducar/intranet/educar_instituicao_cad.php
@@ -153,7 +153,7 @@ return new class extends clsCadastro { @@ -153,7 +153,7 @@ return new class extends clsCadastro {
153 false 153 false
154 ); 154 );
155 foreach ($orgaosRegionais as $orgaoRegional) { 155 foreach ($orgaosRegionais as $orgaoRegional) {
156 - $opcoes[$orgaoRegional->codigo] = $orgaoRegional->codigo; 156 + $opcoes[strtoupper($orgaoRegional->codigo)] = strtoupper($orgaoRegional->codigo);
157 } 157 }
158 } else { 158 } else {
159 $opcoes = [null => 'Informe uma UF']; 159 $opcoes = [null => 'Informe uma UF'];
ieducar/intranet/educar_matricula_det.php
@@ -196,15 +196,28 @@ return new class extends clsDetalhe { @@ -196,15 +196,28 @@ return new class extends clsDetalhe {
196 $existeAtendimentoEspecializado = true; 196 $existeAtendimentoEspecializado = true;
197 } 197 }
198 198
199 - $nomesTurnos[] = match ((int)$enturmacao['turno_id']) { 199 + if ($enturmacao['turno_id']) {
  200 + $nomesTurnos[] = match ((int)$enturmacao['turno_id']) {
  201 + clsPmieducarTurma::TURNO_MATUTINO => 'Matutino',
  202 + clsPmieducarTurma::TURNO_VESPERTINO => 'Vespertino',
  203 + default => null
  204 + };
  205 + }
  206 + }
  207 + $nomesTurmas = implode('<br />', $nomesTurmas);
  208 + $datasEnturmacoes = implode('<br />', $datasEnturmacoes);
  209 +
  210 + if (empty($nomesTurnos)) {
  211 + $nomesTurnos = match ((int)$turma['turma_turno_id']) {
200 clsPmieducarTurma::TURNO_MATUTINO => 'Matutino', 212 clsPmieducarTurma::TURNO_MATUTINO => 'Matutino',
201 clsPmieducarTurma::TURNO_VESPERTINO => 'Vespertino', 213 clsPmieducarTurma::TURNO_VESPERTINO => 'Vespertino',
202 - default => 'Integral', 214 + clsPmieducarTurma::TURNO_NOTURNO => 'Noturno',
  215 + clsPmieducarTurma::TURNO_INTEGRAL => 'Integral',
  216 + default => null
203 }; 217 };
  218 + } else {
  219 + $nomesTurnos = implode('<br />', $nomesTurnos);
204 } 220 }
205 - $nomesTurmas = implode('<br />', $nomesTurmas);  
206 - $datasEnturmacoes = implode('<br />', $datasEnturmacoes);  
207 - $nomesTurnos = implode('<br />', $nomesTurnos);  
208 221
209 if ($nomesTurmas) { 222 if ($nomesTurmas) {
210 $this->addDetalhe(['Turma', $nomesTurmas]); 223 $this->addDetalhe(['Turma', $nomesTurmas]);
ieducar/intranet/educar_matricula_turma_tipo_aee_cad.php
@@ -76,7 +76,7 @@ return new class extends clsCadastro { @@ -76,7 +76,7 @@ return new class extends clsCadastro {
76 76
77 foreach ($arrayTipoAtendimento as $data) { 77 foreach ($arrayTipoAtendimento as $data) {
78 $obj = new clsPmieducarMatriculaTurma($this->cod_matricula, $data['turma'], $this->pessoa_logada); 78 $obj = new clsPmieducarMatriculaTurma($this->cod_matricula, $data['turma'], $this->pessoa_logada);
79 - $tipoAtendimento = implode(',', $data['value']); 79 + $tipoAtendimento = $data['value'] ? implode(',', $data['value']) : null;
80 $obj->sequencial = $data['sequencial']; 80 $obj->sequencial = $data['sequencial'];
81 $obj->tipo_atendimento = $tipoAtendimento; 81 $obj->tipo_atendimento = $tipoAtendimento;
82 $obj->edita(); 82 $obj->edita();
ieducar/intranet/include/pessoa/clsPessoaTelefone.inc.php
@@ -31,8 +31,10 @@ class clsPessoaTelefone @@ -31,8 +31,10 @@ class clsPessoaTelefone
31 // Verifica se ja existe um telefone desse tipo cadastrado para essa pessoa 31 // Verifica se ja existe um telefone desse tipo cadastrado para essa pessoa
32 if (!$db->numLinhas()) { 32 if (!$db->numLinhas()) {
33 // nao tem, cadastra 1 novo 33 // nao tem, cadastra 1 novo
34 - if ($this->ddd && $this->fone) {  
35 - $db->Consulta("INSERT INTO {$this->schema_cadastro}.{$this->tabela_telefone} (idpes, tipo, ddd, fone,origem_gravacao, data_cad, operacao, idpes_cad) VALUES ('$this->idpes', '$this->tipo', '$this->ddd', '$this->fone','M', NOW(), 'I', '$this->idpes_cad')"); 34 + if (!empty($this->ddd) && !empty($this->fone)) {
  35 + $ddd = preg_replace('/\D/', '', $this->ddd);
  36 + $fone = preg_replace('/\D/', '', $this->fone);
  37 + $db->Consulta("INSERT INTO {$this->schema_cadastro}.{$this->tabela_telefone} (idpes, tipo, ddd, fone,origem_gravacao, data_cad, operacao, idpes_cad) VALUES ('$this->idpes', '$this->tipo', '$ddd', '$fone','M', NOW(), 'I', '$this->idpes_cad')");
36 38
37 return true; 39 return true;
38 } 40 }
ieducar/modules/Api/Views/DiarioController.php
@@ -19,7 +19,7 @@ class DiarioController extends ApiCoreController @@ -19,7 +19,7 @@ class DiarioController extends ApiCoreController
19 return App_Model_IedFinder::getComponentesPorMatricula($matriculaId); 19 return App_Model_IedFinder::getComponentesPorMatricula($matriculaId);
20 } 20 }
21 21
22 - protected function getComponentesPorTurma($turmaId) 22 + protected function getComponentesPorTurma($turmaId,$matriculaId = null)
23 { 23 {
24 $objTurma = new clsPmieducarTurma($turmaId); 24 $objTurma = new clsPmieducarTurma($turmaId);
25 $detTurma = $objTurma->detalhe(); 25 $detTurma = $objTurma->detalhe();
@@ -27,9 +27,18 @@ class DiarioController extends ApiCoreController @@ -27,9 +27,18 @@ class DiarioController extends ApiCoreController
27 $serieId = $detTurma['ref_ref_cod_serie']; 27 $serieId = $detTurma['ref_ref_cod_serie'];
28 $ano = $detTurma['ano']; 28 $ano = $detTurma['ano'];
29 29
  30 + //obtem a série da matrícula
  31 + if ($matriculaId && $detTurma['multiseriada'] == 1) {
  32 + $serieId = $this->getSeriePorMatricula($matriculaId) ?: $serieId;
  33 + }
  34 +
30 return App_Model_IedFinder::getComponentesTurma($serieId, $escolaId, $turmaId, null, null, null, null, null, $ano); 35 return App_Model_IedFinder::getComponentesTurma($serieId, $escolaId, $turmaId, null, null, null, null, null, $ano);
31 } 36 }
32 37
  38 + private function getSeriePorMatricula($matriculaId) {
  39 + return \App\Models\LegacyRegistration::where('cod_matricula',$matriculaId)->value('ref_ref_cod_serie');
  40 + }
  41 +
33 protected function validateComponenteCurricular($matriculaId, $componenteCurricularId) 42 protected function validateComponenteCurricular($matriculaId, $componenteCurricularId)
34 { 43 {
35 $componentes = $this->getComponentesPorMatricula($matriculaId); 44 $componentes = $this->getComponentesPorMatricula($matriculaId);
@@ -43,10 +52,9 @@ class DiarioController extends ApiCoreController @@ -43,10 +52,9 @@ class DiarioController extends ApiCoreController
43 return $valid; 52 return $valid;
44 } 53 }
45 54
46 - protected function validateComponenteTurma($turmaId, $componenteCurricularId) 55 + protected function validateComponenteTurma($turmaId, $componenteCurricularId,$matriculaId = null)
47 { 56 {
48 - $componentesTurma = $this->getComponentesPorTurma($turmaId);  
49 - 57 + $componentesTurma = $this->getComponentesPorTurma($turmaId,$matriculaId);
50 if ($componentesTurma instanceof CoreExt_Entity) { 58 if ($componentesTurma instanceof CoreExt_Entity) {
51 $componentesTurma = CoreExt_Entity::entityFilterAttr($componentesTurma, 'id', 'id'); 59 $componentesTurma = CoreExt_Entity::entityFilterAttr($componentesTurma, 'id', 'id');
52 } else { 60 } else {
@@ -207,7 +215,7 @@ class DiarioController extends ApiCoreController @@ -207,7 +215,7 @@ class DiarioController extends ApiCoreController
207 } 215 }
208 216
209 foreach ($notaTurmaAluno as $componenteCurricularId => $notaTurmaAlunoDisciplina) { 217 foreach ($notaTurmaAluno as $componenteCurricularId => $notaTurmaAlunoDisciplina) {
210 - if (!$this->validateComponenteTurma($turmaId, $componenteCurricularId)) { 218 + if (!$this->validateComponenteTurma($turmaId, $componenteCurricularId,$matriculaId)) {
211 continue; 219 continue;
212 } 220 }
213 221
@@ -287,6 +295,7 @@ class DiarioController extends ApiCoreController @@ -287,6 +295,7 @@ class DiarioController extends ApiCoreController
287 295
288 $this->messenger->append('Notas postadas com sucesso!', 'success'); 296 $this->messenger->append('Notas postadas com sucesso!', 'success');
289 } 297 }
  298 +
290 } 299 }
291 300
292 protected function postRecuperacoes() 301 protected function postRecuperacoes()
@@ -304,7 +313,7 @@ class DiarioController extends ApiCoreController @@ -304,7 +313,7 @@ class DiarioController extends ApiCoreController
304 } 313 }
305 314
306 foreach ($notaTurmaAluno as $componenteCurricularId => $notaTurmaAlunoDisciplina) { 315 foreach ($notaTurmaAluno as $componenteCurricularId => $notaTurmaAlunoDisciplina) {
307 - if ($this->validateComponenteTurma($turmaId, $componenteCurricularId)) { 316 + if ($this->validateComponenteTurma($turmaId, $componenteCurricularId,$matriculaId)) {
308 $notaOriginal = $notaTurmaAlunoDisciplina['nota']; 317 $notaOriginal = $notaTurmaAlunoDisciplina['nota'];
309 318
310 if (is_null($notaOriginal)) { 319 if (is_null($notaOriginal)) {
@@ -403,7 +412,7 @@ class DiarioController extends ApiCoreController @@ -403,7 +412,7 @@ class DiarioController extends ApiCoreController
403 foreach ($faltaTurmaAluno as $componenteCurricularId => $faltaTurmaAlunoDisciplina) { 412 foreach ($faltaTurmaAluno as $componenteCurricularId => $faltaTurmaAlunoDisciplina) {
404 if ($matriculaId) { 413 if ($matriculaId) {
405 if ($this->validateMatricula($matriculaId)) { 414 if ($this->validateMatricula($matriculaId)) {
406 - if ($this->validateComponenteTurma($turmaId, $componenteCurricularId)) { 415 + if ($this->validateComponenteTurma($turmaId, $componenteCurricularId,$matriculaId)) {
407 $valor = $faltaTurmaAlunoDisciplina['valor']; 416 $valor = $faltaTurmaAlunoDisciplina['valor'];
408 417
409 $falta = new Avaliacao_Model_FaltaComponente([ 418 $falta = new Avaliacao_Model_FaltaComponente([
@@ -478,7 +487,7 @@ class DiarioController extends ApiCoreController @@ -478,7 +487,7 @@ class DiarioController extends ApiCoreController
478 } 487 }
479 488
480 foreach ($parecerTurmaAluno as $componenteCurricularId => $parecerTurmaAlunoComponente) { 489 foreach ($parecerTurmaAluno as $componenteCurricularId => $parecerTurmaAlunoComponente) {
481 - if ($this->validateComponenteTurma($turmaId, $componenteCurricularId)) { 490 + if ($this->validateComponenteTurma($turmaId, $componenteCurricularId,$matriculaId)) {
482 491
483 $parecerDescritivo = new Avaliacao_Model_ParecerDescritivoComponente([ 492 $parecerDescritivo = new Avaliacao_Model_ParecerDescritivoComponente([
484 'componenteCurricular' => $componenteCurricularId, 493 'componenteCurricular' => $componenteCurricularId,
ieducar/modules/HistoricoEscolar/Views/ProcessamentoApiController.php
@@ -785,6 +785,7 @@ class ProcessamentoApiController extends Core_Controller_Page_EditController @@ -785,6 +785,7 @@ class ProcessamentoApiController extends Core_Controller_Page_EditController
785 } 785 }
786 786
787 $arrayAreaConhecimento[$componenteCurricular->area_conhecimento->id]['nota_conceitual_numerica'] ??= 0 ; 787 $arrayAreaConhecimento[$componenteCurricular->area_conhecimento->id]['nota_conceitual_numerica'] ??= 0 ;
  788 + $arrayAreaConhecimento[$componenteCurricular->area_conhecimento->id]['falta'] ??= 0;
788 789
789 $arrayAreaConhecimento[$componenteCurricular->area_conhecimento->id]['nota'] += $nota; 790 $arrayAreaConhecimento[$componenteCurricular->area_conhecimento->id]['nota'] += $nota;
790 $arrayAreaConhecimento[$componenteCurricular->area_conhecimento->id]['nota_conceitual_numerica'] += is_numeric($notaConceitualNumerica) ? $notaConceitualNumerica : 0; 791 $arrayAreaConhecimento[$componenteCurricular->area_conhecimento->id]['nota_conceitual_numerica'] += is_numeric($notaConceitualNumerica) ? $notaConceitualNumerica : 0;
@@ -906,7 +907,7 @@ class ProcessamentoApiController extends Core_Controller_Page_EditController @@ -906,7 +907,7 @@ class ProcessamentoApiController extends Core_Controller_Page_EditController
906 $falta = $this->getRequest()->faltas; 907 $falta = $this->getRequest()->faltas;
907 } 908 }
908 909
909 - return $falta; 910 + return empty($falta) ? 0 : $falta;
910 } 911 }
911 912
912 protected function getDadosMatricula($matriculaId) 913 protected function getDadosMatricula($matriculaId)
resources/views/enrollments/batch/cancel.blade.php
@@ -51,7 +51,7 @@ @@ -51,7 +51,7 @@
51 </table> 51 </table>
52 </form> 52 </form>
53 53
54 - <form action="{{ Asset::get('/cancelar-enturmacao-em-lote/' . $schoolClass->id) }}" method="post" class="open-sans"> 54 + <form id="enrollments-unenroll" action="{{ Asset::get('/cancelar-enturmacao-em-lote/' . $schoolClass->id) }}" method="post" class="open-sans">
55 55
56 <h3>Alunos matriculados e enturmados</h3> 56 <h3>Alunos matriculados e enturmados</h3>
57 57
@@ -102,9 +102,9 @@ @@ -102,9 +102,9 @@
102 {{ $success->first($enrollment->id) ? 'disabled' : '' }} /> 102 {{ $success->first($enrollment->id) ? 'disabled' : '' }} />
103 </label> 103 </label>
104 </td> 104 </td>
105 - <td>{{ $enrollment->registration->cod_matricula }}</td>  
106 - <td>{{ $enrollment->student_name }}</td>  
107 - <td>{{ $enrollment->data_enturmacao->format('d/m/Y') }}</td> 105 + <td>{{ $enrollment?->registration?->cod_matricula }}</td>
  106 + <td>{{ $enrollment?->student_name }}</td>
  107 + <td>{{ $enrollment?->data_enturmacao->format('d/m/Y') }}</td>
108 <td> 108 <td>
109 {{ $success->first($enrollment->id) }} 109 {{ $success->first($enrollment->id) }}
110 {{ $fails->first($enrollment->id) }} 110 {{ $fails->first($enrollment->id) }}
@@ -137,6 +137,7 @@ @@ -137,6 +137,7 @@
137 </form> 137 </form>
138 138
139 <script> 139 <script>
  140 +
140 $j(document).ready(function () { 141 $j(document).ready(function () {
141 $j('.enrollment-check-master').change(function () { 142 $j('.enrollment-check-master').change(function () {
142 if ($j(this).prop('checked')) { 143 if ($j(this).prop('checked')) {
@@ -155,6 +156,49 @@ @@ -155,6 +156,49 @@
155 $j('.enrollment-check').prop('checked', true); 156 $j('.enrollment-check').prop('checked', true);
156 }); 157 });
157 }); 158 });
  159 +
  160 + $j('#enrollments-unenroll').submit(function (e) {
  161 + e.preventDefault();
  162 + makeDialog({
  163 + title: 'Atenção!',
  164 + content: 'O processo de desenturmação e enturmação manual ' +
  165 + 'não será considerado como remanejamento ou troca de turma, ' +
  166 + 'para isso você deve selecionar a turma nova e remanejar. Deseja continuar?',
  167 + maxWidth: 860,
  168 + width: 860,
  169 + modal: true,
  170 + buttons: [{
  171 + text: 'OK',
  172 + click: function () {
  173 + e.currentTarget.submit();
  174 + $j(this).dialog('destroy');
  175 + }
  176 + },{
  177 + text: 'Cancelar',
  178 + click: function () {
  179 + $j(this).dialog('destroy');
  180 + }
  181 + }]
  182 + });
  183 + });
  184 +
  185 + function makeDialog (params) {
  186 + let container = $j('#dialog-container');
  187 + if (container.length < 1) {
  188 + $j('body').append('<div id="dialog-container" style="width: 400px;"></div>');
  189 + container = $j('#dialog-container');
  190 + }
  191 +
  192 + if (container.hasClass('ui-dialog-content')) {
  193 + container.dialog('destroy');
  194 + }
  195 +
  196 + container.empty();
  197 + container.html(params.content);
  198 + delete params['content'];
  199 +
  200 + container.dialog(params);
  201 + }
158 </script> 202 </script>
159 203
160 @endsection 204 @endsection
src/Modules/Educacenso/Data/Registro30.php
@@ -61,19 +61,32 @@ class Registro30 extends AbstractRegistro @@ -61,19 +61,32 @@ class Registro30 extends AbstractRegistro
61 $this->modelArray[$data->codigoPessoa] = $this->model; 61 $this->modelArray[$data->codigoPessoa] = $this->model;
62 } 62 }
63 63
64 - $unconsideredKnowledgeArea = [32, 99];  
65 -  
66 foreach ($this->modelArray as &$record) { 64 foreach ($this->modelArray as &$record) {
67 $record->formacaoAnoConclusao = Portabilis_Utils_Database::pgArrayToArray($record->formacaoAnoConclusao); 65 $record->formacaoAnoConclusao = Portabilis_Utils_Database::pgArrayToArray($record->formacaoAnoConclusao);
68 $record->formacaoCurso = Portabilis_Utils_Database::pgArrayToArray($record->formacaoCurso); 66 $record->formacaoCurso = Portabilis_Utils_Database::pgArrayToArray($record->formacaoCurso);
69 $record->formacaoInstituicao = Portabilis_Utils_Database::pgArrayToArray($record->formacaoInstituicao); 67 $record->formacaoInstituicao = Portabilis_Utils_Database::pgArrayToArray($record->formacaoInstituicao);
70 $record->formacaoComponenteCurricular = Portabilis_Utils_Database::pgArrayToArray($record->formacaoComponenteCurricular); 68 $record->formacaoComponenteCurricular = Portabilis_Utils_Database::pgArrayToArray($record->formacaoComponenteCurricular);
71 - $record->formacaoComponenteCurricular = array_diff($record->formacaoComponenteCurricular, $unconsideredKnowledgeArea); 69 + $record->formacaoComponenteCurricular = $this->validaFormacaoComponenteCurricular($record->formacaoComponenteCurricular);
72 } 70 }
73 71
74 return $this->modelArray; 72 return $this->modelArray;
75 } 73 }
76 74
  75 + private function validaFormacaoComponenteCurricular($componentes)
  76 + {
  77 + $anulaProximoComponente = false;
  78 + $componentesDesconsiderados = [32, 99];
  79 +
  80 + foreach ($componentes as $key => $componente) {
  81 + if ($anulaProximoComponente === true || (int) $componente === 0 || in_array($componente, $componentesDesconsiderados)) {
  82 + $anulaProximoComponente = true;
  83 + $componentes[$key] = null;
  84 + }
  85 + }
  86 +
  87 + return $componentes;
  88 + }
  89 +
77 /** 90 /**
78 * @param ItemOfRegistro30[] $array 91 * @param ItemOfRegistro30[] $array
79 * @param string $type 92 * @param string $type