<?php
//include('Pagination.php');
session_start();
include('config/koneksi2.php');
$item_per_page = 10;
if(isset($_POST["page"])){

	$page_number = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH); //filter number
	if(!is_numeric($page_number)){die('Invalid page number!');} //incase of invalid page number
}else{
	$page_number = 1; //if there's no page number, set it to 1
}
$page_position = (($page_number-1) * $item_per_page);
	//$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where tipe like '%$tipe%' order by nama ASC LIMIT $page_position, $item_per_page");
//}
$tipe=$_POST['tipe'];
$brand=$_POST['brand'];
$kategori=$_POST['kategori'];
$size=$_POST['size'];
$color=$_POST['color'];
$nama=$_POST['nama'];
$config=$_POST['config'];
$nol=$_POST['nol'];
if($_POST['tipe'] !="")
{
	$username=$_SESSION['username'];
	$akses=mysql_query("select id_level from tab_user where username='$username'");
	$akses1=mysql_fetch_array($akses);
	
	$akses2=mysql_query("select id_level_brand from tab_user where username='$username'");
	$akses3=mysql_fetch_array($akses2);
	$level=$akses3[id_level_brand];
	
	$akses4=mysql_query("select id_level_brand_pa from tab_user where username='$username'");
	$akses5=mysql_fetch_array($akses4);
	$level2=$akses5[id_level_brand_pa];
	
	if($_POST['nol'] =="true")
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
	}
	else
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
	}
}
else if($_POST['brand'] !="")
{
	$username=$_SESSION['username'];
	$akses=mysql_query("select id_level from tab_user where username='$username'");
	$akses1=mysql_fetch_array($akses);
	
	$akses2=mysql_query("select id_level_brand from tab_user where username='$username'");
	$akses3=mysql_fetch_array($akses2);
	$level=$akses3[id_level_brand];
	
	$akses4=mysql_query("select id_level_brand_pa from tab_user where username='$username'");
	$akses5=mysql_fetch_array($akses4);
	$level2=$akses5[id_level_brand_pa];
	
	if($_POST['nol'] =="true")
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
	}
	else
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
	}
}
else if($_POST['kategori'] !="")
{
	$username=$_SESSION['username'];
	$akses=mysql_query("select id_level from tab_user where username='$username'");
	$akses1=mysql_fetch_array($akses);
	
	$akses2=mysql_query("select id_level_brand from tab_user where username='$username'");
	$akses3=mysql_fetch_array($akses2);
	$level=$akses3[id_level_brand];
	
	$akses4=mysql_query("select id_level_brand_pa from tab_user where username='$username'");
	$akses5=mysql_fetch_array($akses4);
	$level2=$akses5[id_level_brand_pa];
	if($_POST['nol'] =="true")
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
	}
	else
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
	}
}
else if($_POST['size'] !="")
{
	$username=$_SESSION['username'];
	$akses=mysql_query("select id_level from tab_user where username='$username'");
	$akses1=mysql_fetch_array($akses);
	
	$akses2=mysql_query("select id_level_brand from tab_user where username='$username'");
	$akses3=mysql_fetch_array($akses2);
	$level=$akses3[id_level_brand];
	
	$akses4=mysql_query("select id_level_brand_pa from tab_user where username='$username'");
	$akses5=mysql_fetch_array($akses4);
	$level2=$akses5[id_level_brand_pa];
	if($_POST['nol'] =="true")
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
	}
	else
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
	}
}
else if($_POST['color'] !="")
{
	
	$username=$_SESSION['username'];
	$akses=mysql_query("select id_level from tab_user where username='$username'");
	$akses1=mysql_fetch_array($akses);
	
	$akses2=mysql_query("select id_level_brand from tab_user where username='$username'");
	$akses3=mysql_fetch_array($akses2);
	$level=$akses3[id_level_brand];
	
	$akses4=mysql_query("select id_level_brand_pa from tab_user where username='$username'");
	$akses5=mysql_fetch_array($akses4);
	$level2=$akses5[id_level_brand_pa];
	if($_POST['nol'] =="true")
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
	}
	else
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
	}
}
else if($_POST['nama'] !="")
{
	
	$username=$_SESSION['username'];
	$akses=mysql_query("select id_level from tab_user where username='$username'");
	$akses1=mysql_fetch_array($akses);
	
	$akses2=mysql_query("select id_level_brand from tab_user where username='$username'");
	$akses3=mysql_fetch_array($akses2);
	$level=$akses3[id_level_brand];
	
	$akses4=mysql_query("select id_level_brand_pa from tab_user where username='$username'");
	$akses5=mysql_fetch_array($akses4);
	$level2=$akses5[id_level_brand_pa];
	if($_POST['nol'] =="true")
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
	}
	else
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
	}
}
else if($_POST['config'] !="")
{
	$username=$_SESSION['username'];
	$akses=mysql_query("select id_level from tab_user where username='$username'");
	$akses1=mysql_fetch_array($akses);
	
	$akses2=mysql_query("select id_level_brand from tab_user where username='$username'");
	$akses3=mysql_fetch_array($akses2);
	$level=$akses3[id_level_brand];
	
	$akses4=mysql_query("select id_level_brand_pa from tab_user where username='$username'");
	$akses5=mysql_fetch_array($akses4);
	$level2=$akses5[id_level_brand_pa];
	if($_POST['nol'] =="true")
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
		}
	}
	else
	{
		if($akses1['id_level'] =='0' and $level=='2')
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
		else
		{
			$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' order by date desc LIMIT $page_position, $item_per_page");
			
			$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
				FROM tab_user u
				INNER JOIN level g ON u.id_level=g.id_level
				INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
				INNER JOIN tipe_new m ON gm.id_tipe=m.id
				WHERE
				u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%'");
		}
	}
}
else if($_POST['nol'] =="true")
{
	
	$username=$_SESSION['username'];
	$akses=mysql_query("select id_level from tab_user where username='$username'");
	$akses1=mysql_fetch_array($akses);
	
	$akses2=mysql_query("select id_level_brand from tab_user where username='$username'");
	$akses3=mysql_fetch_array($akses2);
	$level=$akses3[id_level_brand];
	
	$akses4=mysql_query("select id_level_brand_pa from tab_user where username='$username'");
	$akses5=mysql_fetch_array($akses4);
	$level2=$akses5[id_level_brand_pa];
	if($akses1['id_level'] =='0' and $level=='2')
	{
		$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
			FROM tab_user u
			INNER JOIN level g ON u.id_level=g.id_level
			INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
			INNER JOIN tipe_new m ON gm.id_tipe=m.id
			WHERE
			u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000  and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
		$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
			FROM tab_user u
			INNER JOIN level g ON u.id_level=g.id_level
			INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
			INNER JOIN tipe_new m ON gm.id_tipe=m.id
			WHERE
			u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
	}
	else
	{
		$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
			FROM tab_user u
			INNER JOIN level g ON u.id_level=g.id_level
			INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
			INNER JOIN tipe_new m ON gm.id_tipe=m.id
			WHERE
			u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0 order by date desc LIMIT $page_position, $item_per_page");
		
		$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
			FROM tab_user u
			INNER JOIN level g ON u.id_level=g.id_level
			INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
			INNER JOIN tipe_new m ON gm.id_tipe=m.id
			WHERE
			u.username='$username') and status !='0' and tipe like '%$tipe%' and brand like '%$brand%' and kategori like '%$kategori' and size_ax like '%$size%' and colour_ax like '%$color%' and nama like '%$nama%' and config_ax like '%$config%' and stok > 0");
	}
}
else
{
	$username=$_SESSION['username'];
	$akses=mysql_query("select id_level from tab_user where username='$username'");
	$akses1=mysql_fetch_array($akses);
	
	$akses2=mysql_query("select id_level_brand from tab_user where username='$username'");
	$akses3=mysql_fetch_array($akses2);
	$level=$akses3[id_level_brand];
	
	$akses4=mysql_query("select id_level_brand_pa from tab_user where username='$username'");
	$akses5=mysql_fetch_array($akses4);
	$level2=$akses5[id_level_brand_pa];
	if($akses1['id_level'] =='0' and $level=='2')
	{
		$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
			FROM tab_user u
			INNER JOIN level g ON u.id_level=g.id_level
			INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
			INNER JOIN tipe_new m ON gm.id_tipe=m.id
			WHERE
			u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000  order by date desc LIMIT $page_position, $item_per_page");
		$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
			FROM tab_user u
			INNER JOIN level g ON u.id_level=g.id_level
			INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
			INNER JOIN tipe_new m ON gm.id_tipe=m.id
			WHERE
			u.username='$username') and status !='0' and tipe like '%$tipe%' and dealer < 4000000 ");
	}
	else
	{
		$sql=mysql_query("select *, DATEDIFF(NOW(), date) as new from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
			FROM tab_user u
			INNER JOIN level g ON u.id_level=g.id_level
			INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
			INNER JOIN tipe_new m ON gm.id_tipe=m.id
			WHERE
			u.username='$username') and status !='0' and tipe like '%$tipe%' order by date desc LIMIT $page_position, $item_per_page");
		
		$results = mysql_query("select COUNT(*) as jumlah from bs_stok where(tipe != 'BIKE' and tipe != 'FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand where id_level_brand='$level')) and  (tipe ='BIKE' and tipe ='FRAME AND FORK' or brand NOT IN (SELECT nama_brand from grup_brand_pa where id_level_brand_pa='$level2')) and tipe IN (SELECT m.nama_tipe
			FROM tab_user u
			INNER JOIN level g ON u.id_level=g.id_level
			INNER JOIN grup_menu gm ON gm.id_level=g.id_level 
			INNER JOIN tipe_new m ON gm.id_tipe=m.id
			WHERE
			u.username='$username') and status !='0' and tipe like '%$tipe%' ");
	}
}
	$get_total_rows =mysql_fetch_array($results); //hold total records in variable
	//break records into pages
	$total_pages = ceil($get_total_rows[jumlah]/$item_per_page);
	
	//get starting position to fetch the records
	while($row=mysql_fetch_array($sql))
	{
		?>

		<div class="product-grids simpleCart_shelfItem wow fadeInUp animated" data-wow-delay=".5s">
			<div class="new-top">
		<?php
			if($row['new'] <= 30)
			{
			?>
				<div class="mask2"><span>New</span>
				<a href="#"><img src="http://lokal.bikershop.biz/inside/data/resize/<?php echo "$row[photo]"; ?>" class="img-responsive" alt=""/></a>
			</div>
			<?php
			}
			else
			{
			?>
				<a href="#"><img src="http://lokal.bikershop.biz/inside/data/resize/<?php echo "$row[photo]"; ?>" class="img-responsive" alt=""/></a>
			<?php
			}
			?>				<div class="new-text">
					<ul>
						
						<li><a class="item_add" data-toggle="modal" data-target="#myModal" id="image" name="image" href="#" onclick="image('<?php echo $row[id] ?>')">Lihat Gambar</a></li>
						<li><input type="number" class="item_quantity" name="qty" id="qty_<?php echo $row[id] ?>" min="1" value="1"></li>
						<li><a class="item_add" id="add" name="add" href="#" onclick="cart('<?php echo $row[id] ?>')">Beli</a></li>
					</ul>
				</div>
			</div>
			<div class="new-bottom">
				<h5><?php echo "$row[nama]"; ?> <?php echo "$row[config_ax]"; ?> <?php echo "$row[size_ax]"; ?> <?php echo "$row[colour_ax]"; ?> </h5>
						<!--<div class="rating">
							<span class="on">?</span>
							<span class="on">?</span>
							<span class="on">?</span>
							<span class="on">?</span>
							<span>?</span>
						</div>-->
						<div class="ofr">
							<?php
							$id_diskon=$row[kode_diskon];
							$sql_diskon="select * from diskon where kode_diskon='$id_diskon'";
							$hasil_diskon=mysql_query($sql_diskon);
							$diskon=mysql_fetch_array($hasil_diskon);
							$diskon1= (($row[dealer] * $diskon[diskon])/100);
							$diskon3= $row[dealer] - $diskon1;
							$diskon2=number_format($diskon3);
							$harga_dealer=number_format("$row[dealer]");
							$dis=$diskon[diskon];
							if($row['kode_diskon'] == '0')
							{
								?>
								<p><span class="item_price">Rp. <?php echo "$harga_dealer"; ?></span></p>
								<?php
							}
							else
							{
								
								?>
								<p class="pric1"><del>Rp. <?php echo "$harga_dealer"; ?></del></p>
								<p><span class="item_price">Rp. <?php echo "$diskon2"; ?></span></p>
								<?php
							}
							?>
							
						</div>
							<?php
						if($_SESSION['user_akses'] == 'dealer')
						{
							?>
							<span> Stok : <span class="badge"><?php echo $row[stok_ext] ?></span></span>
							<?php
						}
						else
						{
							?>
								<span><a href="#kode_<?php echo $row[id] ?>" data-toggle="collapse">Stok : <span class="badge"><?php echo $row[stok] ?></span></a></span>
							<?php
						 $kode=$row['kode_ax'];
						    $size=$row['size_ax'];
						    $color=$row['colour_ax'];
						    $config=$row['config_ax'];
							$select=mysql_query("select * from stok where kode_ax='$kode' and size_ax='$size' and colour_ax='$color' and config_ax='$config' and stok > 0 ");
						?>
  <div id="kode_<?php echo $row[id] ?>" class="collapse">
    <?php
							
							while($a=mysql_fetch_array($select))
							{
							?>
							<span style="font-size:10px;"><?php echo $a['warehouse'] ?>:<?php echo $a['stok'] ?></span>,

							<?php
							} 
							?>
  </div>
  <?php 
						}
						?>
					</div>
				</div>

				<?php
			}

	echo '<div align="center">';
	/*We call the pagination function here to generate Pagination link for us. 
	As you can see I have passed several parameters to the function.*/
	echo paginate_function($item_per_page, $page_number, $get_total_rows[jumlah], $total_pages);
	echo '</div>';
	
      //  echo $pagination->createLinks(); 
	
	function paginate_function($item_per_page, $current_page, $total_records, $total_pages)
	{
		$pagination = '';
    if($total_pages > 0 && $total_pages != 1 && $current_page <= $total_pages){ //verify total pages and current page number
    	$pagination .= '<ul class="pagination">';
    	
    	$right_links    = $current_page + 3; 
        $previous       = $current_page - 3; //previous link 
        $next           = $current_page + 1; //next link
        $first_link     = true; //boolean var to decide our first link
        
        if($current_page > 1){
        	$previous_link = ($previous==0)? 1: $previous;
            $pagination .= '<li class="first"><a href="#" data-page="1" title="First">&laquo;</a></li>'; //first link
            $pagination .= '<li><a href="#" data-page="'.$previous_link.'" title="Previous">&lt;</a></li>'; //previous link
                for($i = ($current_page-2); $i < $current_page; $i++)
				{ //Create left-hand side links
                	if($i > 0){
                		$pagination .= '<li><a href="#" data-page="'.$i.'" title="Page'.$i.'">'.$i.'</a></li>';
                	}
                }   
            $first_link = false; //set first link to false
        }
        
        if($first_link){ //if current active page is first link
        	$pagination .= '<li class="first active"><a href="#">'.$current_page.'</a></li>';
        }elseif($current_page == $total_pages){ //if it's the last active link
        $pagination .= '<li class="last active"><a href="#">'.$current_page.'</a></li>';
        }else{ //regular current link
        	$pagination .= '<li class="active"><a href="#">'.$current_page.'</a></li>';
        }
        
        for($i = $current_page+1; $i < $right_links ; $i++){ //create right-hand side links
        	if($i<=$total_pages){
        		$pagination .= '<li><a href="#" data-page="'.$i.'" title="Page '.$i.'">'.$i.'</a></li>';
        	}
        }
        if($current_page < $total_pages){ 
        	$next_link = ($i > $total_pages) ? $total_pages : $i;
                $pagination .= '<li><a href="#" data-page="'.$next_link.'" title="Next">&gt;</a></li>'; //next link
                $pagination .= '<li class="last"><a href="#" data-page="'.$total_pages.'" title="Last">&raquo;</a></li>'; //last link
            }
            
            $pagination .= '</ul>'; 
        }
    return $pagination; //return pagination links
}

?>
