<?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 a.whs_autoid = '$f1'";}
	$q_filter = " WHERE (a.pm_name LIKE '%$q%' or a.pm_code LIKE '%$q%') $f1_filter";
   
   
   

   
   	$sum_sql = "SELECT COUNT(*) as num FROM invtrans a, invtranstype b WHERE 
					a.itt_autoid = b.itt_autoid AND a.invt_status = 1 AND 
					(a.invt_transno LIKE '%$q%' OR a.itt_desc LIKE '%$q%')";				
	$conn_sum_sql = $conn->query($sum_sql) or die($sum_sql);
	$pagenum = $conn_sum_sql->fetch_assoc();
	$total_pages = $pagenum['num'];



   


   	$sql = "SELECT * FROM invtrans a, invtranstype b WHERE 
					a.itt_autoid = b.itt_autoid AND a.invt_status = 1 AND 
					(a.invt_transno LIKE '%$q%' OR a.itt_desc LIKE '%$q%') LIMIT  $start, $limit";
	$sql_con = $conn->query($sql) or die($sql);

   	include ("../../sys/paging.php");

?>

<div class="rec_wrapper">
    <table class="table-striped table-hover table-bordered table table-condensed">
    <thead>
    	<tr class="bold">
     	<td style="width:130px">No Transaksi</td>
        <td style="width:100px;">Tanggal</td>
        <td class="tl" style="width:250px">Tipe Transaksi</td>
        <td style="width:180px">Gudang</td>
        <td style="width:200px">Catatan</td>
        <td style="width:120px">User Input</td>
        <td class="tc" style="width:100px">Action</td>
        </tr>
        </thead>

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

		$fwhs = $rs['invt_fwhs'];
		$twhs = $rs['invt_twhs'];


		if($rs['trans_code']=="MT"){
			$whsdesc = $whsname[$fwhs]." &#8594; ".$whsname[$twhs];
			}else{$whsdesc = $whsname[$twhs];}


			$id = $rs['invt_autoid']	;
		?>
        <tr class="rec_body">
   		<td><?php echo $rs['invt_transno']?></td>
    	    <td><?php echo dtostr($rs['invt_transdate'])?></td>
	        <td class="tl"><?php echo $rs['itt_desc']?></td>
        	<td class="tl"><?php echo $_outlet_name[$rs['outlet_id']]?></td>
            <td class="tc"><?php echo $rs['invt_notes']?></td>
            <td class="tl"><?php echo $rs['invt_userentry']?></td>
            <td class="tc">
            	<a href="edit?id=<?php echo $id?>"  data-toggle="tooltip" title="Edit Produk">
                <img src="../../image/edit.png" title="Edit Cara Pengiriman" class="icon"/></a>
                <a href="delete?id=<?php echo $id?>">
                <img src="../../image/delete.png" title="Hapus Cara Pengiriman" class="icon"/>
                </a>
                <a href="post?id=<?php echo $id?>">
                <img src="../../image/post.png" title="Hapus Cara Pengiriman" class="icon"/>
                </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 Transaksi</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?> <?php echo $pageid?></td>
            </tr>
        </table>
    </div>
