<?php include_once('../includes/head.php'); ?>
<?php include_once('includes/admin_auth.php'); ?>
<?php
	$tlist='';
	include('../includes/connection.php');
	if(isset($_POST['search'])){
		$date1 = $_POST['date1'];
		$date2 = $_POST['date2'];
		
		$getT = mysql_query("SELECT * FROM `customer` where date_of_added BETWEEN '$date1' AND '$date2'");
		$getR = mysql_num_rows($getT);
		$tlist='';
		if($getR>0){
			while($row = mysql_fetch_array($getT)){
				$name = $row['name'];
				$id = $row['id'];
				$email = $row['email'];
				$phone = $row['phone'];
				$amount = $row['amount'];
				$DID = $row['direcPay_ID'];
				$date = $row['date_of_added'];
				$status = $row['flag'];
				
				$tlist.='<tr>
									<td>'.$name.'</td>
									<td>'.$email.'</td>
									<td>'.$phone.'</td>
									<td>'.$amount.'</td>
									<td>'.$DID.'</td>
									<td>'.$status.'</td>
									<td>'.$date.'</td>
									<td><a href="view-transaction.php?tid='.$id.'" target="_blank">View</a></td>
								</tr>';
			}
	}
	}
?>
	</head>
	<body>
		<?php include_once('../includes/header.php'); ?>
        <div class="container">
			<div class="row">
				<?php include_once('../includes/sidebar.php'); ?>
				<!-- Add new sidebar box here -->
				</div><!--Dont remove it-->
				<div class="col-sm-12 admin-content">
					<div class="title col-sm-12" style="padding:0;">Advanced Search</div><br>
					<hr/>
						<div class="col-sm-12" style="padding:0;border:1px solid #e2e2e2;padding:15px;">
							<form action="search.php" method="post">
								<div class="col-sm-6">
									<b>Select Start Date :</b> <input type="date" name="date1" class="form-control"> 
								</div>
								<div class="col-sm-6">
									<b>Select End Date :</b> <input type="date" name="date2" class="form-control"> 
								</div>
								<div class="col-sm-12" style="margin-top:10px;">
									<input type="submit" name="search" value="Search" class="btn btn-primary"> 
								</div>
							</form>
						</div>
						<div class="col-sm-12" style="padding:0;border:1px solid #e2e2e2;padding:15px;">
							<font>Report In Between : <b><?php echo $date1; ?></b> AND <b><?php echo $date2; ?></b></font>
							<table class="table table-bordered" id="t1-table">
							<tr>
								<th>Name</th>
								<th>Email</th>
								<th>Phone</th>
								<th>Amount</th>
								<th>Reference ID</th>
								<th>Status</th>
								<th>Transaction Date</th>
								<th>Action</th>
							</tr>
							<?php echo $tlist; ?>
							<tr>
								<th>Total:</th>
								<th></th>
								<th></th>
								<th id="table8Tot1">Amount</th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
							</tr>
						</table>
						</div>
				</div>
			</div>
			<hr>
		</div>
		
		<?php include_once('../includes/footerjs.php'); ?>
		<script>
			var totRowIndex = tf_Tag(tf_Id('t1-table'), "tr").length;
			var table2_Props = {
				paging: true,  
                    paging_length: 8,  
                    rows_counter: true,  
                    rows_counter_text: "Rows:",
				btn_reset: true,
				col_5: "select",
				col_6: "select",
				col_7: "none",
				display_all_text: "--",
				highlight_keywords: true,
				sort_select: true,
				col_operation: {
					id: ["table8Tot1"],
					col: [3],
					operation: ["sum"],
					write_method: ["innerHTML"],
					exclude_row: [totRowIndex],
				},
				
			};
			var tf2 = setFilterGrid("t1-table", table2_Props);
		
		</script>
	</body>
</html>