<?php 
include("includes/db_config.php");

$sqlid="select * from user_profile ";
$result = mysqli_query($conn, $sqlid);
								
?>


<!DOCTYPE html>
<html lang="en-IN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	  <title>Orange Groceries</title>
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<?php include("includes/css.php")?>
</head>
<body class="hold-transition skin-blue sidebar-mini">
	<div class="wrapper">
		<?php include("includes/header.php");?>
		<?php include("includes/sidebar.php");?>
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<section class="content-header">
				<h1>
					Dashboard
					<small>Control panel</small>
				</h1>
				<ol class="breadcrumb">
					<li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
					<li class="active">Dashboard</li>
				</ol>
			</section>
			<!-- Main content -->
			<section class="content">
				<div class="row">
					<div class="col-xs-12">
						<div class="box box-danger">
							<div class="box-header">
								<div class="row">
									<div class="col-md-12"><h3 class="box-title">Customer Details</h3></div> 
								</div>
							</div>
							<div class="box-body table-responsive">
								<table class="table table-bordered table-striped example3">
									<thead>
										<tr> 
											<th>Sr. No</th>
											<th>Customer Name</th>
											<th>Email</th>
											<th>Contact No.</th> 
											<th>Address</th> 
											<th>Image</th>
											<th>View</th>
											
											<th>Delete</th>
										</tr>
									</thead>
									<tbody>
										<?php
											 $j=1;
											while($res= mysqli_fetch_array($result))
											{ 
												$country=$res['country'];
								$state=$res['state'];
								$city=$res['city'];

								$sql_country = mysqli_query($conn,"select * from countries where id = '$country'");
								$row_country = mysqli_fetch_array($sql_country);
								$sql_state = mysqli_query($conn,"select * from states where id = '$state'");
								$row_state = mysqli_fetch_array($sql_state);
								$sql_city = mysqli_query($conn,"select * from cities where id = '$city'");
								$row_city = mysqli_fetch_array($sql_city);

								/*$shp_country=$resid['shp_country'];
								$shp_state=$resid['shp_state'];
								$shp_city=$resid['shp_city'];
								$sql_country = mysqli_query($conn,"select * from countries where id = '$shp_country'");
								$s_country = mysqli_fetch_array($sql_country);
								$sql_state = mysqli_query($conn,"select * from states where id = '$shp_state'");
								$s_state = mysqli_fetch_array($sql_state);
								$sql_city = mysqli_query($conn,"select * from cities where id = '$shp_city'");
								$s_city = mysqli_fetch_array($sql_city);*/
											?>
										<tr>  
											<td><?php echo $j; $j++; ?></td>
											<td><?php echo $res['fname']. " " .$res['lname']; ?></td> 
											<td><?php echo $res['email']; ?></td> 
											<td><?php echo $res['mob_no']; ?></td> 
											<td><?php $addr=  $res['addr'].", ".$row_city['name'].", ".$row_state['name'].", ".$row_country['name']; echo $addr; ?></td> 
											<td> <img src="img/profile/<?php echo $res['prof_img']; ?>" style="height:50px;" alt="your image" class="img-responsive"/></td>
											<td><a href="customer-details.php?id=<?php echo $res['id']; ?>"><i class="fa fa-eye"></i></a></td> 
											
											<td><a href="javascript:delete_cust_by_ID('<?php echo $res['id']; ?>');" class="ask"><i class="fa fa-trash-o"></i></a></td>
										</tr> 		
										<?php } ?>							
									</tbody>
								</table>
							</div>
							<!-- /.box-body -->
						</div>
						<!-- /.box -->
					</div>
					<!-- /.col -->
				</div>
				<!-- /.row -->
			</section>
			<!-- /.content -->
		</div>
		<!-- /.content-wrapper -->
		<?php include("includes/footer.php");?>
		<div class="control-sidebar-bg"></div>
	</div>
	<?php include("includes/js.php");?>
<script type="text/javascript">
	
	function delete_cust_by_ID(id)
		{
			if (confirm('Do You Want to Deleting This \nContinue anyway?')) {
				window.location.href = 'delete_customer.php?id=' + id;
			}
		}

</script>
</body>
</html>
