<?php session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<?php
require('../cfg/res.php');	

$fecha1 = date('Y-m-j');
$nuevafecha = strtotime ( '-1 month' , strtotime ( $fecha1 ) ) ;
$xfecha1 = date ( 'Y/m/j' , $nuevafecha );
$xfecha1 = date('Y/m/'.'1');
$xfecha2 = date('Y/m/d');
$cdoble='1';

$sql_datesp='SET lc_time_names = "es_UY"';
$res_datesp=mysql_query($sql_datesp,$link_vcrx);


$sql_nvddt='select *,
	sum(tcant) as ttcant,
	sum(tsubt) as ttsubt,
	sum(tingreso) as ttingreso,
	sum(tegreso) as ttegreso,
	sum(tprovi1) as ttprovi1,
	sum(tprovi2) as ttprovi2,
	sum(total) as ttotal
	from nvdd12 where ';

	


$sql_nvddt.='(';

if(isset($_GET['fecha_ini']) && !empty($_GET['fecha_ini']) && isset($_GET['fecha_fin']) && !empty($_GET['fecha_fin']))
{
	$sql_nvddt.='fecha BETWEEN "'.$_GET['fecha_ini'].'" and "'.$_GET['fecha_fin'].'"';
	$xfecha1=$_GET['fecha_ini'];
	$xfecha2=$_GET['fecha_fin'];
}
else
{
	$sql_nvddt.=' fecha BETWEEN "'.$xfecha1.'" and "'.$xfecha2.'"' ;
}

$sql_nvddt.=')';
$sql_nvddt=str_replace(')(',')||(',$sql_nvddt);




if (mb_stristr('gnya',$_SESSION['user_vcrx_empr']))
{$sql_nvddt.=' and(docu!="NV13") ';}

$xfgrou='D';
if(isset($_GET['fgrou']) && !empty($_GET['fgrou']))
{$xfgrou=$_GET['fgrou'];}
$xfgrou=$_GET['grupo'];


$xforde='D';
if(isset($_GET['forde']) && !empty($_GET['forde']))
{$xforde=$_GET['forde'];}

$xfenti='';
if(isset($_GET['fenti']) && !empty($_GET['fenti']))
{$xfenti=$_GET['fenti'];}



switch ($xfgrou)
{
	case 'D':$xgroup='docu,ptoe,numero,idnum1 ';break;
	case 'E':
	$sql_nvddt.=' and enti2 like "'.$_GET['idnum'].'" ';
	$xgroup='docu,ptoe,numero,idnum1,nvdd ';
	break;
	case 'I':
	$sql_nvddt.=' and nvdd like "'.$_GET['idnum'].'%" ';
	$xgroup='docu,ptoe,numero,idnum1,enti2 ';
	break;

	case 'Z':$xgroup='zsub ';break;
	case 'L':$xgroup='item_lsub ';break;
	case 'R':
			if ($xfenti!=''){$sql_nvddt.=' and enti2 like "'.$xfenti.'" ';}
			$xgroup='docu,ptoe,numero,idnum1,nvdd ';
			$cdoble=2;	
	case 'C':$xgroup='cdad ';break;

	case 'A':$xgroup='fanio ';break;
	case 'M':
	//$sql_nvddt.=' and(concat(fanio,fmes)="'.$_GET['idnum'].'") ';
	$xgroup='docu,ptoe,numero,idnum1 ';
	break;
	case 'S':$xgroup='fanio,fsema ';break;
	case 'F':$xgroup='fecha ';break;

	default :$xgroup='';break;
}

switch ($xforde)
{
	case 'D':$xorder=$xgroup;break;
	case 'C':$xorder=str_replace('_descri','',$xgroup);break;
	case 'T':$xorder='ttotal desc, '.str_replace('_descri','',$xgroup);break;

	default :$xorder=$xgroup;break;
}
$res_nvddtt=mysql_query($sql_nvddt,$link_vcrx);
$xttingreso=mysql_result($res_nvddtt,0,'ttingreso');
$xttegreso=mysql_result($res_nvddtt,0,'ttegreso');
$xttprovi1=mysql_result($res_nvddtt,0,'ttprovi1');
$xttprovi2=mysql_result($res_nvddtt,0,'ttprovi2');


$sql_nvddt.=' group by '.$xgroup;

$sql_nvddt.=' order by '.$xorder;
// echo $sql_nvddt;
$res_nvddt=mysql_query($sql_nvddt,$link_vcrx);



?>


<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=shift_jis">

<title>Roles de Pago (Empleados)</title>
<style type="text/css">
body{ font-family:"Courier New", Courier, monospace;}

</style>

</head>
<body>

<div align="center">
<div align="center" style="width:1100px; font-size:12px;">
<div align="center" style="font-size:18px; border:#000 solid 1px; background: #F7F7F7; margin:2px; font-weight: bold;">ROLES DE PAGO</div>

<table width="100%" cellspacing="0" cellpadding="2">
<tr valign="top">
<td width="50%">

<table border="1" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse">
<tr>
	<th width="30%" style="background: #F7F7F7;">PARAMETROS</th>
	<th></th>
</tr>

<tr>
    	<td style="font-weight:bolder;">FECHA</td>
	<td><?php echo date_format(date_create($xfecha1),'d/M/Y').' - '.date_format(date_create($xfecha2),'d/M/Y');?></td>
</tr>



<?php
switch ($xfgrou)
{
	case 'D':
?>
<tr></tr>
<?php	
	break;
	case 'E':
	$sql_clie='select * from enti00 where enti_codigo like "'.$_GET['idnum'].'" ';
	$res_clie=mysql_query($sql_clie,$link_vcrx);
?>
<tr>
	<td><b>EMPLEADO</td>
	<td><?php echo mysql_result($res_clie,0,'enti_codigo').' - '.mysql_result($res_clie,0,'enti_descri');?></td>
<tr>
<?php	
	break;
	case 'I':
	$sql_clie='select * from nvdd0 where nvdd_codigo like "'.$_GET['idnum'].'%" ';
	$res_clie=mysql_query($sql_clie,$link_vcrx);
?>
<tr>
	<td><b>NOVEDAD</td>
	<td><?php echo mysql_result($res_clie,0,'nvdd_codigo').' - '.mysql_result($res_clie,0,'nvdd_descri');?></td>
<tr>
<?php	
	break;
	case 'R':
	$sql_clie='select * from enti00 where enti_codigo like "'.$_GET['idnum'].'" ';
	$res_clie=mysql_query($sql_clie,$link_vcrx);
?>
<tr>
	<td><b>EMPLEADO</td>
	<td><?php echo mysql_result($res_clie,0,'enti_codigo').' - '.mysql_result($res_clie,0,'enti_descri');?></td>
<tr>
<?php 
	break;
	default :
}
	?>



</table>




<td>
<!----++++++++++------>
<table border="1" width="100%" cellspacing="0" cellpadding="2" style="border-collapse:collapse">
<tr>
	<th width="30%"  style="background: #F7F7F7;">I N F O</th>
	<th></th>    
</tr>

<?php
$sql_empr='select * from empr0';
$res_empr=mysql_query($sql_empr,$link_vcrx);
?>
<tr>
	<td align="right">EMPRESA:</td>
	<td><?php echo mysql_result($res_empr,0,'empr_descri');?></td>
</tr>

<tr>
	<td align="right">USUARIO:</td>
	<td><?php echo $_SESSION['user_vcrx_id'].' / '.$_SESSION['user_vcrx_descri'];?></td>
</tr>
<tr>
	<td align="right">FECHA / HORA :</td>
	<td><?php echo date('d/M/Y H:m:s');?></td>
</tr>
</table>
<!----++++++++++------>
</td>

</tr>
</table>
<!----++++++++++------>


<hr/>

<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse">

<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
<?php
switch ($xfgrou)
{
	case 'D':
?>

	<th>DOCU</th>
	<th>NUMERO</th>
	<th>FECHA</th>
	<th>NOMBRE</th>
	<th></th>


<?php	
	break;
	case 'E':
?>

	<th>DOCU</th>
	<th>NUMERO</th>
	<th>FECHA</th>
	<th>NOVEDAD</th>
	<th></th>


<?php	
	break;
	case 'I':
?>
	<th>DOCU</th>
	<th>NUMERO</th>
	<th>FECHA</th>
	<th>NOMBRE</th>
	<th>CANT</th>


<?php	
	break;
	case 'M':
?>
	<th>DOCU</th>
	<th>PTO/NUMERO</th>
	<th>FECHA</th>
	<th>NOMBRE</th>
	<th></th>
<?php	
	break;
	case 'S':
?>
	<th></th>
	<th>ANIO</th>
	<th>SEMA</th>
	<th></th>
	<th></th>
<?php	
	break;
	case 'F':
?>
	<th></th>
	<th>ANIO</th>
	<th>MES</th>
	<th>FECHA</th>
	<th></th>

<?php	
	break;
	case 'P':
?>

	<th>DOCU</th>
	<th>PTO/NUMERO</th>
	<th>FECHA</th>
	<th>NOMBRE</th>
	<th></th>


<?php	
	break;
	case 'V':
?>

	<th>DOCU</th>
	<th>PTO/NUMERO</th>
	<th>FECHA</th>
	<th>NOMBRE</th>
	<th></th>


<?php	
	break;
	case 'Z':
?>
	<th></th>
	<th>ZONA</th>
	<th>NOMBRE</th>
	<th></th>
	<th></th>

<?php	
	break;
	case 'L':
?>
	<th></th>
	<th>LINEA</th>
	<th>NOMBRE</th>
	<th></th>
	<th></th>

<?php	
	break;
	case 'R':
?>
	<th></th>
	<th>COD.RET.</th>
	<th>NOMBRE</th>
	<th></th>
	<th></th>


<?php 
	break;
	default:
}
	?>

	<th>SUBT</th>

	<th>INGRESO</th>
	<th>EGRESO</th>
	<th>PROVI 1</th>
	<th>PROVI 2</th>
	<th>TOTAL</th>

<?php
switch ($xfgrou)
{
	case 'D':
?>
	<th>PROVINCIA /CIUDAD</th>
	<th>VENDEDOR</th>

<?php	
	break;
	case 'E':
?>
	<th></th>

<?php	
	break;
	case 'I':
?>
	<th></th>
<?php } ?>



</tr>

</div>


</tr>

<?php 
$filax=0;
//$urcdd='';
//$res_nvddt=mysql_query($sql_nvddt,$link_vcrx);

while($r_nvddt=mysql_fetch_assoc($res_nvddt))
{
$duni=$r_nvddt['item_duni'];
?>

<tr valign="top" class="filax" id="<?php echo $r_ped['idnum1']; ?>" align="center" style=" <?php if($filax>=4){echo 'border-top:dotted 1px #000;';$filax=1;}else{$filax++;} ?>" >

<?php
switch ($xfgrou)
{
	case 'D':
?>

        <td align="center"><?php echo'<span title="'.$r_nvddt['docu'].'">'.$r_nvddt['docu'].'</span>';?></td>
	<td align="center"><?php echo '<span title="'.$r_nvddt['ptonumero'].'">'.$r_nvddt['numero'].'</span>';?></a> </td>
	<td align="center"><?php echo'<span title="'.$r_nvddt['fechadmy'].'">'.$r_nvddt['fechadmy'].'</span>';?></td>
	<td align="left"><?php echo'<span title="'.$r_nvddt['enti2'].'">'.$r_nvddt['enti_descri'].'</span>';?></td>
	<td></td>


<?php	
	break;
	case 'E':
?>
	<td align="center"><?php echo '<span title="'.$r_nvddt['docu_descri'].'">'.$r_nvddt['docu'].'</span>';?></a> </td>
	<td align="center"><?php echo '<span title="'.$r_nvddt['ptonumero'].'">'.$r_nvddt['numero'].'</span>';?></a> </td>
	<td align="center"><?php echo'<span title="'.$r_nvddt['fechadmy'].'">'.$r_nvddt['fechadmy'].'</span>';?></td>
	<td align="left"><?php echo'<span title="'.$r_nvddt['nvdd'].'">'.$r_nvddt['nvdd_descri'].'</span>';?></td>
	<th></th>


<?php	
	break;
	case 'I':
?>
        <td align="center"><?php echo'<span title="'.$r_nvddt['docu'].'">'.$r_nvddt['docu'].'</span>';?></td>
	<td align="center"><?php echo '<span title="'.$r_nvddt['ptonumero'].'">'.$r_nvddt['numero'].'</span>';?></a> </td>
	<td align="center"><?php echo'<span title="'.$r_nvddt['fechadmy'].'">'.$r_nvddt['fechadmy'].'</span>';?></td>
	<td align="left"><?php echo'<span title="'.$r_nvddt['enti2'].'">'.$r_nvddt['enti_descri'].'</span>';?></td>
   	<td align="right"><?php echo number_format($r_nvddt['ttcant'],2);?></td>


<?php	
	break;
	case 'M':
?>
        <td align="center"><?php echo'<span title="'.$r_nvddt['docu'].'">'.$r_nvddt['docu'].'</span>';?></td>
	<td align="center"><?php echo '<span title="'.$r_nvddt['ptonumero'].'">'.$r_nvddt['numero'].'</span>';?></a> </td>
	<td align="center"><?php echo'<span title="'.$r_nvddt['fechadmy'].'">'.$r_nvddt['fechadmy'].'</span>';?></td>
	<td align="left"><?php echo'<span title="'.$r_nvddt['enti2'].'">'.$r_nvddt['enti_descri'].'</span>';?></td>
	<td></td>

<?php	
	break;
	case 'S':
?>
	<td></td>
        <td align="center"><?php echo'<span title="'.$r_nvddt['fanio'].'">'.$r_nvddt['fanio'].'</span>';?></td>
	<td align="left"><?php echo '<span title="'.$r_nvddt['fsema'].'">'.$r_nvddt['fsema'].'</span>';?></a> </td>
	<td align="left"></td>
	<td></td>

<?php	
	break;
	case 'F':
?>
	<td></td>
        <td align="center"><?php echo'<span title="'.$r_nvddt['fanio'].'">'.$r_nvddt['fanio'].'</span>';?></td>
	<td align="center"><?php echo'<span title="'.$r_nvddt['fmesn'].'">'.$r_nvddt['fmesn'].'</span>';?></td>
	<td align="center"><?php echo '<span title="'.$r_nvddt['fechadmy'].'">'.$r_nvddt['fdian'].'-'.$r_nvddt['fdia'].'</span>';?></a> </td>
	<td></td>

<?php	
	break;
	case 'Z':
?>
	<td></td>
        <td align="center"><?php echo'<span title="'.$r_nvddt['zsub'].'">'.$r_nvddt['zsub'].'</span>';?></td>
	<td align="left"><?php echo '<span title="'.$r_nvddt['zsub_descri'].'">'.$r_nvddt['zsub_descri'].'</span>';?></a> </td>
	<td align="left"></td>
	<td></td>

<?php	
	break;
	case 'R':
?>
	<td align="center"><?php echo '<span title="'.$r_nvddt['docu_descri'].'">'.$r_nvddt['docu'].'</span>';?></a> </td>
	<td align="center"><?php echo '<span title="'.$r_nvddt['ptonumero'].'">'.$r_nvddt['numero'].'</span>';?></a> </td>
	<td align="center"><?php echo'<span title="'.$r_nvddt['fechadmy'].'">'.$r_nvddt['fechadmy'].'</span>';?></td>
	<td align="left"><?php echo'<span title="'.$r_nvddt['nvdd'].'">'.$r_nvddt['nvdd_descri'].'</span>';?></td>
	<th></th>



<?php }?>



   	<td align="right"><?php echo number_format($r_nvddt['ttsubt'],2);?></td>


   	<td align="right"><?php echo number_format($r_nvddt['ttingreso'],2);?></td>
   	<td align="right"><?php echo number_format($r_nvddt['ttegreso'],2);?></td>
   	<td align="right"><?php echo number_format($r_nvddt['ttprovi1'],2);?></td>
   	<td align="right"><?php echo number_format($r_nvddt['ttprovi2'],2);?></td>
<!--    	
		<td align="right"><?php echo number_format($r_nvddt['ttotal'],2);?></td>

 -->


<?php
switch ($xfgrou)
{
	case 'D':
?>

        <td align="center"><?php echo'<span title="'.$r_nvddt['cdad_descri'].'">'.$r_nvddt['cdad_descri'].'</span>';?></td>
	<td align="center"><?php echo'<span title="'.$r_nvddt['vndd'].'">'.$r_nvddt['vndd'].'</span>';?></td>

<?php	
	break;
	case 'E':
?>

	<td align="center"><?php echo'<span title="'.$r_nvddt['enti_telefono'].'">'.$r_nvddt['prvc_descri'].' /'.$r_nvddt['cdad_descri'].'</span>';?></td>
	<td align="center"><?php echo'<span title="'.$r_nvddt['vndd'].'">'.$r_nvddt['vndd'].'</span>';?></td>

<?php	
	break;
	case 'I':
?>
	<td align="center"><?php echo'<span title="'.$r_nvddt['item_mrca'].'">'.$r_nvddt['item_mrca'].' /'.$r_nvddt['item_modelo'].'</span>';?></td>
	<td align="center"></td>
<?php }?>





</tr>
<?php }?>

<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">

<?php
switch ($xfgrou)
{
	case 'M':
?>
	<th></th>
	<th></th>
<?php
	break;
	case 'E':
?>
	<th></th>
	<th></th>
<?php
	break;
	case 'P':
?>
	<th></th>
	<th></th>
<?php
	break;
	case 'I':
?>
	<th></th>
	<th></th>
<?php
	break;
}
?>
	
	<th></th>
	<th>TOTALES</th>
	<th align="right"><?php echo number_format(mysql_result($res_nvddtt,0,'ttcant'),2);?></th>
	<th align="right"><?php echo number_format(mysql_result($res_nvddtt,0,'ttsubt'),2);?></th>
	
	<th align="right"><?php echo number_format(mysql_result($res_nvddtt,0,'ttingreso'),2);?></th>
	<th align="right"><?php echo number_format(mysql_result($res_nvddtt,0,'ttegreso'),2);?></th>
	<th align="right"><?php echo number_format(mysql_result($res_nvddtt,0,'ttprovi1'),2);?></th>
	<th align="right"><?php echo number_format(mysql_result($res_nvddtt,0,'ttprovi2'),2);?></th>

	<th align="right"><?php echo number_format(mysql_result($res_nvddtt,0,'ttotal'),2);?></th>
	
	
	

<tr>

</table>



</div>
<br>
<div id="nvddtot2"></div>

