<?php
session_start();

include("../include/config.php");

include("../include/functions.php");

validate_admin();
$useragent=$_SERVER['HTTP_USER_AGENT'];

if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))){
header('Location: order-list-responsive.php');
exit;	
}


?>
<!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>
<script type="text/javascript">
 if (screen.width <= 768) {
            document.location = "<?php echo SITE_URL;?>admin/order-list-responsive.php";
        }
    </script>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="css/admin.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
        <script>
            function checkall(objForm)
            {
                len = objForm.elements.length;
                var i = 0;
                for (i = 0; i < len; i++) {
                    if (objForm.elements[i].type == 'checkbox')
                        objForm.elements[i].checked = objForm.check_all.checked;
                }
            }

            function del_prompt(frmobj, comb)
            {
                //alert(comb);
                if (comb == 'Delete') {
                    if (confirm("Are you sure you want to delete record(s)"))
                    {
                        frmobj.action = "order-del.php";
                        frmobj.what.value = "Delete";
                        frmobj.submit();
                    } else {
                        return false;
                    }

                } else if (comb == 'Deactivate') {
                    frmobj.action = "order-del.php";
                    frmobj.what.value = "Deactivate";
                    frmobj.submit();
                } else if (comb == 'Activate') {
                    frmobj.action = "order-del.php";
                    frmobj.what.value = "Activate";
                    frmobj.submit();
                }
            }
        </script>
<style>
.order-cta {
	border: 1px solid;
    background: #eaeaea;
    padding: 4px 4px;
    color: #000;
    cursor: pointer;
    margin-top: 10PX;
    display: block;
    text-align: center;
}
</style>
    </head>

    <body>

        <table width="100%" border="0" cellpadding="0" cellspacing="0">

            <?php
							include("header.php");
							$userlocationWhere='';
							$user_type = getFieldWhere('user_type', 'tbl_admin', 'id', $_SESSION['sess_admin_id']);
							$user_location=getFieldWhere('location', 'tbl_admin', 'id', $_SESSION['sess_admin_id']);
							$user_location=implode("','",explode(",",$user_location));
							//echo "select group_concat(distinct zip) as zip from tbl_store_zip where state in ('$user_location') and zip!=''";
							$userziparr=array();
							$userzip=$obj->query("select distinct(zip) as zip from tbl_store_zip where state in ('$user_location') and zip!=''");
							while($resuserZip=$obj->fetchNextObject($userzip)){
								array_push($userziparr,$resuserZip->zip);
							}
							$userLocationZip=implode(',',$userziparr);
							if($user_location!=''){
								$userlocationWhere='and tbl_order.ship_pincode in('.$userLocationZip.')';
							}
							
							$_REQUEST['search_storename'] = '294';
            ?>
            <link rel="stylesheet" href="../css/colorbox.css" />
            <script src="../js/jquery.colorbox.js"></script>
            <link rel="stylesheet" href="calender/css/jquery-ui.css">
                <script src="calender/js/jquery-ui.js"></script>

                <script>
            $(function () {

                $("#search_from_date").datepicker({
                    changeMonth: true,
                    changeYear: true,
                    dateFormat: 'yy-mm-dd',
                    yearRange: '2014:<?php echo date('Y'); ?>',
                    onClose: function (selectedDate) {
                        $("#search_to_date").val(selectedDate);
                        $("#search_to_date").datepicker("option", "minDate", selectedDate);
                    }
                });

                $("#search_to_date").datepicker({
                    changeMonth: true,
                    changeYear: true,
                    numberOfMonths: 2,
                    dateFormat: 'yy-mm-dd',
                    yearRange: '2014:<?php echo date('Y'); ?>',
                })

                $("#search_from_date").datepicker({
                    changeMonth: true,
                    changeYear: true,
                    dateFormat: 'yy-mm-dd',
                    yearRange: '2014:<?php echo date('Y'); ?>',
                    onClose: function (selectedDate) {
                        $("#visit_date_to").val(selectedDate);
                        $("#visit_date_to").datepicker("option", "minDate", selectedDate);
                    }
                });

                $("#search_to_date").datepicker({
                    changeMonth: true,
                    changeYear: true,
                    numberOfMonths: 2,
                    dateFormat: 'yy-mm-dd',
                    yearRange: '2014:<?php echo date('Y'); ?>',
                })
            });
                </script>

					<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="buygiftcard-list.php">
																													<table width="100%" border="0" cellspacing="4" cellpadding="4">
																															<tr>

																																	<td width="10%" align="right" ><strong>Order ID:</strong></td>

																																	<td width="15%"><input type="text" name="search_order_id" value="<?php echo $_REQUEST['search_order_id']; ?>"/></td>

																																	<td width="10%" align="right"  ><strong>Email:</strong></td>

																																	<td width="15%"><input type="text" name="search_email" value="<?php echo $_REQUEST['search_email']; ?>"/></td>

																																	<td width="10%" align="right"  ><strong>Customer Type:</strong></td>

																																	<td width="15%">
																																		<select name="search_customer_type" style="width:150px;" >
																																					<option value="">All</option>
																																					<option  value="New" <?php if ($_REQUEST['search_customer_type'] == 'New') { ?>selected<?php } ?>>New</option>

																																					<option  value="Existing" <?php if ($_REQUEST['search_customer_type'] == 'Existing') { ?>selected<?php } ?>>Existing</option>
																																		 </select>
																																		 <select name="search_storename" style="width:150px;display:none;" >

																																					<?php
																																					$storenum = $obj->query("select storeid,storename from stores where storename = 'Quicklly Gift Card' ");

																																					while ($storenumrec = $obj->fetchNextObject($storenum)) {
																																							?>
																																							<option  value="<?php echo $storenumrec->storeid; ?>" <?php if ($storenumrec->storeid == $_REQUEST['search_storename']) { ?>selected<?php } ?>><?php echo ucwords($storenumrec->storename); ?></option>

																																					<?php } ?>  </select>
																																	</td>
																																	
																																	<td width="10%" align="right"><strong>Ordered Device:</strong></td>

																																	<td width="15%">
																																		<select name="search_device" style="width:150px;" >
																																				<option value="">All</option>
																																				<option  value="Mobile" <?php if ($_REQUEST['search_device'] == 'Mobile') { ?>selected<?php } ?>>Mobile</option>
																																				<option  value="Tablet" <?php if ($_REQUEST['search_device'] == 'Tablet') { ?>selected<?php } ?>>Tablet</option>
																																				<option  value="Desktop" <?php if ($_REQUEST['search_device'] == 'Desktop') { ?>selected<?php } ?>>Desktop</option>
																																		</select>
																																	</td>

																															</tr>
																															
																															<tr>																																			
																																																																									
																																	<td width="10%" align="right"><strong>User ID:</strong></td>

																																	<td width="15%"><input type="text" name="search_user_id" value="<?php echo $_REQUEST['search_user_id']; ?>"/></td>

																																	<td width="10%" align="right"><strong>From Date:</strong></td>

																																	<td width="15%"><input type="text" name="search_from_date" id="search_from_date" value="<?php echo $_REQUEST['search_from_date']; ?>"/></td>

																																	<td width="10%" align="right"><strong>To Date:</strong></td>

																																	<td width="15%"><input type="text" name="search_to_date" id="search_to_date" value="<?php echo $_REQUEST['search_to_date']; ?>"/></td> 
																																	
																																	<td width="7%" align="right"><input type="submit"  name="search" value="Search" style="background:#0099CC; border:5px solid #0099CC; color:#fff" /></td>

																																	<td width="12%" align="center" ><a href="buygiftcard-list.php" style="background:#009966; border:6px solid #009966; color:#fff">View All</a></td>
 
																															</tr>
 
																													</table>
																											</form>
																									</td>
																							</tr>
																					</table>
																			</td>
																	</tr>

																	<tr>
																			<td align="left" valign="middle" class="bodr" style="padding-bottom:20px;"><table width="100%" border="0" cellspacing="0" cellpadding="3">

																							<tr>
																									<?php
																									$where = '';

																									if (trim($_REQUEST['search_order_id']) != '') {
																											$name = trim($_REQUEST['search_order_id']);
																											$where .= " and tbl_order.id='" . $name . "'";
																									}
																																																			 
																									if (trim($_REQUEST['search_user_id']) != '') {
																											$name = trim($_REQUEST['search_user_id']);
																											$where .= " and tbl_order.user_id='" . $name . "'";
																									}

																									if (trim($_REQUEST['search_email']) != '') {
																											$name = trim($_REQUEST['search_email']);
																											$where .= " and ship_email like '%$name%' ";
																									}
																							 
																									if (trim($_REQUEST['search_storename']) != '') {
																											$name = trim($_REQUEST['search_storename']);
																											$where .= " and tbl_order_itmes.storeid like '%$name%'";
																									}

																									if (trim($_REQUEST['search_device']) != '') {
																											$name = trim($_REQUEST['search_device']);
																											$where .= " and tbl_order.order_via='" . $name . "'";
																									}

																									if (trim($_REQUEST['search_from_date']) != '' && trim($_REQUEST['search_to_date']) != '') {
																											$where .= " and tbl_order.order_date>='" . trim($_REQUEST['search_from_date']) . "' and tbl_order.order_date<='" . trim($_REQUEST['search_to_date']) . "' ";
																									}

																									$start = 0;

																									if (isset($_GET['start']))
																											$start = $_GET['start'];

																									$pagesize = 15;
																									if (isset($_GET['pagesize']))
																											$pagesize = $_GET['pagesize'];
																											
																																																							
																									$sql = $obj->Query("select tbl_order_itmes.storeid,tbl_order_itmes.section,tbl_order.id,tbl_order.ship_email,tbl_order.user_id,tbl_order.order_via,tbl_order.tax_value,tbl_order.delivery_type,tbl_order.order_type,tbl_order.total_amount,tbl_order.ship_type,tbl_order.order_date,tbl_order.usps_expected_delivery,tbl_order.tracking_no,tbl_order.payment_method,tbl_order.order_status,tbl_order.payment_status,tbl_order.delivery_note,tbl_order.sub_id,ship_fname,ship_lname,ship_house_no,ship_street,ship_complex,ship_landmark,ship_pincode,ship_area,ship_state,ship_city_id,ship_mobile,tbl_order.deliverby,tbl_order.is_send_to_vendor,tbl_order.vendor_sync_comments from $tbl_order inner join tbl_order_itmes on tbl_order.id=tbl_order_itmes.order_id where 1=1 $userlocationWhere $where group by tbl_order.id order by tbl_order.id desc limit $start,$pagesize");

																									$sql2 = $obj->query("select tbl_order_itmes.storeid,tbl_order.id,tbl_order.ship_email,tbl_order.user_id,tbl_order.order_via,tbl_order.tax_value,tbl_order.delivery_type,tbl_order.delivery_day,tbl_order.total_amount,tbl_order.ship_type,tbl_order.order_date,tbl_order.order_status,tbl_order.payment_status,tbl_order.delivery_note from $tbl_order inner join tbl_order_itmes on tbl_order.id=tbl_order_itmes.order_id where 1=1 $userlocationWhere $where group by tbl_order.id", $debug = -1);
																									// exit;
																									$reccnt = $obj->numRows($sql2);
																									
																									$gc_join = " JOIN tbl_giftcard_orders ON tbl_giftcard_orders.order_id = tbl_order.id JOIN "
																									?>

																									<td><?php if ($user_type == 'admin') { ?>
																										<table width="100%" border="0" cellspacing="0" cellpadding="0">

																												<tr align="center">

																														<td width="17%" class="text14" >Today : &nbsp;<strong>Total Order : <?php echo $numrows1 = $obj->numRows($obj->query("select tbl_order.id,tbl_order_itmes.storeid,tbl_order.order_date from $tbl_order inner join tbl_order_itmes on tbl_order.id=tbl_order_itmes.order_id where tbl_order.order_date like '%" . date('Y-m-d') . "%' $where group by tbl_order.id", $debug = -1)); ?> </strong></td>

																														<!--<td width="14%" class="text14"><strong>Delivered : <?php //echo $numrows11 = $obj->numRows($obj->query("select tbl_order.id,tbl_order_itmes.storeid,tbl_order.order_date from $tbl_order inner join tbl_order_itmes on tbl_order.id=tbl_order_itmes.order_id  where tbl_order.order_status=3 and tbl_order.order_date like '%" . date('Y-m-d') . "%' $where group by tbl_order.id")); ?></strong></td>

																														<td width="11%" class="text14"><strong>Declined : <?php //echo $numrows12 = $obj->numRows($obj->query("select tbl_order.id,tbl_order_itmes.storeid,tbl_order.order_date from $tbl_order inner join tbl_order_itmes on tbl_order.id=tbl_order_itmes.order_id  where tbl_order.order_status=5 and tbl_order.order_date like '%" . date('Y-m-d') . "%' $where group by tbl_order.id")); ?></strong></td>

																														<td width="23%" class="text14"><strong>Pending : <?php //echo $numrows1 - $numrows11 - $numrows12; ?></strong></td>-->

																												</tr>

																												<tr><td>&nbsp;</td></tr>

																												<tr align="center" style="font-weight:bold;">

																														<td width="17%" ><strong>Orders : &nbsp;Total Order : <?php echo $numrows1 = $obj->numRows($obj->query("select tbl_order.id,tbl_order_itmes.storeid,tbl_order.order_date from $tbl_order inner join tbl_order_itmes on tbl_order.id=tbl_order_itmes.order_id  where 1=1 $where group by tbl_order.id", $debug = -1)); ?> </strong></td>

																														<!--<td width="14%"><strong>Delivered : <?php //echo $numrows11 = $obj->numRows($obj->query("select tbl_order.id,tbl_order_itmes.storeid,tbl_order.order_date from $tbl_order inner join tbl_order_itmes on tbl_order.id=tbl_order_itmes.order_id  where tbl_order.order_status=3 $where group by tbl_order.id")); ?></strong></td>

																														<td width="11%"><strong>Declined : <?php //echo $numrows12 = $obj->numRows($obj->query("select tbl_order.id,tbl_order_itmes.storeid,tbl_order.order_date from $tbl_order inner join tbl_order_itmes on tbl_order.id=tbl_order_itmes.order_id  where tbl_order.order_status=5 $where group by tbl_order.id")); ?></strong></td>

																														<td width="23%"><strong>Pending : <?php //echo $numrows1 - $numrows11 - $numrowsl2; ?></strong></td>-->

																												</tr>

																												<tr><td>&nbsp;</td></tr>

																										</table><?php } ?></td>
																							</tr>
																					</table></td>
																	</tr>

																	<tr><td height="10"></td></tr>

																	<!----- Search End ---------> 
																	<!--<tr>
																			<td align="left" valign="middle" class="headingbg bodr text14">
																					<script>
																							$(document).ready(function () {

																									$(".iframerefund").colorbox({iframe: true, width: "800px;", height: "600px;", frameborder: "0", scrolling: true});
																							});
																					</script>	
																					<em><img src="images/arrow2.gif" width="21" height="21" hspace="10" align="absmiddle" /></em>Admin: View Gift Card Orders
																					<a href="addrefund.php"  class="iframerefund"><button name="refund" class="button" style="float:right; margin-right:30px; background:#FF6600; border:5px solid #FF6600; color:#fff; padding:3px 10px 3px 10px">Refund</button></a>
																			</td>
																	</tr>-->
																	
								<tr>
									<td align="left" valign="middle" class="headingbg bodr text14">
									<em><img src="images/arrow2.gif" width="21" height="21" hspace="10" align="absmiddle" /></em>Admin: View Gift Card Report
									<span style="float:right;">
									<form name="exportfrm" action="export-giftcard.php">
										<input type="hidden"  name="exportExcel" value="yes" />
										<input type="hidden" name="search_order_id" value="<?php echo $_REQUEST['search_order_id'];?>" />
										<input type="hidden" name="search_user_id" value="<?php echo $_REQUEST['search_user_id'];?>" />
										<input type="hidden" name="search_email" value="<?php echo $_REQUEST['search_email'];?>" />
										<input type="hidden" name="search_storename" value="<?php echo $_REQUEST['search_storename'];?>" />
										<input type="hidden" name="search_device" value="<?php echo $_REQUEST['search_device'];?>" />
										<input type="hidden" name="search_from_date" value="<?php echo $_REQUEST['search_from_date'];?>" />
										<input type="hidden" name="search_to_date" value="<?php echo $_REQUEST['search_to_date'];?>" />
										<input type="submit" name="export" class="button" value="Export To Excel" />
									</form>
									</span>
									</td>
								</tr>

																	<form name="frm" method="post" id="order-form" action="order-del.php" enctype="multipart/form-data">
																			<tr>
																					<td height="100" align="left" valign="top" bgcolor="#FFFFFF" class="bodr">
																							<table width="100%" cellpadding="0" cellspacing="0">

																									<?php if ($_SESSION['sess_msg']) { ?>

																											<tr>
																												<td  align="center">
																													<font color="#FF0000"><strong>
																														<?php
																															echo $_SESSION['sess_msg'];
																															$_SESSION['sess_msg'] = '';
																														?>
																													</strong></font>
																												 </td>
																											</tr>
																									<?php } ?>

																									<tr>
																											<td align="left">
																													<?php
																													if ($reccnt == 0) {
																															?>
																															<table width="100%" border="0" cellspacing="0" cellpadding="0">
																																	<tr>
																																			<td align="center" valign="middle"><font face="Arial, Helvetica, sans-serif"   color="#FF0000" size="+1">No Record</font></td>
																																	</tr>
																															</table>
																															<?php
																													} else {

																															if ($_REQUEST['search_customer_type'] != '') {

																																	$sql3 = $obj->Query("select tbl_order_itmes.storeid,tbl_order.id,tbl_order.ship_email,tbl_order.user_id,tbl_order.order_via,tbl_order.tax_value,tbl_order.delivery_type,tbl_order.delivery_day,tbl_order.total_amount,tbl_order.ship_type,tbl_order.order_date,tbl_order.payment_method,tbl_order.order_status,tbl_order.payment_status,tbl_order.delivery_note from $tbl_order inner join tbl_order_itmes on tbl_order.id=tbl_order_itmes.order_id where 1=1 $where  group by tbl_order.id order by tbl_order.id desc");

																																	$x = 0;

																																	while ($line3 = $obj->fetchNextObject($sql3)) {

																																			$cuArr = $obj->query("select count(*) as ucs from $tbl_order where user_id='$line3->user_id' and id<='$line3->id'");

																																			$urs = $obj->fetchNextObject($cuArr);

																																			if ($urs->ucs > 1) {
																																					$usercount = "Existing";
																																			} else {
																																					$usercount = "New";
																																			}

																																			if ($_REQUEST['search_customer_type'] == $usercount) {
																																					$x++;
																																			}
																																	} $reccnt = $x;
																															}

																															if ($reccnt == 0) {
																																	?>
																																	<table width="100%" border="0" cellspacing="0" cellpadding="0">
																																			<tr>
																																					<td align="center" valign="middle"><font face="Arial, Helvetica, sans-serif"   color="#FF0000" size="+1">No Record</font></td>
																																			</tr>
																																	</table>
																																	<?php
																															} else {
																																	?>

																																	<table width="100%" border="0" cellspacing="0" cellpadding="0">
																																			<tr>
																																					<td align="center" valign="middle"><strong><?php echo $reccnt; ?> Records Found.</strong></td>
																																			</tr>
																																	</table>

																																	<table width="100%" border="0" cellspacing="0" cellpadding="0">
																																			<tr>
																																					<th width="3%" align="left" class="padd5" bgcolor="#f3f4f6">S No.</th>
																																					<th width="4%" align="left" bgcolor="#f3f4f6" class="padd5">Order ID</th>
																																					<th width="7%" align="left" bgcolor="#f3f4f6" class="padd5">User Id / Email</th>
																																					
																																					<th width="7%" align="left" bgcolor="#f3f4f6" class="padd5">Card Name</th>
																																					<th width="9%" align="left" bgcolor="#f3f4f6" class="padd5">Sender</th>
																																					<th width="9%" align="left" bgcolor="#f3f4f6" class="padd5">Receiver</th>
																																					<th width="9%" align="left" bgcolor="#f3f4f6" class="padd5">Receiver Email</th>
																																					<th width="10%" align="left" bgcolor="#f3f4f6" class="padd5">Delivery Date</th>
																																					<th width="6%" align="left" bgcolor="#f3f4f6" class="padd5">Store Details</th>
																																					<th width="5%" align="left" bgcolor="#f3f4f6" class="padd5">Email Sent</th>
																																					<th width="5%" align="left" bgcolor="#f3f4f6" class="padd5">Wallet Added</th>
																																													
																																					<th width="5%" align="left" bgcolor="#f3f4f6" class="padd5">Total Amount</th>
																																					<th width="8%" align="left" bgcolor="#f3f4f6" class="padd5">Order Details</th>
																																					<th width="4%" align="left" bgcolor="#f3f4f6" class="padd5">Payment Status</th>
																																					<th width="9%" align="left" bgcolor="#f3f4f6" class="padd5">Customer Details</th>
																																			</tr>
																																	 <?php
																																			$i = 0;
																																			$new_order_id = '';

																																			while ($line = $obj->fetchNextObject($sql)) {
																																				
																																				$sql_gc = $obj->query("select * from $tbl_giftcard_orders gc JOIN $tbl_giftcard_order_emails gce ON gc.id = gce.giftcard_order_id where gc.order_id=".$line->id);
																																				
																																				$record_gc = $obj->numRows($sql_gc);
																																				
																																				$prosub='';
																																																							
																																				/*if ($_REQUEST['search_customer_type'] != '') {

																																						$cuArr = $obj->query("select count(*) as ucs from $tbl_order where user_id='$line->user_id' and id<='$line->id'");

																																						$urs = $obj->fetchNextObject($cuArr);

																																						if ($urs->ucs > 1) {
																																								$usercount = "Existing";
																																						} else {
																																								$usercount = "New";
																																						}
																																				}*/
																																				
																																				
																																				if($record_gc > 0){

																																				while($result_gc = $obj->fetchNextObject($sql_gc)) {
																																					
																																					
																																					if ($_REQUEST['search_customer_type'] == $usercount) {
																																							$i++;
																																							if ($line->delivery_day != '') {
																																									$bgcolor = "#66CCFF";
																																							} else {
																																									if ($i % 2 == 0) {
																																											$bgcolor = "#f3f4f6";
																																									} else {
																																											$bgcolor = "";
																																									}
																																							}
																																																																	
																																							?>

																																							<tr bgcolor="<?php echo $bgcolor; ?>">
																																							
																																									<td class="padd5"><strong>
																																										<?php 
																																										if($new_order_id != $line->id){
																																												$new_order_id = $line->id;
																																												echo $i + $start; 
																																										}
																																										else{
																																											echo "&nbsp;";
																																										}
																																										?>
																																										</strong>
																																									</td>
																																									
																																									<td class="padd5"><?php	echo stripslashes($line->id);	?></td>
																																									
																																									<td class="padd5">
																																											<?php	echo stripslashes($line->user_id) . " <br/>" . stripslashes($line->ship_email) . " ";	?>
																																									</td>																																				<td class="padd5"><?php	echo ucfirst(stripslashes($result_gc->card_type))." ".ucfirst(stripslashes($result_gc->card_cat));	?></td>
																																									
																																									
																																									<td class="padd5"><?php	echo stripslashes($result_gc->sender);	?></td>
																																									<td class="padd5"><?php	echo stripslashes($result_gc->receiver);	?></td>
																																									<td class="padd5"><?php	echo stripslashes($result_gc->receiver_email);	?></td>
																																									<td class="padd5"><?php	echo date('d-m-Y', strtotime($result_gc->delivery_date));	?></td>
																																									<td class="padd5"><?php	echo stripslashes($result_gc->storename)." ".stripslashes($result_gc->store_location);	?></td>
																																									<td class="padd5"><?php	echo ($result_gc->email_flag == 1 ? 'Yes' : 'No');	?></td>
																																									<td class="padd5"><?php	echo ($result_gc->wallet_flag == 1 ? 'Yes' : 'No');	?></td>
																																									
																																									<td class="padd5">
																																											<?php
																																											echo $website_currency_symbol . " " . number_format($line->total_amount, 2);
																																											?>
																																									</td>
																																									
																																									<td class="padd5">
																																											<?php echo date('d M Y H:i', strtotime($line->order_date)); ?><br />
																																											<?php echo stripslashes($line->order_via); ?><br />
																																											<?php	echo getField('order_status', $tbl_order_status, $line->order_status);	?>
																																									</td>

																																									<td align="center" class="padd5">
																																											<?php if ($line->payment_status == 1) { ?>
																																													<img src="images/green.gif" title="Successfull" />
																																											<?php } else { ?>
																																													<img src="images/red.gif" title="Unsuccessfull" />
																																											<?php } ?>																	
																																									</td>


																																									<td class="padd5"><?php echo ucwords($line->ship_fname . " " . $line->ship_lname); ?><br /><?php echo $line->ship_mobile; ?><br />

																																											<strong>Add:</strong> <?php 

																																											if($line->ship_full_address==''){

																																													echo $line->ship_house_no . ", " . $line->ship_street . ", " . $line->ship_complex . ", " . $line->ship_area . " " . $line->ship_city_id . " " . $line->ship_state . ", " . $line->ship_pincode;

																																											} else {

																																													echo $line->ship_full_address. ", ".$line->ship_complex .", " . $line->ship_pincode;

																																											}?>
																																									</td>                                
				 
																																							</tr>
																																							<?php
																																					}
																																				}
																																			}
																																			}
																																			?>
																																			<tr>
																																					<td valign="top" colspan="15"  align="right">&nbsp;
																																					</td>  
																																			</tr>    			
																																			<tr>
																																					<td valign="top" colspan="15"  align="right" class="dark_red" style="padding-right:150px;">&nbsp;</td>
																																			</tr>

																																			<tr>
																																					<td valign="top" colspan="12"  align="right" class="dark_red" style="padding-right:150px;"><?php include("../include/paging.inc.php"); ?>
																																					</td> <td colspan="3"></td>  </tr>  
																																			<tr>
																																					<td valign="top" colspan="15"  align="right" class="dark_red" style="padding-right:150px;">&nbsp;</td>
																																			</tr>

																																		<!--<tr>
																																					<td colspan="13"></td>
																																					<td align="right"  style="padding-right:80px;" colspan="2">  <a href="javascript:;" onclick="addBulkComments();"  class="iframeAddc<?php echo $line->id; ?>"><img src="images/add.png" border="0" title="Add Comment" width="20" height="20"  /></a> 
																																					</td>
																																					<td align="right"  style="padding-right:80px;" colspan="2"> <input type="hidden" name="what" value="what" />
																																							<input type="submit" name="Submit" value="Delete" class="button" onclick="return del_prompt(this.form, this.value)" /> 
																																					</td>
																																			</tr>-->

																																	</table><?php
																													}
																											}
																															?>
																											</td>
																									</tr>
																							</table>
																					</td>
																			</tr>
																	</form>
															</table>
													</td>
											</tr>
									</table>
							</td>
					</tr>

					<tr><td height="100"></td></tr>

					<?php include('footer.php'); ?>
					<script>
							/*function addBulkComments() {

									var checkedVals = $('.order-checkbox:checkbox:checked').map(function () {
											return this.value;
									}).get();

									///alert(checkedVals.join(","));
									if (checkedVals != '') {
											$.colorbox({href: "addcommetsBulk.php?order_id=" + checkedVals, iframe: true, width: "700px;", height: "500px;", frameborder: "0", scrolling: true});
									} else {
											alert("Please select checkbox for bulk action");
									}
							}*/
					</script>
        </table>
    </body>
</html>







