<?php $__env->startSection('content'); ?>

<?php
$Group = Auth::user()->group_id;
?>

<div class="page-header" style="background-color: #6382a6;;">
  <div class="modulo"><img class="imagenmodulo1" src="dashboardimage/contract2.png">
  <img class="imagenmodulo2" src="dashboardimage/linea.png">&nbsp   PAGO DE CUOTAS</div>
</div>

<div class="toolbar-nav">
		<div class="row">
			<div class="col-sm-6" >
			<button type="button" class="btn btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="border-color:#f29f41;outline: none !important;box-shadow: none;"><i class="fa fa-bars"></i> Acciones </button>
			<ul class="dropdown-menu">
			<!--<li class="nav-item"><a href="#" onclick="getPDF();" class="nav-link "> Exportar a PDF </a></li>-->
			
			
			
			<?php if($Group==2): ?>
			<li class="nav-item"><a href="<?php echo e(url('registrodepagosmant')); ?>"  class="nav-link "> Salir </a></li>
			<?php else: ?>
			<li class="nav-item"><a href="<?php echo e(url('pagosmantenimientos')); ?>"  class="nav-link "> Salir </a></li>
			<?php endif; ?>
			</ul>
		
			</div>
			<div class="col-md-6 text-right pull-right" >
								
			</div>	
		</div>
	</div>	
<div class="p-3 canvas_div_pdf" style="background-color: white;">
<?php
include 'dbconnection.php';

// Perform queries
$Email = $_GET["Email"]; 
$ID = $_GET["id"]; 


$DB = mysqli_query($mysql,"SELECT dbname FROM tb_users WHERE email ='$Email'");
while($row = mysqli_fetch_array($DB)){
$dbname = $row ['dbname'];}
$hostname2 = "localhost";
$username2 = "tempdpe5_nicolas";
$password2 = "(Made7575)";
$conn = mysqli_connect($hostname2,$username2,$password2,$dbname);
if (mysqli_connect_errno()){
  printf("Connect failed: %s\n", mysqli_connect_error());
  exit();
} 
mysqli_set_charset($conn ,"utf8");


$x2 = mysqli_query($conn,"SELECT * FROM medicionesdetalle WHERE IDmantenimientopago2='$ID'");
while($row2 = mysqli_fetch_array($x2)){
 
$Nombre[] = $row2 ['Nombremedicion'];  
$Vanterior[] = $row2 ['Valoranterior'];   
$Vactual[] = $row2 ['Valoractual'];  
$Medida [] = $row2 ['Unidaddemedida'];
$Factor [] = $row2 ['Factor'];
$Precio [] = $row2 ['Precioactual'];
}

$x3 = mysqli_query($conn,"SELECT count(IDmantenimientopago2) AS num FROM medicionesdetalle  WHERE IDmantenimientopago2 ='$ID'");
while($row3 = mysqli_fetch_array($x3)){
$count = $row3['num'];  
}

if($count==0){ 
 echo"<img class='imagen4' src='dashboardimage/nodatos.png'>";   
}else{

echo"<div div style='text-align:center; font-size:13px;text-transform: uppercase; margin-bottom: -8px;' ><i class='fas fa-weight' style='color:#e3b10b'></i> Mediciones </div><br>";
										
echo"<table class='table table-bordered' style='table-layout:fixed;'>";
			echo"<thead>";
				echo"<tr style='background: #4b6080; color: #fff;text-align: center;font-size:11px;border: 1px solid #4b6080;'>";
					echo"<th class='align-middle' style='background: #4b6080;'    width='30'>Nom. </th>";
					echo"<th class='align-middle'  style='background: #4b6080;'    width='35'>Valor Ant.</th>";
					echo"<th class='align-middle'  style='background: #4b6080;'    width='35'>Valor Act.</th>";
					echo"<th class='align-middle'  style='background: #4b6080;'    width='10'>Und.</th>";
					echo"<th class='align-middle'  style='background: #4b6080;'    width='30'>Factor.</th>";
					echo"<th class='align-middle'   style='background: #4b6080;'   width='35'>Precio($)</th>";
				echo"</tr>";
			echo"</thead>";
			echo"<tbody>";

for ($i=0; $i <$count; $i++) {
echo"<tr style='text-align:center;word-wrap:break-word;' >";	    
echo"<td>$Nombre[$i]</td>";
echo"<td>$Vanterior[$i]</td>";
echo"<td>$Vactual[$i]</td>";
echo"<td>$Medida[$i]</td>";
echo"<td>$Factor[$i]</td>";
echo"<td>$Precio[$i]</td>";
echo"</tr>";
}

}
?>	 				

</div>


<script>
	function getPDF(){

		var HTML_Width = $(".canvas_div_pdf").width();
		var HTML_Height = $(".canvas_div_pdf").height();
		var top_left_margin = 15;
		var PDF_Width = HTML_Width+(top_left_margin*2);
		var PDF_Height = (PDF_Width*1.5)+(top_left_margin*2);
		var canvas_image_width = HTML_Width;
		var canvas_image_height = HTML_Height;
		
		var totalPDFPages = Math.ceil(HTML_Height/PDF_Height)-1;
		

		html2canvas($(".canvas_div_pdf")[0],{allowTaint:true}).then(function(canvas) {
			canvas.getContext('2d');
			
			console.log(canvas.height+"  "+canvas.width);
			
			
			var imgData = canvas.toDataURL("image/jpeg", 1.0);
			var pdf = new jsPDF('p', 'pt',  [PDF_Width, PDF_Height]);
		    pdf.addImage(imgData, 'JPG', top_left_margin, top_left_margin,canvas_image_width,canvas_image_height);
			
			
			for (var i = 1; i <= totalPDFPages; i++) { 
				pdf.addPage(PDF_Width, PDF_Height);
				pdf.addImage(imgData, 'JPG', top_left_margin, -(PDF_Height*i)+(top_left_margin*4),canvas_image_width,canvas_image_height);
			}
			
		    pdf.save("HTML-Document.pdf");
        });
	};    
    

</script>

<style>
 
@media (min-width: 100px) and (max-width: 370px) {

 .table td {
    border: #adadad solid 0.5px !important;
    font-size:7px;
} 

th {
  font-size:7px;  
}

 
}

@media (min-width: 370px) and (max-width: 500px){

 .table td {
    border: #adadad solid 0.5px !important;
    font-size:9px;
} 

th {
  font-size:9px;  
}

 
}

@media (min-width: 500px){

 .table td {
    border: #adadad solid 0.5px !important;
    font-size:12px;
} 

th {
  font-size:12px;  
}
 
}


.imagen4 {
    
display: block;
  margin-left: auto;
  margin-right: auto;
  width: 50%;    
    
    
}



   
</style>
		
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/tempdpe5/public_html/intelpropertyrd/aplicacionmobile/resources/views/mediciones/index.blade.php ENDPATH**/ ?>