<?php 
ob_start();
include("../conexion/conexion.php");
  ?>


  <html lang="es">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Inntel Peru - Panel</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel= "stylesheet" type= "text/css" href= "http://fonts.googleapis.com/css?family=Roboto">  
    


	
	<title>Formulario Contacto</title>
	<style type="text/css">
		 table {color:black; 
		 border: none;
            width: 100%;}
		

		 .header{
		 	/*display: inline-block;*/
		 	padding-left: 20px; 
		 	padding-right: 20px; 

		 	
		 }
		 .text{
		 	padding-left: 40px; 
		 	padding-right: 40px;
		 	/*padding-bottom: : 10px;*/
		 	text-align:justify-all;
			line-height: 120%;
		 }
		  .text1{
		 	padding-left: 40px; 
		 	padding-right: 40px;
		 	padding-bottom: : 10px;
		 	text-align:justify-all;
			line-height: 130%;
		 }
		 .text2{
		 	padding-left: 50px; 
		 	padding-right: 40px;
		 	padding-bottom: : 10px;
		 	text-align:justify-all;
			line-height: 170%;
		 }
		 .info{
		 	width: 30%; 
		 	color: #34495e;
		 	font-size:12px;
		 	text-align:justify-all;
		 }
		 .factura{
		 	color: red;
		 	width: 28%;
		 	height:10px;
		 	border: 1px solid red;
		 	text-align: center;
		 }
		 .linea{
		 	padding-left: 10px; 
		 	padding-right: 10px; 

		 }
		 .cliente{
		 	padding-left: 40px; 
		 	padding-right: 40px;

		 }
		 .articulos{
		 	padding-left: 40px; 
		 	padding-right: 40px;
		 	font-size:11px;
		 }
		 .cabecera{
			background:#38c011;
			color:white;
			font-size:12px;
			padding-left: 20px; 
		 	padding-right: 20px;
		 	border: 1px solid #087DA2;
		 }
		 .foot{
		 	padding-left: 20px; 
		 	padding-right: 20px;
		 	font-size: 8pt;


		 }
		  .productos{
		 	font-size:12px;
		 	border-collapse: collapse;
    		        padding-left: 20px; 
		 	padding-right: 20px;	 	
		 }	
		 .silver{
			background:white;
			padding: 3px 4px 3px;
		}
		.clouds{
			background:#ecf0f1;
			padding: 3px 4px 3px;
		}
		/*#encabezado {padding:10px 0; border-top: 1px solid; border-bottom: 1px solid; width:100%;}*/
		#encabezado .fila #col_1 {width: 15%}
		#encabezado .fila #col_2 {text-align:center; width: 55%}
		#encabezado .fila #col_3 {width: 15%}
		#encabezado .fila #col_4 {width: 15%}
		 
		#encabezado .fila td img {width:50%}
		#encabezado .fila #col_2 #span1{font-size: 15px;}
		#encabezado .fila #col_2 #span2{font-size: 12px; color: #4d9;}
		 .column {
            float: left;
            width: 50%;
            padding: 1px;
            box-sizing: border-box;
        }
	</style>
</head>
<body>
<?php 
    setlocale(LC_ALL, 'spanish');

     
      $anio=$_GET['anio'];
      $mes=$_GET['mes'];

      $dateObj   = DateTime::createFromFormat('!m', $mes);
      $monthName = strftime('%B', $dateObj->getTimestamp());

      $totalutilidad=0.00;
      $totalefectivo=0.00;
      $totaldeposito=0.00;
      $query = "SELECT sum(monto)as ingreso FROM `tb_ingreso` where YEAR(fechahora)='$anio' and month(fechahora)='$mes'";  
      $result = mysqli_query($conexion, $query);
      $row = mysqli_fetch_array($result);
      $ingreso=$row['ingreso'];  
     
      $query = "SELECT sum(monto)as egreso FROM `tb_egreso` where YEAR(pago)='$anio' and month(pago)='$mes'";  
      $result = mysqli_query($conexion, $query);
      $row = mysqli_fetch_array($result);
      $egreso=$row['egreso'];
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////
      $totalutilidad=$ingreso-$egreso;
      //////////////////////////////////////////////////////////////////////////////////////////////////////////////
      $query = "SELECT sum(monto)as efectivoi FROM `tb_ingreso` where YEAR(fechahora)='$anio' and month(fechahora)='$mes' and tipoingreso='2'";  
      $result = mysqli_query($conexion, $query);
      $row = mysqli_fetch_array($result);
      $efectivoi=$row['efectivoi'];

      $query = "SELECT sum(monto)as depositoi FROM `tb_ingreso` where YEAR(fechahora)='$anio' and month(fechahora)='$mes' and tipoingreso='3'";  
      $result = mysqli_query($conexion, $query);
      $row = mysqli_fetch_array($result);
      $depositoi=$row['depositoi'];

      $query = "SELECT sum(monto)as efectivoe FROM `tb_egreso` where YEAR(pago)='$anio' and month(pago)='$mes' and tipopago='2'";  
      $result = mysqli_query($conexion, $query);
      $row = mysqli_fetch_array($result);
      $efectivoe=$row['efectivoe'];

      $query = "SELECT sum(monto)as depositoe FROM `tb_egreso` where YEAR(pago)='$anio' and month(pago)='$mes' and tipopago='3'";  
      $result = mysqli_query($conexion, $query);
      $row = mysqli_fetch_array($result);
      $depositoe=$row['depositoe'];

      $totalefectivo=$efectivoi-$efectivoe;
      $totaldeposito=$depositoi-$depositoe;

         //////////////////////////////////////////////////////////////////////////////////////////////////////////////
      $query = "SELECT b.nombrebanco,sum(i.monto)as monto FROM `tb_ingreso` i join tb_banco b on i.banco=b.id where YEAR(i.fechahora)='$anio' and month(i.fechahora)='$mes' and i.tipoingreso='3' GROUP by b.nombrebanco";  
      $resultingresod = mysqli_query($conexion, $query);
      
      $query = "SELECT u.nombre,sum(i.monto)as monto FROM `tb_ingreso` i join usuario u on i.idresponsable=u.idusuario where YEAR(i.fechahora)='$anio' and month(i.fechahora)='$mes' and i.tipoingreso='2' and i.monto>0 GROUP by u.nombre";  
      $resultingresoi = mysqli_query($conexion, $query);
         //////////////////////////////////////////////////////////////////////////////////////////////////////////////
      $query = "SELECT sum(i.monto)as monto,count(i.idventa)as nroclientea,v.plan,p.planes FROM `tb_ingreso` i LEFT JOIN venta v on i.idventa=v.idventa JOIN tb_planes p on v.plan=p.id where YEAR(i.fechahora)='$anio' and month(i.fechahora)='$mes' and i.tiposervicio='14' and i.tipotrabajo='37' GROUP by p.planes";  
      $fibracont = mysqli_query($conexion, $query);

      $query = "SELECT sum(i.monto)as monto,count(i.idventa)as nroclientea,v.plan,p.planes FROM `tb_ingreso` i LEFT JOIN venta v on i.idventa=v.idventa JOIN tb_planes p on v.plan=p.id where YEAR(i.fechahora)='$anio' and month(i.fechahora)='$mes' and i.tiposervicio='14' and i.tipotrabajo='38' GROUP by p.planes";  
      $wificont = mysqli_query($conexion, $query);

       $query = "SELECT sum(i.monto)as monto,count(i.idventa)as nroclientea,v.plan,p.planes FROM `tb_ingreso` i LEFT JOIN venta v on i.idventa=v.idventa JOIN tb_planes p on v.plan=p.id where YEAR(i.fechahora)='$anio' and month(i.fechahora)='$mes' and i.tiposervicio='14' and i.tipotrabajo='40' GROUP by p.planes";  
      $cablecont = mysqli_query($conexion, $query);

      $query = "SELECT c.nombre,e.tipotrabajo,sum(i.monto)as monto,count(i.cliente)as nroclientea FROM `tb_ingreso` i left join categoriaingreso c on i.tiposervicio=c.idingreso LEFT join conceptoingreso e on i.tipotrabajo=e.idingreso where YEAR(i.fechahora)='$anio' and month(i.fechahora)='$mes' and i.tiposervicio!='14' and i.monto>0 GROUP by e.tipotrabajo";  
      $sercont = mysqli_query($conexion, $query);

      //////////////////////////////////////////////////////////////////////////////////////////
      $query = "SELECT u.nombre,sum(i.monto)as monto FROM `tb_ingreso` i join usuario u on i.idresponsable=u.idusuario where YEAR(i.fechahora)='$anio' and month(i.fechahora)='$mes' GROUP by u.nombre";  
      $contcaja = mysqli_query($conexion, $query);

 $query = "SELECT e.id,u.nombre,sum(e.monto)as monto FROM `tb_egreso` e left join usuario u on e.idresponsable=u.idusuario where YEAR(e.pago)='$anio' and month(e.pago)='$mes' GROUP by u.nombre";  
      $contegreso = mysqli_query($conexion, $query);


 ?>

		<!-- <page backtop="7mm" backbottom="7mm" backleft="10mm" backright="10mm"> -->
		    <page_header>
		        <table id="encabezado">
		            <tr class="fila">
		                <td id="col_1" style="width: 96%" >
		                   <!--  <img style="width: 760px;height: 80px;" src=""> -->
		                </td>
		            </tr>
		        </table>
		    </page_header>
    	 
		 <div class="header">
			 <table style="width: 100%;">
	        	<tr>
		            <td colspan="" style="text-align:center;width: 27%" >
		             </td>
					<td style="width:60%">
						<p> REPORTE DE FINANZAS MES <?php echo strtoupper($monthName); ?>
						</p>
					</td>
					
	        	</tr>
   		 	</table>
		</div>	
		
		<P class="text1"><b>UTILIDAD:</b></p>
		<div  class="productos">
			<table style="border: solid 1px #050505 ">
				<tr class="cabecera" style="width: 100%; text-align: center ; ">
		            <th style="width: 50%; text-align:center">CONCEPTO</th>
		            <th style="width: 50%; text-align: center;">MONTO</th>	          
            
        		</tr>
        	       <tr style="text-align:center">
        			      <td  style="width: 5%;border: solid 0.3px #050505  ">Ingreso</td>
        				<td  style="text-align:center; width: 60%;border: solid 0.3px #050505 ">S/<?php echo number_format($ingreso,2); ?></td>        				
        			</tr>
        			<tr style="border: solid 0.3px #38c011; text-align:center">
        			    <td  style="width: 5%;border: solid 0.3px #050505 ">Egreso</td>
        				<td  style="text-align:center; width: 60%; border: solid 0.3px #050505 ">S/<?php echo number_format($egreso,2); ?></td>        				
        			</tr>
        			<tr style="border: solid 0.3px #087DA2; text-align:center">
        			    <td  style="width: 5%;background:#241e1f;color:white;font-size:9;font-weight:bold">Total</td>
        			    <td  style="text-align:center; width: 60%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($totalutilidad,2); ?></td>        				
        			</tr>

        	
        		</table>

      
      
          	<P class="text1"><b>Efectivo:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Deposito:</b></p>
          <div class="column">
        	<div class="table-responsive">        			
			<table style="border: solid 1px #050505 "  >
				
				<tr style="width: 50%;background:#38c011;color:white; text-align: left; border="1">
				 <td style="text-align: center; width:20%">Concepto</td>
		            <td style="text-align: center; width:20%">Monto</td>
		                      
        		</tr>
        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505 ">Ingreso (E)</td>
					<td style="width:20%;border: solid 0.3px #050505 ">S/<?php echo number_format($efectivoi,2); ?></td>									
				</tr>
				<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505 ">Egreso (E)</td>
					<td style="width:20%;border: solid 0.3px #050505 ">S/<?php echo number_format($efectivoe,2); ?></td>									
				</tr>					
				<tr style="width: 80%; text-align: center;">
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Saldo (E)</td>
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($totalefectivo,2); ?></td>								
				</tr>
			</table>
		</div>
	</div>

		<div class="column">
		
			<div class="table-responsive">				
			<table style="border: solid 1px #050505 " >
				
				<tr style="width: 50%; background:#38c011;color:white;text-align: left; border="0.2">
				 <td style="text-align: center; width:20%">Concepto</td>
		            <td style="text-align: center; width:20%">Monto</td>
		                      
        		</tr>
        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505 ">Ingreso (D)</td>
					<td style="width:20%;border: solid 0.3px #050505 ">S/<?php echo number_format($depositoi,2); ?></td>									
				</tr>	
				<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505 ">Egreso (D)</td>
					<td style="width:20%;border: solid 0.3px #050505 ">S/<?php echo number_format($depositoe,2); ?></td>									
				</tr>					
				<tr style="width: 80%; text-align: center;">
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Saldo (D)</td>
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($totaldeposito,2); ?></td>								
				</tr>
			</table>
		</div>
	</div>
</div>

						
	
<br>
 
 <P class="text"><b>INGRESO:</b></p>  
  <P class="text"><b>Deposito:</b></p> 
    <div  class="productos">
     		
          <div class="column">
        	<div class="table-responsive">        			
			<table style="border: solid 1px #050505 "  >
				
				<tr style="width: 50%;background:#38c011;color:white; text-align: left; border="0.2">
				 <td style="text-align: center; width:20%">Bancos</td>
		            <td style="text-align: center; width:20%">Monto</td>		                     
        		</tr>
        		<?php
        		$sumbanco=0.00; 
        		while($res = mysqli_fetch_array($resultingresod)){
        			 
        			 $sumbanco=$sumbanco+$res['monto'];	
        			?>        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $res['nombrebanco'] ?></td>
					<td style="width:20%;border: solid 0.3px #050505">S/<?php echo number_format($res['monto'],2); ?></td>									
				</tr>
				

					<?php } ?>	
					<tr style="width: 80%; text-align: center;">
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Total Deposito</td>
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($sumbanco,2); ?></td>									
				</tr>				
			</table>
		</div>
	</div>

		<div class="column">		
			<div class="table-responsive">				
			<table style="border: solid 1px #050505 " >
				
				<tr style="width: 50%; background:#38c011;color:white;text-align: left; border="0.2">
				 <td style="text-align: center; width:20%">Cajas</td>
		            <td style="text-align: center; width:20%">Monto</td>
		                      
        		</tr>
        		<?php 
        		$sumcaja=0.00;
        		while($ress = mysqli_fetch_array($resultingresoi)){
        			$sumcaja=$sumcaja+$ress['monto'];	       			
        			?>        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $ress['nombre'] ?></td>
					<td style="width:20%;border: solid 0.3px #050505">S/<?php echo number_format($ress['monto'],2); ?></td>									
				</tr>
					<?php } ?>	
					<tr style="width: 80%; text-align: center;">
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Total Efectivo</td>
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($sumcaja,2); ?></td>									
				</tr>				
			</table>
		</div>
	</div>
</div>

<br><br><br><br><br><br><br><br><br><br>
<br>
<div  class="productos">
          
        	<div class="table-responsive">        			
			<table style="border: solid 1px #fa2041 "   >
				<tr style="width: 50%; background:#fa2041;color:white;text-align: left;">
				 <td style="text-align: center; width:20%;font-size:11;font-weight:bold">Ingreso Total del Mes S/<?php echo number_format($sumbanco+$sumcaja,2); ?></td>
		           
		                      
        		</tr>
			</table>
		
	</div>
</div>
	
<br><br>
       <P class="text"><b>INGRESO (*)</b></p>
       <div  class="productos">
	<P class="text1"><b>Servicio Internet:</b></p>
		<P class="text2"><b>Tecnologia Fibra:</b></p>
           <div class="table-responsive">				
			<table style="border: solid 1px #050505 " >
				
				<tr style="width: 50%; background:#38c011;color:white;text-align: left; border="0.2">
				 <td style="text-align: center; width:20%">Planes</td>
		            <td style="text-align: center; width:20%">Nro Clientes</td>
		            <td style="text-align: center; width:20%">Total</td>
		        </tr>
		        <?php 
        		$sumfi=0.00;
        		$nrofi=0.00;
        		while($fib = mysqli_fetch_array($fibracont)){
        			$sumfi=$sumfi+$fib['monto'];	       			
        			$nrofi=$nrofi+$fib['nroclientea'];
        			?>        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $fib['planes'] ?></td>
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $fib['nroclientea']; ?></td>									
					<td style="width:20%;border: solid 0.3px #050505">S/<?php echo number_format($fib['monto'],2); ?></td>
				</tr>
					<?php } ?>	
					<tr style="width: 80%; text-align: center;">
						<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Total Fibra</td>
					<td  style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold"><?php echo $nrofi;?></td>
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($sumfi,2); ?></td>	
        	</table>

        </div>
        <P class="text2"><b>Tecnologia Wifi:</b></p>
           <div class="table-responsive">				
			<table style="border: solid 1px #050505 " >
				
				<tr style="width: 50%; background:#38c011;color:white;text-align: left; border="0.2">
				 <td style="text-align: center; width:20%">Planes</td>
		            <td style="text-align: center; width:20%">Nro Clientes</td>
		            <td style="text-align: center; width:20%">Total</td>		                      
        		</tr>
        		<?php 
        		$sumwi=0.00;
        		$nrowi=0.00;
        		while($wif = mysqli_fetch_array($wificont)){
        			$sumwi=$sumwi+$wif['monto'];	       			
        			$nrowi=$nrowi+$wif['nroclientea'];
        			?>        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $wif['planes'] ?></td>
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $wif['nroclientea']; ?></td>									
					<td style="width:20%;border: solid 0.3px #050505">S/<?php echo number_format($wif['monto'],2); ?></td>
				</tr>
					<?php } ?>	
					<tr style="width: 80%; text-align: center;">
						<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Total Wifi</td>
					<td  style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold"><?php echo $nrowi;?></td>
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($sumwi,2); ?></td>
        	</table>
        </div>


     <P class="text1"><b>Servicio Tv Cable:</b></p>
     	<P class="text2"><b>Tecnologia Satelital:</b></p>
     	 <div class="table-responsive">				
			<table style="border: solid 1px #050505 ">
				
				<tr style="width: 50%; background:#38c011;color:white;text-align: left; border="0.2">
				 <td style="text-align: center; width:20%">Planes</td>
		            <td style="text-align: center; width:20%">Nro Clientes</td>
		            <td style="text-align: center; width:20%">Total</td>		                      
        		</tr>
                <?php 
        		$sumca=0.00;
        		$nroca=0.00;
        		while($cab = mysqli_fetch_array($cablecont)){
        			$sumca=$sumca+$cab['monto'];	       			
        			$nroca=$nroca+$cab['nroclientea'];
        			?>        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $cab['planes'] ?></td>
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $cab['nroclientea']; ?></td>									
					<td style="width:20%;border: solid 0.3px #050505">S/<?php echo number_format($cab['monto'],2); ?></td>
				</tr>
					<?php } ?>	
					<tr style="width: 80%; text-align: center;">
						<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Total Cable Satelital</td>
					<td  style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold"><?php echo $nroca;?></td>
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($sumca,2); ?></td>

        	</table>
        </div>


	</div>

	<P class="text1"><b>Otros Servicios:</b></p>
     <div  class="productos">  
     	 <div class="table-responsive">				
			<table style="border: solid 1px #050505 " >
				
				<tr style="width: 50%; background:#38c011;color:white;text-align: left; border="0.2">
				 <td style="text-align: center; width:20%">Serivicios</td>
		            <td style="text-align: center; width:20%">Nro Clientes</td>
		            <td style="text-align: center; width:20%">Total</td>		                      
        		</tr>
                <?php 
        		$sumser=0.00;
        		$nroser=0.00;
        		while($ser = mysqli_fetch_array($sercont)){
        			$sumser=$sumser+$ser['monto'];	       			
        			$nroser=$nroser+$ser['nroclientea'];
        			?>        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $ser['tipotrabajo'] ?></td>
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $ser['nroclientea']; ?></td>									
					<td style="width:20%;border: solid 0.3px #050505">S/<?php echo number_format($ser['monto'],2); ?></td>
				</tr>
					<?php } ?>	
					<tr style="width: 80%; text-align: center;">
						<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Total Otro Servicios</td>
					<td  style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold"><?php echo $nroser;?></td>
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($sumser,2); ?></td>
</tr>
        	</table>
        </div>

</div>
	</div>

      <div  class="productos">          
        	<div class="table-responsive">        			
			<table style="border: solid 1px #fa2041 "   >
				<tr style="width: 50%; background:#fa2041;color:white;text-align: left;">
					<td style="text-align: center; width:20%;font-size:11;font-weight:bold"></td>
					<td style="text-align: center; width:20%;font-size:11;font-weight:bold">Total de Servicios</td>
				 <td style="text-align: center; width:20%;font-size:11;font-weight:bold"> S/<?php echo number_format($sumfi+$sumwi+$sumca+$sumser,2); ?></td>
		           
		                      
        		</tr>
			</table>
		
	  </div> 
   </div>


<P class="text1"><b>Ingreso Total:</b></p>
     <div  class="productos">  
     	 <div class="table-responsive">				
			<table style="border: solid 1px #050505 " >
				
				<tr style="width: 50%; background:#38c011;color:white;text-align: left; border="0.2">
				 <td style="text-align: center; width:20%">Nombres / Cajas</td>		           
		            <td style="text-align: center; width:20%">Total</td>		                      
        		</tr>
                <?php 
        		$sumcaj=0.00;        		
        		while($caj = mysqli_fetch_array($contcaja)){
        			$sumcaj=$sumcaj+$caj['monto'];	       			
        		?>        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $caj['nombre'] ?></td>													
					<td style="width:20%;border: solid 0.3px #050505">S/<?php echo number_format($caj['monto'],2); ?></td>
				</tr>
					<?php } ?>	
					<tr style="width: 80%; text-align: center;">
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Ingreso Total</td>					
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($sumcaj,2); ?></td>
                   </tr>
        	</table>
        </div>

</div>
<P class="text1"><b>Egreso Total:</b></p>
     <div  class="productos">  
     	 <div class="table-responsive">				
			<table style="border: solid 1px #050505 " >
				
				<tr style="width: 50%; background:#38c011;color:white;text-align: left; border="0.2">
				 <td style="text-align: center; width:20%">Nombres / Cajas</td>		           
		            <td style="text-align: center; width:20%">Total</td>		                      
        		</tr>
                <?php 
        		$sumegre=0.00;        		
        		while($egre = mysqli_fetch_array($contegreso)){
        			$sumegre=$sumegre+$egre['monto'];	       			
        		?>        		
        		<tr style="width: 80%; text-align: center;">
					<td style="width:20%;border: solid 0.3px #050505"><?php echo $egre['nombre'] ?></td>													
					<td style="width:20%;border: solid 0.3px #050505">S/<?php echo number_format($egre['monto'],2); ?></td>
				</tr>
					<?php } ?>	
					<tr style="width: 80%; text-align: center;">
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">Egreso Total</td>					
					<td style="width:20%;background:#241e1f;color:white;font-size:9;font-weight:bold">S/<?php echo number_format($sumegre,2); ?></td>
                   </tr>
        	</table>
        </div>
</div>

    <div  class="productos">  
     	 <div class="table-responsive">				
			<table style="border: solid 1px #fa2041 " >				
				<tr style="width: 50%; background:#fa2041;color:white;text-align: left; border="0.2">
				 <td style="text-align: center; width:20%;font-size:11;font-weight:bold">Saldo Final</td>		           
		            <td style="text-align: center; width:20%;font-size:11;font-weight:bold">S/<?php echo number_format($sumcaj-$sumegre,2) ?></td>		                      
        		</tr>
              
        	</table>
        </div>

</div>



 	 <page_footer>
		        <table id="">
		            <tr class="">
		                <td style="">
		                    <!-- <img style="width: 760px;height: 140px;" src=""> -->
		                    <!-- 240 -->
		                </td>
		            </tr>
		        </table>
    	</page_footer>
			
</body>
</html>



<?php 
$html=ob_get_clean();


require_once '../reportes/libreria/dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf();

$options = $dompdf->getOptions();
$options->set(array('isRemoteEnabled' => true));
$dompdf->setOptions($options);

$dompdf->loadHtml($html);

$dompdf->setPaper('letter');
$dompdf->setPaper('A4','landscape');
//$dompdf->set

$dompdf->render();
$dompdf->stream("reportefinanzas.pdf",array('Attachment' => false));

?>