-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from secultce/develop
🔗 Merge Develop to Master
- Loading branch information
Showing
10 changed files
with
609 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.