<?php $__env->startSection('content'); ?>
<?php
$Group = Auth::user()->group_id;
?>
<!--<div class="page-header"><h2><?php echo e($pageTitle); ?> <small> <?php echo e($pageNote); ?> </small> </h2></div>-->
<div class="p-2" style="background-color:white">
<div style="margin-bottom:30px;">
      <div class="col-lg-12 col-md-12"><button style="border: none;background: none;float: right;margin-bottom:-40px;margin-top:10px;margin-right:-11px;" onclick="generatePDF();"><img class="imagen" src="dashboardimage/sendreport.png" style="width:30%; float: right;"></button></div>
      
      
    <?php if($Group =='2'): ?>
    <div class="col-lg-12 col-md-12"><button style="border: none;background: none;float: left;margin-bottom:-40px;margin-top:10px;margin-left:-11px;" onclick="location.href='<?php echo e(url('gestioncomunicacion')); ?>'"><img class="imagen" src="dashboardimage/salir.png" style="width:40%; float: left;"></button></div>
    <?php else: ?>
     <div class="col-lg-12 col-md-12"><button style="border: none;background: none;float: left;margin-bottom:-40px;margin-top:10px;margin-left:-11px;" onclick="location.href='<?php echo e(url('comunicacion')); ?>'"><img class="imagen" src="dashboardimage/salir.png" style="width:40%; float: left;"></button></div>
    <?php endif; ?>    
    
 </div>   
<!--inicio-->
<html>

<head>

</head>

<body >  

<div id="reporte" style="width: 90%;text-align:center; margin: auto;">
<img src="dashboardimage/chattitulo.png" style="margin-top: 10px;margin-bottom: 15px;width: 25%"/>

  <?php 

include 'dbconnection.php';

  $Tabla = $_GET['Tabla'];
  $Email = $_GET['Email'];
  
  $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");
  
  

  $sql = mysqli_query($conn,"SELECT * FROM $Tabla");
  $cuenta = mysqli_num_rows($sql);
  
  $username=array();
  $messages=array();
  $Fecha=array();
  
  while($row2 = mysqli_fetch_array($sql) ){
      
      $username[] = $row2['username'];
      $message[] = $row2['message'];
      $Fecha[] = $row2['date'];  
    }
  
 
  echo "<table cellspacing='20' style='text-align:center;'>";
    
    echo "<col width='20'>";
    echo "<col width='35'>";
    echo "<col width='20'>";

    echo "<tr id='x'>";
    echo "<th style='font-weight: 900;font-size: 15px;'> Usuario</th>";
    echo "<th style='font-weight: 900;font-size: 15px;'> Mensaje </th>";
    echo "<th style='font-weight: 900;font-size: 15px;'> Fecha </th>";
   
    echo "</tr>";

  for($i=0;$i<$cuenta;$i++){
   echo "<tr >";
    echo "<td style='word-wrap: break-word;'>".$username[$i]."</td>";
    echo "<td style='word-wrap: break-word;'>".$message[$i]."</td>";
    echo "<td style='word-wrap: break-word;'>".$Fecha[$i]."</td>";
    echo "</tr>";
  } 
    echo "</table>";
  
 ?>
 </div>
 <div style = "margin-bottom:20px">
 
 </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í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 = '<?=$Email?>';
    console.log(email); 

 $("#myModal").modal('show');

let el = document.getElementById('reporte');
let opt = {
    margin:      [0.2, 0.1, 1, -0.7],
              filename:     'myfile.pdf',
              pagebreak: {avoid: 'tr'},
              image:        { type: 'jpeg', quality: 0.98 },
              html2canvas:  { scale: 2,width: 1200,windowWidth: 1024 },
              jsPDF:        { unit: 'in', format: 'letter', orientation: 'landscape' }
                                       };
html2pdf().set( opt ).from( el ).toPdf().output('datauristring').then(function( pdfAsString ) {
   
   // $("#myModal").modal('hide');
    
    let data = {'fileDataURI': pdfAsString, 'Email': email};
    $.post( "mailchat.php", data);
    console.log( data );
} );
};
      
 
			
</script>


<style>
table {
  border-collapse: collapse;
  width: 100%;
  table-layout:fixed;
}

td,th {
  
  padding: 5px;
  text-align:center;

}
#x{

  border-top: 1px solid #9f9fa0;
  border-bottom: 1px solid #9f9fa0;
  background-color: #cecece;
  
  

}
 td {

  border-bottom: 1px solid #9f9fa0;
 }
 
 
 
 </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/chattabla/index.blade.php ENDPATH**/ ?>