Example #1
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
//turn off WSDP caching if not in a production environment
$ini = ini_set("soap.wsdl_cache_enabled", "0");
//instantiate the SOAP client
$client = new SoapClient("http://intranet.tvcultura.com.br/crm_webservices/crm.asmx?WSDL");
if (!isset($_REQUEST["step"])) {
    $_REQUEST["step"] = 0;
}
if ($_REQUEST["step"] == 1 && ($_REQUEST["f1_email"] != "" || $_REQUEST["email"] != "")) {
    $email = $_REQUEST["email"] != "" ? $_REQUEST["email"] : $_REQUEST["f1_email"];
    $protocolo = $_REQUEST["protocolo"] != "" ? $_REQUEST["protocolo"] : $_REQUEST["f1_protocolo"];
    //CHECK STATUS
    $result = $client->sic_andamento(array('email' => $email, 'protocolo' => $protocolo));
    $xml = simplexml_load_string($result->sic_andamentoResult->any);
    $andamento = $xml->NewDataSet->andamento;
    $mensagem = $xml->NewDataSet->mensagem;
    $flag = $xml->NewDataSet->flag;
    //var_dump($xml);
    if ($andamento != NULL && $mensagem != NULL) {
        $last = end($andamento);
        $script = '$("#row1").hide();$("#row2").show();$("#row3").hide();$("#row5").hide();$("f1_email").val("");';
        $data1 = new DateTime($andamento[0]->data_envio);
        $data2 = new DateTime($andamento[count($andamento) - 1]->data_entrega);
        $status = $andamento[count($andamento) - 1]->status;
        $html = "<table class='table table-striped table-bordered table-condensed'><thead><tr><th>Data</th><th>Email</th><th>Protocolo</th><th>Status</th></tr></thead><tbody>";
        $html .= '<tr><td>' . $data1->format('d/m/Y H:i:s') . '</td><td>' . $email . '</td><td>' . $protocolo . '</td><td>' . $status . '</td></tr>';
        $script .= '$("#dados-html").html("' . $html . '");';
        $html = "<table class='table table-striped table-bordered table-condensed'><thead><tr><th>Data</th><th>Status</th><th>Data Limite</th><th>Justificativa</th></tr></thead><tbody>";