Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Usuarios extends CI_Controller {
  5.  
  6. public function obter_informacoes() {
  7.  
  8. $this->form_validation->set_rules('cnpj', 'CNPJ', 'required|trim|xss_clean');
  9. $this->form_validation->set_rules('chave', 'Chave', 'required|trim|xss_clean|callback__validar_chave');
  10.  
  11. $json = array();
  12. if ($this->form_validation->run() == TRUE) {
  13. $res = $this->sqlanywhere->execute("SELECT FIRST * FROM DBA.WCADCDF WHERE C_CGC_TRA='".set_value('cnpj')."'");
  14. $json = fixSybaseStringArrays($res);
  15. $this->sqlanywhere->disconnect();
  16. }
  17.  
  18. echo json_encode($json);
  19. }
  20.  
  21. public function obter_geradores_do_cnpj() {
  22.  
  23. $this->form_validation->set_rules('cnpj', 'CNPJ', 'required|trim|xss_clean');
  24. $this->form_validation->set_rules('chave', 'Chave', 'required|trim|xss_clean|callback__validar_chave');
  25.  
  26. $json = array(134);
  27. if ($this->form_validation->run() == TRUE) {
  28. $sql = "SELECT I_COD_CLI,C_NOM_CLI FROM DBA.WCADCDF
  29. WHERE C_CGC_TRA='".set_value('cnpj')."'
  30. GROUP BY I_COD_CLI,C_NOM_CLI
  31. ORDER BY C_NOM_CLI ASC";
  32. $res = $this->sqlanywhere->execute($sql);
  33. $json = fixSybaseStringArrays($res);
  34. $this->sqlanywhere->disconnect();
  35. }
  36.  
  37. echo json_encode($json);
  38. }
  39.  
  40. public function _validar_chave($chave) {
  41. $this->_ws_chave = $this->config->item('ws_chave');
  42.  
  43. if ($this->_ws_chave == $chave) {
  44. return true;
  45. } else {
  46. $this->form_validation->set_message('_validar_chave', 'A Chave estΓ‘ incorreta!');
  47. return false;
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement