<!DOCTYPE html>
<html lang="en">
<?php include('fixed/top.php');  ?>
    <style>
    .optionGroup {
    font-weight: bold;
    font-style: italic;
}
    
.optionChild {
    padding-left: 25px;
}</style>
<body>
  <div class="loader"></div>
  <div id="app">
    <div class="main-wrapper main-wrapper-1">
      <div class="navbar-bg"></div>

       <?php include('fixed/navigation.php');  ?>
      <!-- Main Content -->
      <div class="main-content">
        <section class="section">
          <div class="section-body">
            <div class="row">
              <div class="col-10">
                   <?php echo $this->session->flashdata('msg'); ?>
                <div class="card">
                  <div class="card-header">
                    <h4><?=$title?></h4>
                  </div>
                  <div class="card-body">
                   <form method="post" action="<?php echo base_url(); ?>admin/do_add_course_details/<?php if(!empty($course_data)){ echo $course_data->id; } ?>" enctype="multipart/form-data">
                    <div class="form-group">
                      <label>Category</label>
                     <select class="form-control" name="category">
                        <option value="">Please Select</option>
                         <?php if(!empty($category_data)) { foreach($category_data as $category) { ?>
                        <option <?php if(! empty($course_data) && $course_data->category == $category->id) echo 'selected'; ?>  class="optionGroup" value="<?=$category->id?>"><?=$category->name?></option>
                        <?php $sub_cat_data =  $this->db->get_where('prepare_category', array('parent_id'=>$category->id))->result(); 
                         if(!empty($sub_cat_data)){ foreach($sub_cat_data as $subcat){ ?><option <?php if(! empty($course_data) && $course_data->category == $subcat->id) echo 'selected'; ?> class="optionChild" value="<?=$subcat->id?>">&nbsp;&nbsp;&nbsp;&nbsp;<?=$subcat->name?></option>
                         <?php }} }} ?>
                        </select>
                    </div> 
                    <div class="form-group">
                      <label>Description</label>
                      <textarea name="textarea1" id="myNicEditor" class="form-control"><?php if(!empty($course_data)) echo $course_data->description ?></textarea>
                    </div>
                       <div class="form-group">
                      <label>Features</label>
                      <textarea name="textarea2" id="myNicEditor2" class="form-control"><?php if(!empty($course_data)) echo $course_data->features ?></textarea>
                    </div>
                     <?php if(!empty($course_data) && !empty($course_data->banner)) { ?>
                    <div class="form-group">
                   <label>Banner Image</label>
                     <img class="d-block w-100" src="<?php echo base_url(); ?>uploads/front/banner_image/<?=$course_data->banner?>" alt="<?=$course_data->category?>" style="">
                    </div>
                     <?php } ?>
                    <div class="form-group">
                      <label><?php if(!empty($course_data)) echo 'Upload New '; ?>Banner Image</label>
                      <input name="main_image" type="file" class="form-control">
                       <input name="ext_photo" type="hidden" class="form-control" value="<?php if(!empty($course_data)) echo $course_data->banner ?>">  
                    </div>
                       <div class="form-group">
                      <label>Banner title</label>
                      <input type="text" name="banner_title" class="form-control" value="<?php if(!empty($course_data)) echo $course_data->title ?>">
                    </div>
                       <!---sec image---->
                          <?php if(!empty($course_data) && !empty($course_data->sec_image)) { ?>
                    <div class="form-group">
                   <label>Description Image</label>
                     <img style="height:200px;width:200px;" class="d-block" src="<?php echo base_url(); ?>uploads/front/courses/<?=$course_data->sec_image?>" alt="<?=$course_data->category?>" style="">
                    </div>
                     <?php } ?>
                    <div class="form-group">
                      <label><?php if(!empty($course_data)) echo 'Upload New '; ?>Description Image</label>
                      <input name="main_image1" type="file" class="form-control">
                       <input name="ext_photo1" type="hidden" class="form-control" value="<?php if(!empty($course_data)) echo $course_data->sec_image ?>">  
                    </div>
                       <!--<label>Status</label>
                   <div class="form-group">
                     <div class="pretty p-switch p-fill">
                      <input type="checkbox" / name="status" <?php if(!empty($blog_data)){ if($blog_data->status == '0') { echo 'unchecked'; } else { echo 'checked'; } } else { echo 'checked'; }  ?>>  
                      <div class="state p-success">
                        <label>Active</label>
                      </div>
                    </div>
                   </div>-->
                   <div class="card-footer text-right">
                    <button class="btn btn-primary mr-1" type="submit"  name="submit" onclick="nicEditors.findEditor('textarea1').saveContent();">Submit</button>
                    <!--button class="btn btn-secondary" type="reset">Reset</button-->
                  </div>
                      </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </section>
      </div>
      <?php include('fixed/footer.php');  ?>
    </div>
  </div>
   <?php include('fixed/bottom.php');  ?>
  <script type="text/javascript">
  //<![CDATA[
  bkLib.onDomLoaded(function() {
  nicEditors.editors.push(
  new nicEditor({fullPanel : true}).panelInstance(
  document.getElementById('myNicEditor2')
  )

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