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 Pedidos extends CI_Controller {
- public function obter_pedidos() {
- $this->form_validation->set_rules('cnpj', 'CNPJ', 'required|trim|xss_clean');
- $this->form_validation->set_rules('periodo_inicial', 'Período Inicial', 'trim|xss_clean');
- $this->form_validation->set_rules('periodo_final', 'Período Final', '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) {
- $sql_periodo_inicial = '';
- if (set_value('periodo_inicial') != '') {
- $sql_periodo_inicial = " AND D_DAT_ORC >= '".set_value('periodo_inicial')." 00:00:00.000'";
- }
- $sql_periodo_final = '';
- if (set_value('periodo_final') != '') {
- $sql_periodo_final = " AND D_DAT_ORC <= '".set_value('periodo_final')." 00:00:00.000'";
- }
- $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
- FROM DBA.WPE96
- WHERE C_CGC_CLI = '".set_value('cnpj')."'".$sql_periodo_inicial.$sql_periodo_final.'
- ORDER BY D_DAT_ORC,T_HOR_ORC ASC';
- //echo $sql; exit;
- $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