<?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>-->
			<li class="nav-item"><a href="#"  onclick="generatePDF()" class="nav-link "> Enviar por Email </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" id="reporte" style="background-color: white;">
<div style="border: 1px solid #9e9e9e;border-radius: 15px;">
<div style="margin:20px">
<?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");


$x = mysqli_query($conn,"SELECT * FROM mantenimientopago WHERE ID ='$ID'");
while($row1 = mysqli_fetch_array($x)){
$Nombres[] = $row1 ['Nombres'];
$Apellidos[] = $row1 ['Apellidos'];  
$Residencia[] = $row1 ['Residencia'];  
$Condominio[] = $row1 ['Condominio']; 
$Mes[] = $row1 ['Mes']; 
$Ano[] = $row1 ['Ano'];
$Email2[] = $row1 ['email'];
$Total[] = number_format($row1 ['InvTotal'],2);  
$Descuento[] = number_format($row1 ['InvDiscount'],2);
$Nota[] = $row1 ['Nota'];
$Pagostatus[] = $row1 ['Pagostatus'];
}

$Mesano = $Mes[0].' - '.$Ano[0];
$Email3 = $Email2[0];
$Condominio2 = $Condominio[0];

if($Pagostatus[0]=='Pagado'){

echo"<div style='text-align:right;margin:-5px;'><img class='imagen' style='width: 17%;margin-bottom:-30px;' src='dashboardimage/pagado.png'></div>";

}
?>
<div style="font-weight: 900; font-size: 14px;display: inline;" > No: <?php echo $ID; ?></div>
<h4 style="text-transform: uppercase;text-align:center;margin-bottom:-35px;margin-top:15px;font-weight: 900;">Cuota de Mantenimiento</h4><br><br>
<div style="text-align:center; font-size:13px;text-transform: uppercase;"><i class="fa fa-user" style="color:#e3b10b"></i> Información del Residente :</div><br> 

   
			<div  class="col-md-12 col-sm-12 text-center" >
					
					<div id="info">
					<b>Nombres : </b><?php echo $Nombres[0]; ?> | <b>Apellidos : </b><?php echo $Apellidos[0]; ?><br/> 
				  	<b>Residencia : </b> <?php echo $Residencia[0]; ?> | <b>Condominio : </b> <?php echo $Condominio[0] ; ?><br/> 
				  	<b>Mes : </b> <?php echo $Mes[0]; ?> | <b>Año : </b> <?php echo $Ano[0]; ?> 
				  	</div>							
			 </div>



<table class="table table-bordered " style="margin-top:15px;table-layout: fixed;">
			<thead>
				<tr style="background: #4b6080; color: #fff;text-align: center;font-size:12px;border: 1px solid #477ead;">
					<th class="align-middle" style="background: #4b6080;"   width="65" >Concepto a Facturar </th>
					<th class="align-middle" style="background: #4b6080;"  width="35" >Cant. </th>
					<th class="align-middle"  style="background: #4b6080;"    width="70" >Total por Unidad </th>
					<th class="align-middle"  style="background: #4b6080;"    width="70" >Total</th>
				</tr>
			</thead>
			<tbody>
				
<?php
$x2 = mysqli_query($conn,"SELECT * FROM mantenimientopagodetalle WHERE InvID ='$ID'");
while($row2 = mysqli_fetch_array($x2)){
 
$Items[] = $row2 ['Items'];  
$Qty[] = $row2 ['Qty'];   
$Amount[] = number_format($row2 ['Amount'],2);  
$Total2[] = number_format(($row2 ['Amount']*$row2['Qty']),2);
}

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

for ($i=0; $i <$count[0]; $i++) {
echo"<tr style='text-align:center;word-wrap:break-word;'>"; 
echo"<td>$Items[$i]</td>";
echo"<td>$Qty[$i]</td>";
echo"<td>$ $Amount[$i]</td>";
echo"<td>$ $Total2[$i]</td>";
echo"</tr>";
}

?>	 				

								
				<tr>
					<td colspan="3" style="text-align:right;font-weight: 500"> Descuento </td>
					<td style="text-align:center;" ><?php echo" $ $Descuento[0]"; ?> </td>				
				</tr>
				
				<tr>
					<td colspan="3" style="text-align:right;text-transform: uppercase;font-size:12px;"> <b> Total a Pagar </b> </td>	
					<td style="font-weight: 900; text-align:center;font-size:12px;"><?php echo" $ $Total[0]";?>  </td>				
				</tr>								
			</tbody>
		
        </table>
        <table class="table table-bordered center" style="margin-top:15px;table-layout: fixed;text-align:center;">
       	 <tr >
	           <th  colspan="4" style="background-color: #4b6080;color:white;text-align: left;">&nbsp Nota</th>
		       </tr>
               <tr>
		       <td colspan="4" style="text-align: justify;"><b> </b><?php echo $Nota[0]; ?> <br /></td>
		       </tr> 
		 </table>     
       	
        </div>	
			

</div>
</div>
</div>

<div>
<!-- Modal -->
  <div class="modal fade p-5 " id="myModal" role="dialog" style="margin-top:-60px;">
    <div class="modal-dialog modal-dialog-centered">
    
      <!-- Modal content-->
      <div class="modal-content modal-sm text-center" >
       
        <div class="modal-body">
        	<img src="sximo5/images/send2.png" style="width: 40%;" />
          <H5>Proceso de Env&iacute;o Completado !</H5>
          <button type="button" class="btn btn-default" data-dismiss="modal" style="border-color: #f29f41;margin-bottom: -1px;margin-top: 5px;font-size:13px;">Cerrar</button>
        </div>
        
      </div>
      
    </div>
  </div>
<!-- Modal -->
</div>

<script type="text/javascript" src="<?php echo e(asset('sximo5/js/jquery.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('html2pdf.bundle.min.js')); ?>"></script>

<script>
function generatePDF() {
 
 var email = '<?=$Email3?>';
    console.log(email); 
    
  var condominio = '<?=$Condominio2?>';
    console.log(condominio);  
    
  var mesano = '<?=$Mesano?>';
    console.log(mesano);   
 
 $("#myModal").modal('show');

let el = document.getElementById('reporte');
let opt = {
    margin:       [0.6, 0.9, 1, -1.7],
              filename:     'Cuota.pdf',
              image:        { type: 'jpeg', quality: 0.98 },
              html2canvas:  { scale: 2,width: 1250,windowWidth: 1024 },
              jsPDF:        { unit: 'in', format: 'letter', orientation: 'portrait' }
                                       };
html2pdf().set( opt ).from( el ).toPdf().output('datauristring').then(function( pdfAsString ) {
   
   // $("#myModal").modal('hide');
    
    let data = {'fileDataURI': pdfAsString, 'Email':email, 'Condominio':condominio, 'Mesano':mesano};
    $.post( "mailcuota.php", data);
    console.log( data );
} );
};

</script>

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

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

th {
  font-size:10px;
  
}
 #info {
   font-size:8px;    
     
 }
p {
  font-size:9px;  
} 
 
}

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

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

th {
  font-size:11px;
  
}
 #info {
   font-size:10px;    
     
 }
 
 p {
  font-size:10px;  
} 
 
}

@media (min-width: 500px){

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

th {
  font-size:12px;  
}
 #info {
   font-size:12px;    
     
 }
 
 p {
  font-size:12px;  
} 
}


</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/cuota/index.blade.php ENDPATH**/ ?>