<?php
    include('config.php');
	$limit = 10;	
	$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


   	if($f1){$f1_filter = " AND outlet_autoid = '$f1'";}

      
   	$query_string = " FROM jtheader where (jt_transno LIKE '%$q%' or jt_vcno LIKE '%$q%') AND jt_flagpost = 'N' $f1_filter";


   	$sum_sql = "SELECT COUNT(*) as num $query_string";
	$conn_sum_sql = $conn->query($sum_sql) or die($sum_sql);
	$pagenum = $conn_sum_sql->fetch_assoc();
	$total_pages = $pagenum["num"];
   
  	include ("../../sys/paging.php");
 
   	$sql = "SELECT * $query_string ORDER BY jt_transno ASC LIMIT $start,$limit";
	$sql_con = $conn->query($sql) or die($sql);

?>

<div class="rec_wrapper">
    <table class="table-striped table-hover table-bordered table table-condensed">
    <thead>
    	<tr class="bold">
     	<td style="width:15%">No Jurnal </td>
        <td style="width:15%">No VC</td>
        <td style="width:40%">Catatan</td>
        <td style="width:15%"></td>

        <td class="tc" style="width:20%">Action</td>
        </tr>
        </thead>

		<tbody>
        <?php
		$i = 0;
			while($rs = $sql_con->fetch_assoc()){



			$id = $rs['jt_autoid']	;
		?>
        <tr class="rec_body">
	   		<td>
				<?php echo $rs['jt_transno']?>  
    	        <hr style="margin:0px;border:1px solid #CCC"> 
				<?php echo dtostr($rs['jt_transdate'])?>
            </td>
	   		<td>
				<?php echo $rs['jt_vcno']?> 
	            <hr style="margin:0px;border:1px solid #CCC"> 
				<?php echo dtostr($rs['jt_vcdate'])?>
            </td>
            <td><?php echo $rs['jt_notes']?></td>
            <td>
				<?php echo $rs['jt_userentry']?>        
				<hr style="margin:0px;border:1px solid #CCC"> 
                <?php echo $rs['jt_dateentry']?>        
            </td>
            <td class="tc">
            	<a href="edit?id=<?php echo $id?>" class="btn btn-primary">EDIT</a>
                <a href="delete?id=<?php echo $id?>" class="btn btn-danger">
                DELETE
                </a>
                <a href="post?id=<?php echo $id?>" class="btn btn-success">
                POST
                </a>
            </td>         
        </tr>
	<?php 
	$i = $i + 1;
	} 
	if($i==0){
		?>
        <tr class="rec_body">
        	<td colspan="10" style="height:400px;" class="tc"><h4>No Records</h4></td>       
        </tr>
	<?php	} ?>
	</tbody>
    </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?> Pesanan</td>
            </tr>
        </table>
    </div>
