<?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">Sub Category</h4>
						 
					</div>
					<div class="row">
						<div class="col-md-12">
							<div class="card">
								
								<div class="card-body">
								<!--<div class="d-flex justify-content-center">-->
								<!--    <button type="button" class="btn btn-success" data-target="#exampleModal" data-toggle="modal" >-->
        <!--                                <i class="fas fa-plus"></i>   Add New Sub Category-->
        <!--                            </button>-->
								<!--</div>-->
									<div class="table-responsive">
										<table id="basic-datatables" class="display table table-striped table-hover" >
											<thead>
												<tr>
													<th>S.No</th>
													<th>Main Category</th>
													<th>Sub Category</th>
													<!--<th>Overview And Image </th>-->
													<!--<th>Course Content</th>-->
													<!--<th>Course Duration</th>-->
													<th>Sub Category Status</th>
													<th>Action</th>
												</tr>
											</thead>
											 
											<tbody>
											<?php 
											$sc=1;
											$sub_cate=mysqli_query($config,"select * from sub_category");
											while($subcate=mysqli_fetch_object($sub_cate))
											{
											?>
												
												
												<tr>
													<td><?php echo $sc;?></td>
													<td><?php 

												$Main_id=$subcate->Main_Category_sub;
												
												$subsmain_cate=mysqli_query($config,"select Main_Category_Name from main_category where Main_Category_id='$Main_id'");
											 $main_subcatee=mysqli_fetch_object($subsmain_cate);
												
												
												echo  $main_subcatee->Main_Category_Name;
												
												?></td>
												<td><?php echo $subcate->Sub_Category_Name;?></td>
												<!--<td><a class="btn btn-success" href="add_course_img.php?sid=<?php echo $subcate->Sub_Category_id;?>"><i class="fas fa-plus"></i> Add</a></td>-->
												<!--<td><a class="btn btn-success" href="add_course_details.php?sid=<?php echo $subcate->Sub_Category_id;?>"><i class="fas fa-plus"></i> Add</a></td>-->
												<!--<td><a class="btn btn-success" href="add_course_duration.php?sid=<?php echo $subcate->Sub_Category_id;?>"><i class="fas fa-plus"></i> Add</a></td>-->
													<td><?php 

													$enablestatus=$subcate->Sub_Category_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 class="d-flex align-items-center">
<a href="" class="btn btn-primary" data-toggle="modal" data-target="#<?php echo $sc;?>" style="margin-right:10px;"> <i class="fas fa-pencil-alt"></i>  </a>
<!--<a href="Function/sub_category_delete.php?delcateid=<?php # echo $subcate->Sub_Category_id;?>&delcat=300" class="btn btn-danger" onclick="return confirm('Are you confirm to delete this Sub category?');"> <i class="fas fa-trash"></i>  </a>-->

 

</td>

<!-- Modal -->
<div class="modal fade" id="<?php echo $sc;?>" 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">Sub Category Edit</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_sub_category.php" method="post" enctype="multipart/form-data">
        <div class="form-group">
			<label for="email2">Main Category Name</label>
			<input type="hidden" class="form-control" id="email2" name="main_cate_id"  value="<?php echo $subcate->Sub_Category_id;?>">
			<input type="text" class="form-control" id="email2" name="Edit_sub_cate_name" readonly placeholder="Sub Category Name" value="<?php $Main_id=$subcate->Main_Category_sub;
												
												$subsmain_cate=mysqli_query($config,"select Main_Category_Name from main_category where Main_Category_id='$Main_id' And sub_menu = 1 ");
											 $editsubcatee=mysqli_fetch_object($subsmain_cate);
												
												
												echo  $editsubcatee->Main_Category_Name;?>">
			</div>
        


	<div class="form-group">
			<label for="email2">Sub Category Name</label>
			<input type="text" class="form-control" id="email2" name="Edit_sub_cate_name" placeholder="Sub Category Name" value="<?php echo $subcate->Sub_Category_Name;?>">
			</div>



			<div class="form-group" style="display:none">
			<img src="../../photos/Slider/<?php echo $subcate->Add_sub_cate_icon;?>" style="width:100px;" >

			<label for="email2">Icon (250px * 250px)</label>
			<input type="file" class="form-control" id="email2" name="Add_sub_cate_icon" placeholder="Sub Category Name"  >
			</div>  



		<div class="form-group">
												<label for="exampleFormControlSelect1">Sub Category Active Status</label>
												<select class="form-control" id="exampleFormControlSelect1" name="subcate_status">
												<?php 

													$enablestatus=$subcate->Sub_Category_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="Sub_category_content_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 $sc++;} ?>
												
											</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 Sub Category</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_sub_category.php " method="post" enctype="multipart/form-data">
       

  <div class="form-group">
			<label for="email2">Main Category Name</label>
			<select class="form-control" name="Add_sub_main_cate_Name">
			<?php
			
			$main_cate=mysqli_query($config,"select * from main_category where Main_Category_Status=1 And sub_menu = 1");
											while($addsubcate=mysqli_fetch_object($main_cate))
											{
			
			
			?>
			
			<option value="<?php echo $addsubcate->Main_Category_id;?>"><?php echo $addsubcate->Main_Category_Name;?></option>
			
			
			
			
											<?php } ?>
			
			</select>
 			
			</div> 



	        <div class="form-group">
    			<label for="email2">Sub Category Name</label>
    			<input type="text" class="form-control" id="email2" name="Add_sub_cate_name" placeholder="Sub Category Name"  >
			</div>  

			<div class="form-group" style="display:none">
			<label for="email2">Icon (250px * 250px)</label>
			<input type="file" class="form-control" id="email2" name="Add_sub_cate_icon" placeholder="Sub Category Name"  >
			</div>  
       
		 <div class="form-group">
		<label for="exampleFormControlSelect1">Sub Category Active Status</label>
		<select class="form-control" id="exampleFormControlSelect1" name="Add_sub_category_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="sub_category_add">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="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
      $('#summernote').summernote({
        placeholder: 'Hello Bootstrap 4',
        tabsize: 2,
        height: 100
      });
    </script>
	<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>