<?php include('../config/setup.php');?>
<?php include "head.php" ?>


	<div class="wrapper">
		<div class="main-header">
			<!-- Logo Header -->
			 <?php include('logo.php');?>
			<!-- End Logo Header -->

			<!-- Navbar Header -->
			<?php include('topbar.php');?>
			 <!-- End Navbar -->
		</div>
		<!-- Sidebar -->
		<?php include('sidebar.php');?>
		
		
		<div class="main-panel">
			<div class="content">
				<div class="page-inner">
					<div class="page-header">
						<h4 class="page-title">Location Master</h4>
						 
					</div>
					<div class="row">
						<div class="col-md-12">
							<div class="card">
								
								<div class="card-body">
								<center> <button type="button" class="btn btn-success" data-toggle="modal" data-target="#exampleModal">
                                    <i class="fas fa-plus"></i>   Add New Location
</button></center>
									<div class="table-responsive">
										<table id="basic-datatables" class="display table table-striped table-hover" >
											<thead>
												<tr>
													<th>S.No</th>
													<th> Location Name</th>
														
													 <th>Status</th>
													<th>Action</th>
												</tr>
											</thead>
											 
											<tbody>
											<?php 
											$mc=1;
											$main_loc=mysqli_query($config,"select * from city_master");
											while($macate=mysqli_fetch_object($main_loc))
											{
											?>
												
												
												<tr>
													<td><?php echo $mc;?></td>
													<td><?php echo $macate->City_Name;?></td>
													

													<td><?php 

													$enablestatus=$macate->City_Status;
													
													if($enablestatus== 1)
													{ ?>
												<label class="btn btn-success text-white">Active</label>
<?php														
													}else{
														?>
														<label class="btn btn-danger text-white">In-Active</label>
														<?php
													}
													
													
													?></td>
													<td>
													<a href="" class="btn btn-primary" data-toggle="modal" data-target="#<?php echo $mc;?>"> <i class="fas fa-pencil-alt"></i>  </a>

 <a href="Function/location_delete.php?delprefid=<?php echo $macate->City_id;?>&redelpt=700" class="btn btn-danger" onclick="return confirm('Are you confirm to delete this City?');"> <i class="fas fa-trash"></i>  </a>

 

</td>
 		<div class="modal fade" id="<?php echo $mc;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Edit Location Status</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
	  <form action="Function/Edit_location_Master.php" method="post">
        <div class="form-group">
			<label for="email2">Location Name</label>
			<input type="hidden" class="form-control" id="email2" name="Location_id"  value="<?php echo $macate->City_id;?>">
			 
			<input type="text" class="form-control" id="email2" name="Location_Name"  value="<?php echo $macate->City_Name;?>">
			 
		</div> 
		
		<div class="form-group" style="display:none">
			<label for="email2">District Name</label>
			
			 
			<input type="text" class="form-control" id="email2" name="distr_Name"  value="<?php echo	$macate->City_district;?>">
			 
		</div> 
		
	
		
		
		  <div class="form-group">
	<label for="exampleFormControlSelect1">City Status</label>
												<select class="form-control" id="exampleFormControlSelect1" name="location_status">
												<?php 

													$enablestatus=$macate->CIty_Status;
													
													if($enablestatus == 1)
													{ ?>
												
													<option value="1" selected>Active</option>
													<option value="0">In-Active</option>
													<?php }else if($enablestatus == 0){?>

														<option value="1" >Active</option>
													<option value="0" selected>In-Active</option>
													<?php }else{ ?>
													<option value="1" >Active</option>
													<option value="0" >In-Active</option>
													
													
													<?php } ?>
												
												</select>
											</div>			
		
		     <div class="form-group">
									<button class="btn btn-success" type="submit" name="city_edit">Submit</button>
 								</div>
			
			
			</form>
			
			
      </div>
 
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
         
      </div>
    </div>
  </div>
</div>							
													 
												</tr>
												
											<?php $mc++;} ?>
												
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
	</div>
				</div>
			</div>
			
			<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Add New Location</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form action="Function/add_location.php" method="post" enctype="multipart/form-data">
     
			<div class="form-group" style="display:none">
			<label for="email2">District Name</label>
			<input type="text" class="form-control" id="email2" name="Add_district_name" placeholder="Enter New District Name"  >
			</div>  
			 	<div class="form-group" >
			<label for="email2">Location Name</label>
			<input type="text" class="form-control" id="email2" name="Add_location_name" placeholder="Enter New Location Name"  >
			</div> 
			  
		 <div class="form-group">
		<label for="exampleFormControlSelect1">Location Status</label>
		<select class="form-control" id="exampleFormControlSelect1" name="Add_location_status">
		<option value="1">Active</option>
		<option value="0">In-Active</option>
		
		</select>
											</div>	
 		
		     <div class="form-group">
									<button class="btn btn-success" type="submit" name="add_new_location">Add New</button>
 								</div>
			
			
			</form>
	
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        
      </div>
    </div>
  </div>
</div>
			
			
			
			
			
			
			
			
			
			
			
			
			
			 <?php include('footer.php');?>
		</div>
		
		 
		<!-- End Custom template -->
	</div>
	<!--   Core JS Files   -->
	<script src="../assets/js/core/jquery.3.2.1.min.js"></script>
	<script src="../assets/js/core/popper.min.js"></script>
	<script src="../assets/js/core/bootstrap.min.js"></script>
	<!-- jQuery UI -->
	<script src="../assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
	<script src="../assets/js/plugin/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js"></script>
	
	<!-- jQuery Scrollbar -->
	<script src="../assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>
	<!-- Datatables -->
	<script src="../assets/js/plugin/datatables/datatables.min.js"></script>
	<!-- Atlantis JS -->
	<script src="../assets/js/atlantis.min.js"></script>
	<!-- Atlantis DEMO methods, don't include it in your project! -->
	<script src="../assets/js/setting-demo2.js"></script>
	<script >
		$(document).ready(function() {
			$('#basic-datatables').DataTable({
			});

		 
 
			 
		});
	</script>
</body>
</html>