Example #1
0
     echo "<option value=\"" . $row['periodicidade'] . "\"" . ($periodicidade == $row['periodicidade'] ? ' Selected' : '') . ">" . $row['periodicidade'] . "</option>";
 }
 echo "</select></label>";
 echo "<br>";
 echo "<div style=\"width:100%; text-align: center\">";
 echo "<br>";
 echo "<input type=\"hidden\" name=\"cod_tipo_empresa\" id=\"cod_tipo_empresa\" value=" . $tipo_empresa . ">";
 echo "<input type=\"hidden\" name=\"comando\" id=\"comando\">";
 echo "<input type=\"button\" name=\"alterar\"  value=\"Alterar\"  onClick=\"comando.value='alterar'; document.formEditaCredenciado.submit();\">";
 echo "<input type=\"button\" name=\"excluir\" value=\"Excluir\" onClick=\"if(confirm('Deseja realmente excluir a empresa " . $row['desc_empresa'] . "?')){comando.value='excluir'; document.formEditaCredenciado.submit();}else{return false;}\">";
 echo "</div>";
 echo "</fieldset>";
 echo "</form>";
 //Validação consultor
 if ($nvl < 3 && $tipo_empresa == 2) {
     $valida_especialista = buscaTabela("c.nome, ce.cod_consultor", "consultor c INNER JOIN consultor_especialista ce ON (ce.cod_consultor=c.cod_consultor)", "ce.pdv_empresa = '" . $pdv_empresa . "'");
     echo "<fieldset id=\"fieldset_os\">";
     echo "<legend id=\"legend\">Validação Consultor</legend>";
     echo "<table style=\"border:1px solid black; width:100%\">";
     $ce_index = 0;
     while ($row = mysql_fetch_array($valida_especialista)) {
         echo "<tr>";
         echo "<td style=\"border:1px dotted black; width:10px\"><input type=\"button\" value=\"Excluir\" onClick=\"if(confirm('Deseja realmente excluir este consultor da validação?')){location.assign('edita_credenciado.php?alterar_ce=0&cod_consultor=" . $row['cod_consultor'] . "&pdv_empresa=" . $pdv_empresa . "')}\"></td>";
         echo "<td style=\"border:1px dotted black\">" . $row['nome'] . "</td>";
         echo "</tr>";
         $ce_consultor[$ce_index] = $row['cod_consultor'];
         //Lista consultores validadores
         $ce_index++;
     }
     echo "<tr>";
     echo "<td style=\"border:1px dotted black; width:10px\"><input type=\"button\" value=\"Incluir\" onClick=\"if(ce_cod_consultor.value==0){alert('Escolha um consultor')}else{location.assign('edita_credenciado.php?alterar_ce=1&cod_consultor='+ce_cod_consultor.value+'&pdv_empresa=" . $pdv_empresa . "')}\"></td>";
}
require_once 'formulario_topo.php';
echo "\t\t<form id=\"formCadastro\" name=\"formCadastro\" action=\"../modulos/cadastra_usuario.php\" method=\"POST\" enctype=\"multipart/form-data\" onSubmit=\"return ValidaCampos(this)\">";
echo "\t\t<div id=\"barra_horizontal\">DADOS DO USUÁRIO</div>";
echo "\t\t<br>";
//======== TIPO VISTORIA - INICIO ========//
echo "\t\t<fieldset id=\"fieldset_os\">";
echo "\t\t<legend id=\"legend\">Dados do Usuário</legend>";
echo "\t\t<br>Este formulário destina-se exclusivamente para cadastro de usuários de empresas especialistas.<br><br>";
echo "\t\t<label>Nome:</label><input type=\"text\" name=\"nome\" id=\"nome\" class=\"input\">";
echo "\t\t<br>";
echo "\t\t<label>E-mail:</label><input type=\"text\" name=\"email\" id=\"email\" class=\"input\">";
echo "\t\t<br>";
echo "\t\t<label>Empresa:</label>";
//Monta Select da Regional";
$result = buscaTabela('*', 'credenciados', 'cod_tipo_empresa = 2 ORDER BY desc_empresa ASC');
echo "\t\t<select name=\"pdv_empresa\" id=\"pdv_empresa\">";
echo "\t\t\t<option value=\"\"></option>";
while ($row = mysql_fetch_array($result)) {
    echo "\t\t\t<option value=\"" . $row['pdv_empresa'] . "\">" . $row['desc_empresa'] . "</option>";
}
echo "\t\t</select>";
echo "\t\t</fieldset>";
//======== INSTALACAO - FIM ========//
echo "\t\t<br>";
echo "\t\t<div style=\"width:100%; text-align: center\">";
echo "\t\t<input type=\"hidden\" name=\"moderacao\" id=\"moderacao\" value=\"" . (buscaCampo("nivel_acesso", "SELECT", "consultor", "nivel_acesso", "cod_consultor = " . $_SESSION['login']) == 4 ? 0 : 1) . "\" style=\"width: 100px\">";
echo "\t\t<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Enviar\" style=\"width: 100px\">";
echo "\t\t<input type=\"button\" name=\"btnVoltar\" id=\"btnVoltar\" value=\"Menu Inicial\" onClick=\"window.location.replace('http://" . $_SERVER['HTTP_HOST'] . "/km')\" style=\"width: 100px\">";
echo "\t\t</div>";
echo "\t\t</form>";
Example #3
0
     $valida = 'false';
     $msg = 'Erro ao tentar gravar os dados no banco de dados!';
 } else {
     //OK
     $retorno = 1;
     $titulo = 'Concluído';
     $valida = 'true';
     $msg = 'Dados gravados com sucesso no banco de dados!';
     //
     // Envio de Emails - INICIO
     //
     //Cópia do email para os gestores
     $email_cc = buscaCampo("email", "SELECT", "consultor", "email", "cod_grupo = " . $consulta_login['cod_grupo'] . " AND nivel_acesso < 3");
     //Se a vistoria for de especialista, busca email dos consultores responsaveis
     if ($consulta_login['pdv_sede'] != 'SKY0000') {
         $resultado_emailcc = buscaTabela("c.email", "consultor c INNER JOIN consultor_especialista ce ON (ce.cod_consultor = c.cod_consultor)", "ce.pdv_empresa = '" . $consulta_login['pdv_sede'] . "'");
         while ($row = mysql_fetch_array($resultado_emailcc)) {
             $email_cc .= ',' . $row['email'];
         }
     }
     //Email de confirmação para o usuário
     $email_notificacao = emailNotificacao($consulta_login['nome'], $_POST['os'], $url, $consulta_login['cod_grupo'], $to, $email_from, $email_cc, $_POST['tipo_aprovacao'], 'PayTV');
     if ($email_notificacao != 1) {
         $valida = 'false';
         $title = 'ATENÇÃO';
         $msg = 'Não foi possível enviar o email de confirmação!';
         retornaMensagem('true', 'true', 'ATENÇÃO', $msg, 'OK');
         exit;
     }
     //Email de solicitação de abertura de OS
     if (strtoupper($_POST['abrir_nova_os']) == 'SIM' && $aprovacao == 1 && $consulta_login['nivel_acesso'] != 4) {
Example #4
0
}
echo "\t\t</select>";
echo "\t\t<br>";
echo "\t\t<label>Defeito relatado:</label>";
//Retorna a lista de Defeitos Relatados";
$result = buscaTabela('*', 'qb_defeito', '1');
echo "\t\t<select name=\"defeito_relatado\" id=\"defeito_relatado\">";
echo "\t\t<option value=\"\"></option>";
while ($row = mysql_fetch_array($result)) {
    echo "\t\t<option value=\"" . $row['desc_defeito'] . "\">" . $row['desc_defeito'] . "</option>";
}
echo "\t\t</select>";
echo "\t\t<br>";
echo "\t\t<label>Defeito constatado:</label>";
//Retorna a lista de Defeitos Constatados";
$result = buscaTabela('*', 'qb_defeito', '1');
echo "\t\t<select name=\"defeito_constatado\" id=\"defeito_constatado\" onChange=\"if(this.value=='Sem defeito'){troca_devida.value='NÃO'}\">";
echo "\t\t<option value=\"\"></option>";
while ($row = mysql_fetch_array($result)) {
    echo "\t\t<option value=\"" . $row['desc_defeito'] . "\">" . $row['desc_defeito'] . "</option>";
}
echo "\t\t</select>";
echo "\t\t<br>";
echo "\t\t<label>Troca devida?</label>";
echo "\t\t<select name=\"troca_devida\" id=\"troca_devida\" onChange=\"if(this.value=='SIM' && defeito_constatado.value=='Sem defeito'){this.value='NÃO'; alert('A troca só pode ser DEVIDA se existir algum Defeito Constatado!')}\">";
echo "\t\t<option value=\"\"></option>";
echo "\t\t<option value=\"SIM\">SIM</option>";
echo "\t\t<option value=\"NÃO\">NÃO</option>";
echo "\t\t</select>";
echo "\t\t</fieldset>";
//======== TIPO SERVICO - FIM ========//
    }
    echo "\t\t</select><br>";
}
echo "\t\t</div>";
echo "\t\t</fieldset>";
//======== Divergência de Materiais - FIM ========//
echo "\t\t<br>";
//======== Indicação Momento SKY - INICIO ========//
echo "\t\t<fieldset id=\"fieldset_momento_sky\">";
echo "\t\t<legend id=\"legend\">Indicação Momento SKY</legend>";
echo "\t\t<label>Indicar para:</label>";
echo "\t\t<select name=\"indicacao_momento_sky\" id=\"indicacao_momento_sky\" onChange=\"momentoSKY(this.id, false)\">";
echo "\t\t<option value=\"NÃO\">NÃO</option>";
//Retorna o recordset da query "SELECT * FROM indicacao_momento_sky";
$tabela = "indicacao_momento_sky";
$result = buscaTabela('*', $tabela, '1');
while ($row = mysql_fetch_array($result)) {
    echo "\t\t<option value=\"" . $row['desc_indicacao_momento_sky'] . "\">" . $row['desc_indicacao_momento_sky'] . "</option>";
}
echo "\t\t</select>";
echo "\t\t<br>";
echo "\t\t<label>Comentário 1:</label><input type=\"text\" name=\"com_1\" id=\"com_1\" size=\"50\" maxlength=\"50\" onKeyUp=\"if(this.value.length==this.maxLength){alert('Máximo permitido de 50 caracteres. Escreva um comentário mais simplificado.')}\">";
echo "\t\t<br>";
echo "\t\t<label>Comentário 2:</label><input type=\"text\" name=\"com_2\" id=\"com_2\" size=\"50\" maxlength=\"50\">";
echo "\t\t<br>";
echo "\t\t<label>Comentário 3:</label><input type=\"text\" name=\"com_3\" id=\"com_3\" size=\"50\" maxlength=\"50\">";
echo "\t\t<br>";
echo "\t\t<label>Comentário 4:</label><input type=\"text\" name=\"com_4\" id=\"com_4\" size=\"50\" maxlength=\"50\">";
echo "\t\t<br>";
echo "\t\t<label>Comentário 5:</label><input type=\"text\" name=\"com_5\" id=\"com_5\" size=\"50\" maxlength=\"50\">";
echo "\t\t<br>";
Example #6
0
function geraPDF($os)
{
    $html = '<html>';
    $html .= '<head><title>Vistoria - OS ' . $os . '</title>';
    $html .= '<meta charset="utf-8">';
    $html .= '<style>';
    $html .= '#borded-1px{white-space:nowrap; width:183px; border:1px solid black; padding:3px; font-size:11px; text-align:center; font-size:14;height:50px} ';
    $html .= '#borded-1px-head{border:1px solid #ddd; background-color:#ddd; padding:3px; font-size:11px; text-align:center; font-size:16} ';
    $html .= '#borded-2px{border:2px solid black; padding:3px; font-size:18; text-align:center;height:120px} ';
    $html .= 'body{font-family:arial; font-size:14} ';
    $html .= '#img{width:130px} ';
    $html .= '</style>';
    $html .= '</head>';
    $html .= '<body>';
    $html .= '<center>';
    $html .= '<table>';
    $html .= '<tr>';
    $html .= '<td id="borded-1px" cellpadding="5">';
    $html .= '<table style="width:953">';
    $html .= '<tr>';
    $html .= '<td style="width:20%" id="borded-2px"><img src=http://skyengenhariadecampo.com.br/img/logosky_bl.png width=170></td>';
    $html .= '<td style="width:60%" id="borded-2px"><h2 style="width:100%;height:20px">Relatório de Visita Técnica - Banda Larga</h2>Engenharia de Campo Banda Larga</td>';
    $html .= '<td style="width:20%" id="borded-2px">Natureza da visita<br><b>' . buscaCampo("desc_tipo_vistoria", "SELECT", "tipo_vistoria tv INNER JOIN vistoria_bl v ON (v.cod_tipo_vistoria = tv.cod_tipo_vistoria)", "tv.desc_tipo_vistoria", "v.os = " . $os) . '</b></td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td id="borded-1px" colspan="3">Vistoriador:<b> ' . buscaCampo("nome", "SELECT", "vistoria_bl v INNER JOIN consultor c ON (c.cod_consultor = v.cod_consultor)", "c.nome", "v.os =" . $os) . ' - ' . buscaCampo("desc_empresa", "SELECT", "credenciados cred INNER JOIN consultor c ON (c.pdv_sede = cred.pdv_empresa) INNER JOIN vistoria_bl v ON (v.cod_consultor=c.cod_consultor)", "cred.desc_empresa", "v.os = " . $os) . '</b></td>';
    $html .= '</tr>';
    $html .= '</table>';
    $html .= '<table style="width:950">';
    //Dados da OS
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>DADOS DA OS</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td id="borded-1px">';
    $html .= 'OS<br><b>' . $os . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Customer<br><b>' . buscaCampo("customer", "SELECT", "vistoria_bl", "customer", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Data vistoria<br><b>' . date("d/m/Y", strtotime(buscaCampo("data_vistoria", "SELECT", "vistoria_bl", "data_vistoria", "os =" . $os))) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Inicio<br><b>' . date("H:i", strtotime(buscaCampo("hora_inicio_vistoria", "SELECT", "vistoria_bl", "hora_inicio_vistoria", "os =" . $os))) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Término<br><b>' . date("H:i", strtotime(buscaCampo("hora_termino_vistoria", "SELECT", "vistoria_bl", "hora_termino_vistoria", "os =" . $os))) . '</b>';
    $html .= '</td>';
    $html .= '</tr>';
    //Dados do serviço
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>DADOS DO SERVIÇO</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td id="borded-1px">';
    $html .= 'Tipo serviço<br><b>' . buscaCampo("desc_tipo_servico", "SELECT", "tipo_servico ts INNER JOIN vistoria_bl v ON (v.cod_tipo_servico = ts.cod_tipo_servico)", "ts.desc_tipo_servico", "v.os = " . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Regional / UF<br><b>' . buscaCampo("desc_regional", "SELECT", "regional r INNER JOIN vistoria_bl v ON (v.cod_regional = r.cod_regional)", "r.desc_regional", "v.os = " . $os) . ' / ' . buscaCampo("cod_uf", "SELECT", "vistoria_bl", "cod_uf", "os = " . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Data serviço<br><b>' . date("d/m/Y", strtotime(buscaCampo("data_servico", "SELECT", "vistoria_bl", "data_servico", "os =" . $os))) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'ID Técnico<br><b>' . buscaCampo("id_tecnico", "SELECT", "vistoria_bl", "id_tecnico", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'PDV Empresa<br><b>' . buscaCampo("pdv_empresa", "SELECT", "vistoria_bl", "pdv_empresa", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '</tr>';
    //Dados do local
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>DADOS DO LOCAL</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td id="borded-1px">';
    $html .= 'Modelo CPE<br><b>' . buscaCampo("desc_modelo_cpe", "SELECT", "modelo_cpe mi INNER JOIN vistoria_bl v ON (v.cod_modelo_cpe = mi.cod_modelo_cpe)", "mi.desc_modelo_cpe", "v.os = " . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'IMSI<br><b>' . buscaCampo("imsi", "SELECT", "vistoria_bl", "imsi", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Versão de FW<br><b>' . buscaCampo("desc_versao_firmware_cpe", "SELECT", "versao_firmware_cpe vf INNER JOIN vistoria_bl v ON (v.cod_versao_firmware_cpe = vf.cod_versao_firmware_cpe)", "vf.desc_versao_firmware_cpe", "v.os = " . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Velocidade Contratada<br><b>' . buscaCampo("desc_velocidade_contratada", "SELECT", "velocidade_contratada vc INNER JOIN vistoria_bl v ON (v.cod_velocidade_contratada = vc.cod_velocidade_contratada)", "vc.desc_velocidade_contratada", "v.os = " . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Área Coberta?<br><b>' . buscaCampo("area_coberta", "SELECT", "vistoria_bl", "area_coberta", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<td id="borded-1px">';
    $html .= 'Endereço IP <br><b>' . buscaCampo("endereco_ip", "SELECT", "vistoria_bl", "endereco_ip", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Técnico Treinado?<br><b>' . buscaCampo("treinamento_bl", "SELECT", "vistoria_bl", "treinamento_bl", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'BSID<br><b>' . buscaCampo("padrao_bsid", "SELECT", "vistoria_bl", "padrao_bsid", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Distância do Site<br><b>' . buscaCampo("padrao_distancia_site", "SELECT", "vistoria_bl", "padrao_distancia_site", "os =" . $os) . ' m</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Localização do CPE (Lat/Lon)<br><b>' . buscaCampo("padrao_lat", "SELECT", "vistoria_bl", "padrao_lat", "os =" . $os) . ',' . buscaCampo("padrao_lon", "SELECT", "vistoria_bl", "padrao_lon", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '</tr>';
    //Avaliação
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>AVALIAÇÃO DO SERVIÇO</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td id="borded-1px">';
    $html .= 'CINR<br><b>' . buscaCampo("padrao_cinr", "SELECT", "vistoria_bl", "padrao_cinr", "os =" . $os) . ' dB</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'RSRP<br><b>' . buscaCampo("padrao_rsrp", "SELECT", "vistoria_bl", "padrao_rsrp", "os =" . $os) . ' dBm</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'TX Power<br><b>' . buscaCampo("padrao_tx_power", "SELECT", "vistoria_bl", "padrao_tx_power", "os =" . $os) . ' dBm</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Problema de Navegação?<br><b>' . buscaCampo("desc_problema_navegacao", "SELECT", "tipo_problema_navegacao tpn INNER JOIN vistoria_bl v ON (v.cod_problema_navegacao = tpn.cod_problema_navegacao)", "tpn.desc_problema_navegacao", "v.os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Comitê Notificado?<br><b>' . (buscaCampo("comite_notificado", "SELECT", "vistoria_bl", "comite_notificado", "os =" . $os) == 'SIM' ? 'SIM' : 'NÃO') . '</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td id="borded-1px">';
    $html .= 'Download / Upload<br><b>' . buscaCampo("padrao_download", "SELECT", "vistoria_bl", "padrao_download", "os =" . $os) . ' Mbps / ' . buscaCampo("padrao_upload", "SELECT", "vistoria_bl", "padrao_upload", "os =" . $os) . ' Mbps</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Latência<br><b>' . buscaCampo("padrao_latencia", "SELECT", "vistoria_bl", "padrao_latencia", "os =" . $os) . ' ms</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Status<br><b>' . buscaCampo("desc_tipo_aprovacao", "SELECT", "tipo_aprovacao ta INNER JOIN vistoria_bl v ON (v.cod_tipo_aprovacao = ta.cod_tipo_aprovacao)", "ta.desc_tipo_aprovacao", "v.os = " . $os) . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    $html .= 'Abrir nova OS?<br><b>' . ($abrir_os = buscaCampo("os", "SELECT", "vistoria_bl_abrir_nova_os", "os", "os =" . $os) != 0 ? 'SIM' : 'NÃO') . '</b>';
    $html .= '</td>';
    $html .= '<td id="borded-1px">';
    if ($abrir_os == 'SIM') {
        $data_agendamento = date("d/m/Y", strtotime(buscaCampo("data_agendamento", "SELECT", "vistoria_bl_abrir_nova_os", "data_agendamento", "os =" . $os))) . ' / ' . buscaCampo("periodo", "SELECT", "vistoria_bl_abrir_nova_os", "periodo", "os =" . $os);
    } else {
        $data_agendamento = 'Não agendado';
    }
    $html .= 'Agendado para<br><b>' . $data_agendamento . '</b>';
    $html .= '</td>';
    $html .= '</tr>';
    //Itens Fora do Padrão - Insatisfação Cliente - Divergencia Materiais
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>DISPOSITIVOS CONECTADOS</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px">';
    //Seleciona dispositivo conectado
    $campos = "dc.desc_dispositivo_conectado_bl";
    $tabela = "dispositivo_conectado_bl dc INNER JOIN vistoria_bl_dispositivo_conectado vdc ON (vdc.cod_dispositivo_conectado = dc.cod_dispositivo_conectado_bl) INNER JOIN vistoria_bl v ON (v.os = vdc.os)";
    $criterio = "v.os = " . $os;
    //Seleciona itens fora do padrão - FIM
    $result = buscaTabela($campos, $tabela, $criterio);
    while ($row = mysql_fetch_array($result)) {
        $html .= '<li><b>' . $row['desc_dispositivo_conectado_bl'] . '</b></li>';
    }
    $html .= '</td>';
    $html .= '</tr>';
    //Itens Fora do Padrão - Insatisfação Cliente - Divergencia Materiais
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>ITENS FORA DO PADRÃO</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px">';
    //Seleciona itens fora do padrão - INICIO
    $campos = "ifp.desc_item_fora_padrao_bl";
    $tabela = "item_fora_padrao_bl ifp INNER JOIN vistoria_bl_item_fora_padrao vifp ON (vifp.cod_item_fora_padrao = ifp.cod_item_fora_padrao_bl) INNER JOIN vistoria_bl v ON (v.os = vifp.os)";
    $criterio = "v.os = " . $os;
    //Seleciona itens fora do padrão - FIM
    $result = buscaTabela($campos, $tabela, $criterio);
    while ($row = mysql_fetch_array($result)) {
        $html .= '<li><b>' . $row['desc_item_fora_padrao_bl'] . '</b></li>';
    }
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>INSATISFAÇÃO DO CLIENTE</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px">';
    //Seleciona insatisfacao do cliente - INICIO
    $campos = "ic.desc_insatisfacao_cliente_bl";
    $tabela = "insatisfacao_cliente_bl ic INNER JOIN vistoria_bl_insatisfacao_cliente vic ON (vic.cod_insatisfacao_cliente = ic.cod_insatisfacao_cliente_bl) INNER JOIN vistoria_bl v ON (v.os = vic.os)";
    $criterio = "v.os = " . $os;
    //Seleciona insatisfacao do cleinte - FIM
    $result = buscaTabela($campos, $tabela, $criterio);
    while ($row = mysql_fetch_array($result)) {
        $html .= '<li><b>' . $row['desc_insatisfacao_cliente_bl'] . '</b></li>';
    }
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>DIVERGÊNCIA DE MATERIAIS</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px">';
    //Seleciona divergencia de materiais - INICIO
    $campos = "dm.desc_divergencia_materiais_bl";
    $tabela = "divergencia_materiais_bl dm INNER JOIN vistoria_bl_divergencia_materiais vdm ON (vdm.cod_divergencia_materiais = dm.cod_divergencia_materiais_bl) INNER JOIN vistoria_bl v ON (v.os = vdm.os)";
    $criterio = "v.os = " . $os;
    //Seleciona divergencia de materiais - FIM
    $result = buscaTabela($campos, $tabela, $criterio);
    while ($row = mysql_fetch_array($result)) {
        $html .= '<li><b>' . $row['desc_divergencia_materiais_bl'] . '</b></li>';
    }
    $html .= '</td>';
    $html .= '</tr>';
    //FOTOS
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>FOTOS</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px">';
    $html .= '<table style="width:930">';
    $html .= '<tr>';
    $html .= '<td id="borded-1px" style="vertical-align:text-top;">';
    // Cria caminho para gravação das fotos
    $protocolo = strpos(strtolower($_SERVER['SERVER_PROTOCOL']), 'https') === false ? 'http' : 'https';
    $host = $_SERVER['HTTP_HOST'];
    $url = $protocolo . '://' . $host . '/files/fotos/' . $os . '/';
    //Foto CPE
    $html .= '<b>Foto CPE</b><br><br>';
    $html .= '<a href="' . $url . $os . '-cpe.jpeg"><img src="' . $url . $os . '-cpe.jpeg" id="img"></a>';
    $html .= '</td>';
    $html .= '<td id="borded-1px" style="vertical-align:text-top;">';
    //Foto Cabo
    $html .= '<b>Foto Cabo</b><br><br>';
    $html .= '<a href="' . $url . $os . '-cabo.jpeg"><img src="' . $url . $os . '-cabo.jpeg" id="img"></a>';
    $html .= '</td>';
    $html .= '<td id="borded-1px" style="vertical-align:text-top;">';
    //Foto Conector
    $html .= '<b>Foto Conector</b><br><br>';
    $html .= '<a href="' . $url . $os . '-conector.jpeg"><img src="' . $url . $os . '-conector.jpeg" id="img"></a>';
    $html .= '</td>';
    $html .= '<td id="borded-1px" style="vertical-align:text-top;">';
    //Foto ITSA
    $html .= '<b>Foto ITSA</b><br><br>';
    $html .= '<a href="' . $url . $os . '-itsa.jpeg"><img src="' . $url . $os . '-itsa.jpeg" id="img"></a>';
    $html .= '</td>';
    $html .= '<td id="borded-1px" style="vertical-align:text-top;">';
    //Foto Mapa
    $html .= '<b>Foto Mapa</b><br><br>';
    $html .= '<a href="' . $url . $os . '-mapa.jpeg"><img src="' . $url . $os . '-mapa.jpeg" id="img"></a>';
    $html .= '</td>';
    $html .= '<td id="borded-1px" style="vertical-align:text-top;">';
    //Foto Velocidade
    $html .= '<b>Foto Velocidade</b><br><br>';
    $html .= '<a href="' . $url . $os . '-velocidade.jpeg"><img src="' . $url . $os . '-velocidade.jpeg" id="img"></a>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '</table>';
    $html .= '</td>';
    $html .= '</tr>';
    //Comentários
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px-head">';
    $html .= '<b>COMENTÁRIOS</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td colspan=5 id="borded-1px">';
    $html .= '<b>' . buscaCampo("comentarios_texto", "SELECT", "vistoria_bl", "comentarios_texto", "os =" . $os) . '</b>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '</table>';
    $data_vistoria = buscaCampo("log_data", "SELECT", "vistoria_bl", "log_data", "os =" . $os);
    $html .= 'Relatório gerado pelo SIGA em ' . date("d/m/Y - H:i", strtotime($data_vistoria)) . '</td>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '</table>';
    $html .= '</center>';
    $html .= '</body>';
    $html .= '</html>';
    //Cria o relatório em HTML
    $html_path = realpath($_SERVER['DOCUMENT_ROOT']) . '\\files\\fotos\\' . $os . '\\' . $os . '.html';
    $fo_html = fopen($html_path, 'w');
    fwrite($fo_html, $html);
    fclose($fo_html);
    /*
    //Converte o relatório em PDF
    define('MPDF_PATH', realpath($_SERVER['DOCUMENT_ROOT']) .'\\modulos\\');
    $pdf_path = realpath($_SERVER['DOCUMENT_ROOT']) .'\\files\\fotos\\'. $os .'\\'. $os .'.pdf';
    
    try {
    	include(MPDF_PATH . 'mpdf56/mpdf.php');
    	$mpdf = new mPDF();
    	$mpdf->WriteHTML($html);
    	$mpdf->Output($pdf_path,'F');
    	$mpdf->Close();
    	return 1;
    }
    catch (Exception $e) {
    	return $e->getMessage();
    }
    */
}
echo "\t\t<div id=\"div_insatisfacao_cliente\" style=\"display:none\">";
$row_number = 0;
while ($row = mysql_fetch_array($result)) {
    echo "\t\t<input style=\"cursor: pointer;\" type=\"checkbox\" name=\"" . $tabela . "_" . $itens[$row_number] . "\" value=\"" . $row['desc_insatisfacao_cliente_bl'] . "\"><span style=\"cursor: pointer;\" onClick=\"if(" . $tabela . "_" . $itens[$row_number] . ".checked==true){" . $tabela . "_" . $itens[$row_number] . ".checked=false}else{" . $tabela . "_" . $itens[$row_number] . ".checked=true}\">" . $row['desc_insatisfacao_cliente_bl'] . "</span><br>";
    $row_number++;
}
echo "\t\t</div>";
echo "\t\t</fieldset>";
//======== Insatisfação Cliente - FIM ========//
echo "\t\t<br>";
//======== Divergência de Materiais - INICIO ========//
echo "\t\t<fieldset id=\"fieldset_divergencia_materiais\">";
echo "\t\t<legend id=\"legend\">Divergência de Materiais <select name=\"divergencia_materiais\" id=\"divergencia_materiais\" onChange=\"if(this.value=='Sim'){div_divergencia_materiais.style.display='block'}else{div_divergencia_materiais.style.display='none'}\"><option value=\"Sim\">Sim</option><option value=\"Não\" Selected>Não</option></select></legend>";
//Retorna o recordset da query "SELECT * FROM insatisfacao_cliente";
$tabela = "divergencia_materiais";
$result = buscaTabela('*', $tabela . '_bl', '1');
//Prepara campos para tabela divergencia_materiais
$itens = array('Cabo', 'CPE', 'Roteador', 'Mastro', 'Prolongador', 'Conector');
echo "\t\t<div id=\"div_divergencia_materiais\" style=\"display:none\">";
$row_number = 0;
while ($row = mysql_fetch_array($result)) {
    echo "\t\t<input style=\"cursor: pointer;\" type=\"checkbox\" name=\"" . $tabela . "_" . $itens[$row_number] . "\" value=\"" . $row['desc_divergencia_materiais_bl'] . "\"><span style=\"cursor: pointer;\" onClick=\"if(" . $tabela . "_" . $itens[$row_number] . ".checked==true){" . $tabela . "_" . $itens[$row_number] . ".checked=false}else{" . $tabela . "_" . $itens[$row_number] . ".checked=true}\">" . $row['desc_divergencia_materiais_bl'] . "</span><br>";
    $row_number++;
}
echo "\t\t</div>";
echo "\t\t</fieldset>";
//======== Divergência de Materiais - FIM ========//
echo "\t\t<br>";
//======== COMENTÁRIOS - INICIO ========//
echo "\t\t<fieldset id=\"fieldset_comentarios\">";
echo "\t\t<legend id=\"legend\">Comentários</legend>";
Example #8
0
function geraMomentoSKY($periodo_inicial, $periodo_final, $tipo)
{
    $campos = "v.os, v.comentarios_texto, cd.desc_empresa, r.desc_regional, c.nome, " . "vims.nome_tecnico, vims.selecionada, ims.desc_indicacao_momento_sky";
    $tabela = "vistoria_indicacao_momento_sky vims " . "INNER JOIN vistoria v ON (v.os = vims.os) " . "INNER JOIN credenciados cd ON (cd.pdv_empresa = v.pdv_empresa) " . "INNER JOIN consultor c ON (c.cod_consultor = v.cod_consultor) " . "INNER JOIN regional r ON (r.cod_regional = v.cod_regional) " . "INNER JOIN indicacao_momento_sky ims ON (ims.cod_indicacao_momento_sky = vims.cod_indicacao_momento_sky)";
    $sel = !isset($_GET['sel']) || $_GET['sel'] == 1 ? 'true' : $_GET['sel'];
    $criterios = "vims.nome_tecnico is not null " . "AND ims.desc_indicacao_momento_sky = '" . $tipo . "' " . "AND (v.data_vistoria BETWEEN '" . $periodo_inicial . "' AND '" . $periodo_final . "')";
    $criterios .= $sel == 'true' ? ' AND vims.selecionada = 1' : '';
    $criterios .= " ORDER BY r.desc_regional ASC";
    $result = buscaTabela($campos, $tabela, $criterios);
    $html = '<html>';
    $html .= '<head><title>Indicações Ultrapassagens e Derrapadas</title>';
    $html .= '<meta charset="utf-8">';
    $html .= '<style>';
    $html .= '#borded-1px{white-space:nowrap; width:183px; border:1px solid black; padding:3px; font-size:11px; text-align:center; font-size:14;height:50px} ';
    $html .= '#borded-1px-head-green{border:1px solid #ddd; background-color:#3f0; padding:3px; font-size:11px; text-align:center; font-size:16} ';
    $html .= '#borded-1px-head-red{border:1px solid #ddd; background-color:#f60; padding:3px; font-size:11px; text-align:center; font-size:16} ';
    $html .= '#borded-2px{border:2px solid black; padding:3px; font-size:18; text-align:center;height:120px} ';
    $html .= 'body{font-family:arial; font-size:14} ';
    $html .= '#img{width:130px} ';
    $html .= '</style>';
    $html .= '</head>';
    $html .= '<body>';
    $html .= '<center>';
    $html .= '<table>';
    $html .= '<tr>';
    $html .= '<td id="borded-1px" cellpadding="5">';
    $html .= '<table style="width:953">';
    $html .= '<tr>';
    $html .= '<td style="width:20%" id="borded-2px"><img src=http://skyengenhariadecampo.com.br/img/logo_sky_engcampo.png width=170></td>';
    $html .= '<td style="width:60%" id="borded-2px"><h2 style="width:100%;height:20px">MOMENTO SKY</h2>BLOCO MANDOU BEM<br>Período: 11/' . date('m/Y', strtotime("-1 month", strtotime(". {$periodo_final} ."))) . ' a 10/' . date('m/Y', strtotime(". {$periodo_final} .")) . '</td>';
    $html .= '<td style="width:20%" id="borded-2px">';
    $html .= '		<select name="mes" id="mes" onChange="window.location.assign(\'napista.php?sel=\'+ sel.checked +\'&nvl=' . $_GET['nvl'] . '&ano=' . $_GET['ano'] . '&mes=\'+ mes.value +\'&tipo=' . $_GET['tipo'] . '\')">';
    if (isset($_GET['mes'])) {
        $mes_selecionado = $_GET['mes'];
    } else {
        $mes_selecionado = date("m");
    }
    if (isset($_GET['ano'])) {
        $ano_selecionado = $_GET['ano'];
    } else {
        $ano_selecionado = date("Y");
    }
    for ($i = 1; $i <= 12; $i++) {
        $html .= '			<option value="' . $i . '"' . ($i == $mes_selecionado ? ' Selected' : '') . '>' . $i . '</option>';
    }
    $html .= '		</select> / ';
    $html .= '		<select name="ano" id="ano" onChange="window.location.assign(\'napista.php?sel=\'+ sel.checked +\'&nvl=' . $_GET['nvl'] . '&ano=\'+ ano.value +\'&mes=' . $_GET['mes'] . '&tipo=' . $_GET['tipo'] . '\')">';
    for ($i = 2012; $i <= date("Y"); $i++) {
        $html .= '			<option value="' . $i . '"' . ($i == $ano_selecionado ? ' Selected' : '') . '>' . $i . '</option>';
    }
    $html .= '		</select><br>';
    $html .= '		<select name="tipo" id="tipo" onChange="window.location.assign(\'napista.php?sel=\'+ sel.checked +\'&nvl=' . $_GET['nvl'] . '&ano=' . $_GET['ano'] . '&mes=' . $_GET['mes'] . '&tipo=\'+ tipo.value)">';
    $html .= '			<option value="DERRAPADA"' . ($_GET['tipo'] == 'DERRAPADA' ? ' Selected' : '') . '>Derrapadas</option>';
    $html .= '			<option value="ULTRAPASSAGEM"' . ($_GET['tipo'] == 'ULTRAPASSAGEM' ? ' Selected' : '') . '>Ultrapassagens</option>';
    $html .= '		</select><br>';
    $html .= '		<input type="checkbox" name="sel" id="sel" value="1"' . ($sel == 'true' ? ' checked' : '') . ' onChange="window.location.assign(\'napista.php?sel=\'+ sel.checked +\'&nvl=' . $_GET['nvl'] . '&ano=' . $_GET['ano'] . '&mes=' . $_GET['mes'] . '&tipo=' . $_GET['tipo'] . '\')"><span style="font-size:12px">Selecionadas</span>';
    $html .= '		<br>';
    $html .= '		<input type="button" name="btnVoltar" id="voltar" value="Menu Inicial" onClick="window.location.assign(\'http://' . $_SERVER['HTTP_HOST'] . '/km\')">';
    $html .= '		<br>';
    $html .= '		<input type="button" name="btnIndicar" id="voltar" value="Indicar ' . ucfirst(strtolower($_GET['tipo'])) . '" ' . 'onClick="window.open(\'indica_mandou_bem.php?tipo=' . ucfirst(strtolower($_GET['tipo'])) . '\',\'_blank\',\'fullscreen=no,toolbar=no,scrollbars=no,resizable=no,location=no,top=\'+screen.height/2+\',left=\'+screen.width/2+\',width=350,height=215\')">';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '</table>';
    $html .= '<table style="width:950">';
    $indice = 1;
    while ($row = mysql_fetch_array($result)) {
        //ULTRAPASSAGEM - INICIO
        $html .= '<tr>';
        $html .= '<td colspan=5 id="borded-1px-head-' . ($row['selecionada'] ? 'green' : 'red') . '">';
        $html .= '<b>' . $tipo . ' #' . $indice . '</b>';
        $html .= '</td>';
        $html .= '</tr>';
        $html .= '<tr>';
        $html .= '<td id="borded-1px">';
        $html .= '<b>OS<br><a href="http://' . $_SERVER['HTTP_HOST'] . '/files/fotos/' . $row['os'] . '/' . $row['os'] . '.html" target="_blank">' . $row['os'] . '</a></b>';
        $html .= '</td>';
        $html .= '<td id="borded-1px">';
        $html .= '<b>EMPRESA</b><br>' . $row['desc_empresa'];
        $html .= '</td>';
        $html .= '<td id="borded-1px">';
        $html .= '<b>REGIONAL</b><br>' . $row['desc_regional'];
        $html .= '</td>';
        $html .= '<td id="borded-1px">';
        $html .= '<b>TÉCNICO</b><br>' . $row['nome_tecnico'];
        $html .= '</td>';
        $html .= '<td id="borded-1px">';
        $html .= '<b>CONSULTOR</b><br>' . $row['nome'];
        $html .= '</td>';
        $html .= '</tr>';
        //COMENTÁRIOS
        $html .= '<tr>';
        $html .= '<td id="borded-1px" onMouseOver="this.style.backgroundColor=\'#ff0\';this.style.cursor=\'pointer\';" onMouseOut="this.style.backgroundColor=\'#fff\'">';
        if ($_SESSION['nivel_acesso'] < 3) {
            $html .= '<b><a href="javascript:if(confirm(\'Deseja alterar o status dessa indicação?\')){if(' . $_GET['nvl'] . '<2){alert(\'Indicação alterada com sucesso!\');document.location.href=\'napista.php?sel=' . $_GET['sel'] . '&nvl=' . $_GET['nvl'] . '&ano=' . $_GET['ano'] . '&mes=' . $_GET['mes'] . '&tipo=' . $_GET['tipo'] . '&alterar=' . $row['os'] . '&status=' . (!$row['selecionada'] ? 1 : 0) . '\'}else{alert(\'Você não tem permissão para fazer alterações nesta página!\')}}">' . ($row['selecionada'] ? 'EXCLUIR' : 'INCLUIR') . ' INDICAÇÃO</a>';
        }
        $html .= '</td>';
        $html .= '<td colspan=4 id="borded-1px">';
        $html .= '<b>' . $row['comentarios_texto'] . '</b>';
        $html .= '</td>';
        $html .= '</tr>';
        //ULTRAPASSAGENS - FIM
        $indice++;
    }
    $html .= '</table>';
    $html .= '<b>Relatório gerado pelo Sistema Engenharia de Campo em ' . date("d/m/Y") . ' às ' . date("h:i:s") . '</b></td>';
    $html .= '</td>';
    $html .= '</tr>';
    $html .= '</table>';
    $html .= '</center>';
    $html .= '</body>';
    $html .= '</html>';
    echo $html;
}
Example #9
0
require_once '../modulos/dao.php';
mysqlConnection();
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
// get the q parameter from URL
$q = $_REQUEST["q"];
$hint = "";
$campo = $_REQUEST["campo"];
$pdv = $_REQUEST["pdv"];
if ($campo == 'txtHint') {
    $tabela_pa = buscaTabela("pdv_empresa campo1, desc_empresa campo2, cod_regional campo3", "credenciados", "pdv_empresa LIKE '%" . $pdv . "%'");
    $msg = "Empresa não cadastrada!";
} else {
    $tabela_pa = buscaTabela("tec.id_tecnico campo1, tec.nome_tecnico campo2, tec.nivel_tecnico campo3", "tecnico tec INNER JOIN credenciados cred ON (cred.pdv_empresa = tec.pdv_empresa)", "cred.pdv_empresa='" . $pdv . "'");
    $msg = "Técnico não encontrado!";
}
$registros = mysql_num_rows($tabela_pa);
while ($row = mysql_fetch_array($tabela_pa)) {
    $a[$row['campo1']] = $row['campo2'];
}
// lookup all hints from array if $q is different from ""
if (!$registros) {
    $hint = 0;
} elseif ($q !== "") {
    $q = strtolower($q);
    $len = strlen($q);
    foreach ($a as $x => $x_value) {
        if (stristr($q, substr($x, 0, $len))) {
            if ($hint === "") {
Example #10
0
session_start();
header('Content-Type: text/html; charset=utf-8');
require_once '../modulos/dao.php';
require_once '../modulos/envia_email.php';
mysqlConnection();
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
// get the q parameter from URL
//$os = buscaCampo("os","SELECT","vistoria","os","os=".$_GET["os"]);
$campos = "c.nome, c.email, v.os";
$tabela = "vistoria v INNER JOIN consultor c ON (c.cod_consultor = v.cod_consultor)";
$criterios = "v.os = " . $_GET["os"];
$consulta_especialista = buscaTabela($campos, $tabela, $criterios);
$comando = $_GET['comando'];
$row = mysql_fetch_array($consulta_especialista);
if ($row['os'] == '') {
    $msg = "OS não encontrada!";
} else {
    if ($comando == 'Validar') {
        $tabela = buscaCampo("", "UPDATE", "vistoria", "moderacao=1", "os=" . $row['os']);
        $msg = "Vistoria validada com sucesso!";
    } elseif ($comando == 'Reenviar') {
        if (isset($_POST['mensagem'])) {
            $tabela = buscaCampo("", "UPDATE", "vistoria", "moderacao=2", "os=" . $row['os']);
            if (mysql_affected_rows() > 0) {
                //Busca email do consultor responsavel
                $email_cc = buscaCampo("email", "SELECT", "consultor", "email", "cod_consultor = " . $_SESSION['login']);
                //Envia email de notificação para reenvio de vistoria
echo "\t\t<br>";
echo "\t\t<label>E-mail:</label><input type=\"text\" name=\"email\" id=\"email\" class=\"input\">";
echo "\t\t<br>";
echo "\t\t<label>Regional:</label>";
//Monta Lista da Regional";
$result = buscaTabela('*', 'regional', 'cod_regional < 99 ORDER BY cod_regional ASC');
echo "\t\t<select name=\"regional\" id=\"regional\">";
echo "\t\t\t<option value=\"\"></option>";
while ($row = mysql_fetch_array($result)) {
    echo "\t\t\t<option value=\"" . $row['cod_regional'] . "\">" . $row['desc_regional'] . "</option>";
}
echo "\t\t</select>";
echo "\t\t<br>";
echo "\t\t<label>Grupo:</label>";
//Monta Lista de Supervisores"
$result = buscaTabela('g.cod_grupo, c.nome', 'grupo g INNER JOIN consultor c ON (g.cod_consultor = c.cod_consultor)', 'g.cod_grupo != 5 ORDER BY c.nome');
echo "\t\t<select name=\"supervisor\" id=\"supervisor\">";
echo "\t\t\t<option value=\"\">Selecione</option>";
while ($row = mysql_fetch_array($result)) {
    echo "\t\t\t<option value=\"" . $row['cod_grupo'] . "\">" . $row['nome'] . "</option>";
}
echo "\t\t\t<option value=\"0\">Operador</option>";
echo "\t\t\t<option value=\"-1\">Novo Supervisor</option>";
echo "\t\t</select>";
echo "\t\t<input type=\"hidden\" name=\"pdv_empresa\" id=\"pdv_empresa\" value=\"SKY0000\">";
echo "\t\t</fieldset>";
//======== INSTALACAO - FIM ========//
echo "\t\t<br>";
echo "\t\t<div style=\"width:100%; text-align: center\">";
echo "\t\t<input type=\"hidden\" name=\"moderacao\" id=\"moderacao\" value=\"" . (buscaCampo("nivel_acesso", "SELECT", "consultor", "nivel_acesso", "cod_consultor = " . $_SESSION['login']) == 4 ? 0 : 1) . "\" style=\"width: 100px\">";
echo "\t\t<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Enviar\" style=\"width: 100px\">";
Example #12
0
echo "\t\t<br>";
echo "\t\t<label>Grupo:</label>";
//Monta Lista de Supervisores"
$result = buscaTabela('g.cod_grupo, c.nome', 'grupo g INNER JOIN consultor c ON (g.cod_consultor = c.cod_consultor)', '1 ORDER BY c.nome');
echo "\t\t<select name=\"supervisor\" id=\"supervisor\"" . ($_SESSION['nivel_acesso'] >= 3 ? ' disabled' : '') . ">";
echo "\t\t\t<option value=\"\">Selecione</option>";
echo "\t\t\t<option value=\"0\" Selected>Nenhum</option>";
echo "\t\t\t<option value=\"-1\">Novo Supervisor</option>";
while ($row = mysql_fetch_array($result)) {
    echo "\t\t\t<option value=\"" . $row['cod_grupo'] . "\"" . ($row['cod_grupo'] == $consultor['cod_grupo'] ? ' Selected' : '') . ">" . $row['nome'] . "</option>";
}
echo "\t\t</select>";
echo "\t\t<br>";
echo "\t\t<label>Perfil:</label>";
//Monta Lista de Nivel de acesso"
$result = buscaTabela('*', 'nivel_acesso', '1 ORDER BY 1 ASC');
echo "\t\t<select name=\"nivel_acesso\" id=\"nivel_acesso\"" . ($_SESSION['nivel_acesso'] >= 3 ? ' disabled' : '') . ">";
echo "\t\t\t<option value=\"\">Selecione</option>";
while ($row = mysql_fetch_array($result)) {
    echo "\t\t\t<option value=\"" . $row['nivel_acesso'] . "\"" . ($row['nivel_acesso'] == $consultor['nivel_acesso'] ? ' Selected' : '') . ">" . $row['desc_acesso'] . "</option>";
}
echo "\t\t</select>";
echo "\t\t<br>";
echo "\t\t<label>Ativo:</label>";
//Monta Lista Ativo"
$result = array('Não', 'Sim');
echo "\t\t<select name=\"ativo\" id=\"ativo\"" . ($_SESSION['nivel_acesso'] >= 3 ? ' disabled' : '') . ">";
foreach ($result as $key => $row) {
    echo "\t\t\t<option value=\"" . $key . "\"" . ($key == $consultor['ativo'] ? ' Selected' : '') . ">" . $row . "</option>";
}
echo "\t\t</select>";
Example #13
0
function geraXLS($tipo_relatorio, $exportar)
{
    // $exportar=1 -> exporta p/ xls; $exportar=0 -> exibe na tela
    //Constroi o HTML
    $msg = "";
    $html = '<style>table{border:1px solid black;background-color:#fff;width:100%} td{font-size:11px;text-align:center;white-space:nowrap;border:1px solid black;padding:3px} td.head{background-color:#ff0;font-weight:bold;}</style>';
    $html .= '<table>';
    if ($tipo_relatorio == 1) {
        //Vistoria PayTV(1); Vistoria BL(2); QB(3); Tecnicos(4)
        $campos = "v.os, v.data_vistoria, v.data_servico, v.pdv_empresa, v.cod_regional, v.id_tecnico, v.nivel_tecnico, v.padrao_ber, " . "v.padrao_taxa, v.padrao_checkup_sky, v.regiao_tem_uhf, v.cod_modelo_ird, v.smart_card, v.modulo_terrestre_habilitado, " . "v.tv_lcd_led, tv.desc_tipo_vistoria, resp.nome resp_nome, cons.nome cons_nome, cons.pdv_sede, ts.desc_tipo_servico, " . "ta.desc_tipo_aprovacao, mt.desc_modulo_terrestre, cons.cod_grupo, cred.desc_empresa, " . "cred.periodicidade, ti.desc_tipo_instalacao, tlnb.desc_tipo_lnb, tbl.desc_tipo_banda_larga, " . "top.desc_tipo_operadora, mird.desc_modelo_ird, v.moderacao";
        $tabela = "vistoria v INNER JOIN tipo_vistoria tv on (tv.cod_tipo_vistoria = v.cod_tipo_vistoria) " . "INNER JOIN credenciados cred ON (cred.pdv_empresa = v.pdv_empresa) " . "INNER JOIN tipo_servico ts ON (ts.cod_tipo_servico = v.cod_tipo_servico) " . "INNER JOIN tipo_instalacao ti ON (ti.cod_tipo_instalacao = v.cod_tipo_instalacao) " . "INNER JOIN tipo_aprovacao ta ON (ta.cod_tipo_aprovacao = v.cod_tipo_aprovacao) " . "INNER JOIN tipo_lnb tlnb ON (tlnb.cod_tipo_lnb = v.cod_tipo_lnb) " . "INNER JOIN tipo_banda_larga tbl ON (tbl.cod_tipo_banda_larga = v.cod_tipo_banda_larga) " . "INNER JOIN tipo_operadora top ON (top.cod_tipo_operadora = v.cod_tipo_operadora) " . "INNER JOIN modelo_ird mird ON (mird.cod_modelo_ird = v.cod_modelo_ird) " . "INNER JOIN modulo_terrestre mt ON (mt.cod_modulo_terrestre = v.cod_modulo_terrestre) " . "INNER JOIN consultor cons ON (cons.cod_consultor = v.cod_consultor) " . "INNER JOIN consultor resp ON (resp.cod_consultor = cred.cod_consultor)";
        if ($_REQUEST['os'] != '') {
            //Com número de OS
            $criterios = "v.os = " . trim($_REQUEST['os']);
        } else {
            //Sem número de OS
            $primeiro_dia = "01";
            $mes = $_REQUEST['mes'] != '' ? $_REQUEST['mes'] : date("m");
            $ano = $_REQUEST['ano'] != '' ? $_REQUEST['ano'] : date("Y");
            $ultimo_dia = date('t', mktime(0, 0, 0, $mes, '01', $ano));
            if ($_GET['meses_anteriores'] != 'true') {
                //Somente mês selecionado
                $ultimo_dia = date('t', mktime(0, 0, 0, $mes, '01', $ano));
                $data_inicial = date('Y-m-d', strtotime($ano . "-" . $mes . "-" . $primeiro_dia));
            } else {
                //Inclui 2 últimos meses
                $ano_mes = date('Y-m', strtotime($ano . "-" . $mes));
                $meses_anteriores = date('Y-m', strtotime("-2 month", strtotime(". {$ano_mes} .")));
                $data_inicial = date('Y-m-d', strtotime($meses_anteriores . "-" . $primeiro_dia));
            }
            $data_final = date('Y-m-d', strtotime($ano . "-" . $mes . "-" . $ultimo_dia));
            $criterios .= "v.data_vistoria BETWEEN '" . $data_inicial . "' AND '" . $data_final . "'";
            if ($_REQUEST['cnst'] != 0) {
                //Selecionado um 'Consultor'
                if ($_REQUEST['especialista'] > 0) {
                    //Selecionado 'Somente Especialista'
                    $tabela .= "INNER JOIN consultor_especialista ce ON (ce.pdv_empresa = cons.pdv_sede) ";
                    $criterios .= " AND ce.cod_consultor = " . $_REQUEST['cnst'];
                } else {
                    //Selecionado 'Somente consultor'
                    $criterios .= " AND v.cod_consultor = " . $_REQUEST['cnst'];
                }
            } elseif ($_SESSION['nivel_acesso'] > 2 && $_SESSION['nivel_acesso'] < 6) {
                $criterios .= " AND v.cod_consultor = " . $_SESSION['login'];
            } elseif ($_SESSION['nivel_acesso'] == 5 && strlen($_REQUEST['pdv_especialista']) > 1) {
                $criterios .= " AND cons.pdv_sede = '" . $_REQUEST['pdv_especialista'] . "'";
            } elseif (($_SESSION['nivel_acesso'] < 3 || $_SESSION['nivel_acesso'] > 4) && $_REQUEST['grp'] != 0) {
                $criterios .= " AND cons.cod_grupo = " . $_REQUEST['grp'];
            }
            if (strlen($_REQUEST['pdv_empresa']) > 1) {
                $criterios .= " AND v.pdv_empresa = '" . $_REQUEST['pdv_empresa'] . "'";
            }
            if ($_REQUEST['reg'] > 0) {
                $criterios .= " AND v.cod_regional = " . $_REQUEST['reg'];
            }
        }
        $criterios .= " AND v.moderacao < 2";
        $query = "SELECT " . $campos . " FROM " . $tabela . " WHERE " . $criterios . " ORDER BY v.data_vistoria DESC";
        $resultado = mysql_query($query);
        if (mysql_num_rows($resultado) == 0) {
            $msg = 'Não há VISTORIAS de PAYTV com os critérios escolhidos!';
            $html .= '<tr>';
            $html .= '<td><b>' . $msg . '</b></td>';
            $html .= '</tr>';
        } elseif ($_REQUEST['exibir']) {
            if ($_REQUEST['os'] > 0) {
                header('Location: ../files/fotos/' . trim($_REQUEST['os']) . '/' . trim($_REQUEST['os']) . '.html');
            } else {
                $msg = 'Digite uma OS válida!';
                $html .= '<tr>';
                $html .= '<td><b>' . $msg . '</b></td>';
                $html .= '</tr>';
            }
        } else {
            // Nome do arquivo que será exportado
            $arquivo = 'relatorio_vistoria.xls';
            if (!$exportar) {
                $html .= '<span id="num_vistorias">' . mysql_num_rows($resultado) . '</span> VISTORIAS';
            }
            $html .= '<tr>';
            $html .= '<td class="head">TIPO INSPEÇÃO</td>';
            $html .= '<td class="head">DATA VISTORIA</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">DATA SERVIÇO</td>';
            }
            $html .= '<td class="head">PDV</td>';
            $html .= '<td class="head">CREDENCIADO</td>';
            $html .= '<td class="head">REGIONAL</td>';
            $html .= '<td class="head">CONSULTOR</td>';
            $html .= '<td class="head">SEDE</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">PERIODICIDADE</td>';
            }
            $html .= '<td class="head">OS</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">TIPO INSTALAÇÃO</td>';
                $html .= '<td class="head">TIPO SERVIÇO</td>';
                $html .= '<td class="head">TIPO LNB</td>';
                $html .= '<td class="head">ID DO TÉCNICO</td>';
                $html .= '<td class="head">NÍVEL TÉCNICO</td>';
            }
            $html .= '<td class="head">APROVAÇÃO</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">BER</td>';
                $html .= '<td class="head">TAXA</td>';
                $html .= '<td class="head">CHECKUP SKY</td>';
                $html .= '<td class="head">ABRIR NOVA OS?</td>';
                $html .= '<td class="head">BANDA LARGA</td>';
                $html .= '<td class="head">OPERADORA</td>';
                $html .= '<td class="head">TEM UHF?</td>';
                $html .= '<td class="head">MODELO IRD</td>';
                $html .= '<td class="head">SMART CARD</td>';
                $html .= '<td class="head">MODULO TERRESTRE</td>';
                $html .= '<td class="head">HABILITADO</td>';
                $html .= '<td class="head">TV LCD</td>';
                $html .= '<td class="head">MODELO IRD 2</td>';
                $html .= '<td class="head">MODULO TERRESTRE 2</td>';
                $html .= '<td class="head">HABILITADO 2</td>';
                $html .= '<td class="head">TV LCD 2</td>';
                $html .= '<td class="head">MODELO IRD 3</td>';
                $html .= '<td class="head">MODULO TERRESTRE 3</td>';
                $html .= '<td class="head">HABILITADO 3</td>';
                $html .= '<td class="head">TV LCD 3</td>';
                $html .= '<td class="head">MODELO IRD 4</td>';
                $html .= '<td class="head">MODULO TERRESTRE 4</td>';
                $html .= '<td class="head">HABILITADO 4</td>';
                $html .= '<td class="head">TV LCD 4</td>';
                $html .= '<td class="head">MODELO IRD 5</td>';
                $html .= '<td class="head">MODULO TERRESTRE 5</td>';
                $html .= '<td class="head">HABILITADO 5</td>';
                $html .= '<td class="head">TV LCD 5</td>';
                $html .= '<td class="head">MODELO IRD 6</td>';
                $html .= '<td class="head">MODULO TERRESTRE 6</td>';
                $html .= '<td class="head">HABILITADO 6</td>';
                $html .= '<td class="head">TV LCD 6</td>';
                $html .= '<td class="head">Apontamento e Visada (I.F.E.)</td>';
                $html .= '<td class="head">Antena irregular (I.F.E.)</td>';
                $html .= '<td class="head">Antena fixação (I.F.E.)</td>';
                $html .= '<td class="head">LNB irregular (I.F.E.)</td>';
                $html .= '<td class="head">LNB fixação (I.F.E.)</td>';
                $html .= '<td class="head">Silicone (I.F.E.)</td>';
                $html .= '<td class="head">Fita de auto fusão (I.F.E.)</td>';
                $html .= '<td class="head">Cabo irregular (I.F.E.)</td>';
                $html .= '<td class="head">Cabo fixação (I.F.E.)</td>';
                $html .= '<td class="head">Conector irregular (I.F.E.)</td>';
                $html .= '<td class="head">Conector crimpagem (I.F.E.)</td>';
                $html .= '<td class="head">Dispositivos de distribuição (I.F.E.)</td>';
                $html .= '<td class="head">Conexão de áudio e vídeo (I.F.E.)</td>';
                $html .= '<td class="head">Conexão modem (I.F.E.)</td>';
                $html .= '<td class="head">Controle codificado (I.F.E.)</td>';
                $html .= '<td class="head">Instalação módulo terrestre (I.F.E.)</td>';
                $html .= '<td class="head">Qualidade Técnica (I.C.)</td>';
                $html .= '<td class="head">Uniforme ou identificação (I.C.)</td>';
                $html .= '<td class="head">Limpeza do local (I.C.)</td>';
                $html .= '<td class="head">Danos no local (I.C.)</td>';
                $html .= '<td class="head">Cobrança do serviço (I.C.)</td>';
                $html .= '<td class="head">Cumprimento agendamento (I.C.)</td>';
                $html .= '<td class="head">Atendimento SAC (I.C.)</td>';
                $html .= '<td class="head">Informações do vendedor (I.C.)</td>';
                $html .= '<td class="head">Programação (I.C.)</td>';
                $html .= '<td class="head">Informações da grade (I.C.)</td>';
                $html .= '<td class="head">Qualidade de som e imagem (I.C.)</td>';
                $html .= '<td class="head">Fatura (I.C.)</td>';
                $html .= '<td class="head">Antena DTH (D.M.)</td>';
                $html .= '<td class="head">Antena UHF (D.M.)</td>';
                $html .= '<td class="head">LNB (D.M.)</td>';
                $html .= '<td class="head">Cabo (D.M.)</td>';
                $html .= '<td class="head">Conector (D.M.)</td>';
                $html .= '<td class="head">Amplificador (D.M.)</td>';
                $html .= '<td class="head">Dispositivos de distribuição (D.M.)</td>';
            }
            $html .= '</tr>';
            while ($coluna = mysql_fetch_array($resultado)) {
                $html .= '<tr>';
                $html .= '<td>' . $coluna['desc_tipo_vistoria'] . '</td>';
                $html .= '<td>' . date("d/m/Y", strtotime($coluna['data_vistoria'])) . '</td>';
                if ($exportar == 1) {
                    $html .= '<td>' . date("d/m/Y", strtotime($coluna['data_servico'])) . '</td>';
                }
                $html .= '<td>' . $coluna['pdv_empresa'] . '</td>';
                $html .= '<td>' . $coluna['desc_empresa'] . '</td>';
                $html .= '<td>R' . $coluna['cod_regional'] . '</td>';
                $html .= '<td>' . $coluna[($coluna['pdv_sede'] == 'SKY0000' ? 'cons' : 'resp') . '_nome'] . '</td>';
                $cor_validacao = array("red", "green", "black");
                $html .= '<td><b style="color:' . $cor_validacao[$coluna['moderacao']] . '">' . buscaCampo("desc_empresa", "SELECT", "credenciados ", "desc_empresa", "pdv_empresa = '" . $coluna['pdv_sede'] . "'") . '</td>';
                if ($exportar == 1) {
                    $html .= '<td>' . $coluna['periodicidade'] . '</td>';
                }
                $html .= '<td><a href="http://' . $_SERVER['HTTP_HOST'] . '/files/fotos/' . $coluna['os'] . '/' . $coluna['os'] . '.html" target="_blank">' . $coluna['os'] . '</a></td>';
                if ($exportar == 1) {
                    $html .= '<td>' . $coluna['desc_tipo_instalacao'] . '</td>';
                    $html .= '<td>' . $coluna['desc_tipo_servico'] . '</td>';
                    $html .= '<td>' . $coluna['desc_tipo_lnb'] . '</td>';
                    $html .= '<td>' . $coluna['id_tecnico'] . '</td>';
                    $html .= '<td>' . $coluna['nivel_tecnico'] . '</td>';
                }
                $html .= '<td>' . $coluna['desc_tipo_aprovacao'] . '</td>';
                if ($exportar == 1) {
                    $html .= '<td>' . $coluna['padrao_ber'] . '</td>';
                    $html .= '<td>' . $coluna['padrao_taxa'] . '</td>';
                    $html .= '<td>' . $coluna['padrao_checkup_sky'] . '</td>';
                    $html .= '<td>' . (buscaCampo("os", "SELECT", "vistoria_abrir_nova_os", "os", "os = " . $coluna['os']) != 0 ? 'Sim' : 'Não') . '</td>';
                    $html .= '<td>' . $coluna['desc_tipo_banda_larga'] . '</td>';
                    $html .= '<td>' . $coluna['desc_tipo_operadora'] . '</td>';
                    $html .= '<td>' . $coluna['regiao_tem_uhf'] . '</td>';
                    $html .= '<td>' . $coluna['desc_modelo_ird'] . '</td>';
                    $html .= '<td>' . $coluna['smart_card'] . '</td>';
                    $html .= '<td>' . $coluna['desc_modulo_terrestre'] . '</td>';
                    $html .= '<td>' . $coluna['modulo_terrestre_habilitado'] . '</td>';
                    $html .= '<td>' . $coluna['tv_lcd_led'] . '</td>';
                    //Insere IRDs 2 a 6 - INICIO
                    $tabela_pa = buscaTabela("mi.desc_modelo_ird, mt.desc_modulo_terrestre, vpa.modulo_terrestre_habilitado, vpa.tv_lcd_led", "modelo_ird mi INNER JOIN vistoria_ponto_adicional vpa ON (vpa.cod_modelo_ird = mi.cod_modelo_ird) INNER JOIN modulo_terrestre mt ON (mt.cod_modulo_terrestre = vpa.cod_modulo_terrestre)", "vpa.os = " . $coluna['os']);
                    $registros = mysql_num_rows($tabela_pa);
                    while ($row = mysql_fetch_array($tabela_pa)) {
                        $html .= '<td>' . $row['desc_modelo_ird'] . '</td>';
                        $html .= '<td>' . $row['desc_modulo_terrestre'] . '</td>';
                        $html .= '<td>' . $row['modulo_terrestre_habilitado'] . '</td>';
                        $html .= '<td>' . $row['tv_lcd_led'] . '</td>';
                    }
                    for ($i = 1; $i <= (5 - $registros) * 4; $i++) {
                        $html .= '<td></td>';
                    }
                    //Insere IRDs 2 a 6 - FIM
                    //Busca IFEs (Itens Fora do Padrão) - INICIO
                    $campo_ife = "cod_item_fora_padrao";
                    $tabela_ife = "vistoria_item_fora_padrao";
                    $criterio_ife = "os = " . $coluna['os'];
                    //Loop para preenchimento dos IFEs
                    for ($i = 1; $i <= 16; $i++) {
                        $print = 0;
                        $ife = mysql_query("SELECT " . $campo_ife . " FROM " . $tabela_ife . " WHERE " . $criterio_ife);
                        while ($row = mysql_fetch_array($ife)) {
                            if ($i == $row['cod_item_fora_padrao']) {
                                $html .= '<td>1</td>';
                                $print = 1;
                            }
                        }
                        if ($print == 0) {
                            $html .= '<td></td>';
                        }
                    }
                    //Busca Itens Fora do Padrão - FIM
                    //Busca ICs (Insatisfação Cliente) - INICIO
                    $campo_ic = "cod_insatisfacao_cliente";
                    $tabela_ic = "vistoria_insatisfacao_cliente";
                    $criterio_ic = "os = " . $coluna['os'];
                    //Loop para preenchimento dos ICs
                    for ($i = 1; $i <= 12; $i++) {
                        $print = 0;
                        $ic = mysql_query("SELECT " . $campo_ic . " FROM " . $tabela_ic . " WHERE " . $criterio_ic);
                        while ($row = mysql_fetch_array($ic)) {
                            if ($i == $row['cod_insatisfacao_cliente']) {
                                $html .= '<td>1</td>';
                                $print = 1;
                            }
                        }
                        if ($print == 0) {
                            $html .= '<td></td>';
                        }
                    }
                    //Busca Insatisfação Cliente - FIM
                    //Insere Divergência de Materiais - INICIO
                    $div_mat = '';
                    $div_mat = array('DTH', 'UHF', 'LNB', 'CABO', 'CONECTOR', 'AMPLIFICADOR', 'DISPOSITIVOS');
                    foreach ($div_mat as $items) {
                        $flag = 0;
                        $tabela_dm = buscaTabela("dm.desc_divergencia_materiais", "divergencia_materiais dm INNER JOIN vistoria_divergencia_materiais vdm ON (vdm.cod_divergencia_materiais = dm.cod_divergencia_materiais)", "vdm.os = " . $coluna['os'] . " ORDER BY dm.cod_divergencia_materiais");
                        while ($row = mysql_fetch_array($tabela_dm)) {
                            $valor = strpos(strtoupper($row['desc_divergencia_materiais']), $items);
                            if (is_numeric($valor)) {
                                $html .= '<td>' . $row['desc_divergencia_materiais'] . '</td>';
                                $flag = 1;
                                break;
                            }
                        }
                        if ($flag == 0) {
                            $html .= '<td></td>';
                        }
                    }
                    //Insere Divergência de Materiais - FIM
                }
                $html .= '</tr>';
            }
        }
    } elseif ($tipo_relatorio == 2) {
        //Vistoria PayTV(1); Vistoria BL(2); QB(3); Tecnicos(4)
        $campos = "v.*, tv.desc_tipo_vistoria, resp.nome resp_nome, cons.nome cons_nome, cons.pdv_sede, cons.cod_grupo, " . "ts.desc_tipo_servico, ta.desc_tipo_aprovacao, cred.desc_empresa, tbl.desc_tipo_banda_larga, top.desc_tipo_operadora, " . "mcpe.desc_modelo_cpe, fw.desc_versao_firmware_cpe, vc.desc_velocidade_contratada, tco.desc_tipo_conexao";
        $tabela = "vistoria_bl v INNER JOIN tipo_vistoria tv on (tv.cod_tipo_vistoria = v.cod_tipo_vistoria) " . "INNER JOIN credenciados cred ON (cred.pdv_empresa = v.pdv_empresa) " . "INNER JOIN tipo_servico ts ON (ts.cod_tipo_servico = v.cod_tipo_servico) " . "INNER JOIN tipo_aprovacao ta ON (ta.cod_tipo_aprovacao = v.cod_tipo_aprovacao) " . "INNER JOIN tipo_banda_larga tbl ON (tbl.cod_tipo_banda_larga = v.cod_tipo_banda_larga) " . "INNER JOIN tipo_operadora top ON (top.cod_tipo_operadora = v.cod_tipo_operadora) " . "INNER JOIN tipo_conexao tco ON (tco.cod_tipo_conexao = v.cod_tipo_conexao) " . "INNER JOIN velocidade_contratada vc ON (vc.cod_velocidade_contratada = v.cod_velocidade_contratada) " . "INNER JOIN modelo_cpe mcpe ON (mcpe.cod_modelo_cpe = v.cod_modelo_cpe) " . "INNER JOIN versao_firmware_cpe fw ON (fw.cod_versao_firmware_cpe = v.cod_versao_firmware_cpe) " . "INNER JOIN consultor cons ON (cons.cod_consultor = v.cod_consultor) " . "INNER JOIN consultor resp ON (resp.cod_consultor = cred.cod_consultor)";
        if ($_REQUEST['os'] != '') {
            //Com número de OS
            $criterios = "v.os = " . trim($_REQUEST['os']);
        } else {
            //Sem número de OS
            $primeiro_dia = "01";
            $mes = $_REQUEST['mes'] != '' ? $_REQUEST['mes'] : date("m");
            $ano = $_REQUEST['ano'] != '' ? $_REQUEST['ano'] : date("Y");
            $ultimo_dia = date('t', mktime(0, 0, 0, $mes, '01', $ano));
            if ($_GET['meses_anteriores'] != 'true') {
                //Somente mês selecionado
                $ultimo_dia = date('t', mktime(0, 0, 0, $mes, '01', $ano));
                $data_inicial = date('Y-m-d', strtotime($ano . "-" . $mes . "-" . $primeiro_dia));
            } else {
                //Inclui 2 últimos meses
                $ano_mes = date('Y-m', strtotime($ano . "-" . $mes));
                $meses_anteriores = date('Y-m', strtotime("-2 month", strtotime(". {$ano_mes} .")));
                $data_inicial = date('Y-m-d', strtotime($meses_anteriores . "-" . $primeiro_dia));
            }
            $data_final = date('Y-m-d', strtotime($ano . "-" . $mes . "-" . $ultimo_dia));
            $criterios .= "v.data_vistoria BETWEEN '" . $data_inicial . "' AND '" . $data_final . "'";
            if ($_REQUEST['cnst'] != 0) {
                //Selecionado um 'Consultor'
                if ($_REQUEST['especialista'] > 0) {
                    //Selecionado 'Somente Especialista'
                    $tabela .= "INNER JOIN consultor_especialista ce ON (ce.pdv_empresa = cons.pdv_sede) ";
                    $criterios .= " AND ce.cod_consultor = " . $_REQUEST['cnst'];
                } else {
                    //Selecionado 'Somente consultor'
                    $criterios .= " AND v.cod_consultor = " . $_REQUEST['cnst'];
                }
            } elseif ($_SESSION['nivel_acesso'] > 2 && $_SESSION['nivel_acesso'] < 6) {
                $criterios .= " AND v.cod_consultor = " . $_SESSION['login'];
            } elseif ($_SESSION['nivel_acesso'] == 5 && strlen($_REQUEST['pdv_especialista']) > 1) {
                $criterios .= " AND cons.pdv_sede = '" . $_REQUEST['pdv_especialista'] . "'";
            } elseif (($_SESSION['nivel_acesso'] < 3 || $_SESSION['nivel_acesso'] > 4) && $_REQUEST['grp'] != 0) {
                $criterios .= " AND cons.cod_grupo = " . $_REQUEST['grp'];
            }
            if (strlen($_REQUEST['pdv_empresa']) > 1) {
                $criterios .= " AND v.pdv_empresa = '" . $_REQUEST['pdv_empresa'] . "'";
            }
            if ($_REQUEST['reg'] > 0) {
                $criterios .= " AND v.cod_regional = " . $_REQUEST['reg'];
            }
        }
        $criterios .= " AND v.moderacao < 2";
        $query = "SELECT " . $campos . " FROM " . $tabela . " WHERE " . $criterios . " ORDER BY v.data_vistoria DESC";
        $resultado = mysql_query($query);
        if (mysql_num_rows($resultado) == 0) {
            $msg = 'Não há VISTORIAS de BANDA LARGA com os critérios escolhidos!';
            $html .= '<tr>';
            $html .= '<td><b>' . $msg . '</b></td>';
            $html .= '</tr>';
        } elseif ($_REQUEST['exibir']) {
            if ($_REQUEST['os'] > 0) {
                header('Location: ../files/fotos/' . trim($_REQUEST['os']) . '/' . trim($_REQUEST['os']) . '.html');
            } else {
                $msg = 'Digite uma OS válida!';
                $html .= '<tr>';
                $html .= '<td><b>' . $msg . '</b></td>';
                $html .= '</tr>';
            }
        } else {
            // Nome do arquivo que será exportado
            $arquivo = 'relatorio_vistoria_bl.xls';
            if (!$exportar) {
                $html .= '<span id="num_vistorias">' . mysql_num_rows($resultado) . '</span> VISTORIAS';
            }
            $html .= '<tr>';
            $html .= '<td class="head">TIPO INSPEÇÃO</td>';
            $html .= '<td class="head">DATA VISTORIA</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">DATA SERVIÇO</td>';
            }
            $html .= '<td class="head">PDV</td>';
            $html .= '<td class="head">CREDENCIADO</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">REGIONAL</td>';
            }
            $html .= '<td class="head">UF</td>';
            $html .= '<td class="head">CONSULTOR</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">SEDE</td>';
            }
            $html .= '<td class="head">OS</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">TIPO SERVIÇO</td>';
                $html .= '<td class="head">ID DO TÉCNICO</td>';
                $html .= '<td class="head">TREINAMENTO BL?</td>';
            }
            $html .= '<td class="head">APROVAÇÃO</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">MODELO CPE</td>';
                $html .= '<td class="head">IMSI</td>';
                $html .= '<td class="head">VERSÃO FW</td>';
                $html .= '<td class="head">VEL. CONTRATADA</td>';
                $html .= '<td class="head">RSRP</td>';
                $html .= '<td class="head">CINR</td>';
                $html .= '<td class="head">TX POWER</td>';
                $html .= '<td class="head">DL</td>';
                $html .= '<td class="head">UL</td>';
                $html .= '<td class="head">LATÊNCIA</td>';
                $html .= '<td class="head">ABRIR NOVA OS?</td>';
                $html .= '<td class="head">PROBLEMA NAVEGAÇÃO?</td>';
                $html .= '<td class="head">COMITÊ NOTIFICADO?</td>';
                $html .= '<td class="head">BANDA LARGA</td>';
                $html .= '<td class="head">OPERADORA</td>';
                $html .= '<td class="head">CONEXÃO</td>';
                //Query dispositivo_conectado_bl";
                $result = buscaTabela('*', 'dispositivo_conectado_bl', '1');
                while ($row = mysql_fetch_array($result)) {
                    $html .= '<td class="head">' . $row['desc_dispositivo_conectado_bl'] . ' (D.C.)</td>';
                }
                $num_dispositivo_conectado_bl = mysql_num_rows($result);
                //Query item_fora_padrao_bl";
                $result = buscaTabela('*', 'item_fora_padrao_bl', '1');
                while ($row = mysql_fetch_array($result)) {
                    $html .= '<td class="head">' . $row['desc_item_fora_padrao_bl'] . ' (I.F.E.)</td>';
                }
                $num_item_fora_padrao_bl = mysql_num_rows($result);
                //Query insatisfacao_cliente_bl";
                $result = buscaTabela('*', 'insatisfacao_cliente_bl', '1');
                while ($row = mysql_fetch_array($result)) {
                    $html .= '<td class="head">' . $row['desc_insatisfacao_cliente_bl'] . ' (I.C.)</td>';
                }
                $num_insatisfacao_cliente_bl = mysql_num_rows($result);
                //Query insatisfacao_cliente_bl";
                $result = buscaTabela('*', 'divergencia_materiais_bl', '1');
                while ($row = mysql_fetch_array($result)) {
                    $html .= '<td class="head">' . $row['desc_divergencia_materiais_bl'] . ' (D.M.)</td>';
                }
                $num_divergencia_materiais_bl = mysql_num_rows($result);
            }
            $html .= '</tr>';
            while ($coluna = mysql_fetch_array($resultado)) {
                $html .= '<tr>';
                $html .= '<td>' . $coluna['desc_tipo_vistoria'] . '</td>';
                $html .= '<td>' . date("d/m/Y", strtotime($coluna['data_vistoria'])) . '</td>';
                if ($exportar == 1) {
                    $html .= '<td>' . date("d/m/Y", strtotime($coluna['data_servico'])) . '</td>';
                }
                $html .= '<td>' . $coluna['pdv_empresa'] . '</td>';
                $html .= '<td>' . $coluna['desc_empresa'] . '</td>';
                if ($exportar == 1) {
                    $html .= '<td>R' . $coluna['cod_regional'] . '</td>';
                }
                $html .= '<td>' . $coluna['cod_uf'] . '</td>';
                $html .= '<td>' . $coluna[($coluna['pdv_sede'] == 'SKY0000' ? 'cons' : 'resp') . '_nome'] . '</td>';
                if ($exportar == 1) {
                    $cor_validacao = array("red", "green", "black");
                    $html .= '<td><b style="color:' . $cor_validacao[$coluna['moderacao']] . '">' . buscaCampo("desc_empresa", "SELECT", "credenciados ", "desc_empresa", "pdv_empresa = '" . $coluna['pdv_sede'] . "'") . '</td>';
                }
                $html .= '<td><a href="http://' . $_SERVER['HTTP_HOST'] . '/files/fotos/' . $coluna['os'] . '/' . $coluna['os'] . '.html" target="_blank">' . $coluna['os'] . '</a></td>';
                if ($exportar == 1) {
                    $html .= '<td>' . $coluna['desc_tipo_servico'] . '</td>';
                    $html .= '<td>' . $coluna['id_tecnico'] . '</td>';
                    $html .= '<td>' . $coluna['treinamento_bl'] . '</td>';
                }
                $html .= '<td>' . $coluna['desc_tipo_aprovacao'] . '</td>';
                if ($exportar == 1) {
                    $html .= '<td>' . $coluna['desc_modelo_cpe'] . '</td>';
                    $html .= '<td>' . $coluna['imsi'] . '</td>';
                    $html .= '<td>' . $coluna['desc_versao_firmware_cpe'] . '</td>';
                    $html .= '<td>' . $coluna['desc_velocidade_contratada'] . '</td>';
                    $html .= '<td>' . $coluna['padrao_rsrp'] . '</td>';
                    $html .= '<td>' . $coluna['padrao_cinr'] . '</td>';
                    $html .= '<td>' . $coluna['padrao_tx_power'] . '</td>';
                    $html .= '<td>' . $coluna['padrao_download'] . '</td>';
                    $html .= '<td>' . $coluna['padrao_upload'] . '</td>';
                    $html .= '<td>' . $coluna['padrao_latencia'] . '</td>';
                    $html .= '<td>' . (buscaCampo("os", "SELECT", "vistoria_bl_abrir_nova_os", "os", "os = " . $coluna['os']) != 0 ? 'SIM' : 'NÃO') . '</td>';
                    $html .= '<td>' . buscaCampo("desc_problema_navegacao", "SELECT", "vistoria_bl v INNER JOIN tipo_problema_navegacao tpn ON (tpn.cod_problema_navegacao = v.cod_problema_navegacao)", "tpn.desc_problema_navegacao", "v.os = " . $coluna['os']) . '</td>';
                    $html .= '<td>' . buscaCampo("comite_notificado", "SELECT", "vistoria_bl", "comite_notificado", "os = " . $coluna['os']) . '</td>';
                    $html .= '<td>' . $coluna['desc_tipo_banda_larga'] . '</td>';
                    $html .= '<td>' . $coluna['desc_tipo_operadora'] . '</td>';
                    $html .= '<td>' . $coluna['desc_tipo_conexao'] . '</td>';
                    //Busca DCs (Dispositivos Conectados) - INICIO
                    $campo_ife = "cod_dispositivo_conectado";
                    $tabela_ife = "vistoria_bl_dispositivo_conectado";
                    $criterio_ife = "os = " . $coluna['os'];
                    //Loop para preenchimento dos IFPs
                    for ($i = 1; $i <= $num_dispositivo_conectado_bl; $i++) {
                        $print = 0;
                        $ife = mysql_query("SELECT " . $campo_ife . " FROM " . $tabela_ife . " WHERE " . $criterio_ife);
                        while ($row = mysql_fetch_array($ife)) {
                            if ($i == $row['cod_dispositivo_conectado']) {
                                $html .= '<td>1</td>';
                                $print = 1;
                            }
                        }
                        if ($print == 0) {
                            $html .= '<td></td>';
                        }
                    }
                    //Busca DC - FIM
                    //Busca IFEs (Itens Fora do Padrão) - INICIO
                    $campo_ife = "cod_item_fora_padrao";
                    $tabela_ife = "vistoria_bl_item_fora_padrao";
                    $criterio_ife = "os = " . $coluna['os'];
                    //Loop para preenchimento dos IFPs
                    for ($i = 1; $i <= $num_item_fora_padrao_bl; $i++) {
                        $print = 0;
                        $ife = mysql_query("SELECT " . $campo_ife . " FROM " . $tabela_ife . " WHERE " . $criterio_ife);
                        while ($row = mysql_fetch_array($ife)) {
                            if ($i == $row['cod_item_fora_padrao']) {
                                $html .= '<td>1</td>';
                                $print = 1;
                            }
                        }
                        if ($print == 0) {
                            $html .= '<td></td>';
                        }
                    }
                    //Busca IFP - FIM
                    //Busca ICs (Insatisfação Cliente) - INICIO
                    $campo_ic = "cod_insatisfacao_cliente";
                    $tabela_ic = "vistoria_bl_insatisfacao_cliente";
                    $criterio_ic = "os = " . $coluna['os'];
                    //Loop para preenchimento dos ICs
                    for ($i = 1; $i <= $num_insatisfacao_cliente_bl; $i++) {
                        $print = 0;
                        $ic = mysql_query("SELECT " . $campo_ic . " FROM " . $tabela_ic . " WHERE " . $criterio_ic);
                        while ($row = mysql_fetch_array($ic)) {
                            if ($i == $row['cod_insatisfacao_cliente']) {
                                $html .= '<td>1</td>';
                                $print = 1;
                            }
                        }
                        if ($print == 0) {
                            $html .= '<td></td>';
                        }
                    }
                    //Busca IC - FIM
                    //Insere Divergência de Materiais - INICIO
                    $campo_ic = "cod_divergencia_materiais";
                    $tabela_ic = "vistoria_bl_divergencia_materiais";
                    $criterio_ic = "os = " . $coluna['os'];
                    //Loop para preenchimento dos DMs
                    for ($i = 1; $i <= $num_divergencia_materiais_bl; $i++) {
                        $print = 0;
                        $ic = mysql_query("SELECT " . $campo_ic . " FROM " . $tabela_ic . " WHERE " . $criterio_ic);
                        while ($row = mysql_fetch_array($ic)) {
                            if ($i == $row['cod_divergencia_materiais']) {
                                $html .= '<td>1</td>';
                                $print = 1;
                            }
                        }
                        if ($print == 0) {
                            $html .= '<td></td>';
                        }
                    }
                    //Insere DMs - FIM
                }
                $html .= '</tr>';
            }
        }
    } elseif ($tipo_relatorio == 3) {
        //Vistoria PayTV(1); Vistoria BL(2); QB(3); Tecnicos(4)
        $campos = "tqb.pdv_empresa, cred.desc_empresa, cons.nome, cred.cod_regional, tqb.data_teste_qb, tqb.os, mird.desc_modelo_ird, " . "qbrel.desc_defeito defeito_relatado, qbconst.desc_defeito defeito_constatado, tqb.id_tecnico, tqb.troca_devida";
        $tabela = "teste_qb tqb INNER JOIN credenciados cred ON (cred.pdv_empresa = tqb.pdv_empresa) " . "INNER JOIN consultor cons ON (cons.cod_consultor = tqb.cod_consultor) " . "INNER JOIN modelo_ird mird ON (mird.cod_modelo_ird = tqb.cod_modelo_ird) " . "INNER JOIN qb_defeito qbrel ON (qbrel.cod_defeito = tqb.defeito_relatado) " . "INNER JOIN qb_defeito qbconst ON (qbconst.cod_defeito = tqb.defeito_constatado)";
        if ($_REQUEST['os'] != '') {
            //Com número de OS
            $criterios = "tqb.os = " . trim($_REQUEST['os']);
        } else {
            //Sem número de OS
            $primeiro_dia = "01";
            $mes = $_REQUEST['mes'] != '' ? $_REQUEST['mes'] : date("m");
            $ano = $_REQUEST['ano'] != '' ? $_REQUEST['ano'] : date("Y");
            $ultimo_dia = date('t', mktime(0, 0, 0, $mes, '01', $ano));
            if ($_GET['meses_anteriores'] != 'true') {
                //Somente mês selecionado
                $ultimo_dia = date('t', mktime(0, 0, 0, $mes, '01', $ano));
                $data_inicial = date('Y-m-d', strtotime($ano . "-" . $mes . "-" . $primeiro_dia));
            } else {
                //Inclui 2 últimos meses
                $ano_mes = date('Y-m', strtotime($ano . "-" . $mes));
                $meses_anteriores = date('Y-m', strtotime("-2 month", strtotime(". {$ano_mes} .")));
                $data_inicial = date('Y-m-d', strtotime($meses_anteriores . "-" . $primeiro_dia));
            }
            $data_final = date('Y-m-d', strtotime($ano . "-" . $mes . "-" . $ultimo_dia));
            $criterios .= "tqb.data_teste_qb BETWEEN '" . $data_inicial . "' AND '" . $data_final . "'";
            if ($_REQUEST['cnst'] != 0) {
                $criterios .= " AND tqb.cod_consultor = " . $_REQUEST['cnst'];
            } elseif ($_SESSION['nivel_acesso'] < 3 && $_REQUEST['grp'] != 0) {
                $criterios .= " AND cons.cod_grupo = " . $_REQUEST['grp'];
            }
            if (strlen($_REQUEST['pdv_empresa']) > 1) {
                $criterios .= " AND tqb.pdv_empresa = '" . $_REQUEST['pdv_empresa'] . "'";
            }
            if ($_REQUEST['reg'] > 0) {
                $criterios .= " AND cred.cod_regional = " . $_REQUEST['reg'];
            }
        }
        $query = "SELECT " . $campos . " FROM " . $tabela . " WHERE " . $criterios . " ORDER BY tqb.data_teste_qb DESC";
        $resultado = mysql_query($query);
        if (mysql_num_rows($resultado) == 0) {
            $msg = 'Não há Teste de QB com os critérios escolhidos!';
            $html .= '<tr>';
            $html .= '<td><b>' . $msg . '</b></td>';
            $html .= '</tr>';
        } elseif ($_REQUEST['exibir']) {
            if ($_REQUEST['os'] > 0) {
                $msg = 'Não é possivel visualizar relatórios de Teste de QB!';
            } else {
                $msg = 'Digite uma OS válida!';
            }
            $html .= '<tr>';
            $html .= '<td><b>' . $msg . '</b></td>';
            $html .= '</tr>';
        } else {
            // Nome do arquivo que será exportado
            $arquivo = 'relatorio_teste_qb.xls';
            if (!$exportar) {
                $html .= mysql_num_rows($resultado) . ' TESTES DE QB';
            }
            $html .= '<tr>';
            $html .= '<td class="head">PDV</td>';
            $html .= '<td class="head">EMPRESA</td>';
            $html .= '<td class="head">CONSULTOR</td>';
            $html .= '<td class="head">REGIONAL</td>';
            $html .= '<td class="head">DATA</td>';
            $html .= '<td class="head">OS</td>';
            $html .= '<td class="head">MODELO IRD</td>';
            if ($exportar == 1) {
                $html .= '<td class="head">DEFEITO RELATADO</td>';
                $html .= '<td class="head">DEFEITO CONSTATADO</td>';
                $html .= '<td class="head">ID DO TÉCNICO</td>';
            }
            $html .= '<td class="head">TROCA DEVIDA?</td>';
            $html .= '</tr>';
            while ($coluna = mysql_fetch_array($resultado)) {
                $html .= '<tr>';
                $html .= '<td>' . $coluna['pdv_empresa'] . '</td>';
                $html .= '<td>' . $coluna['desc_empresa'] . '</td>';
                $html .= '<td>' . $coluna['nome'] . '</td>';
                $html .= '<td>R' . $coluna['cod_regional'] . '</td>';
                $html .= '<td>' . date("d/m/Y", strtotime($coluna['data_teste_qb'])) . '</td>';
                $html .= '<td>' . $coluna['os'] . '</td>';
                $html .= '<td>' . $coluna['desc_modelo_ird'] . '</td>';
                if ($exportar == 1) {
                    $html .= '<td>' . $coluna['defeito_relatado'] . '</td>';
                    $html .= '<td>' . $coluna['defeito_constatado'] . '</td>';
                    $html .= '<td>' . $coluna['id_tecnico'] . '</td>';
                }
                $html .= '<td>' . $coluna['troca_devida'] . '</td>';
                $html .= '</tr>';
            }
        }
    } elseif ($tipo_relatorio == 4) {
        //Vistoria PayTV(1); Vistoria BL(2); QB(3); Tecnicos(4)
        $campos = "tec.id_tecnico, tec.nome_tecnico, tec.nivel_tecnico, tec.pdv_empresa, " . "tec.status_banda_larga, tec.apto_mudanca_nivel, cred.cod_regional";
        $tabela = "tecnico tec INNER JOIN credenciados cred ON (cred.pdv_empresa = tec.pdv_empresa)";
        //				"INNER JOIN grupo grp ON (grp.cod_consultor = cons.cod_consultor)";
        $criterios = "tec.status_tecnico = 'S'";
        /*
        				if ($_REQUEST['cnst'] != 0)
        					$criterios .= " AND cred.cod_consultor = " . $_REQUEST['cnst'];
        				elseif ($_SESSION['nivel_acesso'] < 3 && $_REQUEST['grp'] != 0)
        					$criterios .= " AND cons.cod_consultor > 1";
        		//			$criterios .= " AND cons.cod_grupo = " . $_REQUEST['grp'];
        			if (strlen($_REQUEST['pdv_empresa']) > 1)
        						$criterios .= " AND cred.pdv_empresa = '" . $_REQUEST['pdv_empresa'] . "'";
        					if ($_REQUEST['reg'] > 0)
        						$criterios .= " AND cred.cod_regional = " . $_REQUEST['reg'];
        				}
        */
        $query = "SELECT " . $campos . " FROM " . $tabela . " WHERE " . $criterios . " ORDER BY 2 ASC";
        $resultado = mysql_query($query);
        if (mysql_num_rows($resultado) == 0) {
            $msg = 'Não há Técnicos com os critérios escolhidos!';
            $html .= '<tr>';
            $html .= '<td><b>' . $msg . '</b></td>';
            $html .= '</tr>';
        } elseif ($_REQUEST['exibir']) {
            $html .= '<tr>';
            $html .= '<td><b>' . $msg . '</b></td>';
            $html .= '</tr>';
        } else {
            // Nome do arquivo que será exportado
            $arquivo = 'relatorio_tecnicos.xls';
            if (!$exportar) {
                $html .= mysql_num_rows($resultado) . ' TECNICOS';
            }
            $html .= '<tr>';
            $html .= '<td class="head">REGIONAL</td>';
            $html .= '<td class="head">PDV</td>';
            $html .= '<td class="head">EMPRESA</td>';
            $html .= '<td class="head">ID</td>';
            $html .= '<td class="head">TÉCNICO</td>';
            $html .= '<td class="head">NÍVEL</td>';
            $html .= '<td class="head">BANDA LARGA</td>';
            $html .= '<td class="head">APTO MUDANÇA NÍVEL</td>';
            $html .= '</tr>';
            while ($coluna = mysql_fetch_array($resultado)) {
                $html .= '<tr>';
                $html .= '<td>R' . $coluna['cod_regional'] . '</td>';
                $html .= '<td>' . $coluna['pdv_empresa'] . '</td>';
                $html .= '<td>' . $coluna['pdv_empresa'] . '</td>';
                $html .= '<td>' . $coluna['id_tecnico'] . '</td>';
                $html .= '<td>' . $coluna['nome_tecnico'] . '</td>';
                $html .= '<td>' . $coluna['nivel_tecnico'] . '</td>';
                $html .= '<td>' . $coluna['status_banda_larga'] . '</td>';
                $html .= '<td>' . $coluna['apto_mudanca_nivel'] . '</td>';
                $html .= '</tr>';
            }
        }
    }
    $html .= '</table>';
    //Acesso ao BD - FIM
    if ($exportar == 0) {
        echo $html;
    } elseif ($msg != "") {
        header('Location: ' . $_SERVER['HTTP_REFERER'] . '&msg=' . $msg);
    } else {
        // Configurações header para forçar o download
        header("Content-type: application/x-msexcel");
        header("Content-Disposition: attachment; filename=\"{$arquivo}\"");
        header("Pragma: no-cache");
        header("Expires: 0");
        header("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
        header("Cache-Control: no-cache, must-revalidate");
        header("Content-Description: PHP Generated Data");
        // Detecta o Browser e Plataforma e Envia o conteúdo do arquivo no formato correto
        $ua = getBrowser();
        echo $ua['platform'] == 'windows' ? utf8_decode($html) : $html;
    }
}
echo "\t\t<br>";
echo "\t\t<label>Empresa:</label><input type=\"text\" name=\"empresa\" id=\"empresa\" onKeyUp=\"this.value=this.value.toUpperCase()\">";
echo "\t\t<br>";
echo "\t\t<label>Regional:</label>";
//Monta Select da Regional";
$result = buscaTabela('*', 'regional', '1');
echo "\t\t<select name=\"regional\" id=\"regional\">";
echo "\t\t\t<option value=\"\"></option>";
while ($row = mysql_fetch_array($result)) {
    echo "\t\t\t<option value=\"" . $row['desc_regional'] . "\">" . $row['desc_regional'] . "</option>";
}
echo "\t\t</select>";
echo "\t\t<br>";
echo "\t\t<label>Periodicidade:</label>";
//Monta Select da Regional";
$result = buscaTabela('periodicidade', 'credenciados', '1 GROUP BY periodicidade');
echo "\t\t<select name=\"periodicidade\" id=\"periodicidade\">";
echo "\t\t\t<option value=\"\"></option>";
while ($row = mysql_fetch_array($result)) {
    echo "\t\t\t<option value=\"" . $row['periodicidade'] . "\">" . $row['periodicidade'] . "</option>";
}
echo "\t\t</select>";
echo "\t\t<br>";
echo "\t\t<label>Empresa Especialista?</label>";
echo "\t\t<select name=\"especialista\" id=\"especialista\">";
echo "\t\t\t<option value=\"NÃO\" selected>NÃO</option>";
echo "\t\t\t<option value=\"SIM\">SIM</option>";
echo "\t\t</select>";
echo "\t\t</fieldset>";
//======== INSTALACAO - FIM ========//
echo "\t\t<br>";