Skip to content

Commit

Permalink
Merge pull request #70 from secultce/develop
Browse files Browse the repository at this point in the history
🔗 Merge Develop to Master
  • Loading branch information
Junior-Shyko authored Nov 29, 2023
2 parents 5ffb511 + 7916cdf commit d52dfdc
Show file tree
Hide file tree
Showing 10 changed files with 609 additions and 41 deletions.
105 changes: 105 additions & 0 deletions Controllers/SearchAll.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

namespace Ceara\Controllers;

use DateTime;
use MapasCulturais\App;

class SearchAll extends \MapasCulturais\Controller
{

function GET_all()
{
$this->requireAuthentication();
$app = App::i();
$app->view->enqueueScript('app', 'agent-search', 'js/agents/search/ng.agent-search.js');
$app->view->enqueueStyle('app', 'tabs-style', 'css/search/style.css');
$this->render("index");
}
/**
* Metodo que recebe os paramentros e realiza uma busca no banco e devolvo para front
*
* @return void
*/
function POST_searchAgent()
{
$this->requireAuthentication();

$app = App::i();
if ($this->data['type'] == 'email') {
//Busca somente por um resultado por que não tem o mesmo email varias vezes
$row = $app->repo('User')->findOneBy(['email' => $this->data['value']]);
//Dados para envio
$result = $this->getReturnData($row);
return $this->json(['data' => $result], 200);
}

if ($this->data['type'] == 'cpf') {
try {
//Busca por cpf ou documento em caso de agente em rascunho
$row = $app->repo("AgentMeta")->findBy([
'key' => array('cpf','documento'), 'value' => $this->data['value']
]);
$result = $this->getReturnData($row);
return $this->json(['data' => $result], 200);
} catch (\Throwable $th) {
throw $th;
}
}

if ($this->data['type'] == 'dataDeNascimento') {
//Alterando formato da data
$birthDate = str_replace("/", "-", $this->data['value']);
try {
$row = $app->repo("AgentMeta")->findBy([
'key' => 'dataDeNascimento', 'value' => date('Y-m-d', strtotime($birthDate))
]);
$result = $this->getReturnData($row);

return $this->json(['data' => $result], 200);
} catch (\Throwable $th) {
throw $th;
}
}

if ($this->data['type'] == 'cnpj') {
try {
$row = $app->repo("AgentMeta")->findBy([
'key' => array('cnpj','documento'), 'value' => $this->data['value']
]);
$result = $this->getReturnData($row);

return $this->json(['data' => $result], 200);
} catch (\Throwable $th) {
throw $th;
}
}
}

/**
* Funcao que retorna uma matriz de array
*
* @param [object] $rows
* @return array
*/
function getReturnData($rows) {
$result = [];
$app = App::i();
//Para busca com email
if(gettype($rows) == 'object'){
$agent = $app->repo('Agent')->find($rows->profile->id);
$result['id'] = $agent->owner->user->id;
$result['name'] = $agent->name;
$result['longDescription'] = $agent->longDescription;
}
foreach ($rows as $key => $value) {
//Buscando instancia de cada agente para montar o array de resultado
$agent = $app->repo('Agent')->find($value->owner->id);
//Preenchendo array
$result[$key]['id'] = $agent->owner->user->id;
$result[$key]['name'] = $agent->name;
$result[$key]['longDescription'] = $agent->longDescription;
}
return $result;
}
}
25 changes: 24 additions & 1 deletion Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ protected function _init()
//Para notificação ao usuário
$this->enqueueScript('app', 'pnotify', 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.0.0/pnotify.min.js');
$this->enqueueScript('app', 'pnotify-animate', 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.0.0/pnotify.animate.min.js');
$this->enqueueScript('app', 'pnotify-confirm', 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.0.0/pnotify.confirm.min.js');
$this->enqueueScript('app', 'pnotify-buttons', 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.0.0/pnotify.buttons.min.js');
$this->enqueueStyle('app', 'pnotify', 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.0.0/pnotify.min.css');
$this->enqueueStyle('app', 'pnotify-theme', 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.0.0/pnotify.brighttheme.min.css');
$this->enqueueStyle('app', 'pnotify-buttons', 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.0.0/pnotify.buttons.min.css');
//chamada do arquivo js que contém o ocultar botão + da modal criação
$this->enqueueScript('app', 'hidebutton', 'js/opportunity-ceara/hidebutton.js');

Expand Down Expand Up @@ -1992,6 +1995,10 @@ protected function _init()
$this->part('report/opportunity-report-buttons', ['entity' => $opportunity]);
});

$app->hook('template(opportunity.single.tab-about):begin', function () use ($app) {
$app->view->enqueueScript('app', 'btn-disable-on-register', 'js/opportunity-ceara/btn-disable-on-register.js');
});

//relatórios de inscritos botão antigo
$app->hook("<<GET|POST>>(opportunity.reportOld)", function () use ($app) {
//return var_dump("ola");
Expand Down Expand Up @@ -2308,7 +2315,20 @@ protected function _init()
$app->hook('template(registration.view.form):begin', function() use ($app) {
$this->part('registration/ceara/alert-collective');
});
}

/**
* Hook para colocar link na lateral esqueda
*/
$app->hook('template(<<*>>.nav.panel.userManagement):before', function() use ($app) {
$url = $app->config['base.url'] . 'pesquisar/all';
echo '<li>
<a href="'. $url .'" target="_blank">
<span class="icon icon-publication-status-open"></span> Busca avançada Usuário </a>
</li>';
});


}

/**
* Mesmo métido da Entidade User.php, mas com uma validação para tratar o erro
Expand Down Expand Up @@ -2387,6 +2407,7 @@ public function register()
$app = App::i();
parent::register();

$app->registerController('pesquisar', Controllers\SearchAll::class);
/**
* Adicionando novos metadata na entidade Projeto
*
Expand Down Expand Up @@ -2762,6 +2783,8 @@ public function register()
//ID É O VALOR DO INDICE DO ARRAY DO ARQUIVO TAXONOMI
$def = new \MapasCulturais\Definitions\Taxonomy(6, 'funcao', 'Função', $newsTaxo, false);
$app->registerTaxonomy('MapasCulturais\Entities\Agent', $def);


}
/**
* Fix agent Permission
Expand Down
10 changes: 10 additions & 0 deletions assets/css/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion assets/css/sass/_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,13 @@
white-space: break-spaces;
min-height: 75px;
}
}
}

#sidebars {
position: sticky;
top: 0 !important;
display: block !important;
justify-content: space-between; }
@media (max-width: 1199px) {
#sidebars {
flex-direction: column; } }
174 changes: 174 additions & 0 deletions assets/css/search/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
.form-control {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
}
.form-group {
margin-bottom: 15px;
}
.form-group-sm .form-control {
height: 30px;
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
.form-group-sm select.form-control {
height: 30px;
line-height: 30px;
}
.panel {
margin-bottom: 20px;
background-color: #fff;
border: 1px solid transparent;
border-radius: 4px;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}
.panel-body {
padding: 15px;
}
.panel-heading {
padding: 10px 15px;
border-bottom: 1px solid transparent;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.panel-heading > .dropdown .dropdown-toggle {
color: inherit;
}
.panel-title {
margin-top: 0;
margin-bottom: 0;
font-size: 16px;
color: inherit;
}
.panel-title > a,
.panel-title > small,
.panel-title > .small,
.panel-title > small > a,
.panel-title > .small > a {
color: inherit;
}
.panel-footer {
padding: 10px 15px;
background-color: #f5f5f5;
border-top: 1px solid #ddd;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
}
.panel-default {
border-color: #ddd;
}
.panel-default > .panel-heading {
color: #333333;
background-color: #f5f5f5;
border-color: #ddd;
}
.panel-default > .panel-heading + .panel-collapse > .panel-body {
border-top-color: #ddd;
}
.panel-default > .panel-heading .badge {
color: #f5f5f5;
background-color: #333333;
}
.panel-default > .panel-footer + .panel-collapse > .panel-body {
border-bottom-color: #ddd;
}

.list-group {
padding-left: 0;
margin-bottom: 20px;
}
.list-group-item {
position: relative;
display: block;
padding: 10px 15px;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid #ddd;
}

.list-group-item.active > .badge,
.nav-pills > .active > a > .badge {
color: #337ab7;
background-color: #fff;
}
.list-group-item > .badge {
float: right;
}
.list-group-item > .badge + .badge {
margin-right: 5px;
}

.list-group-item.active,
.list-group-item.active:hover,
.list-group-item.active:focus {
z-index: 2;
color: #fff;
background-color: #337ab7;
border-color: #337ab7;
}
.list-group-item.active .list-group-item-heading,
.list-group-item.active:hover .list-group-item-heading,
.list-group-item.active:focus .list-group-item-heading,
.list-group-item.active .list-group-item-heading > small,
.list-group-item.active:hover .list-group-item-heading > small,
.list-group-item.active:focus .list-group-item-heading > small,
.list-group-item.active .list-group-item-heading > .small,
.list-group-item.active:hover .list-group-item-heading > .small,
.list-group-item.active:focus .list-group-item-heading > .small {
color: inherit;
}
.list-group-item.active .list-group-item-text,
.list-group-item.active:hover .list-group-item-text,
.list-group-item.active:focus .list-group-item-text {
color: #c7ddef;
}
.list-group-item,
button.list-group-item {
color: #555;
}
a.list-group-item .list-group-item-heading,
button.list-group-item .list-group-item-heading {
color: #333;
}
a.list-group-item:hover,
button.list-group-item:hover,
a.list-group-item:focus,
button.list-group-item:focus {
color: #555;
text-decoration: none;
background-color: #f5f5f5;
}
button.list-group-item {
width: 100%;
text-align: left;
}
.sub-title-search {
font-weight: 300 !important;
font-size: small;
color: #918f8f;
}
.btn-search-all {
display: flex;
width: 100%;
justify-content: center;
text-align: center !important;
}
Loading

0 comments on commit d52dfdc

Please sign in to comment.