<?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 = "campaign-del.php";

					frmobj.what.value="Delete";

					frmobj.submit();

					

				}

				else{ 

				return false;

				}

		}

		else if(comb=='Deactivate'){

			frmobj.action = "campaign-del.php";

			frmobj.what.value="Deactivate";

			frmobj.submit();

		}

		else if(comb=='Activate'){

			frmobj.action = "campaign-del.php";

			frmobj.what.value="Activate";

			frmobj.submit();

		}

		else if(comb=='Make Latest'){

			frmobj.action = "campaign-del.php";

			frmobj.what.value="Make Latest";

			frmobj.submit();

		}

		else if(comb=='Remove Latest'){

			frmobj.action = "campaign-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>User Id: </strong></div></td>

    <td width="18%"><input type="text" name="search_user" value="<?php echo $_REQUEST['search_user']; ?>"/></td>

    <td width="18%"><div align="center"><strong></strong></div></td>

    <td width="18%"></td>

   <td width="15%" align="right" ><div align="center"><strong></strong></div></td>

    <td width="18%"></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="campaign-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="" enctype="multipart/form-data">
<?php 
$where='1=1';
if($_REQUEST['search_user']){
$where.=" and user_id='".$_REQUEST['search_user']."' ";	
}

$start=0;
if(isset($_GET['start'])) $start=$_GET['start'];
$pagesize=500;
if(isset($_GET['pagesize'])) $pagesize=$_GET['pagesize'];

$sql=$obj->query("select * from tbl_trackcampaign where $where");
$reccnt=$obj->numRows($sql); ?>

<div align="center"><?php if($reccnt==0){  ?><p style="color:#FF0000; font-size:14px">No records found.</p>
<?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>
</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">Product Name</th>
	<th scope="col" class="padd5">Price</th>
	<th scope="col" class="padd5">Quantity</th>
	<th scope="col" class="padd5">User ID</th>
    <th scope="col" class="padd5">Added Date</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 * from tbl_trackcampaign where $where order by id desc 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->product_name; ?></td>
	<td class="padd5"><?php echo $line->price; ?></td>
	<td class="padd5"><?php echo $line->qty; ?></td>
	<td class="padd5"><?php echo $line->user_id; ?></td>
    <td class="padd5"><?php echo $line->added_date; ?></td>
	<td class="padd5"><?php if($line->status==1){ echo "<span style='color:red'>Pending</span>"; }else{ echo "<span style='color:green'>Success</span>"; } ?></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>