<?php
    include('config.php');
	
	$targetpage = "record.php"; 	//your file name  (the name of this file)
	$page = $_POST['page'];
	if($page) 
		$start = ($page - 1) * $limit; 			//first item to display on this page
	else
		$start = 0;								//if no page var is given, set start to 0


	
	
 	$q = $conn->real_escape_string($_POST['q']);
	$f1 = $_POST['f1'];
	
	if($f1){$query_f1 = " ";}

   $query_string = " FROM dl_product WHERE product_name like '%$q%' AND status_paket = 1";
   
   	$sum_sql = "SELECT COUNT(*) as num $query_string";
	$conn_sum_sql = $conn->query($sum_sql);
	$pagenum = $conn_sum_sql->fetch_assoc();
	$total_pages = $pagenum["num"];
   
  	include ("../../sys/paging.php");
 
   	$sql = "SELECT * $query_string ORDER BY product_name LIMIT $start,$limit";
	$sql_con = $conn->query($sql) or die($sql);

?>
<div style="height:575px;">
    <table class="tbl tl table-striped table-hover table-bordered table">
    <thead>
		<tr class="bold theader">
        	<td style="width:15%;">Kode Paket</td>
            <td style="width:45%;">Deskripsi Paket</td>
            <td style="width:15%;" class="tr">Harga</td>
            <td style="width:10%;" class="tc">Cover</td>            
            <td style="width:10%;"></td>
        </tr>
        <style>
        .link_judul{color:#003366;}
		.link_judul:hover{color:#06F}
        </style>
        </thead>
        <?php
		$i = 0;
			while($rs = $sql_con->fetch_assoc()){
			$autoid = $rs['product_id'];
			
			if($rs['tipe_produk']==1){$url_edit = "edit_2?";}
			else{
				$url_edit = "edit?";
				}
	?>
        <tr class="rec_body">
        	<td><?php echo $rs['product_code']?></td>
            <td><?php echo $rs['product_name']?></td>
            <td class="tr"><?php echo number_format($rs['hrg_3'])?></td>
            <td class="tc"><img src="../../../<?php echo $rs['image_url']?>" style="height:50px;" /></td>
            <td class="tc">
            	<a href="<?php echo $url_edit?>id=<?php echo $autoid?>"  data-toggle="tooltip" title="Edit Produk">
                <img src="../../image/edit.png" title="Edit Produk"/></a>
                <a href="delete?id=<?php echo $autoid?>"><img src="../../image/delete.png" title="Hapus Produk"/></a>
            </td>         
        </tr>
	<?php 
	$i = $i + 1;
	} 
	if($i==0){
		?>
        <tr class="rec_body">
        	<td colspan="10" style="height:400px;" class="tc"><h4>Belum Ada Data Produk</h4></td>       
        </tr>
	<?php	} ?>

    </table>
    </div>
    <div class="record_footer">
            <table class="tbl">
        	<tr class="pad5">
            	<td colspan="5" class="tl pad5" style="border:none"><?php echo $pagination?></td>
                <td colspan="4" class="tr pad5 bold" style="border:none;color:#333">Jumlah <?php echo $total_pages?> Produk</td>
            </tr>
        </table>
    </div>
