-
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 #930 from portabilis/portabilis-patch-2023-12-26
Portabilis patch 26/12/2023
- Loading branch information
Showing
25 changed files
with
951 additions
and
29 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,24 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
|
||
use App\Models\LegacyRegistration; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class RegistrationCopyEvent | ||
{ | ||
use Dispatchable; | ||
use InteractsWithSockets; | ||
use SerializesModels; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(public LegacyRegistration $newRegistration, public LegacyRegistration $oldRegistration) | ||
{ | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
namespace App\Listeners; | ||
|
||
use App\Events\RegistrationCopyEvent; | ||
use App\Exceptions\Transfer\MissingDescriptiveOpinionType; | ||
use App\Exceptions\Transfer\StagesAreNotSame; | ||
use App\Services\RegistrationDataService; | ||
use App\Services\TransferRegistrationDataService; | ||
|
||
class RegistrationCopyListener | ||
{ | ||
/** | ||
* @var TransferRegistrationDataService | ||
*/ | ||
protected $service; | ||
|
||
public function __construct(RegistrationDataService $service) | ||
{ | ||
$this->service = $service; | ||
} | ||
|
||
/** | ||
* Handle the event. | ||
* | ||
* @param object $event | ||
* @return void | ||
* | ||
* @throws MissingDescriptiveOpinionType | ||
* @throws StagesAreNotSame | ||
*/ | ||
public function handle(RegistrationCopyEvent $event) | ||
{ | ||
$this->service->copy($event->newRegistration, $event->oldRegistration); | ||
} | ||
} |
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,72 @@ | ||
<?php | ||
|
||
namespace App\Models\Exporter\Builders; | ||
|
||
use App\Support\Database\JoinableBuilder; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Query\JoinClause; | ||
|
||
class EmployeeEloquentBuilder extends Builder | ||
{ | ||
use JoinableBuilder; | ||
|
||
/** | ||
* @param array $columns | ||
* @return TeacherEloquentBuilder | ||
*/ | ||
public function person($columns) | ||
{ | ||
$this->addSelect( | ||
$this->joinColumns('person', $columns) | ||
); | ||
|
||
return $this->join('exporter_person as person', function (JoinClause $join) { | ||
$join->on('exporter_employee.id', '=', 'person.id'); | ||
}); | ||
} | ||
|
||
/** | ||
* @return TeacherEloquentBuilder | ||
*/ | ||
public function disabilities() | ||
{ | ||
$this->addSelect( | ||
$this->joinColumns('disabilities', ['disabilities']) | ||
); | ||
|
||
return $this->leftJoin('exporter_disabilities as disabilities', function (JoinClause $join) { | ||
$join->on('exporter_employee.id', '=', 'disabilities.person_id'); | ||
}); | ||
} | ||
|
||
/** | ||
* @return TeacherEloquentBuilder | ||
*/ | ||
public function phones() | ||
{ | ||
$this->addSelect( | ||
$this->joinColumns('phones', ['phones']) | ||
); | ||
|
||
return $this->leftJoin('exporter_phones as phones', function (JoinClause $join) { | ||
$join->on('exporter_employee.id', '=', 'phones.person_id'); | ||
}); | ||
} | ||
|
||
/** | ||
* @param array $columns | ||
* @return TeacherEloquentBuilder | ||
*/ | ||
public function place($columns) | ||
{ | ||
$this->addSelect( | ||
$this->joinColumns('place', $columns) | ||
); | ||
|
||
return $this->leftJoin('person_has_place', function (JoinClause $join) { | ||
$join->on('exporter_employee.id', '=', 'person_has_place.person_id'); | ||
})->leftJoin('addresses as place', function (JoinClause $join) { | ||
$join->on('person_has_place.place_id', '=', 'place.id'); | ||
}); | ||
} | ||
} |
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,120 @@ | ||
<?php | ||
|
||
namespace App\Models\Exporter; | ||
|
||
use App\Models\Exporter\Builders\EmployeeEloquentBuilder; | ||
use App\Models\Exporter\Builders\TeacherEloquentBuilder; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Query\Builder; | ||
use Illuminate\Support\Collection; | ||
|
||
class Employee extends Model | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $table = 'exporter_employee'; | ||
|
||
/** | ||
* @var Collection | ||
*/ | ||
protected $alias; | ||
|
||
/** | ||
* @param Builder $query | ||
* @return TeacherEloquentBuilder | ||
*/ | ||
public function newEloquentBuilder($query) | ||
{ | ||
return new EmployeeEloquentBuilder($query); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getExportedColumnsByGroup() | ||
{ | ||
return [ | ||
'Códigos' => [ | ||
'id' => 'ID Pessoa', | ||
'school_id' => 'ID Escola', | ||
], | ||
'Servidor' => [ | ||
'name' => 'Nome', | ||
'social_name' => 'Nome social e/ou afetivo', | ||
'cpf' => 'CPF', | ||
'rg' => 'RG', | ||
'rg_issue_date' => 'RG (Data Emissão)', | ||
'rg_state_abbreviation' => 'RG (Estado)', | ||
'date_of_birth' => 'Data de nascimento', | ||
'email' => 'E-mail', | ||
'sus' => 'Número SUS', | ||
'nis' => 'NIS (PIS/PASEP)', | ||
'occupation' => 'Ocupação', | ||
'organization' => 'Empresa', | ||
'monthly_income' => 'Renda Mensal', | ||
'gender' => 'Gênero', | ||
'race' => 'Raça', | ||
], | ||
'Alocação' => [ | ||
'employee_workload' => 'Carga horária do servidor', | ||
'year' => 'Ano', | ||
'school' => 'Escola', | ||
'period' => 'Período', | ||
'role' => 'Função', | ||
'link' => 'Vínculo', | ||
'allocated_workload' => 'Carga horária alocada', | ||
], | ||
'Informações' => [ | ||
'phones.phones' => 'Telefones', | ||
'disabilities.disabilities' => 'Deficiências', | ||
'schooling_degree' => 'Escolaridade', | ||
'high_school_type' => 'Tipo de ensino médio cursado', | ||
'employee_postgraduates_complete' => 'Pós-Graduações concluídas', | ||
'continuing_education_course' => 'Outros cursos de formação continuada', | ||
'employee_graduation_complete' => 'Curso(s) superior(es) concluído(s)', | ||
], | ||
'Endereço' => [ | ||
'place.address' => 'Logradouro', | ||
'place.number' => 'Número', | ||
'place.complement' => 'Complemento', | ||
'place.neighborhood' => 'Bairro', | ||
'place.postal_code' => 'CEP', | ||
'place.latitude' => 'Latitude', | ||
'place.longitude' => 'Longitude', | ||
'place.city' => 'Cidade', | ||
'place.state_abbreviation' => 'Sigla do Estado', | ||
'place.state' => 'Estado', | ||
'place.country' => 'País', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLabel() | ||
{ | ||
return 'Servidores'; | ||
} | ||
|
||
public function getDescription() | ||
{ | ||
return 'Os dados exportados serão contabilizados por quantidade de servidores(as) alocados(as) no ano filtrado, agrupando as informações das alocações nas escolas.'; | ||
} | ||
|
||
/** | ||
* @param string $column | ||
* @return string | ||
*/ | ||
public function alias($column) | ||
{ | ||
if (empty($this->alias)) { | ||
$this->alias = collect($this->getExportedColumnsByGroup())->flatMap(function ($item) { | ||
return $item; | ||
}); | ||
} | ||
|
||
return $this->alias->get($column, $column); | ||
} | ||
} |
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
Oops, something went wrong.