D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
rosario
/
adm
/
vendor_ant
/
api
/
PHPMailer
/
Filename :
pesquisa-teste.php
back
Copy
<?php ini_set('display_errors', true); ini_set('error_reporting', E_ALL); header('Content-Type: text/html; charset=UTF-8'); mb_internal_encoding("UTF-8"); include("../Banco.class.php"); $Banco = new Banco(); if(strlen($_GET['op'])>0 && $_GET['op']===0){ echo "Pronto para transferencia"; } if($_GET['op']=='turma'){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT AD_NOMETURMA FROM TGFPAR WHERE codparc ={$_GET['codparc']} "); while (($rowPesquisa = oci_fetch_assoc($stpesquisa)) != false) { $arr[] = $rowPesquisa; } echo json_encode($arr); } if($_GET['op']=='pesquisa'){ $arr = $_REQUEST; // $arr = array(); //print_r($_REQUEST); // die(); // $str = str_replace(",]","]",$arr['json']); $str = str_replace(chr(13),'', $str ); $str =str_replace("\n", "", $str); //$str =str_replace("\n", "", $str); $str =str_replace('"cobrem"', 'cobrem', $str); // $str =str_replace('""', "", $str); $str =str_replace("null", "", $str); //$str =str_replace(', "', "", $str); $json = json_decode($str); // $json = $str; $fp = fopen("./transmissao_".date("YmdHis").".log", "a"); // die(); // Escreve "exemplo de escrita" no bloco1.txt $escreve = fwrite($fp, $str); // Fecha o arquivo fclose($fp); if (json_last_error() == 0) { $pergunta = array(); $codturma = null; foreach ($json as $e ) { $codturma = $e->CODTURMA; $codevento = $e->CODEVENTO; $codauditor = $e->CODAUDITOR; $perguntas[] = $e->CODPERGUNTA; $respostas[] = $e->CODRESPOSTA; $observacao[] = $e->OBSERVACAO; } if( $codturma != null ){ //die("ddd" . $codturma); $sqlproj = "SELECT AD_CODPRJ FROM TGFPAR WHERE CODPARC = {$codturma} AND AD_TURMAT = 'S' AND ATIVO = 'S'"; //echo $sqlproj; //die(); $stturma = $Banco->exeQuey($sqlproj); while (($rowturma = oci_fetch_assoc($stturma)) != false) { $codproj = $rowturma['AD_CODPRJ']; } $sttpesqua = $Banco->exeQuey("SELECT NVL(MAX(NROUNICO),0)+1 NROUNICO FROM AD_PESQUA"); while (($rowpesqua = oci_fetch_assoc($sttpesqua)) != false) { $nrounico = $rowpesqua['NROUNICO']; } $sqlInsPesQu = "INSERT INTO AD_PESQUA (NROUNICO, CODPARC, CODEVENTO, CODCONTATO, CODPROJ, CODAUDITOR, TIPOPESQUISA ) VALUES ( {$nrounico}, {$codturma}, {$codevento}, NULL, {$codproj}, {$codauditor}, 5 )"; // echo $sqlInsPesQu; if($Banco->exeQuey($sqlInsPesQu)){ for($i=0;$i<count($perguntas);$i++ ) { //if(gettype($perguntas[$i])=='integer') //{ $sql = "INSERT INTO AD_PESPER (NROUNICO,CODPERG,OBSERVACAO) VALUES ({$nrounico},{$perguntas[$i]},'{$respostas[$i]}')"; // echo $sql; if($Banco->exeQuey($sql)){ $sqlIResp = "INSERT INTO AD_PESRES (NROUNICO,CODPERG,CODRES,OBSERVACAO) VALUES ({$nrounico},{$perguntas[$i]},'{$respostas[$i]}', '{$observacao[$i]}')"; //echo "<pre>".$sqlIResp."</pre>"; if($Banco->exeQuey($sqlIResp)){ $r = true; }else{ $r = false; } }else{ $r = false; } //} } if($r == true){ echo "sucesso"; }else{ echo "erro"; } } } }else{ echo 'Erro!'; switch (json_last_error()) { case JSON_ERROR_DEPTH: echo ' - profundidade maxima excedida'; break; case JSON_ERROR_STATE_MISMATCH: echo ' - state mismatch'; break; case JSON_ERROR_CTRL_CHAR: echo ' - Caracter de controle encontrado'; break; case JSON_ERROR_SYNTAX: echo ' - Erro de sintaxe! String JSON mal-formada!'; break; case JSON_ERROR_UTF8: echo ' - Erro na codificação UTF-8'; break; default: echo ' – Erro desconhecido'; break; } } } if($_GET['op']=='auditor'){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT NOMEPARC FROM TGFPAR WHERE codparc ={$_GET['codparc']} "); while (($rowPesquisa = oci_fetch_assoc($stpesquisa)) != false) { $arr[] = $rowPesquisa; } echo json_encode($arr); } if($_GET['op']=='evento'){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT ECL.CODEVENTO CODEVENTO , EVE.NOME EVENTO , TO_CHAR(ECL.DTEVE,'DD/MM/YYYY') DTEVE FROM AD_EVECHECKLIST ECL INNER JOIN AD_EVENTO EVE ON EVE.CODIGO = ECL.CODEVENTO WHERE codparc ={$_GET['codparc']} AND CODEVENTO IN (5,6,7)"); while (($rowPesquisa = oci_fetch_assoc($stpesquisa)) != false) { $arr[] = $rowPesquisa; } echo json_encode($arr); } if($_GET['op']==1){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT VALOR,OPCAO FROM TDDOPC WHERE NUCAMPO = 9999995253 ORDER BY ORDEM "); while (($rowPesquisa = oci_fetch_assoc($stpesquisa)) != false) { $arr[] = $rowPesquisa; } echo json_encode($arr); } if($_GET['op']==2){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT CODGRUPOPERG , DESCRGRUPOPERG FROM TPQGRP WHERE codgrupoperg IN ( SELECT CODGRUPOPERG FROM TPQPER WHERE AD_TIPOPESQUISA = 5)"); while (($rowPesquisa = oci_fetch_object($stpesquisa)) != false) { // $arr[] = $rowPesquisa; $arr[] = array( 'CODGRUPOPERG' => $rowPesquisa->CODGRUPOPERG, 'DESCRGRUPOPERG' => htmlentities($rowPesquisa->DESCRGRUPOPERG) ); //print_r($arr); } echo json_encode($arr); } if($_GET['op']==3){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT CODPERG,CODGRUPOPERG,DESCRPERG,TIPO,AD_SUBAREA,ACEITAOBSERVACAO FROM tpqper WHERE AD_TIPOPESQUISA = 5 AND codperg >= {$_REQUEST['ini']} AND codperg <= {$_REQUEST['fim']} "); while (($rowPesquisa = oci_fetch_object($stpesquisa)) != false) { $arr[] = array( 'CODPERG' => htmlentities($rowPesquisa->CODPERG), 'CODGRUPOPERG' => htmlentities($rowPesquisa->CODGRUPOPERG), 'DESCRPERG' => htmlentities($rowPesquisa->DESCRPERG), 'TIPO' => htmlentities($rowPesquisa->TIPO), 'AD_SUBAREA' => htmlentities($rowPesquisa->AD_SUBAREA), 'ACEITAOBSERVACAO' => htmlentities($rowPesquisa->ACEITAOBSERVACAO), ); } echo json_encode($arr); } if($_GET['op']==6){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT CODPERG,CODGRUPOPERG,DESCRPERG,TIPO,AD_SUBAREA FROM tpqper WHERE AD_TIPOPESQUISA = 5 "); while (($rowPesquisa = oci_fetch_assoc($stpesquisa)) != false) { $arr[] = $rowPesquisa; } echo json_encode($arr); } if($_GET['op']==7){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT CODPERG,CODRESP,DESCRRESP FROM tpqres r WHERE r.codperg IN (SELECT codperg FROM tpqper WHERE AD_TIPOPESQUISA = 5)"); while (($rowPesquisa = oci_fetch_assoc($stpesquisa)) != false) { $arr[] = $rowPesquisa; } echo json_encode($arr); } if($_GET['op']==4){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT CODPERG,CODRESP,DESCRRESP FROM tpqres r WHERE r.codperg IN (SELECT codperg FROM tpqper WHERE AD_TIPOPESQUISA = 5) AND codperg >= {$_REQUEST['ini']} AND codperg <= {$_REQUEST['fim']} " ); while (($rowPesquisa = oci_fetch_object($stpesquisa)) != false) { $arr[] = array( 'CODPERG' => htmlentities($rowPesquisa->CODPERG), 'CODRESP' => htmlentities($rowPesquisa->CODRESP), 'DESCRRESP' => htmlentities($rowPesquisa->DESCRRESP) ); } echo json_encode($arr); } if($_GET['op']==5){ $arr = array(); $stpesquisa = $Banco->exeQuey("SELECT VALOR, OPCAO FROM TDDOPC WHERE NUCAMPO = 9999995422"); while (($rowPesquisa = oci_fetch_object($stpesquisa)) != false) { $arr[] = array( 'OPCAO' => htmlentities($rowPesquisa->OPCAO), 'VALOR' => htmlentities($rowPesquisa->VALOR) ); } echo json_encode($arr); }