Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Pedidos extends CI_Controller {
  5.  
  6. public function obter_pedidos() {
  7.  
  8. $this->form_validation->set_rules('cnpj', 'CNPJ', 'required|trim|xss_clean');
  9. $this->form_validation->set_rules('periodo_inicial', 'Período Inicial', 'trim|xss_clean');
  10. $this->form_validation->set_rules('periodo_final', 'Período Final', 'trim|xss_clean');
  11. $this->form_validation->set_rules('chave', 'Chave', 'required|trim|xss_clean|callback__validar_chave');
  12.  
  13. $json = array();
  14. if ($this->form_validation->run() == TRUE) {
  15. $sql_periodo_inicial = '';
  16. if (set_value('periodo_inicial') != '') {
  17. $sql_periodo_inicial = " AND D_DAT_ORC >= '".set_value('periodo_inicial')." 00:00:00.000'";
  18. }
  19.  
  20. $sql_periodo_final = '';
  21. if (set_value('periodo_final') != '') {
  22. $sql_periodo_final = " AND D_DAT_ORC <= '".set_value('periodo_final')." 00:00:00.000'";
  23. }
  24.  
  25. $sql = "SELECT D_DAT_ORC,T_HOR_ORC,I_NRO_PED,PLACA,MTR,NF_CLI,TRANSPORTADORA,C_NOM_CLI,C_CID_CLI,C_EST_CLI,C_NOM_SER,PESO_BRU,PESO_LIQ,UNIDADE,N_VLR_SER,N_VLR_TOT,C_CGC_CLI,C_CPF_CLI
  26. FROM DBA.WPE96
  27. WHERE C_CGC_CLI = '".set_value('cnpj')."'".$sql_periodo_inicial.$sql_periodo_final.'
  28. ORDER BY D_DAT_ORC,T_HOR_ORC ASC';
  29. //echo $sql; exit;
  30. $res = $this->sqlanywhere->execute($sql);
  31. $json = fixSybaseStringArrays($res);
  32. $this->sqlanywhere->disconnect();
  33. }
  34.  
  35. echo json_encode($json);
  36. }
  37.  
  38. public function _validar_chave($chave) {
  39. $this->_ws_chave = $this->config->item('ws_chave');
  40.  
  41. if ($this->_ws_chave == $chave) {
  42. return true;
  43. } else {
  44. $this->form_validation->set_message('_validar_chave', 'A Chave está incorreta!');
  45. return false;
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement