<?php
defined("BASEPATH") or exit("No direct access allowed");
if (isset($_GET['hapus']) && is_numeric($_GET['hapus'])) {
		$hapus = $_GET['hapus'];
		mysqli_query($con,"DELETE FROM qrcode_detail WHERE id=$hapus");
		echo '
		
        <script>
        	        swal("Good Job","berhasil menghapus data validasi","success");
                </script>     
                
		';
		
	}
	
$tampil=mysqli_fetch_row(mysqli_query($con,"select * from qrcode where id='".$_GET['id']."'"));	
	
?>
	
	<div class="card-header">

          <nav aria-label="breadcrumb">
                      <ol class="breadcrumb bg-warning text-white-all">
                        <li class="breadcrumb-item"><a href="#"><i class="fas fa-tachometer-alt"></i> Home</a></li>
                        <li class="breadcrumb-item"><a href="index.php?page=qrc"><i class="far fa-file"></i> Data</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><i class="fas fa-list"></i> Validasi QRCode</li>
                      </ol>
                    </nav>
					
          </div>
          
    <div class="card-body">   
	<div class="alert alert-primary alert-has-icon p-4">
            <div class="alert-icon"><i class="far fa-lightbulb"></i></div>
            <div class="alert-body">
            <div class="alert-title">Petunjuk:</div>
            1. Data <b><?php echo $tampil[2]; ?></b><br>
            2. Klik tombol <img src='<?php echo $weburl ?>/images/user_delete.png'/> untuk menghapus.
            </div>
            </div>
	<div class="table-responsive">
	    <right>
		<a target="_blank" href="qrcode/excelexport.php?qr=<?php echo $_GET['id'] ?>"><input class="btn btn-secondary btn-border" type="submit" name="" value="CETAK"/></a>
	</right>
				<table id="example" class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>Aksi</th>
                            <th>Nama Prospek</th>
                            <th>Email</th>
                            <th>Handphone/WA</th>
                            <th>Tgl.Validasi</th>
                        </tr>
                    </thead>
                    <tbody>
                       <?php
                            $id = $_GET['id'];
                            $qu=mysqli_query($con,"select qrcode_detail.id as id,prospek.nama as nama,prospek.email as email,prospek.hp as hp,qrcode_detail.tglv as tglv from qrcode_detail, prospek where qrcode_detail.email=prospek.email and qrcode_detail.idqr ='$id' order by qrcode_detail.tglv desc");
                            while($data=mysqli_fetch_row($qu)){
                                
                                $hp = $data[3];
                        	    $hp =substr($hp, 1,12);
                        	    $hp = '62'.$hp;
                        	    $ctw ='<a href="https://api.whatsapp.com/send?phone='.$hp.'&text=%20Hallo '.$data[1].'" target="_blank"><img src="'.$weburl.'/images/WA.jpg" width="16"></a>';
                        	    If (strlen($hp)>9){
                        	        $ctw = $ctw;
                        	    }else{
                        	        $ctw='';
                        	    }
                            

            				    
                                echo "
                                <tr>
                                    
                                    <td>
                                   <a onclick='return konfirmasi()' href='?page=qrc&aksi=view&hapus=$data[0]'><img src='$weburl/images/user_delete.png' alt='Delete' title='Delete'/></a> 
                                   
                                    </td>
                                    
                                    <td>
                                        $data[1] 
                                    </td>
                                    <td>
                                        $data[2] 
                                    </td>
                                    <td>
                                        $ctw $data[3] 
                                    </td>
                                    <td>
                                        $data[4] 
                                    </td>
                                    
                                </tr>
                                ";
                            }
                       ?>
                    </tbody>
                    </table>
            
                
                </div>
    
