From a98e44fd79d5b1d4f6ab2147eeb564e06f8ea5e8 Mon Sep 17 00:00:00 2001 From: Jefferson Oliveira Date: Mon, 5 Dec 2022 19:10:57 -0300 Subject: [PATCH 01/12] =?UTF-8?q?Verifica=C3=A7=C3=A3o=20de=20CPF=20duplic?= =?UTF-8?q?ado=20em=20conta=20desativada=20na=20edi=C3=A7=C3=A3o=20do=20ag?= =?UTF-8?q?ente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Theme.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Theme.php b/Theme.php index 1a2b0aca9..a6d23709d 100755 --- a/Theme.php +++ b/Theme.php @@ -2,10 +2,11 @@ namespace Saude; -use MapasCulturais\Themes\BaseV1; use MapasCulturais\App; -use MapasCulturais\Entities\Project; use MapasCulturais\i; +use MapasCulturais\Entities\Project; +use MapasCulturais\Entities\User; +use MapasCulturais\Themes\BaseV1; class Theme extends BaseV1\Theme{ @@ -621,7 +622,6 @@ function _init() { $msgEmailVinculado = 'CPF vinculado ao e-mail: ' . $email; } - if (checkValidDocument($cpf) && $cpf && count($result)) { $this->errorJson(json_decode('{"field_'.$field_id.'": ["Já existe um cadastro vinculado a este CPF. ' . $msgEmailVinculado . '. Verifique se você possui outra conta no Mapa da Saúde."]}'), 400); } elseif (!checkValidDocument($cpf) && $cpf) { From d78616793638a7fc4517517457c3614d7a1c12ad Mon Sep 17 00:00:00 2001 From: Jefferson Oliveira Date: Tue, 6 Dec 2022 14:57:56 -0300 Subject: [PATCH 02/12] =?UTF-8?q?Verifica=C3=A7=C3=A3o=20de=20duplicidade?= =?UTF-8?q?=20de=20CPF=20somente=20em=20contas=20ativas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Theme.php | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/Theme.php b/Theme.php index a6d23709d..f7b3333ea 100755 --- a/Theme.php +++ b/Theme.php @@ -593,39 +593,52 @@ function _init() { */ $app->hook('PATCH(registration.single):data', function(&$data) use ($app) { $registration = $app->repo('Registration')->find(intval($data['id'])); - $query = $app->em->createQuery("SELECT rfc.id FROM MapasCulturais\Entities\RegistrationFieldConfiguration rfc WHERE rfc.owner = :opportunityId AND rfc.config LIKE '%documento%'"); + + $query = $app->em->createQuery( + "SELECT rfc.id FROM MapasCulturais\Entities\RegistrationFieldConfiguration rfc + WHERE rfc.owner = :opportunityId AND rfc.config LIKE '%documento%'" + ); $query->setParameter('opportunityId', $registration->opportunity->id); - if (count($query->getResult())) { + if ($query->getResult()) { $result = $query->getSingleResult(); $field_id = $result['id']; $cpf = $data["field_{$field_id}"]; - $query = $app->em->createQuery("SELECT IDENTITY(am.owner) FROM MapasCulturais\Entities\AgentMeta am WHERE am.value = :cpf AND am.owner != :agentId"); + + $query = $app->em->createQuery( + "SELECT IDENTITY(am.owner) AS agent_id FROM MapasCulturais\Entities\AgentMeta am + INNER JOIN MapasCulturais\Entities\User u WITH am.owner = u.profile + WHERE am.value = :cpf AND am.owner != :agentId AND u.status = :userStatus" + ); + $query->setParameter('cpf', $cpf); $query->setParameter('agentId', $registration->owner->id); + $query->setParameter('userStatus', User::STATUS_ENABLED); $result = $query->getResult(); - $msgEmailVinculado = ''; - if (!empty($result) && $result[0][1]) { - $agent = $app->repo('Agent')->find($result[0][1]); - + if ($result) { + $agent = $app->repo('Agent')->find($result[0]["agent_id"]); + $emailVinculado = $agent->getMetadata('emailPrivado'); - $emailVinculadoPart = explode('@', $emailVinculado); $user = substr($emailVinculadoPart[0], 0, -3); $dominio = $emailVinculadoPart[1]; - $email = $user . '***@' . $dominio; - $msgEmailVinculado = 'CPF vinculado ao e-mail: ' . $email; - } - if (checkValidDocument($cpf) && $cpf && count($result)) { - $this->errorJson(json_decode('{"field_'.$field_id.'": ["Já existe um cadastro vinculado a este CPF. ' . $msgEmailVinculado . '. Verifique se você possui outra conta no Mapa da Saúde."]}'), 400); - } elseif (!checkValidDocument($cpf) && $cpf) { - $this->errorJson(json_decode('{"field_'.$field_id.'": ["O número de documento informado é inválido."]}'), 400); + if (checkValidDocument($cpf) && $cpf) { + $this->errorJson( + json_decode( + '{"field_'.$field_id.'": ["Já existe um cadastro vinculado a este CPF. ' . $msgEmailVinculado . '. Verifique se você possui outra conta no Mapa da Saúde."]}' + ), 400 + ); + } elseif (!checkValidDocument($cpf) && $cpf) { + $this->errorJson( + json_decode('{"field_'.$field_id.'": ["O número de documento informado é inválido."]}'), 400 + ); + } } } }); From 9ae86652c2d71956972d485e09bed7b9177bf1db Mon Sep 17 00:00:00 2001 From: Jefferson Oliveira Date: Fri, 16 Dec 2022 12:01:42 -0300 Subject: [PATCH 03/12] =?UTF-8?q?Valida=C3=A7=C3=A3o=20na=20edi=C3=A7?= =?UTF-8?q?=C3=A3o=20do=20agente=20somente=20com=20agentes=20ativos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Repositories/Agent.php | 26 ++++++++++++++++ Theme.php | 69 ++++++++++++++++++------------------------ Utils/Validation.php | 31 +++++++++++++++++++ 3 files changed, 86 insertions(+), 40 deletions(-) create mode 100644 Repositories/Agent.php create mode 100644 Utils/Validation.php diff --git a/Repositories/Agent.php b/Repositories/Agent.php new file mode 100644 index 000000000..4da9c84c2 --- /dev/null +++ b/Repositories/Agent.php @@ -0,0 +1,26 @@ +em->createQuery( + "SELECT IDENTITY(am.owner) AS agent_id FROM MapasCulturais\Entities\AgentMeta am + INNER JOIN MapasCulturais\Entities\User u WITH am.owner = u.profile + WHERE am.value = :cpf AND am.owner != :agentId AND u.status = :userStatus" + ); + + $query->setParameter('cpf', $typed_cpf); + $query->setParameter('agentId', $agent_id); + $query->setParameter('userStatus', User::STATUS_ENABLED); + + return $query->getResult(); + } +} diff --git a/Theme.php b/Theme.php index f7b3333ea..50e5e9cd5 100755 --- a/Theme.php +++ b/Theme.php @@ -5,8 +5,9 @@ use MapasCulturais\App; use MapasCulturais\i; use MapasCulturais\Entities\Project; -use MapasCulturais\Entities\User; use MapasCulturais\Themes\BaseV1; +use Saude\Repositories\Agent; +use Saude\Utils\Validation; class Theme extends BaseV1\Theme{ @@ -591,7 +592,7 @@ function _init() { /** * Não permite que CPF seja salvo no agente responsável pela inscrição se este já estiver vinculado a outro agente */ - $app->hook('PATCH(registration.single):data', function(&$data) use ($app) { + $app->hook('PATCH(registration.single):data', function (&$data) use ($app) { $registration = $app->repo('Registration')->find(intval($data['id'])); $query = $app->em->createQuery( @@ -606,17 +607,7 @@ function _init() { $field_id = $result['id']; $cpf = $data["field_{$field_id}"]; - $query = $app->em->createQuery( - "SELECT IDENTITY(am.owner) AS agent_id FROM MapasCulturais\Entities\AgentMeta am - INNER JOIN MapasCulturais\Entities\User u WITH am.owner = u.profile - WHERE am.value = :cpf AND am.owner != :agentId AND u.status = :userStatus" - ); - - $query->setParameter('cpf', $cpf); - $query->setParameter('agentId', $registration->owner->id); - $query->setParameter('userStatus', User::STATUS_ENABLED); - - $result = $query->getResult(); + $result = Agent::checkCpfLinkedAnotherAgent($cpf, $registration->owner->id); if ($result) { $agent = $app->repo('Agent')->find($result[0]["agent_id"]); @@ -628,13 +619,13 @@ function _init() { $email = $user . '***@' . $dominio; $msgEmailVinculado = 'CPF vinculado ao e-mail: ' . $email; - if (checkValidDocument($cpf) && $cpf) { + if (Validation::checkValidDocument($cpf) && $cpf) { $this->errorJson( json_decode( '{"field_'.$field_id.'": ["Já existe um cadastro vinculado a este CPF. ' . $msgEmailVinculado . '. Verifique se você possui outra conta no Mapa da Saúde."]}' ), 400 ); - } elseif (!checkValidDocument($cpf) && $cpf) { + } elseif (!Validation::checkValidDocument($cpf) && $cpf) { $this->errorJson( json_decode('{"field_'.$field_id.'": ["O número de documento informado é inválido."]}'), 400 ); @@ -642,6 +633,29 @@ function _init() { } } }); + + $app->hook('PUT(agent.single):data', function (&$data) use ($app) { + $typed_cpf = $data["documento"]; + $agent = $app->repo('Agent')->find(intval($this->data["id"])); + + $result = Agent::checkCpfLinkedAnotherAgent($typed_cpf, $agent->id); + + if (Validation::checkValidDocument($typed_cpf) && $result) { + $this->json( + json_decode('{ + "data": { + "documento": ["Já existe um cadastro vinculado a este CPF/CNPJ. Verifique se você possui outra conta no Mapa da Saúde."] + }, + "error": true + }'), 200 + ); + } elseif (Validation::checkValidDocument($typed_cpf)) { + $agent->documento = $typed_cpf; + $agent->save(true); + + $this->json($agent); + } + }); } private function validateRegistrationLimitPerOwnerProject() @@ -935,28 +949,3 @@ public function getLoginLinkAttributes() { } } - -function checkValidDocument($document) -{ - // Extrai somente os números - $document = preg_replace('/[^0-9]/is', '', $document); - - // Verifica se o documento está completo - if (strlen($document) !== 11) return false; - - // Verifica se o documento é uma sequência de números iguais - if (preg_match('/(\d)\1{10}/', $document)) return false; - - // Faz o calculo para validar o CPF - for ($digits = 9; $digits < 11; $digits++) { - for ($sum_digits = 0, $digit_index = 0; $digit_index < $digits; $digit_index++) { - $sum_digits += $document[$digit_index] * (($digits + 1) - $digit_index); - } - - $sum_digits = ((10 * $sum_digits) % 11) % 10; - - if ($document[$digit_index] != $sum_digits) return false; - } - - return true; -} diff --git a/Utils/Validation.php b/Utils/Validation.php new file mode 100644 index 000000000..51742828b --- /dev/null +++ b/Utils/Validation.php @@ -0,0 +1,31 @@ + Date: Tue, 27 Dec 2022 12:20:24 -0300 Subject: [PATCH 04/12] =?UTF-8?q?Verifica=20se=20CPF=20est=C3=A1=20vincula?= =?UTF-8?q?do=20a=20outro=20agente=20no=20momento=20da=20inscri=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Theme.php | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/Theme.php b/Theme.php index 50e5e9cd5..0b5ad20d8 100755 --- a/Theme.php +++ b/Theme.php @@ -5,6 +5,7 @@ use MapasCulturais\App; use MapasCulturais\i; use MapasCulturais\Entities\Project; +use MapasCulturais\Entities\User; use MapasCulturais\Themes\BaseV1; use Saude\Repositories\Agent; use Saude\Utils\Validation; @@ -560,14 +561,6 @@ function _init() { } }); - /** - * Adiciona máscara de CPF/CNPJ na criação e edição de um agente - */ - $app->hook('entity(Agent).get(site)', function() use ($app) { - $app->view->enqueueScript('app', 'agent', 'js/agent.js'); - }); - - /** * Adiciona novos menus no painel */ @@ -634,6 +627,16 @@ function _init() { } }); + /** + * Adiciona máscara de CPF/CNPJ na criação e edição de um agente + */ + $app->hook('entity(Agent).get(site)', function() use ($app) { + $app->view->enqueueScript('app', 'agent', 'js/agent.js'); + }); + + /** + * Faz validação de CPF vinculado a outro agente somente se este estiver com status ativo + */ $app->hook('PUT(agent.single):data', function (&$data) use ($app) { $typed_cpf = $data["documento"]; $agent = $app->repo('Agent')->find(intval($this->data["id"])); @@ -656,6 +659,23 @@ function _init() { $this->json($agent); } }); + + /** + * Verifica se CPF está vinculado a outro agente no momento da inscrição + * Remove CPF do agente que tem um email como Username no Keycloak + * Deixa o CPF somente no novo usuário, que tem o CPF como Username no Keycloak + */ + $app->hook('auth.createUser:before', function ($data) use ($app) { + $cpf = preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $data['auth']['raw']['preferred_username']); + $agent_meta = $app->repo('AgentMeta')->findOneBy(['value' => $cpf]); + + if ($agent_meta && $agent_meta->owner->user->status === User::STATUS_ENABLED) { + $agent_meta->value = null; + + $app->em->persist($agent_meta); + $app->em->flush(); + } + }); } private function validateRegistrationLimitPerOwnerProject() From ecd4477438b4514c250db60185a62be06fc0db48 Mon Sep 17 00:00:00 2001 From: Jefferson Oliveira Date: Fri, 6 Jan 2023 09:50:01 -0300 Subject: [PATCH 05/12] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20de=20conflito=20no?= =?UTF-8?q?=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Theme.php | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/Theme.php b/Theme.php index f0c244b9f..ae8396557 100755 --- a/Theme.php +++ b/Theme.php @@ -634,6 +634,13 @@ function _init() { $app->view->enqueueScript('app', 'agent', 'js/agent.js'); }); + $app->hook('template(registration.view.form):begin', function () { + $entity = $this->controller->requestedEntity; + + $current_registration = $entity; + $this->jsObject['entity']['object']->category = $current_registration->category; + }); + /** * Faz validação de CPF vinculado a outro agente somente se este estiver com status ativo */ @@ -659,30 +666,6 @@ function _init() { $this->json($agent); } }); - - /** - * Verifica se CPF está vinculado a outro agente no momento da inscrição - * Remove CPF do agente que tem um email como Username no Keycloak - * Deixa o CPF somente no novo usuário, que tem o CPF como Username no Keycloak - */ - $app->hook('auth.createUser:before', function ($data) use ($app) { - $cpf = preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $data['auth']['raw']['preferred_username']); - $agent_meta = $app->repo('AgentMeta')->findOneBy(['value' => $cpf]); - - if ($agent_meta && $agent_meta->owner->user->status === User::STATUS_ENABLED) { - $agent_meta->value = null; - - $app->em->persist($agent_meta); - $app->em->flush(); - } - }); - - $app->hook('template(registration.view.form):begin', function() use($app) { - $entity = $this->controller->requestedEntity; - - $current_registration = $entity; - $this->jsObject['entity']['object']->category = $current_registration->category; - }); } private function validateRegistrationLimitPerOwnerProject() From b6a16af793f6330c83123bc2be61bf5d730ffa0a Mon Sep 17 00:00:00 2001 From: Jefferson Oliveira Date: Fri, 6 Jan 2023 16:03:27 -0300 Subject: [PATCH 06/12] =?UTF-8?q?Valida=C3=A7=C3=A3o=20de=20CPF=20vinculad?= =?UTF-8?q?o=20a=20outro=20agente=20somente=20se=20este=20estiver=20com=20?= =?UTF-8?q?status=20ativo=20(edi=C3=A7=C3=A3o=20do=20agente)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Theme.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Theme.php b/Theme.php index ae8396557..3136907a3 100755 --- a/Theme.php +++ b/Theme.php @@ -642,7 +642,7 @@ function _init() { }); /** - * Faz validação de CPF vinculado a outro agente somente se este estiver com status ativo + * Faz validação de CPF vinculado a outro agente somente se este estiver com status ativo (edição do agente) */ $app->hook('PUT(agent.single):data', function (&$data) use ($app) { $typed_cpf = $data["documento"]; @@ -659,11 +659,8 @@ function _init() { "error": true }'), 200 ); - } elseif (Validation::checkValidDocument($typed_cpf)) { - $agent->documento = $typed_cpf; - $agent->save(true); - - $this->json($agent); + } else { + return; } }); } From d3942ddd7cd67f57b7551318aea9d041505c7ca1 Mon Sep 17 00:00:00 2001 From: victorMagalhaesPacheco Date: Thu, 12 Jan 2023 15:30:44 -0300 Subject: [PATCH 07/12] =?UTF-8?q?Implementa=20extens=C3=A3o=20de=20envio?= =?UTF-8?q?=20de=20email=20na=20avalia=C3=A7=C3=A3o=20documental?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/EvaluationDocumental.php | 67 +++ Theme.php | 14 + assets/css/alert_changes.css | 4 + assets/js/sendMailRegistrationEvaluation.js | 52 +++ ...evaluation-documental-sendmail--button.php | 8 + .../send_mail_registration_evaluation.html | 381 ++++++++++++++++++ 6 files changed, 526 insertions(+) create mode 100644 Controllers/EvaluationDocumental.php create mode 100644 assets/js/sendMailRegistrationEvaluation.js create mode 100644 layouts/parts/singles/button/evaluation-documental-sendmail--button.php create mode 100644 templates/pt_BR/send_mail_registration_evaluation.html diff --git a/Controllers/EvaluationDocumental.php b/Controllers/EvaluationDocumental.php new file mode 100644 index 000000000..5a3764a9d --- /dev/null +++ b/Controllers/EvaluationDocumental.php @@ -0,0 +1,67 @@ +data['id']) { + $registrationId = $this->data['id']; + + $registration = $app->repo("Registration")->find($registrationId); + if ($registration) { + $evaluation = null; + if(isset($this->data['uid'])){ + $evaluation = $app->repo('RegistrationEvaluation')->findOneBy([ + 'registration' => $registration, + 'user' => $this->data['uid'] + ]); + if($evaluation && !$evaluation->registration->equals($registration)){ + $evaluation = null; + } + } + + $app->em->remove($evaluation); + $app->em->flush(); + + $registration->setStatusToDraft(); + + $fieldInvalids = ''; + $fieldInvalids .= '
    '; + foreach ($evaluation->evaluationData as $evaluationData) { + if ($evaluationData && $evaluationData['evaluation'] == 'invalid') { + $observacao = !empty($observacao) ? ' Observação: ' . $evaluationData['obs'] : ''; + $fieldInvalids .= '
  • ' . $evaluationData['label'] . '' . $observacao . '
  • '; + } + } + $fieldInvalids .= '
'; + + $urlOpportunity = $app->getBaseUrl() . 'oportunidade/' . $registration->opportunity->id; + + $dataValue = [ + 'urlOpportunity' => $urlOpportunity, + 'registrationId' => $registration->id, + 'opportunity' => $registration->opportunity->name, + 'name' => $registration->owner->name, + 'fieldInvalids' => $fieldInvalids, + ]; + + $message = $app->renderMailerTemplate('send_mail_registration_evaluation', $dataValue); + + $app->createAndSendMailMessage([ + 'from' => $app->config['mailer.from'], + 'to' => $registration->owner->user->email, + 'subject' => 'MAPA DA SAÚDE - ALERTA DE DOCUMENTAÇÃO INVÁLIDA.', + 'body' => $message['body'] + ]); + + return $this->json(['message' => 'Envio do e-mail realizado com sucesso.', 'type' => 'success', 'status' => 200], 200); + } + } + } +} \ No newline at end of file diff --git a/Theme.php b/Theme.php index f71ebe2de..f921ea416 100755 --- a/Theme.php +++ b/Theme.php @@ -636,6 +636,15 @@ function _init() { $current_registration = $entity; $this->jsObject['entity']['object']->category = $current_registration->category; }); + + // adiciona o botão de enviar o email na avaliação documental + $app->hook('template(registration.view.documentary-evaluation-view):after', function() use($app) { + $registration = $this->controller->requestedEntity; + if ($registration->opportunity->canUser('@control') && $registration->consolidatedResult == -1) { + $userId = $registration->controller->urlData['uid']; + $this->part('singles/button/evaluation-documental-sendmail--button', ['registration' => $registration, 'userId' => $userId]); + } + }); } private function validateRegistrationLimitPerOwnerProject() @@ -724,6 +733,9 @@ protected function _publishAssets() { // Alerts $app->view->enqueueScript('app', 'sweetalert2', 'js/sweetalert2.all.min.js'); + + + $app->view->enqueueScript('app', 'sendMailRegistrationEvaluation', 'js/sendMailRegistrationEvaluation.js'); } @@ -804,6 +816,8 @@ function register() { // $app->registerController('panel', 'Saude\Controllers\Panel'); $app->registerController('categoria-profissional', 'Saude\Controllers\ProfessionalCategory'); $app->registerController('indicadores', 'Saude\Controllers\Indicadores'); + $app->registerController('EvaluationDocumental', 'Saude\Controllers\EvaluationDocumental'); + $this->registerRegistrationMetadata('preliminaryResult', [ 'label' => i::__('Resultado Preliminar'), diff --git a/assets/css/alert_changes.css b/assets/css/alert_changes.css index bf8c08f5f..6d8e7cce9 100644 --- a/assets/css/alert_changes.css +++ b/assets/css/alert_changes.css @@ -5,4 +5,8 @@ top: 25px; bottom: 25px; font-size: 20px; +} + +.swal2-confirm { + margin-left: 20px; } \ No newline at end of file diff --git a/assets/js/sendMailRegistrationEvaluation.js b/assets/js/sendMailRegistrationEvaluation.js new file mode 100644 index 000000000..8d92a9cf8 --- /dev/null +++ b/assets/js/sendMailRegistrationEvaluation.js @@ -0,0 +1,52 @@ +function sendMailRegistrationEvaluation(opportunityId, registrationId, userId) { + const swalWithBootstrapButtons = Swal.mixin({ + customClass: { + confirmButton: 'btn btn-success', + cancelButton: 'btn btn-danger' + }, + buttonsStyling: false + }); + + swalWithBootstrapButtons.fire({ + title: 'ATENÇÃO!!!', + html: "- Você tem certeza que deseja enviar um e-mail contendo todos os campos inválidos na avaliação para o INSCRITO?

- Você tem certeza que deseja mudar a situação do inscrito para RASCUNHO?", + icon: 'warning', + showCancelButton: true, + confirmButtonText: 'Sim! Enviar e e-mail e mudar situação para RASCUNHO!', + cancelButtonText: 'Não! Cancelar!', + reverseButtons: true + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "GET", + url:`${MapasCulturais.baseURL}EvaluationDocumental/sendMailRegistrationEvaluation/${registrationId}/uid:${userId}`, + dataType: "json", + success: function (response) { + if (response.type == 'success') { + swalWithBootstrapButtons.fire({ + icon: 'success', + title: 'Sucesso!', + html: '- E-mail para o inscrito enviado com sucesso!

- Atualização do status para RASCUNHO atualizado com sucesso. ', + }).then((result) => { + if (result.isConfirmed) { + window.location.replace( `${MapasCulturais.baseURL}oportunidade/${opportunityId}/#/tab=evaluations`); + } + }); + } else { + Swal.fire({ + icon: 'error', + title: 'Oops...', + text: 'Não foi possível enviar o e-mail.', + }); + } + } + }).fail(function(error) { + Swal.fire({ + icon: 'error', + title: 'Oops...', + text: 'Não foi possível enviar o e-mail.', + }); + }); + } + }); +} \ No newline at end of file diff --git a/layouts/parts/singles/button/evaluation-documental-sendmail--button.php b/layouts/parts/singles/button/evaluation-documental-sendmail--button.php new file mode 100644 index 000000000..3689b358e --- /dev/null +++ b/layouts/parts/singles/button/evaluation-documental-sendmail--button.php @@ -0,0 +1,8 @@ +
+ ATENÇÃO!!! Ao clicar no botão "Enviar e-mail para o inscrito e alterar SITUAÇÃO para RASCUNHO" será realizado as seguintes ações:

+ - Ação de envio de e-mail para o inscrito contendo os campos/anexos invalidos pela avaliação.

+ - Ação de mudança de situação para RASCUNHO
+

+
+ +
diff --git a/templates/pt_BR/send_mail_registration_evaluation.html b/templates/pt_BR/send_mail_registration_evaluation.html new file mode 100644 index 000000000..4a5b870bd --- /dev/null +++ b/templates/pt_BR/send_mail_registration_evaluation.html @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file From 9c2ab3ec1abb62a17d8d64dd330e83ecb955fcfa Mon Sep 17 00:00:00 2001 From: victorMagalhaesPacheco Date: Thu, 12 Jan 2023 15:50:46 -0300 Subject: [PATCH 08/12] =?UTF-8?q?mostra=20observa=C3=A7=C3=A3o=20avalia?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/EvaluationDocumental.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Controllers/EvaluationDocumental.php b/Controllers/EvaluationDocumental.php index 5a3764a9d..5c6050367 100644 --- a/Controllers/EvaluationDocumental.php +++ b/Controllers/EvaluationDocumental.php @@ -34,9 +34,9 @@ public function GET_sendMailRegistrationEvaluation() $fieldInvalids = ''; $fieldInvalids .= '
    '; foreach ($evaluation->evaluationData as $evaluationData) { - if ($evaluationData && $evaluationData['evaluation'] == 'invalid') { - $observacao = !empty($observacao) ? ' Observação: ' . $evaluationData['obs'] : ''; - $fieldInvalids .= '
  • ' . $evaluationData['label'] . '' . $observacao . '
  • '; + if ($evaluationData && $evaluationData['evaluation'] ==cd 'invalid') { + $observacao = !empty($evaluationData['obs']) ? '
    Observação: ' . $evaluationData['obs'] : ''; + $fieldInvalids .= '
  • ' . $evaluationData['label'] . '' . $observacao . '

  • '; } } $fieldInvalids .= '
'; From d83e8aba2718c1069a193ceb7006bcc53e43890d Mon Sep 17 00:00:00 2001 From: victorMagalhaesPacheco Date: Thu, 12 Jan 2023 16:08:31 -0300 Subject: [PATCH 09/12] =?UTF-8?q?atualiza=20valida=C3=A7=C3=A3o=20situa?= =?UTF-8?q?=C3=A7=C3=A3o=20evaluation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/EvaluationDocumental.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controllers/EvaluationDocumental.php b/Controllers/EvaluationDocumental.php index 5c6050367..f0b06ba83 100644 --- a/Controllers/EvaluationDocumental.php +++ b/Controllers/EvaluationDocumental.php @@ -34,7 +34,7 @@ public function GET_sendMailRegistrationEvaluation() $fieldInvalids = ''; $fieldInvalids .= '
    '; foreach ($evaluation->evaluationData as $evaluationData) { - if ($evaluationData && $evaluationData['evaluation'] ==cd 'invalid') { + if ($evaluationData && $evaluationData['evaluation'] == 'invalid') { $observacao = !empty($evaluationData['obs']) ? '
    Observação: ' . $evaluationData['obs'] : ''; $fieldInvalids .= '
  • ' . $evaluationData['label'] . '' . $observacao . '

  • '; } From 329b6ace45ceebfc8dabadab63812b6484fd1204 Mon Sep 17 00:00:00 2001 From: Jefferson Oliveira Date: Thu, 12 Jan 2023 19:08:59 -0300 Subject: [PATCH 10/12] =?UTF-8?q?Valida=C3=A7=C3=A3o=20de=20CPF=20vinculad?= =?UTF-8?q?o=20a=20outro=20agente=20somente=20se=20este=20estiver=20ativo?= =?UTF-8?q?=20(cria=C3=A7=C3=A3o=20e=20edi=C3=A7=C3=A3o=20do=20agente)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Repositories/Agent.php | 2 +- Theme.php | 60 ++++++++++++++++++++++++++++++++++-------- agent-types.php | 2 +- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/Repositories/Agent.php b/Repositories/Agent.php index 4da9c84c2..af5a7c21a 100644 --- a/Repositories/Agent.php +++ b/Repositories/Agent.php @@ -14,7 +14,7 @@ public static function checkCpfLinkedAnotherAgent($typed_cpf, $agent_id) $query = $app->em->createQuery( "SELECT IDENTITY(am.owner) AS agent_id FROM MapasCulturais\Entities\AgentMeta am INNER JOIN MapasCulturais\Entities\User u WITH am.owner = u.profile - WHERE am.value = :cpf AND am.owner != :agentId AND u.status = :userStatus" + WHERE am.key = 'documento' AND am.value = :cpf AND am.owner != :agentId AND u.status = :userStatus" ); $query->setParameter('cpf', $typed_cpf); diff --git a/Theme.php b/Theme.php index 3136907a3..d9fa40950 100755 --- a/Theme.php +++ b/Theme.php @@ -3,9 +3,9 @@ namespace Saude; use MapasCulturais\App; -use MapasCulturais\i; use MapasCulturais\Entities\Project; use MapasCulturais\Entities\User; +use MapasCulturais\i; use MapasCulturais\Themes\BaseV1; use Saude\Repositories\Agent; use Saude\Utils\Validation; @@ -580,12 +580,12 @@ function _init() { $app->hook('template(space.<<*>>.tab-about-extra-info):before', function(){ $entity = $this->controller->requestedEntity; $this->part('singles/space-services', ['entity' => $entity]); - }); + }); /** * Não permite que CPF seja salvo no agente responsável pela inscrição se este já estiver vinculado a outro agente */ - $app->hook('PATCH(registration.single):data', function (&$data) use ($app) { + $app->hook('PATCH(registration.single):data', function ($data) use ($app) { $registration = $app->repo('Registration')->find(intval($data['id'])); $query = $app->em->createQuery( @@ -604,7 +604,7 @@ function _init() { if ($result) { $agent = $app->repo('Agent')->find($result[0]["agent_id"]); - + $emailVinculado = $agent->getMetadata('emailPrivado'); $emailVinculadoPart = explode('@', $emailVinculado); $user = substr($emailVinculadoPart[0], 0, -3); @@ -615,12 +615,14 @@ function _init() { if (Validation::checkValidDocument($cpf) && $cpf) { $this->errorJson( json_decode( - '{"field_'.$field_id.'": ["Já existe um cadastro vinculado a este CPF. ' . $msgEmailVinculado . '. Verifique se você possui outra conta no Mapa da Saúde."]}' - ), 400 + '{"field_' . $field_id . '": ["Já existe um cadastro vinculado a este CPF. ' . $msgEmailVinculado . '. Verifique se você possui outra conta no Mapa da Saúde."]}' + ), + 400 ); } elseif (!Validation::checkValidDocument($cpf) && $cpf) { $this->errorJson( - json_decode('{"field_'.$field_id.'": ["O número de documento informado é inválido."]}'), 400 + json_decode('{"field_' . $field_id . '": ["O número de documento informado é inválido."]}'), + 400 ); } } @@ -630,7 +632,7 @@ function _init() { /** * Adiciona máscara de CPF/CNPJ na criação e edição de um agente */ - $app->hook('entity(Agent).get(site)', function() use ($app) { + $app->hook('entity(Agent).get(site)', function () use ($app) { $app->view->enqueueScript('app', 'agent', 'js/agent.js'); }); @@ -644,20 +646,56 @@ function _init() { /** * Faz validação de CPF vinculado a outro agente somente se este estiver com status ativo (edição do agente) */ - $app->hook('PUT(agent.single):data', function (&$data) use ($app) { + $app->hook('PUT(agent.single):data', function ($data) use ($app) { $typed_cpf = $data["documento"]; $agent = $app->repo('Agent')->find(intval($this->data["id"])); $result = Agent::checkCpfLinkedAnotherAgent($typed_cpf, $agent->id); - if (Validation::checkValidDocument($typed_cpf) && $result) { + if ($result && Validation::checkValidDocument($typed_cpf)) { $this->json( json_decode('{ "data": { "documento": ["Já existe um cadastro vinculado a este CPF/CNPJ. Verifique se você possui outra conta no Mapa da Saúde."] }, "error": true - }'), 200 + }'), + 200 + ); + } else { + if (Validation::checkValidDocument($typed_cpf)) { + $agent->documento = $typed_cpf; + + $agent->save(true); + } + + return; + } + }); + + $app->hook('POST(agent.index):data', function ($data) use ($app) { + $typed_cpf = $data["documento"]; + + $query = $app->em->createQuery( + "SELECT IDENTITY(am.owner) AS agent_id FROM MapasCulturais\Entities\AgentMeta am + INNER JOIN MapasCulturais\Entities\Agent a WITH am.owner = a.id + WHERE am.key = 'documento' AND am.value = :cpf AND a.status = :agentStatus" + ); + + $query->setParameter('cpf', $typed_cpf); + $query->setParameter('agentStatus', User::STATUS_ENABLED); + + $result = $query->getResult(); + + if ($result && Validation::checkValidDocument($typed_cpf)) { + $this->json( + json_decode('{ + "data": { + "documento": ["Este CPF/CNPJ já está vinculado a outro agente"] + }, + "error": true + }'), + 200 ); } else { return; diff --git a/agent-types.php b/agent-types.php index bdbfa69d3..312ce85be 100755 --- a/agent-types.php +++ b/agent-types.php @@ -51,7 +51,7 @@ 'label' => \MapasCulturais\i::__('CPF ou CNPJ'), 'validations' => array( 'required' => \MapasCulturais\i::__('Seu documento deve ser informado.'), - 'unique' => \MapasCulturais\i::__('Já existe um cadastro vinculado a este CPF/CNPJ. Verifique se você possui outra conta no Mapa da Saúde.'), + // 'unique' => \MapasCulturais\i::__('Já existe um cadastro vinculado a este CPF/CNPJ. Verifique se você possui outra conta no Mapa da Saúde.'), 'v::oneOf(v::cpf(),v::cnpj())' => \MapasCulturais\i::__('O número de documento informado é inválido.') ), 'available_for_opportunities' => true From 38613eb1ece85524da71315772c4c6d984aeca60 Mon Sep 17 00:00:00 2001 From: Jefferson Oliveira Date: Mon, 16 Jan 2023 16:00:56 -0300 Subject: [PATCH 11/12] =?UTF-8?q?Altera=C3=A7=C3=A3o=20do=20texto=20inform?= =?UTF-8?q?ativo=20no=20upload=20de=20arquivo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Theme.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Theme.php b/Theme.php index e71afdf37..ac9d2b9ae 100755 --- a/Theme.php +++ b/Theme.php @@ -112,10 +112,10 @@ function _init() { /* INSCRIÇÕES */ // modifica mensagem de ajuda no form de upload - $app->hook('view.partial(singles/registration-edit--upload-form).params', function (&$__data) { + /* $app->hook('view.partial(singles/registration-edit--upload-form).params', function (&$__data) { $__data['form_help'] = i::__('Consulte o edital desta oportunidade para entender as limitações de tamanho e formato dos arquivos solicitados.'); - }); - + }); */ + /* PROJETOS */ // muda o nome da aba Principal para Detalhes $app->hook('view.partial(tab).params', function(&$__data, &$__template) { From 0d9161e048f3150fc0ea6e83b2beb1d7d611ae31 Mon Sep 17 00:00:00 2001 From: Jefferson Oliveira Date: Tue, 17 Jan 2023 11:44:41 -0300 Subject: [PATCH 12/12] =?UTF-8?q?Inser=C3=A7=C3=A3o=20de=20uma=20nova=20ta?= =?UTF-8?q?xonomia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taxonomies.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/taxonomies.php b/taxonomies.php index d6da1a163..d9db6afa9 100644 --- a/taxonomies.php +++ b/taxonomies.php @@ -34,5 +34,12 @@ ), 'restricted_terms' => array() + ), + 4 => array( + 'slug' => 'funcao', + 'description' => i::__('Função'), + 'entities' => array( + 'MapasCulturais\Entities\Agent' + ) ) );