<?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 = "zip-del.php";

					frmobj.what.value="Delete";

					frmobj.submit();

					

				}

				else{ 

				return false;

				}

		}

		else if(comb=='Deactivate'){

			frmobj.action = "zip-del.php";

			frmobj.what.value="Deactivate";

			frmobj.submit();

		}

		else if(comb=='Activate'){

			frmobj.action = "zip-del.php";

			frmobj.what.value="Activate";

			frmobj.submit();

		}

		else if(comb=='Make Latest'){

			frmobj.action = "zip-del.php";

			frmobj.what.value="Make Latest";

			frmobj.submit();

		}

		else if(comb=='Remove Latest'){

			frmobj.action = "zip-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="zip-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_zipcode']){
$where.=" and z.zip='".$_REQUEST['search_zipcode']."' ";	
}
if($_REQUEST['search_store']){
$where.=" and z.storeid='".$_REQUEST['search_store']."' ";	
}
if($_REQUEST['search_area']){
$where.=" and z.zip_area='".$_REQUEST['search_area']."' ";	
}
$start=0;
if(isset($_GET['start'])) $start=$_GET['start'];
$pagesize=500;
if(isset($_GET['pagesize'])) $pagesize=$_GET['pagesize'];

$sql=$obj->query("select s.storeid from stores s inner join tbl_store_zip z on s.storeid=z.storeid $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="zip-addf.php" style="background:green; padding:5px 10px; color:#fff; border-radius:4px"><strong>Add Zipcode</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="zip-addf.php" style="background:green; padding:5px 10px; color:#fff; border-radius:4px;"><strong>Add Zipcode</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" class="padd5">Zipcode</th>
	<th scope="col" class="padd5">Zip Area</th>
    <th scope="col" class="padd5">City</th>
	<th scope="col">State</th>
    <th scope="col">URL</th>
	<th scope="col">Pickup/Delivery</th>
    <th scope="col">Minimum / Fee</th>
	<th scope="col">Commission</th>
	<th scope="col">Delivery Fee</th>
    <th scope="col" class="padd5">Zone</th>
	<th scope="col">UPS Status</th>
	<th scope="col">Short Description</th>
	<th scope="col">Open Time / Close Time</th>
    <th scope="col">Wholesale Delivery</th>
	<th scope="col">Grocery Delivery</th>
    <th scope="col">Food Delivery</th>
    <th scope="col">Alcochol Delivery</th>
	<th scope="col" class="padd5">Store Status</th>
    <th scope="col" class="padd5">Zip Status</th>
	<th scope="col" class="padd5">Edit</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 *,s.storeid,z.zip,z.zip_area,z.city,z.status from stores s inner join tbl_store_zip z on s.storeid=z.storeid $where order by z.zip_area 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->zip; ?></td>
	<td class="padd5"><?php echo $line->zip_area; ?></td>
    <td class="padd5"><?php echo $line->city; ?></td>
	<td class="padd5"><?php echo $line->state; ?></td>
    <td class="padd5"><?php echo $line->url; ?></td>
	<td class="padd5"><?php if($line->pickup==1){ echo "<span style='color:green'>Yes</span>"; }else{ echo "<span style='color:red'>No</span>"; } ?> / <?php if($line->delivery==1){ echo "<span style='color:green'>Yes</span>"; }else{ echo "<span style='color:red'>No</span>"; } ?></td>
	<td class="padd5"><?php echo $line->minimum; ?> / <?php echo $line->minimum_fee; ?></td>
	<td class="padd5"><?php echo $line->commission; ?></td>
	<td class="padd5"><?php echo $line->delivery_fee; ?></td>
	<td class="padd5"><?php echo $line->zone; ?></td>
	<td class="padd5"><?php if($line->ups==1){ echo "<span style='color:green'>Yes</span>"; }else{ echo "<span style='color:red'>No</span>"; } ?></td>
	<td class="padd5"><?php echo $line->short_description.'<br>'.$line->mini_desccription.'<br>'.$line->estd_delivery; ?></td>
	<td class="padd5"><?php echo $line->open_time.' / '.$line->close_time; ?></td>
	<td class="padd5"><?php echo $line->wholesale_delevery_partner; ?></td>
	<td class="padd5"><?php echo $line->grocery_delivery_partner; ?></td>
	<td class="padd5"><?php echo $line->food_delivery_partner; ?></td>
	<td class="padd5"><?php echo $line->alocohol_delivery_partner; ?></td>
	<td class="padd5"><?php if($line->store_status==1){ echo "<span style='color:green'>Active</span>"; }else{ echo "<span style='color:red'>Deactive</span>"; } ?></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"><a href="zip-addf.php?id=<?php echo $line->id; ?>">Edit</a></td>
	<td class="padd5"><input type="checkbox" name="ids[]" class="checkall" value="<?php echo $line->id;?>" /></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>