<?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());

  


 ?>

		<!-- <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> REGISTRO DE LLAMADAS MES <?php echo strtoupper($monthName); ?>
						</p>
					</td>
					
	        	</tr>
   		 	</table>
		</div>	
		
	
		<div  class="productos">
			<table style="border: solid 1px #050505 ">
				<tr class="cabecera" style="width: 100%; text-align: center;font-size:16px;font-weight:bold ">
		            <td style="width:20%";text-align:center">USUARIO</td>
		            <td style="text-align: center;">FECHA REGISTRO</td>	          
		            <td style="text-align: center;">CONTRATO</td>
		            <td style="text-align: center;">CLIENTE</td>
		            <td style="text-align: center;">SERVICIO</td>
		            <td style="text-align: center;">TECNOLOGIA</td>
		            <td style="text-align: center;">DESCRIPCION</td>
            
        		</tr>
                 <?php 
               
                  $query = "SELECT date(m.fecha_insert)as fecha,s.name,u.nombre,v.servicio,m.idusuario FROM `movimientollamada` m left join venta v on m.idventa=v.idventa left join usuario u on m.idusuario=u.idusuario left join users s on v.user_id=s.id where year(m.fecha_insert)='$anio' and month(m.fecha_insert)='$mes' and m.tipo='4' group by u.nombre";
                  $adicional = mysqli_query($conexion,$query);
                  while ($row = mysqli_fetch_array($adicional)){

                    $nombre=$row['nombre'];
                    $idusu=$row['idusuario'];
                  ?>


        	 <tr style="font-size:14px; text-align:center; background-color:#CCCCCC"> 
                 <td style="text-align:center; width:20%"><?php echo "$nombre"; ?></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>


                  <?php
           
 
              $query = "SELECT m.idmov,date(m.fecha_insert)as fecha,s.name,m.nrocontrato,t.tecnologia,m.descripcion,u.nombre,v.servicio,m.idusuario FROM `movimientollamada` m left join venta v on m.idventa=v.idventa left join usuario u on m.idusuario=u.idusuario left join users s on v.user_id=s.id LEFT join tb_tecnologia t on v.tecnologia=t.id where year(m.fecha_insert)='$anio' and month(m.fecha_insert)='$mes' and m.tipo='4' and m.idusuario='$idusu' order by m.idmov desc ";
                  $adicional3 = mysqli_query($conexion,$query);
               $cont=0;
               while ($row5 = mysqli_fetch_array($adicional3)){
                   
               if($row['servicio']==1){
                $servicio='Internet';
               }else{
               $servicio='Cable TV';
               }

              $fecha =$row5['fecha']; 
              $nro = $row5['nrocontrato'];
              $cliente = $row5['name'];
              $tecnologia = $row5['tecnologia'];
              $des = $row5['descripcion'];
              

    ?>
        			
           <tr style="font-size:14px; text-align:center;border: solid 0.3px #050505"> 
           <td style="border: solid 0.3px #050505"></td>
           <td style="border: solid 0.3px #050505"><?php echo "$fecha"; ?> </td>
           <td style="border: solid 0.3px #050505"><?php echo "$nro"; ?> </td>
           <td style="border: solid 0.3px #050505"><?php echo "$cliente"; ?></td>
           <td style="border: solid 0.3px #050505"><?php echo "$servicio"; ?></td>
           <td style="border: solid 0.3px #050505"><?php echo "$tecnologia"; ?></td>
           <td style="border: solid 0.3px #050505"><?php echo "$des"; ?></td>
           </tr>

            <?php
       $cont++;
        }
        
  
       ?>
      <tr style="font-size:16px; text-align:center;background-color:#fa2041;color:white"> 
       <th colspan="5"></th>
       <th style="font-size:16px; text-align:right">TOTAL:</th>
      <th><?php echo $cont; ?></th>
      </tr>
<?php 


}
?>
        	
        		</table>

      

	
</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));

?>