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

<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<title><?php 
            
            $leename=mysqli_query($config,"select Name,Name_status from lee_master");
            while($lee=mysqli_fetch_array($leename))
            {
                 $namestatus=$lee[1];
if($namestatus == 1)
{
    echo  $lee[0];
}else{
    echo "Need Name";

}

            }
            
            ?>  </title>
	<meta content='width=device-width, initial-scale=1.0, shrink-to-fit=no' name='viewport' />
	<link rel="icon" href="<?php 
            
            $inro_logo=mysqli_query($config,"select Logo_Path,logo_status from lee_master");
            while($logo=mysqli_fetch_array($inro_logo))
            {
                 $logstatus=$logo[1];
if($logstatus == 1)
{
	
	 $ms=substr($logo[0],3);
				//   echo  $ms;
				echo "../../photos/logo/favicon.ico";
	
     
}else{
    echo "../../photos/logo/no_logo.png";

}

            }
            
            ?>" type="image/x-icon"/>
	
	 	 
	<!-- Fonts and icons -->
	<script src="../assets/js/plugin/webfont/webfont.min.js"></script>
	<script>
		WebFont.load({
			google: {"families":["Lato:300,400,700,900"]},
			custom: {"families":["Flaticon", "Font Awesome 5 Solid", "Font Awesome 5 Regular", "Font Awesome 5 Brands", "simple-line-icons"], urls: ['../assets/css/fonts.min.css']},
			active: function() {
				sessionStorage.fonts = true;
			}
		});
	</script>
 
	<!-- CSS Files -->
	<link rel="stylesheet" href="../assets/css/bootstrap.min.css">
	<link rel="stylesheet" href="../assets/css/atlantis.min.css">
	<!-- CSS Just for demo purpose, don't include it in your project -->
	<link rel="stylesheet" href="../assets/css/demo.css">
	<!-- <script src='https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.0.5/tinymce.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'> -->

</script><script  src="notes/script.js"></script>

</head>
<body>
	<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">
				    <?php  
					    $sid = $_GET['sid'];
						$sql = "select * from sub_category WHERE Sub_Category_id = '$sid' ";
						$res = $config->query($sql);
						$sub = $res->fetch_assoc();
					?>
					<!-- course content -->
					<div class="page-header">
						<h4 class="page-title">Add Course Duration (<?= $sub['Sub_Category_Name'] ?>)</h4>	
						<a href="sub_category_Master.php" class="btn btn-info" style="margin-left:auto;">Back</a>
					</div>
					<div class="row">
						<div class="container">
							<div class="col-md-12">
							    <?php
								    if(isset($_GET['change'])){
								        $cd_id = $_GET['change'];
								        $sql= "SELECT * FROM course_duration WHERE cd_id = '$cd_id' ";
        								$res = $config->query($sql);
        								$edit = $res->fetch_assoc();
								?>
								<div class="d-flex justify-content-center">
            					    <a href="add_course_duration.php?sid=<?= $edit['cd_sub_cate_id'] ?> " class="btn btn-success"><i class="fas fa-plus"></i>Add new</a>
            					</div>
							        <form action="edit_course_details.php" method="post">
                                        <div class="form-group">
                                            <label for="cc_title">Title</label>
                                            <input type="text" class="form-control" id="cd_title" name="cd_title" value="<?= $edit['cd_title'] ?>">
                                        </div>
                                        <div class="form-group">
                                            <label for="">Description</label>
                                            <textarea id="cd_desc" name="cd_desc" style="width:100%;" ><?= $edit['cd_desc'] ?></textarea>
                                        </div>
									    <input type="hidden" name="cd_edit_id" value="<?= $edit['cd_id'] ?>">
									    <input type="hidden" name="Sub_Category_id" value="<?= $edit['cd_sub_cate_id'] ?>">
									    <input type="hidden" name="action" value="cd_edit">
									    <button type="submit" name="submit" class="btn btn-warning my-3">Submit</button>
								    </form>
								<?php
								    }else{
								?>
								<!-- course duration -->
								<form action="edit_course_details.php" method="post">
									<div class="form-group">
										<input type="hidden" class="form-control" name="Sub_Category_id"  value="<?= $sub['Sub_Category_id'] ?>">		
										<input type="hidden" class="form-control" name="Main_Category_sub"  value="<?= $sub['Main_Category_sub'] ?>">		
										<label for="cd_title">Title</label>
										<input type="text" class="form-control" name="cd_title" >		
									</div> 
									<div class="form-group">
										<label for="cd_desc">Topics &nbsp; (Avoid this symbol ( ' ))</label>
										<textarea name="cd_desc" style="width:100%;" id="cd_desc"></textarea><br>	 
									</div> 
									<div class="form-group">
									    <input type="hidden" name="action" value="cd_add" >
										<button class="btn btn-success" type="submit" >Submit</button>
									</div>
								</form>
								<?php } ?>
							</div>
						</div>
					</div>
					<!-- course content table-->
					<div class="page-header">
						<h4 class="page-title">Course Duration</h4> 
					</div>
					<div class="row">
						<div class="col-md-12">
							<div class="card">
								<div class="card-body">
									<div class="table-responsive">
										<table id="basic-datatables" class="display table table-striped table-hover" >
											<thead>
												<tr>
													<th>S.No</th>
													<th>Title</th>
													<th>Description</th>
													<!--<th>Status</th>-->
													<th>Action</th>
												</tr>
											</thead>
											<tbody>
											    <?php 
        											$sno=1;
        											$sql= "SELECT * FROM course_duration WHERE cd_sub_cate_id = '".$sub['Sub_Category_id']."' ";
        											$res = $config->query($sql);
        											while($cd = $res->fetch_assoc()){
        										?>
											    <tr>
													<td><?= $sno ?></td>
													<td><?= $cd['cd_title'] ?></td>
													<td><?= $cd['cd_desc'] ?></td>
													<td class="d-flex align-items-center">
													    <a href="add_course_duration.php?change=<?= $cd['cd_id'] ?>&sid=<?= $sub['Sub_Category_id'] ?> " class="btn btn-primary" style="margin-right:10px;"><i class="fas fa-pencil-alt"></i></a>
													    <form action="edit_course_details.php" method="post">
    													    <input type="hidden" name="cd_del_id" value="<?= $cd['cd_id'] ?>">
    													    <input type="hidden" name="Sub_Category_id" value="<?= $sub['Sub_Category_id'] ?>">
    													    <input type="hidden" name="action" value="cd_del">
    													    <button type="submit" name="submit" class="btn btn-danger" onclick="return confirm('Are you confirm to delete this?');"><i class="fas fa-trash"></i></button>
													    </form>
													</td>
												</tr> 
											    <?php $sno++; } ?>
											    
											    
											    
											    
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>	    
				</div>
			</div>

				<?php include('footer.php');?>	
		</div>
		<!-- End Custom template -->
	</div>
<script type="text/javascript" src="richtext.js"></script> 
  <script type="text/javascript">
 
        bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
  </script>
	<!--   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>