Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Usuarios extends CI_Controller {
- public function obter_informacoes() {
- $this->form_validation->set_rules('cnpj', 'CNPJ', 'required|trim|xss_clean');
- $this->form_validation->set_rules('chave', 'Chave', 'required|trim|xss_clean|callback__validar_chave');
- $json = array();
- if ($this->form_validation->run() == TRUE) {
- $res = $this->sqlanywhere->execute("SELECT FIRST * FROM DBA.WCADCDF WHERE C_CGC_TRA='".set_value('cnpj')."'");
- $json = fixSybaseStringArrays($res);
- $this->sqlanywhere->disconnect();
- }
- echo json_encode($json);
- }
- public function obter_geradores_do_cnpj() {
- $this->form_validation->set_rules('cnpj', 'CNPJ', 'required|trim|xss_clean');
- $this->form_validation->set_rules('chave', 'Chave', 'required|trim|xss_clean|callback__validar_chave');
- $json = array(134);
- if ($this->form_validation->run() == TRUE) {
- $sql = "SELECT I_COD_CLI,C_NOM_CLI FROM DBA.WCADCDF
- WHERE C_CGC_TRA='".set_value('cnpj')."'
- GROUP BY I_COD_CLI,C_NOM_CLI
- ORDER BY C_NOM_CLI ASC";
- $res = $this->sqlanywhere->execute($sql);
- $json = fixSybaseStringArrays($res);
- $this->sqlanywhere->disconnect();
- }
- echo json_encode($json);
- }
- public function _validar_chave($chave) {
- $this->_ws_chave = $this->config->item('ws_chave');
- if ($this->_ws_chave == $chave) {
- return true;
- } else {
- $this->form_validation->set_message('_validar_chave', 'A Chave estΓ‘ incorreta!');
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement