Created
January 21, 2019 16:40
-
-
Save CarlosDanielDev/902acebff97b97623ac08bdc0af8540f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?php | |
| namespace App\Controller; | |
| class AcoesConsulta{ | |
| private $token; | |
| public function __construct(){ | |
| $this->geraToken(); | |
| } | |
| public function geraToken(){ | |
| $vars = array( | |
| "user"=>"daniel@suldopara.com.br", | |
| "pwd"=> "1234" | |
| ); | |
| $strings = http_build_query($vars); | |
| $ch = curl_init(); | |
| $url ="http://192.168.3.150:3000/api/login"; | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_POST, count($vars)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS,$strings); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $result = curl_exec($ch); | |
| curl_close($ch); | |
| $decode = json_decode($result, true); | |
| $token = $decode["data"]; | |
| return $token; | |
| } | |
| public function listPrm($idGrupo){ | |
| $dataPerm = array('token'=>$this->token, 'idGrupo'=>$idGrupo); | |
| $str_dataPerm = http_build_query($dataPerm); | |
| $urlListar = 'http://192.168.3.150:3000/api/permissoes/listPrm'; | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $urlListar); | |
| curl_setopt($ch, CURLOPT_POST, count($dataPerm)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str_dataPerm); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $data_grupo = curl_exec($ch); | |
| curl_close($ch); | |
| $data_formated = json_decode($data_grupo, true); | |
| $dadosPermissao = $data_formated['data']; | |
| return $dadosPermissao; | |
| } | |
| public function listSub(){ | |
| $dataListSub = array('token'=>$this->token); | |
| $str_listSub = http_build_query($dataListSub); | |
| $ch = curl_init(); | |
| $url_listSub = 'http://192.168.3.150:3000/api/permissoes/list'; | |
| curl_setopt($ch, CURLOPT_URL, $url_listSub); | |
| curl_setopt($ch, CURLOPT_POST, count($dataListSub)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str_listSub); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $result = curl_exec($ch); | |
| $res = json_decode($result, true); | |
| $array = $res['data']; | |
| return $array; | |
| } | |
| public function listarLotesGrupo($id){ | |
| $dataListLotes = array('token'=>$this->token, 'idGrupo'=>$id); | |
| $str_ListLotes = http_build_query($dataListLotes); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/grupo/lotes/list'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($dataListLotes)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str_ListLotes); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $result = curl_exec($ch); | |
| $res = json_decode($result, true); | |
| $array = $res['data']; | |
| return $array; | |
| } | |
| public function listarEstruturas(){ | |
| $dataListEstruturas = array('token'=>$this->token); | |
| $str = http_build_query($dataListEstruturas); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/permissoes/listEstrutura'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($dataListEstruturas)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $result = curl_exec($ch); | |
| $res = json_decode($result, true); | |
| $array = $res['data']; | |
| print_r($res); | |
| return $array; | |
| } | |
| public function listCertificados($idLote){ | |
| $dataListCertificados = array('token'=>$this->token, 'idLote'=>$idLote); | |
| $str = http_build_query($dataListCertificados); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/certificado/list'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($dataListCertificados)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $result = curl_exec($ch); | |
| $res = json_decode($result, true); | |
| $array = $res['data']; | |
| return $array; | |
| } | |
| public function listUsers($idGrupo){ | |
| $dataListUsers = array('token'=>$this->token, 'idGrupo' => $idGrupo); | |
| $str = http_build_query($dataListUsers); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/grupo/users/list'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($dataListUsers)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $users = curl_exec($ch); | |
| $user = json_decode($users, true); | |
| $array = $user['data']; | |
| return $array; | |
| } | |
| public function listUnidades($idGrupo){ | |
| $dataListUnidades = array('token'=>$this->token, 'idGrupo' => $idGrupo); | |
| $str = http_build_query($dataListUnidades); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/grupo/unidades/list'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($dataListUnidades)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $unidades = curl_exec($ch); | |
| curl_close($ch); | |
| $uni = json_decode($unidades, true); | |
| $array = $uni['data']; | |
| return $array; | |
| } | |
| public function listOneLote($idUnidade, $idLote){ | |
| $dataListOndeLote = array("token" => $this->token, "idUnidade"=>$idUnidade, "idLote"=>$idLote); | |
| $str = http_build_query($dataListOndeLote); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/lotes/list/id'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($dataListOndeLote)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $lotes = curl_exec($ch); | |
| curl_close($ch); | |
| $lt = json_decode($lotes, true); | |
| // print_r($lt); | |
| $array = $lt['data']; | |
| return $array; | |
| } | |
| public function listLotes($idUnidade){ | |
| $data = array("token" => $this->token, "idUnidade"=>$idUnidade); | |
| $str = http_build_query($data); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/lotes/list'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($data)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $lotes = curl_exec($ch); | |
| curl_close($ch); | |
| $lt = json_decode($lotes, true); | |
| $array = $lt['data']; | |
| return $array; | |
| } | |
| public function setStatusCertificado($idMonit, $idLote_){ | |
| $data = array('token'=>$this->token, 'idMonitoramento'=>$idMonit, 'idLote'=>$idLote_); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/certificados/desvincular'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function vinculaCertificado($idMonitoramento, $idLote, $idUnidade, $idGrupo, $user_cadastro, $status){ | |
| $data = array( | |
| 'token'=>$this->token, | |
| 'idMonitoramento'=>$idMonitoramento, | |
| 'idLote'=>$idLote, | |
| 'idUnidade'=>$idUnidade, | |
| 'idGrupo'=>$idGrupo, | |
| 'user_cadastro'=>$user_cadastro, | |
| 'status'=>$status | |
| ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/certificados/vinc'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function listGrupo(){ | |
| $data = array("token" => $this->token); | |
| $str = http_build_query($data); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/grupo/list'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($data)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $grupos = curl_exec($ch); | |
| curl_close($ch); | |
| $gp = json_decode($grupos, true); | |
| $array = $gp['data']; | |
| return $array; | |
| } | |
| public function listOneUnidade($idUnidade){ | |
| $data = array('token' => $this->token, 'idUnidade'=>$idUnidade ); | |
| $str = http_build_query($data); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/grupo/unidade/id'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($data)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $unidade = curl_exec($ch); | |
| curl_close($ch); | |
| $uni = json_decode($unidade, true); | |
| $array = $uni['data']; | |
| return $array; | |
| } | |
| public function listOne($id){ | |
| $data = array('token' => $this->token, 'id'=>$id ); | |
| $str = http_build_query($data); | |
| $ch = curl_init(); | |
| $http = 'http://192.168.3.150:3000/api/grupo/id'; | |
| curl_setopt($ch, CURLOPT_URL, $http); | |
| curl_setopt($ch, CURLOPT_POST, count($data)); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $data_grupo = curl_exec($ch); | |
| curl_close($ch); | |
| $data_formated = json_decode($data_grupo, true); | |
| $array = $data_formated['data'][0]; | |
| return $array; | |
| } | |
| public function editUser($nome, $email, $login, $senha, $user_alteracao, $idUser){ | |
| $data = array('token'=>$this->token, 'nome'=>$nome, 'email'=>$email, 'login'=>$login, 'senha'=>$senha, 'user_alteracao'=>$user_alteracao, 'idUser'=>$idUser); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/users/edit'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function editUidade($unidade, $cnpj, $idUser, $idUnidade){ | |
| $data = array('token'=>$this->token, 'unidade'=>$unidade, 'cnpj'=>$cnpj, 'user_alteracao'=>$idUser, 'idUnidade'=>$idUnidade); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/grupo/unidade/edit'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function editGrupo($grupo, $status, $idGrupo, $idUser){ | |
| $data = array('token'=>$this->token, 'grupo'=>$grupo, 'status'=>$status, 'id'=>$idGrupo, 'user_alteracao'=>$idUser); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/grupo/edit'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function insertGrupo($grupo, $status, $idUser){ | |
| $data = array('token' => $this->token, 'grupo' => $grupo, 'status' => $status, 'user_cadastro' => $idUser, 'user_alteracao' => $idUser ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/grupo/inserir'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function insertUnidade($unidade, $cnpj, $idGrupo, $id){ | |
| $data = array('token'=>$this->token, 'unidade'=>$unidade, 'cnpj'=>$cnpj, 'user_cadastro'=>$id, 'user_alteracao'=>$id, 'idGrupo'=>$idGrupo, 'status'=>'1' ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/grupo/unidade/inserir'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function insertUser($nome, $email, $pass, $login, $idUser, $cpf, $idGrupo, $idIndutria){ | |
| $data = array( | |
| 'token'=>$this->token, | |
| 'nome'=>$nome, | |
| 'email'=>$email, | |
| 'senha'=>$pass, | |
| 'login'=>$login, | |
| 'user_cadastro'=>$idUser, | |
| 'user_alteracao'=>$idUser, | |
| 'status'=>'1', | |
| 'cpf'=>$cpf, | |
| 'idGrupo'=>$idGrupo, | |
| 'idIndustria'=>$idIndutria | |
| ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/users/insert'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function setStatusLote($idLote){ | |
| $data = array( | |
| 'token'=>$this->token, | |
| 'idLote'=>$idLote | |
| ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/lotes/setStatus'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function setStatusUnidade($idUnidade){ | |
| $data = array('token'=>$this->token, 'idUnidade'=>$idUnidade); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/grupo/unidade/setStatus'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function setStatusGrupo($idGrupo){ | |
| $data = array('token'=>$this->token, 'idGrupo'=>$idGrupo); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/grupo/setStatus'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function setStatusUser($idUser, $idGrupo){ | |
| $data = array( | |
| 'token'=>$this->token, | |
| 'idUser'=>$idUser, | |
| 'idGrupo'=>$idGrupo | |
| ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/users/setStatus'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function insertLote($id, $nfs, $idUnidade, $cnpj, $obs){ | |
| $data = array( | |
| 'token'=>$this->token, | |
| 'user_cadastro'=>$id, | |
| 'nfs'=>$nfs, | |
| 'idUnidade'=>$idUnidade, | |
| 'cnpj'=>$cnpj, | |
| 'obs'=>$obs, | |
| 'status'=>'1', | |
| 'user_alteracao'=>$id | |
| ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/grupo/unidade/lote/inserir'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function insertPermissao($idGrupo, $idPermissoes){ | |
| $data = array( | |
| 'token'=>$this->token, | |
| 'idGrupo'=>$idGrupo, | |
| 'idPermissao'=>$idPermissoes, | |
| 'status'=>'1' | |
| ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/permissoes/insert'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function editarLote($idLote, $nfs, $obs, $idUser){ | |
| $data = array( | |
| 'token'=>$this->token, | |
| 'idLote'=>$idLote, | |
| 'nfs'=>$nfs, | |
| 'obs'=>$obs, | |
| 'idUserAlteracao'=>$idUser | |
| ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/lotes/edit'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| public function removePermissao($idGrupo, $idPermissoes){ | |
| $data = array( | |
| 'token'=>$this->token, | |
| 'idGrupo'=>$idGrupo, | |
| 'idPermissao'=>$idPermissoes | |
| ); | |
| $str = http_build_query($data); | |
| $http = 'http://192.168.3.150:3000/api/permissoes/remove'; | |
| $ch = curl_init($http); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | |
| $return = curl_exec($ch); | |
| $data_formated = json_decode($return, true); | |
| return $data_formated; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment