diff --git a/src/protected/application/lib/modules/Diligence/Repositories/Diligence.php b/src/protected/application/lib/modules/Diligence/Repositories/Diligence.php index f68ae03f5..646c3e569 100644 --- a/src/protected/application/lib/modules/Diligence/Repositories/Diligence.php +++ b/src/protected/application/lib/modules/Diligence/Repositories/Diligence.php @@ -173,4 +173,23 @@ public static function getFinancialReportsAccountability($registration_id) return $result; } + + /** + * Verifica se quem está logado tem controle na opp. e se é o fiscal de uma diligência + * @param $registration + * @return DiligenceEntity|null + */ + public static function getIsAuditor($registration) + { + $app = App::i(); + $auditorDiligence = $app->repo(DiligenceEntity::class)->findOneBy(['registration' => $registration], ['id' => 'desc']); + + $isAdmin = $auditorDiligence->registration->opportunity->canUser("@control", $app->user); + if($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)); + } + return $auditorDiligence; + } + } diff --git a/src/protected/application/lib/modules/Diligence/layouts/parts/diligence/body-diligence-multi.php b/src/protected/application/lib/modules/Diligence/layouts/parts/diligence/body-diligence-multi.php index 6f73d6505..4cb8d70b8 100644 --- a/src/protected/application/lib/modules/Diligence/layouts/parts/diligence/body-diligence-multi.php +++ b/src/protected/application/lib/modules/Diligence/layouts/parts/diligence/body-diligence-multi.php @@ -1,5 +1,4 @@ applyTemplateHook("body-diligence-multi", "before"); $this->applyTemplateHook("body-diligence-multi-div", "begin"); + +DiligenceRepo::getIsAuditor($entity->id); + ?>

diff --git a/src/protected/application/themes/BaseV1/layouts/parts/singles/opportunity-evaluations--committee--table.php b/src/protected/application/themes/BaseV1/layouts/parts/singles/opportunity-evaluations--committee--table.php index d19085fe3..481c3760a 100644 --- a/src/protected/application/themes/BaseV1/layouts/parts/singles/opportunity-evaluations--committee--table.php +++ b/src/protected/application/themes/BaseV1/layouts/parts/singles/opportunity-evaluations--committee--table.php @@ -1,10 +1,20 @@ -applyTemplateHook('opportunity-evaluations--committee--table','before'); ?> +applyTemplateHook('opportunity-evaluations--committee--table','before'); ?>
applyTemplateHook('opportunity-evaluations--committee--table','begin'); ?>

+ getCookie("denied-auditor"))) { + echo '
' . $app->getCookie("denied-auditor") . '
'; + $app->deleteCookie("denied-auditor"); +} if($entity->isUserEvaluationsSent()): ?>