<?php
	session_start(); 

	include("../include/config.php");

	include("../include/functions.php"); 

	validate_admin();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title><?php echo SITE_TITLE; ?></title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="css/admin.css" rel="stylesheet" type="text/css" />
<script>

	function del_prompt(frmobj,comb)

		{

		//alert(comb);

			if(comb=='Delete'){

				if(confirm ("Are you sure you want to delete record(s)"))

				{

					frmobj.action = "bt-del.php";

					frmobj.what.value="Delete";

					frmobj.submit();

					

				}

				else{ 

				return false;

				}

		}

		else if(comb=='Deactivate'){

			frmobj.action = "bt-del.php";

			frmobj.what.value="Deactivate";

			frmobj.submit();

		}

		else if(comb=='Activate'){

			frmobj.action = "bt-del.php";

			frmobj.what.value="Activate";

			frmobj.submit();

		}

		else if(comb=='Make Latest'){

			frmobj.action = "bt-del.php";

			frmobj.what.value="Make Latest";

			frmobj.submit();

		}

		else if(comb=='Remove Latest'){

			frmobj.action = "bt-del.php";

			frmobj.what.value="Remove Latest";

			frmobj.submit();

		}

		

	}

</script>
<script type="text/javascript">

$(document).ready(function(){

	$("#check_all").click(function(){

		if($(this).is(":checked")){

	        $(".checkall").attr("checked","checked");	
	      }else{
	    	$(".checkall").removeAttr("checked");
	      } 
		})

	})
</script>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">

<?php include("header.php"); ?>
<tr>

		<td align="right" class="paddRtLt70" valign="top">

			<table width="99%" border="0" cellspacing="0" cellpadding="0">

					<tr>

						<td align="right" valign="top">

							<table width="100%" border="0" cellspacing="0" cellpadding="0">

                              <!------------ Search Section ----------------->

                            <tr>

									<td align="left" valign="middle" class="bodr" style="padding-bottom:20px;">

									<table width="100%" border="0" cellspacing="0" cellpadding="3">

  <tr>

    <td class="headingbg bodr text14" style="padding-left:20px;">Search<span  style="float:right; padding-right:10px;"></span></td>

  </tr>

  <tr><td height="10"></td></tr>
 <tr>

    <td>

    <form name="searchForm" method="post" action="">

    <table width="100%" border="0" cellspacing="0" cellpadding="0">

    <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td width="72%"><table width="89%" border="0" cellspacing="0" cellpadding="0">

  <tr>

     <td width="13%" align="right"  ><!--<div align="center"><strong>Zipcode: </strong></div>--></td>

    <td width="18%"><!--<input type="text" name="search_zipcode" value="<?php echo $_REQUEST['search_zipcode']; ?>"/>--></td>

    <td width="18%"><div align="center"><strong>Store Name: </strong></div></td>

    <td width="18%"><select name="search_store" style="width:200px">
<option value="">All</option>
<?php $sql=$obj->query("select storename,storeid from stores where status=1 order by storename");
while($record=$obj->fetchNextObject($sql)){ ?>
<option value="<?php echo $record->storeid; ?>" <?php if($record->storeid==$_REQUEST['search_store']){ ?> selected="selected" <?php } ?>><?php echo ucwords(strtolower($record->storename)); ?></option>
<?php } ?>
</select></td>

   <td width="15%" align="right" ><!--<div align="center"><strong>Zipcode Area: </strong></div>--></td>

    <td width="18%"><!--<select name="search_area" style="width:240px">
<option value="">All</option>
<option value="Local" <?php if($_REQUEST['search_area']=='Local'){ ?> selected="selected"<?php } ?>>Local</option>
<option value="Suburb" <?php if($_REQUEST['search_area']=='Subsurb'){ ?> selected="selected"<?php } ?>>Suburb</option>
<option value="UPS" <?php if($_REQUEST['search_area']=='UPS'){ ?> selected="selected"<?php } ?>>UPS</option>
</select>--></td>

   <td width="18%" align="right" ></td>

    <td width="18%"></td>

  </tr>

</table>

</td>

    <td width="28%"><table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td width="26%"><input type="submit"  class="button" name="search" value="Search" style="padding:7px 10px; border:none" /></td>

    <td width="74%"><a href="btsubmerchant-list.php" class="button" style="padding:7px 10px; border:none; color:#fff">View All</a></td>

  </tr>

</table>

</td>

  </tr>

</table>

</td></tr>

</table>

</form>

</td>

  </tr>

</table>
</td></tr></table></td></tr></table>

<hr />
<form name="frm" method="post" action="product-del.php" enctype="multipart/form-data">
<?php 
$where='';
if($_REQUEST['search_store']){
$where.="where storeid='".$_REQUEST['search_store']."' ";	
}
$start=0;
if(isset($_GET['start'])) $start=$_GET['start'];
$pagesize=100;
if(isset($_GET['pagesize'])) $pagesize=$_GET['pagesize'];

$sql=$obj->query("select storeid,storename,BT_storename,status,in_stock from stores $where");
$reccnt=$obj->numRows($sql); ?>

<div align="center"><?php if($reccnt==0){  ?><p style="color:#FF0000; font-size:14px">No records found.</p>
<span  style="float:right; padding-right:10px;"><a href="bt-submerchant.php" style="background:green; padding:5px 10px; color:#fff; border-radius:4px"><strong>Add BT MerchantID</strong></a></span>
<?php }else{ ?>
<p style="color:#00CC00; font-size:14px"><strong><?php if($_SESSION['sess_msg']){ echo $_SESSION['sess_msg']; $_SESSION['sess_msg']=''; }else{ echo $reccnt." records found."; } ?></strong></p>
<span  style="float:right; padding-right:3%; margin-top:-35px"><a href="bt-submerchant.php" style="background:green; padding:5px 10px; color:#fff; border-radius:4px"><strong>Add BT MerchantID</strong></a></span>
</div>
<div align="right" style="margin-right:3%"><?php include("../include/paging.inc.php"); ?></div>
<table width="100%" cellspacing="2" cellpadding="3">
<tbody>
  <tr style="background:#ddd; box-shadow:-2px 1px 5px #ccc">
    <th scope="col" class="padd5">S. No.</th>
    <th scope="col" class="padd5">Store Name</th>
	<th scope="col">Store ID</th>
	<th scope="col">BT Merchant iD</th>
	<th scope="col" class="padd5">Status</th>
	<th scope="col" class="padd5"><input name="check_all" type="checkbox"   id="check_all" value="check_all" /></th>
  </tr>
  <?php $sql=$obj->query("select storeid,storename,BT_storename,status,in_stock from stores $where order by storename limit $start,$pagesize");
  $i=0;
while($line=$obj->fetchNextObject($sql)){ 
$i++; 
if($i%2==0){ $bgcolor = "#f3f4f6"; } else {	$bgcolor = "";	} ?>
  <tr bgcolor="<?php echo $bgcolor; ?>" align="center">
    <td class="padd5"><?php echo $i+$start; ?></td>
    <td class="padd5"><?php echo $line->storename; ?></td>
	<td class="padd5"><?php echo $line->storeid; ?></td>
	<td class="padd5"><?php echo $line->BT_storename; ?></td>
	<td class="padd5"><?php if($line->status==1){ echo "<span style='color:green'>Active</span>"; }else{ echo "<span style='color:red'>Deactive</span>"; } ?></td>
	<td class="padd5"><input type="checkbox" name="ids[]" class="checkall" value="<?php echo $line->storeid;?>" /></td>

  </tr>
  <?php } //while ?>
  </tbody>
</table>
<?php include("../include/paging.inc.php"); ?>
<br />
<div align="right" style="margin-right:10%">
<input type="hidden" name="what" value="what" />
<input type="submit" name="Submit" value="Activate" class="button" onclick="return del_prompt(this.form,this.value)" />
<input type="submit" name="Submit" value="Deactivate" class="button" onclick="return del_prompt(this.form,this.value)" />
<input type="submit" name="Submit" value="Delete" class="button" onclick="return del_prompt(this.form,this.value)" />
</div>
<?php } //numrows ?>
</form>
<br />
<?php include('footer.php'); ?>
</body>

</html>