| Server IP : 162.214.74.102 / Your IP : 216.73.217.80 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/public_html/lrsys_apps/imobles/application/controllers/ |
Upload File : |
<?php
_auth();
$action = $routes['1'];
switch ($action) {
//busca a lista de cidades
case 'date_time':
echo date( $config['df']." H:i");
break;
case 'city':
$state_id = intval($_GET['state_id']);
//recebe o parametro do estado
if ($state_id > 0) {
$city = ORM::for_table('city')->select('id')->select('city_name')->where('id_state', $state_id)->find_many();
foreach ($city as $c) {
$data[] = array(
'id' => $c->id,
'city_name' => $c->city_name,
);
}
echo json_encode($data);
}
break;
case 'state-list':
$city = ORM::for_table('state')->find_many();
foreach ($city as $c) {
$data[] = array(
'id' => $c->id,
'state_name' => $c->state_name,
'uf_state' => $c->uf_state,
);
}
echo json_encode($data);
break;
case 'state-by-uf':
$state_id = $routes['2'];
$state = ORM::for_table('state')->where('uf_state',$state_id)->find_many();
if(count($state)>0){
echo $state[0]->id;
}else{
echo "";
}
break;
case 'groups':
$gs = ORM::for_table('crm_groups')->order_by_asc('sorder')->find_many();
foreach ($gs as $g) {
// LEONARDO LOPES
// 02/06/2020
// Oculto o grupo de Employee para cadastro de contatos
// Verificar se não vai dar erro no cadastro de Coloboradores (module_hr)
if($g->id == 5)
{
continue;
}
$data[] = array(
'id' => $g->id,
'gname' => isset($_L[$g->gname])? $_L[$g->gname] : $g->gname,
);
}
echo json_encode($data);
break;
case 'tags':
$tags = Tags::get_all('Contacts');
foreach ($tags as $t) {
$data[] = array(
'text' => $t->text,
);
}
echo json_encode($data);
break;
case 'zip':
// TODO: API DOS CORREIOS NÃO FUNCIONA MAIS. MUDAR PARA https://viacep.com.br/ws/88050150/json/
header('Content-Type: application/json');
$data[] = array(
'status' => 'BUSCA POR CEP ESTÁ TEMPORARIAMENTE INDISPONÍVEL.');
echo json_encode($data);
break;
require('application/lib/correios/Correios.php');
//recebe cep e retira a m�scara
$zip = preg_replace('/\D/', '', _post('zip'));
//aciona a pasta correios de dentro da lib, adequado do plugin do magento
$data = Correios::getEndereco($zip);
header('Content-Type: application/json');
if ($data) {
//busca a cidade
$state = ORM::for_table('state')->select('id')
->where_raw('uf_state = "'.$data['state'].'"')
->find_one();
$city_aux = str_replace('\'', '\\\'', $data['city']);
$city = ORM::for_table('city')->select('id')->select('city_name')->select('id_state')
->where_raw("city_name like '" . $city_aux . "' AND id_state = ".$state->id)->find_one();
//carrega os dados
$data[] = array(
'status' => 'OK',
'city_id' => ($city) ? $city->id : '',
'state_id' => ($city) ? $city->id_state : '',
'address' => $data['address'],
'zip' => $data['zip'],
'neighborhood' => $data['neighborhood']
);
} else {
//valida para as mensagens de erro
if (count($zip != 8)) {
$data[] = array(
'status' => $_L['Could not retrieve zip code data. Reason: SEARCH AS DEFINED AS EXACT, ZIP SHOULD BE 8 DIGITS']);
} else {
//mensagem caso n�o tenha encontrado o cep
$data[] = array(
'status' => $_L['Could not retrieve zip code data.Reason: ZIP NOT FOUND']);
}
}
echo json_encode($data);
break;
default:
echo 'action not defined';
}