-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #654 from portabilis/portabilis-patch-2019-09-21
[2.2] Portabilis patch 21/09/2019
- Loading branch information
Showing
301 changed files
with
2,130 additions
and
12,176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.