Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚸 #344 - Validações e verificações de fiscais #350

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,33 @@ public function POST_save(): void
$app = App::i();
$registration = $app->repo('Registration')->find($this->data['registration']);

if (($this->data['idDiligence'] ?: 0) == 0 && (is_null($registration->opportunity->use_multiple_diligence) || $registration->opportunity->use_multiple_diligence === 'Não')) {
$diligences = $app->repo(EntityDiligence::class)->findBy([
'registration' => $registration,
'status' => [EntityDiligence::STATUS_DRAFT, EntityDiligence::STATUS_OPEN, EntityDiligence::STATUS_SEND]
]);
$isDiligence = $app->repo('Diligence\Entities\Diligence')->findOneBy(['registration' => $this->data['registration']]);

if(is_null($isDiligence)){
if (($this->data['idDiligence'] ?: 0) == 0 && (is_null($registration->opportunity->use_multiple_diligence) || $registration->opportunity->use_multiple_diligence === 'Não')) {
$diligences = $app->repo(EntityDiligence::class)->findBy([
'registration' => $registration,
'status' => [EntityDiligence::STATUS_DRAFT, EntityDiligence::STATUS_OPEN, EntityDiligence::STATUS_SEND]
]);

if (count($diligences) > 0) {
$this->json([
'message' => 'Já foi aberta uma diligência para essa inscrição. Não é permitida a abertura de outra',
'error' => 'multiple_diligence_not_alowed',
], 400);

return;
}
}

if (count($diligences) > 0) {
$this->json([
'message' => 'Já foi aberta uma diligência para essa inscrição. Não é permitida a abertura de outra',
'error' => 'multiple_diligence_not_alowed',
], 400);
$answer = new EntityDiligence();
$entity = $answer->createOrUpdate($this);

return;
}
$this->json(['message' => 'success', 'status' => 200, 'entityId' => $entity['entityId']]);
}else{
$this->json(['message' => 'Essa prestação de conta já está em diligência.', 'status' => 403]);
}

$answer = new EntityDiligence();
$entity = $answer->createOrUpdate($this);

$this->json(['message' => 'success', 'status' => 200, 'entityId' => $entity['entityId']]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,11 @@ public static function getFinancialReportsAccountability($registration_id)
public static function getIsAuditor($registration)
{
$app = App::i();
$auditorDiligence = $app->repo(DiligenceEntity::class)->findOneBy(['registration' => $registration], ['id' => 'desc']);
$auditorDiligence = $app->repo('Diligence\Entities\Diligence')->findOneBy(['registration' => $registration], ['id' => 'desc']);
$reg = $app->repo('Registration')->find($registration);

$isAdmin = $auditorDiligence->registration->opportunity->canUser("@control", $app->user);
if($auditorDiligence->openAgent->userId !== $app->user->id && !$isAdmin) {
$isAdmin = $reg->opportunity->canUser("@control", $app->user);
if(isset($auditorDiligence->openAgent->userId) && $auditorDiligence->openAgent->userId !== $app->user->id && !$isAdmin) {
$app->setCookie("denied-auditor", 'Esse monitoramento já está sendo acompanhado por outro Fiscal', time()+3600);;
$app->redirect($app->createUrl('oportunidade', $auditorDiligence->registration->opportunity->id));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@
box-shadow: 2px 2px 2px #a6a6a6;
}

.btn-diligence-open-active {
color: white !important;
}

.btn-success-rec {
color: #fff !important;
background-color: #085E55 !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function saveDiligence(status, st, idDiligence) {
//Mensagem de confirmação
Swal.fire({
title: "Confirmar o envio da diligência?",
text: "Essa ação não pode ser desfeita. Por isso, revise sua diligência com cuidado.",
text: "Você pode desfazer o envio em até 10 segundos. Revise sua diligência com cuidado.",
showConfirmButton: true,
showCloseButton: false,
showCancelButton: true,
Expand Down Expand Up @@ -291,6 +291,9 @@ function sendAjaxDiligence(status, idDiligence) {
showSaveContent(status)
$("#id-input-diligence").val(res.entityId);
}
if (res.status == 403) {
diligenceMessage.messageError('Ops! Um erro.', res.message, 3500);
}
},
error: function () {
MapasCulturais.Messages.error('Ocorreu um erro ao enviar a diligência');
Expand Down
Loading