Skip to content

Commit

Permalink
Merge pull request #654 from portabilis/portabilis-patch-2019-09-21
Browse files Browse the repository at this point in the history
[2.2] Portabilis patch 21/09/2019
  • Loading branch information
edersoares authored Sep 23, 2019
2 parents d55515c + 32d1718 commit 1de8ef7
Show file tree
Hide file tree
Showing 301 changed files with 2,130 additions and 12,176 deletions.
64 changes: 64 additions & 0 deletions app/Console/Commands/QueryAllCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace App\Console\Commands;

use App\Menu;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class QueryAllCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'query:all';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Count duplicated scores';

/**
* @return array
*/
private function getConnections()
{
$connections = config('database.connections');

return array_diff(array_keys($connections), ['sqlite', 'mysql', 'pgsql', 'sqlsrv', 'bussolastaging']);
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$array = [];
$data = [];
$file = file_get_contents(storage_path('query.sql'));

foreach ($this->getConnections() as $connection) {
try {
$data = (array) DB::connection($connection)->selectOne($file);
} catch (Exception $exception) {
continue;
}

if (isset($data)) {
$array[] = array_merge([$connection], $data);
}
}

$header = array_keys($data);
array_unshift($header, 'connection');

$this->table($header, $array);
}
}
65 changes: 65 additions & 0 deletions app/Http/Controllers/ExemptionListController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace App\Http\Controllers;

use App\Models\LegacyDisciplineExemption;
use App\Process;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Illuminate\View\View;

class ExemptionListController extends Controller
{
/**
* @param Request $request
* @return View
*/
public function index(Request $request)
{
$this->breadcrumb('Consulta de dispensas', [
url('intranet/educar_index.php') => 'Escola',
]);

$this->menu(Process::EXEMPTION_LIST);

$query = LegacyDisciplineExemption::active()->with('registration.student.person');

if ($request->get('ano')) {
$ano = $request->get('ano');
$query->whereHas('registration', function ($registrationQuery) use ($ano) {
$registrationQuery->where('ano', $ano);
});
}

$schools[] = $request->get('ref_cod_escola');

if ($request->user()->isSchooling()) {
$schools = $request->user()->schools->pluck('cod_escola')->all();
}

if (array_filter($schools)) {
$query->whereIn('ref_cod_escola', $schools);
}

if ($request->get('ref_cod_serie')) {
$query->where('ref_cod_serie', $request->get('ref_cod_serie'));
}

if ($request->get('ref_cod_curso')) {
$courseId = $request->get('ref_cod_curso');
$query->whereHas('registration', function ($registrationQuery) use ($courseId) {
$registrationQuery->where('ref_cod_curso', $courseId);
});
}

if ($request->get('ref_cod_componente_curricular')) {
$query->where('ref_cod_disciplina', $request->get('ref_cod_componente_curricular'));
}

$query->orderBy('data_cadastro', 'desc');

$exemptions = $query->paginate(20)->appends(Input::except('page'));

return view('exemption.index', compact('exemptions'));
}
}
3 changes: 1 addition & 2 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\ChangeAppName::class,
\App\Http\Middleware\ConnectTenantDatabase::class,
];

/**
Expand All @@ -36,8 +37,6 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
// \App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\ChangeAppName::class,
\App\Http\Middleware\ConnectTenantDatabase::class,
\App\Http\Middleware\SetLayoutVariables::class,
\App\Http\Middleware\LoadSettings::class,
],
Expand Down
92 changes: 92 additions & 0 deletions app/Models/LegacyDisciplineExemption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
* Class LegacyDisciplineExemption
* @property LegacyRegistration $registration
*/
class LegacyDisciplineExemption extends Model
{
/**
* @var string
*/
protected $table = 'pmieducar.dispensa_disciplina';

protected $primaryKey = 'cod_dispensa';

/**
* @var array
*/
protected $fillable = [
'ref_cod_matricula',
'ref_cod_disciplina',
'ref_cod_escola',
'ref_cod_serie',
'ref_usuario_exc',
'ref_usuario_cad',
'ref_cod_tipo_dispensa',
'data_cadastro',
'data_exclusao',
'ativo',
'observacao',
'cod_dispensa',
'updated_at',
];

protected $dates = [
'data_cadastro',
'data_exclusao',
'updated_at'
];

/**
* @var bool
*/
public $timestamps = false;

/**
* Relação com a matrícula.
*
* @return BelongsTo
*/
public function registration()
{
return $this->belongsTo(LegacyRegistration::class, 'ref_cod_matricula');
}

/**
* @return BelongsTo
*/
public function discipline()
{
return $this->belongsTo(LegacyDiscipline::class, 'ref_cod_disciplina');
}

/**
* @return BelongsTo
*/
public function type()
{
return $this->belongsTo(LegacyExemptionType::class, 'ref_cod_tipo_dispensa');
}

/**
* @param Builder $query
*
* @return Builder
*/
public function scopeActive($query)
{
return $query->where('ativo', 1);
}

public function getDateFormat()
{
return 'Y-m-d H:i:s.u';
}
}
43 changes: 43 additions & 0 deletions app/Models/LegacyExemptionType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
* Class LegacyDisciplineExemption
* @property LegacyRegistration $registration
*/
class LegacyExemptionType extends Model
{
/**
* @var string
*/
protected $table = 'pmieducar.tipo_dispensa';

protected $primaryKey = 'cod_tipo_dispensa';

/**
* @var array
*/
protected $fillable = [
'ref_usuario_exc',
'ref_usuario_cad',
'nm_tipo',
'descricao',
'data_cadastro',
'data_exclusao',
'ativo',
'ref_cod_instituicao',
];

/**
* @var bool
*/
public $timestamps = false;

public function __toString()
{
return $this->nm_tipo;
}
}
6 changes: 6 additions & 0 deletions app/Models/LegacySchool.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Support\Facades\DB;

/**
* LegacySchool
Expand Down Expand Up @@ -86,4 +87,9 @@ public function organization()
{
return $this->belongsTo(LegacyOrganization::class, 'ref_idpes');
}

public function getNameAttribute()
{
return DB::selectOne('SELECT relatorio.get_nome_escola(:escola) AS nome', ['escola' => $this->id])->nome;
}
}
9 changes: 9 additions & 0 deletions app/Models/LegacySchoolGradeDiscipline.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class LegacySchoolGradeDiscipline extends Model
{
Expand All @@ -21,4 +22,12 @@ class LegacySchoolGradeDiscipline extends Model
];

public $timestamps = false;

/**
* @return BelongsTo
*/
public function discipline()
{
return $this->belongsTo(LegacyDiscipline::class, 'ref_cod_disciplina');
}
}
3 changes: 3 additions & 0 deletions app/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ class Process
const MENU_LIBRARY = 57;
const MENU_CONFIGURATIONS = 25;

const CONSULTAS = 9998890;

const ENROLLMENT_HISTORY = 1001;
const ATTENDED_CANDIDATE = 1002;
const UNDO_STUDENT_UNIFICATION = 2001;
const EXEMPTION_LIST = 2002;
}
20 changes: 20 additions & 0 deletions app/Services/SchoolGradeDisciplineService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Services;

use App\Models\LegacySchoolGradeDiscipline;
use Illuminate\Support\Collection;

class SchoolGradeDisciplineService
{
/**
* @param $schoolId
* @param $gradeId
* @return LegacySchoolGradeDiscipline[]|Collection
*/
public function getDisciplines($schoolId, $gradeId)
{
return LegacySchoolGradeDiscipline::where('ref_ref_cod_escola', $schoolId)
->where('ref_ref_cod_serie', $gradeId)->get()->pluck('discipline');
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Software livre de gestão escolar",
"type": "project",
"license": "GPL-2.0-or-later",
"version": "2.2.5",
"version": "2.2.6",
"keywords": [
"Portabilis",
"i-Educar"
Expand Down
Loading

0 comments on commit 1de8ef7

Please sign in to comment.