<html>
<head>
<title> CHECKLIST OBRA </title>
<link href="inclusos/css_precopratico.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
error_reporting(0);
ini_set("display_errors", 0 );
header('Content-Type: text/html; charset=utf-8');
include("../configuracao.php");//confirma no banco de dados
include("../inclusos/funcoes.php");
include("../seguranca.php"); // Inclui o arquivo com o sistema de seguran?a
protegePagina(); // Protege a página
$idobra = $_GET['idobra'];
$SelecionaObra = Seleciona("obras", "WHERE idobra='$idobra'", "LIMIT 0,1");
while($linha_obras = mysql_fetch_array($SelecionaObra)){
$idobra = $linha_obras['idobra']; 
$codmax = $linha_obras['codmax']; 
}
?>

<?php
$SelecionaObrasServico = Seleciona("obras_servicos", "WHERE idobra='$idobra' ", "ORDER BY coditem ASC");
$contar = mysql_num_rows($SelecionaObrasServico);

for($i=0;$i<1;$i++){   
$html[$i] = "";
    $html[$i] .= "<table id='tblExport'>";
    $html[$i] .= "<tr>";
    $html[$i] .= "<td><b>Cód.(BLOCK)</b></td>";
    $html[$i] .= "<td><b>Item</b></td>";
    $html[$i] .= "<td><b>Descrição</b></td>";	
    $html[$i] .= "<td><b>Percentual</b></td>";
    $html[$i] .= "<td><b>Data Inicio</b></td>";
    $html[$i] .= "<td><b>Data Fim</b></td>";
    $html[$i] .= "<td><b>Status</b></td>";				
    $html[$i] .= "</tr>";
}

$i = 1;
while($ret = mysql_fetch_array($SelecionaObrasServico)){
    $html[$i] .= "<tr>";
    $html[$i] .= "<td><b>".$ret['idservicoobra']."</b></td>";
    $html[$i] .= "<td><b>".$ret['coditem']."</b></td>";
    $html[$i] .= "<td><b>".$ret['titulo']."</b></td>";	
    $html[$i] .= "<td><b>".$ret['percentual_executado']."</b></td>";
	if($ret['datainicio'] != ""){ 
    $html[$i] .= "<td><b>".InverteDataNovoSeparador($ret['datainicio'], "-", "/")."</b></td>";
	}
	if($ret['datafim'] != ""){ 	
	$html[$i] .= "<td><b>".InverteDataNovoSeparador($ret['datafim'], "-", "/")."</b></td>";
	}
	if($ret['status'] == ""){
		$status = "Andamento";
	}else{
		$status = $ret['status'];	
	}
    $html[$i] .= "<td><b>".$status."</b></td>";	

    $html[$i] .= "</tr>";
    $i++;
}
    $html[$i] .= "</table>";
for($i=0;$i<=$contar;$i++){  
    echo $html[$i];
}	

?>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="js/excel/jquery.btechco.excelexport.js" charset="utf8"></script>
<script src="js/excel/jquery.base64.js" charset="utf8"></script>
<script>
    $(document).ready(function () {
            $("#tblExport").btechco_excelexport({
                containerid: "tblExport"
               , datatype: $datatype.Table
               , filename: 'CHECKLIST - <?php echo $codmax;?> - <?php echo date('Y');?>'
            });
			window.close();
    });
</script>
</body>
</html>