diff --git a/app/routes/api.php b/app/routes/api.php index 63cf1d1e46..cd7fcf08e6 100644 --- a/app/routes/api.php +++ b/app/routes/api.php @@ -4,6 +4,7 @@ use App\Controller\Api\WelcomeApiController; use Symfony\Component\HttpFoundation\Request; +use App\Controller\Api\OpportunityApiController; $routes = [ '/api' => [ @@ -14,6 +15,9 @@ Request::METHOD_POST => [WelcomeApiController::class, 'create'], Request::METHOD_DELETE => [WelcomeApiController::class, 'delete'], ], + '/api/findOpportunitiesModels' => [ + Request::METHOD_GET => [OpportunityApiController::class, 'findOpportunitiesModels'], + ] ]; $files = glob(__DIR__.'/api/*.php'); diff --git a/app/src/Controller/Api/OpportunityApiController.php b/app/src/Controller/Api/OpportunityApiController.php index e7c82399df..e5a3c90562 100644 --- a/app/src/Controller/Api/OpportunityApiController.php +++ b/app/src/Controller/Api/OpportunityApiController.php @@ -88,4 +88,11 @@ public function delete(array $params): JsonResponse return new JsonResponse(['error' => $exception->getMessage()], Response::HTTP_BAD_REQUEST); } } + + public function findOpportunitiesModels(): JsonResponse + { + $models = $this->repository->findOpportunitiesModels(); + + return new JsonResponse($models); + } } diff --git a/app/src/Repository/OpportunityRepository.php b/app/src/Repository/OpportunityRepository.php index 004b99a73d..d55413b26a 100644 --- a/app/src/Repository/OpportunityRepository.php +++ b/app/src/Repository/OpportunityRepository.php @@ -37,7 +37,6 @@ public function save(Opportunity $opportunity): void $this->mapaCulturalEntityManager->persist($opportunity); $this->mapaCulturalEntityManager->flush(); } - public function findOpportunitiesByAgentId(int $agentId): array { $queryBuilder = $this->getEntityManager() @@ -50,10 +49,61 @@ public function findOpportunitiesByAgentId(int $agentId): array return $queryBuilder->getQuery()->getArrayResult(); } - public function softDelete(Opportunity $opportunity): void { $opportunity->setStatus(EntityStatusEnum::TRASH->getValue()); $this->save($opportunity); } + + public function findOpportunitiesModels(): array { + $app = \MapasCulturais\App::i(); + $em = $app->em; + $queryBuilder = $em->createQueryBuilder() + ->select( + 'o.id', + 'o.name', + '(COUNT(p.id) + 2) AS numeroFases', + 'o.registrationTo', + 'o.registrationFrom', + 'o.shortDescription AS descricao', + 'o.registrationProponentTypes AS tipoAgente' + ) + ->from(Opportunity::class, 'o') + ->leftJoin(Opportunity::class, 'p', 'WITH', 'p.parent = o.id') + ->where('o.parent IS NULL') + ->andWhere('o.status = -1') + ->groupBy('o.id, o.name'); + + $results = $queryBuilder->getQuery()->getArrayResult(); + + foreach ($results as &$result) { + if (isset($result['registrationTo']) && isset($result['registrationFrom'])) { + $registrationTo = $result['registrationTo']; + $registrationFrom = $result['registrationFrom']; + + if (!$registrationTo instanceof \DateTime) { + $registrationTo = new \DateTime($registrationTo); + } + if (!$registrationFrom instanceof \DateTime) { + $registrationFrom = new \DateTime($registrationFrom); + } + + $interval = $registrationFrom->diff($registrationTo); + $days = $interval->days; + + $result['tempoEstimado'] = "$days dias"; + } else { + $result['tempoEstimado'] = 'N/A'; + } + + if (isset($result['tipoAgente'])){ + + $result['tipoAgente'] = implode(', ', $result['tipoAgente']); + }else { + $result['tipoAgente'] = 'N/A'; + } + } + return $results; + } + } diff --git a/src/modules/EvaluationMethodQualification/Module.php b/src/modules/EvaluationMethodQualification/Module.php index 31d6774cba..368a237818 100644 --- a/src/modules/EvaluationMethodQualification/Module.php +++ b/src/modules/EvaluationMethodQualification/Module.php @@ -157,7 +157,7 @@ protected function _register() return json_encode($val); }, 'unserialize' => function ($val) { - return json_decode($val); + return $val !== null ? json_decode($val) : null; } ]); @@ -168,7 +168,7 @@ protected function _register() return json_encode($val); }, 'unserialize' => function ($val) { - return json_decode($val); + return $val !== null ? json_decode($val) : null; } ]); } diff --git a/src/modules/Panel/components/panel--entity-card/template.php b/src/modules/Panel/components/panel--entity-card/template.php index ba9beb355f..af9eddfc6c 100644 --- a/src/modules/Panel/components/panel--entity-card/template.php +++ b/src/modules/Panel/components/panel--entity-card/template.php @@ -14,7 +14,7 @@ '); ?> -
+
diff --git a/src/modules/Panel/components/panel--entity-tabs/script.js b/src/modules/Panel/components/panel--entity-tabs/script.js index b36f6bc5fb..446bedc500 100644 --- a/src/modules/Panel/components/panel--entity-tabs/script.js +++ b/src/modules/Panel/components/panel--entity-tabs/script.js @@ -8,6 +8,19 @@ app.component('panel--entity-tabs', { }, created() { + fetch('/api/findOpportunitiesModels') + .then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); + }) + .then(data => { + this.models = data; + }) + .catch(error => { + console.error('There was a problem with the fetch operation:', error); + }); }, data() { @@ -43,6 +56,7 @@ app.component('panel--entity-tabs', { archived: { status: 'EQ(-2)', ...query }, }, showPrivateKey: false, + models: [], } }, diff --git a/src/modules/Panel/components/panel--entity-tabs/template.php b/src/modules/Panel/components/panel--entity-tabs/template.php index 9e67392fd2..5de12c6f50 100644 --- a/src/modules/Panel/components/panel--entity-tabs/template.php +++ b/src/modules/Panel/components/panel--entity-tabs/template.php @@ -36,7 +36,7 @@ $this->applyComponentHook('.sortOptions', [&$tabs]); ?> - + applyComponentHook('begin') ?> + + + + + + + applyComponentHook($status, 'end') ?> diff --git a/src/themes/BaseV2/assets-src/sass/2.components/_entity-card.scss b/src/themes/BaseV2/assets-src/sass/2.components/_entity-card.scss index ec5b4a5f81..75f03f2442 100644 --- a/src/themes/BaseV2/assets-src/sass/2.components/_entity-card.scss +++ b/src/themes/BaseV2/assets-src/sass/2.components/_entity-card.scss @@ -598,6 +598,11 @@ font-size: 14px; line-height: 19px; } + .models &{ + position: absolute; + bottom: 30px; + left: 15px; + } } &.right { @@ -628,6 +633,11 @@ justify-content: center; } } + .models &{ + position: absolute; + bottom: 30px; + right: 25px; + } } button { @@ -664,4 +674,22 @@ } } } -} \ No newline at end of file +} + +article.panel-entity-card.col-6{ + min-width: 450px; + max-width: 450px; + min-height: 530px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); + .panel-entity-card__header--info{ + margin-top: 85px; + margin-left: -80px; + } +} +.icon-model{ + font-size: size(20) !important; + color: #117C83; + margin-right: 8px; + margin-top: 15px; + vertical-align: text-bottom; +} diff --git a/src/themes/BaseV2/assets-src/sass/layouts/_entity-tabs.scss b/src/themes/BaseV2/assets-src/sass/layouts/_entity-tabs.scss index f6ad44b6f2..848397f78d 100644 --- a/src/themes/BaseV2/assets-src/sass/layouts/_entity-tabs.scss +++ b/src/themes/BaseV2/assets-src/sass/layouts/_entity-tabs.scss @@ -82,4 +82,19 @@ $iconUrl: 'https://api.iconify.design/ic/baseline-arrow-drop-down.svg' +#{$iconC } } + span.card-info{ + position: relative; + top: -125px; + left: 300px; + color: rgb(127, 122, 122); + font-weight: 600; + font-size: 14px; + } + + div.card-desc{ + text-transform: none; + strong{ + margin-top: 5px; + } + } } \ No newline at end of file