<?php session_start();?>
<?php include('../_cfg/config.php');?>
<?php include('php_gene1.php'); ?>
<?php include('php_session.php');?>


<?php
$ahora=date('Y-m-d');
$ahorita=date('G:i');

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<style>
body{font-family:Arial, Helvetica, sans-serif; font-size:14px;}
</style>
</head>

<body>
<?php
//include('php_session.php');
$fini=$_GET['fini'];
$ffin=$_GET['ffin'];
$clie=$_GET['clie'];
$recu=$_GET['recu'];
   
tfle_costatvd($fini,$ffin);
   
   
$valo=0;
if(isset($_GET['valo']) && !empty($_GET['valo'])){$valo=1;}
$tipo=$_GET['tipo'];

//solo sera temporal para corregir el checkbox


$tcant=0;
$tpuni=0;
$ttotal=0;
$atv_sql ='select * ';
$atv_sql.=' from plan12 where status!="O" ';
if(isset($fini) && !empty($fini)){ $atv_sql.=' and fecha>="'.$fini.'" ';}	 
if(isset($ffin) && !empty($ffin)){ $atv_sql.=' and fecha<="'.$ffin.'" ';}	 
if(isset($recu) && !empty($recu)){ $atv_sql.=' and enti2="'.$recu.'" ';}
elseif(isset($clie) && !empty($clie)){$atv_sql.=' and enti="'.$clie.'" ';}

$atv_sql.=' order by idnum1,iddet';	 
// echo $atv_sql;	 
//	idnum1="'.$_POST['idnum'].'"';
?>
<table cellpadding="4" width="100%" border="1" style="border-collapse:collapse;">
<tr align="center" style="font-weight:bolder;font-size:18px;"><td colspan="5">Consulta de Planificaciones</td></tr>
<tr align="center" style="background: #F0F0F0; font-weight:bolder;"><td colspan="6">FILTROS</td></tr>
<tr>
	<td style="font-weight:bolder;" width="10%">DESDE</td><td width="10%"><?php echo $fini;?></td>
    <td style="font-weight:bolder;"  width="10%">CLIENTE</td><td><?php if(empty($clie) || !isset($clie)){echo 'TODOS';}	else {echo r_fiel('enti',$clie,$campo="descri",$valor="");}?></td>
    <td colspan="2" rowspan="2" style="font-weight:bolder;" width="50%">
    <div>usuario</div>
    <div>fecha: <?php echo $ahora;?></div>
    <div>hora: <?php echo $ahorita;?></div>
    </td>
</tr>
<tr style="border-bottom:#CCC solid 1px;">
	<td style="font-weight:bolder;">HASTA</td><td><?php echo $ffin;?></td>
    <td style="font-weight:bolder;"><!--RECURSO--></td><td><?php //echo $recu;?></td>
</tr>

</table>
<hr />
<?php $atv_res=msql_query($atv_sql,$link_vcrx);?>
<?php if(msql_num_rows($atv_res)==0){echo 'no se encontraron datos';}
if(msql_num_rows($atv_res)!=0){?>
<table border="0" width="100%" cellpadding="4" style="border-collapse:collapse;">
<?php $aux_idnum1='';?>
<?php while($atv_r=msql_fetch_assoc($atv_res)){?>
	
    	<?php if($aux_idnum1!=$atv_r['idnum1']&& !empty($aux_idnum1)){$linea=0;?>
        <tr style="border-top:2px solid #000;">
            <td align="center"><?php echo number_format($tcant,2);?></td>
            <td align="left"><?php //echo $atv_r['asub_descri'];?></td>
            <td align="left"><?php  //if($tipo=='actcli'){echo $atv_r['enti_descri'];}else{echo $atv_r['enti2'];}?></td>
            <?php if($valo=='1'){?><td align="right"></td><?php }?>
            <?php if($valo=='1'){?><td align="right"><?php echo number_format($ttotal,2);?></td><?php }?>
            <td align="left"><?php //echo $atv_r['detalle'];?></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <?php if($valo=='1'){?><td></td><?php }?>
            <?php if($valo=='1'){?><td></td><?php }?>
            <td></td>
        </tr>
		<?php 	$tcant=0;		$tpuni=0;		$ttotal=0;		?>
		<?php }?>


	<?php if($aux_idnum1!=$atv_r['idnum1']){$aux_idnum1=$atv_r['idnum1'];?>
	
    <tr><td colspan="7">
    <table width="100%">
        <tr>
            <td style="font-weight:bolder;">CLIENTE</td>
            <td><?php  echo $atv_r['enti'].' - '.r_fiel('enti',$atv_r['enti']);?></td>
            <td style="font-weight:bolder;">FECHA</td>
                        <td><?php echo $atv_r['fechadmy'];?></td>
            <td><strong>EMPRESA : </strong></td>
            <td><?php echo $atv_r['empr1'];?></td>
            <td><strong>VALORACION : </strong></td>
            <td><?php echo number_format($atv_r['valorpla'],2);?></td>

        </tr>
        <tr>
	        <td style="font-weight:bolder;">SERVICIO</td>
            <td><?php echo $atv_r['asub_descri'];?></td>
            <td style="font-weight:bolder;">CONCEPTO</td>
            <td><?php echo $atv_r['concepto'];?></td>
        </tr>
	</table>
    </td>
	</tr>
    
    <tr  style="background: #F0F0F0;border-top:2px solid #000;border-bottom:2px solid #000; ">
		    <td style="font-weight:bolder;">HORAS</td>
            <td style="font-weight:bolder;">ACTIVIDAD</td>
            <td style="font-weight:bolder;">RECURSO</td>
            <?php if($valo=='1'){?><td style="font-weight:bolder;">VALOR</td><?php }?>
            <?php if($valo=='1'){?><td style="font-weight:bolder;">TOTAL</td><?php }?>
            <td style="font-weight:bolder;">OBSERVACION</td>
        </tr>
    <?php }?>
<tr style=" <?php $linea++;if($linea==3){echo 'border-bottom:1px  dotted #000;';$linea=0;}?>">
	<td align="center"><?php echo number_format($atv_r['cant'],2);$tcant+=$atv_r['cant'];?></td>
    <td align="left"><?php echo $atv_r['asub_descri'];?></td>
    <td align="left"><?php  echo r_fiel('enti',$atv_r['enti2'],$campo="descri",$valor="");?></td>
    <?php if($valo=='1'){?><td align="right"><?php echo number_format($atv_r['puni'],2);$tpuni+=$atv_r['puni'];?></td><?php }?>
    <?php if($valo=='1'){?><td align="right"><?php echo number_format($atv_r['total'],2);$ttotal+=$atv_r['total'];?></td><?php }?>
    <td align="left"><?php echo $atv_r['detalle'];?></td>
</tr>
<?php }?>

        <tr style="border-top:2px solid #000;">
            <td align="center"><?php echo number_format($tcant,2);?></td>
            <td align="left"><?php //echo $atv_r['asub_descri'];?></td>
            <td align="left"><?php  //if($tipo=='actcli'){echo $atv_r['enti_descri'];}else{echo $atv_r['enti2'];}?></td>
            <?php if($valo=='1'){?><td align="right"></td><?php }?>
            <?php if($valo=='1'){?><td align="right"><?php echo number_format($ttotal,2);?></td><?php }?>
            <td align="left"><?php //echo $atv_r['detalle'];?></td>
        </tr>

</table>	

<?php }?>
</body>
</html>
