<?php session_start();
require('../cfg/cfg.php');
require('../cfg/res.php');
include('../../_lib/php_gene1.php');
//include('php_session.php');
$pla_sql='select *,date_format(fecha,"%d/%M")as fechadm from atvd1
INNER JOIN enti0
on enti=enti_codigo
where 1=1 ';
if(isset($_GET['enti']) && !empty($_GET['enti'])){$pla_sql.=' and enti="'.$_GET['enti'].'" '  ;}
if(isset($_GET['fini']) && !empty($_GET['fini'])){$pla_sql.=' and fecha>="'.$_GET['fini'].'" ';}
if(isset($_GET['ffin']) && !empty($_GET['ffin'])){$pla_sql.=' and fecha<="'.$_GET['ffin'].'" ';}
$pla_sql.=' ORDER BY enti_descri';

$pla_res=mysql_query($pla_sql,$link_vcrx);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="http://vcrxol.com/_lib/vrgets.css">  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $pagina_descri; ?></title>
</head>
<body>
<div align="center">
<div style="max-width:1000px;">
<table width="100%">
<tr align="center"><td colspan="7" style="font-weight:bolder; background:#F7F7F7;"><div >INFORME DE ACTIVIDADES POR RECURSO</div></td></tr>
<tr>
	<td            width="12%" style="font-weight:bolder; background:#F7F7F7;">PARAMETROS</td>
    <td colspan="3"></td>
    <td             width="8%" style="font-weight:bolder; background:#F7F7F7;">INFO</td>
    <td colspan="2" width="37%" ></td>
</tr>
<tr>
	<td             style="font-weight:bold;">FECHA</td>
    <td colspan="3"><?php echo $_GET['fini'];?> - <?php echo $_GET['ffin'];?></td>
    <td 			style="font-weight:bold;">RECURSO</td>
    <td colspan="2"><?php if(isset($_GET['enti']) && !empty($_GET['enti'])){echo r_fiel('enti',$_GET['enti'],$campo="descri",$valor="");}else{echo 'TODOS';}?></td>
</tr>
</table>
<hr />
<?php if(mysql_num_rows($pla_res)!=0){?>

<table style="border-collapse:collapse;" width="100%" cellpadding="4">

<?php while($pla_r=mysql_fetch_assoc($pla_res)){$tpuni=0;$tcant=0;?>

<tr><td style="font-weight:bolder;">RECURSO: </td><td colspan="7" ><?php echo $pla_r['enti_descri'];?></td></tr>

<tr style=" border:#000 solid 1px;font-weight:bolder; background:#F7F7F7;">
	<th>FECHA</th>
    <th>ACTIVIDAD</th>
    <th>DESCRIPCION</th>
    <th>ENTIDAD</th>
    <th>HORAS</th>
    <th>VALOR</th>
    <th>TOTAL</th>
</tr>
	<?php $pla2_sql='select *,(puni * cant) as total from atvd2 where idnum2='.$pla_r['idnum1']; ?>
    <?php $pla2_res=mysql_query($pla2_sql,$link_vcrx);?>
    <?php if(mysql_num_rows($pla2_res)!=0){$i=1;
			while($pla2_r=mysql_fetch_assoc($pla2_res)){$tpuni+=$pla2_r['puni'];$tcant+=$pla2_r['cant'];?>
                <tr align="left" style=" <?php  if($i%3==0){echo 'border-botom:solid 1px #000;';}$i++; ?>">
                    <td align="center"><?php echo $pla_r['fechadm'];?></td>
                    <td><?php echo $pla2_r['asub'];?></td>
                    <td><?php echo r_fiel('asub',$pla2_r['asub'],$campo="descri",$valor="");?></td>
                    <td><?php echo r_fiel('enti',$pla2_r['enti2'],$campo="descri",$valor="");?></td>
                    <td align="right"><?php echo number_format($pla2_r['puni'],2);?></td>
                    <td align="right"><?php echo number_format($pla2_r['cant'],2);?></td>
                    <td align="right"><?php echo number_format($pla2_r['total'],2);?></td>
                </tr>
	<?php	}	?>
    
<tr align="right" style="border-top:#000 solid 1px; font-weight:bolder;">
	<td></td>
    <td></td>
    <td></td>
    <td align="left">TOTAL</td>
    <td><?php echo number_format($tpuni,2);?></td>
    <td><?php echo number_format($tcant,2);?></td>
    <td><?php echo number_format($tpuni * $tcant,2);?></td>
</tr>
<tr>
	<td></td>
    <td></td>
    <td></td>
    <td>&nbsp;</td>
    <td></td>
    <td></td>
    <td></td>
</tr>
	<?php }?>
	<?php	}?>
</table>
<?php }?>

</div>
</div>
</body>
</html>