<div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <div class="img-profile ml-3 mt-3">

                    </div>
                    <h1 class="m-0 text-dark"><?php echo (isset($course)) ? 'Edit Course' : 'Edit Course' ?>
                    </h1>

                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="<?= base_url(); ?>dashboard/courses">Courses</a></li>
                        <li class="breadcrumb-item active"><?php echo (isset($course)) ? 'Edit Course' : 'Edit Course' ?></li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <form method="post" id="add_driver" class="card" action="<?php echo base_url().'course/updatecoursedata' ?>" enctype="multipart/form-data">
        <section class="content">
            <div class="container-fluid">
                <div class="card-body">
                  <?php
                   
                  ?>

                    <div class="row">
                        <input type="hidden" name="id" id="d_id" value="<?php echo (isset($course)) ? $course['id'] : '' ?>">
                        
                        <div class="col-sm-6 col-md-12">
                            <label class="form-label">Title<span class="form-required">*</span></label>
                            <div class="form-group">
                                <input type="text" name="title" id="title" class="form-control" placeholder="Title" required 
                                value="<?php echo (isset($course)) ? $course['title'] : '' ?>">
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-12">
                            <div class="form-group">
                                <label class="form-label">Description</label>
                                <textarea rows="5" name="description" id="description"
                                 placeholder="Description" class="form-control" required><?php echo (isset($course)) ? $course['description'] : '' ?></textarea>
                            </div>
                        </div>
                        <div class="col-sm-6 col-md-6 ">
                            <div class="form-group">
                                <label class="form-label">Content Type<span class="form-required">*</span></label>
                                <select id="coachesId" name="contentType" class="form-control"  required="">
                                 <option value="course" <?php if($course['contentType']=="course"){echo 'selected';} ?>>Course</option> 
                                 <option value="video" <?php if($course['contentType']=="video"){echo 'selected';} ?>>Video</option> 
                                 
                                 
                                 
                                </select>
                            </div>
                        </div>

                        <div class="col-sm-6 col-md-6 ">
                            <div class="form-group">
                                <label class="form-label">Badge Available<span class="form-required">*</span></label>
                                <select id="coachesId" name="badgeAvailable" class="form-control"  required="">
                                 <option value="true" <?php if($course['badgeAvailable']==true){echo 'selected';} ?>>True</option> 
                                 <option value="false" <?php if($course['badgeAvailable']==false){echo 'selected';} ?>>false</option> 
                                 
                                 
                                 
                                </select>
                            </div>
                        </div>

                        <!--
                        <div class="col-sm-12 col-md-12">
                            <div class="form-group">
                                <label class="form-label">Coaches<span class="form-required">*</span></label>
                                <select id="coachesId" name="coachesId" class="form-control"  required="">
                                  
                                 
                                    <?php
                                      foreach($coach as $key => $category){
                                    ?>
                                    <option value="<?=$key?>" <?php if($course['coachesId']==$key){echo 'selected';} ?>><?=$category['name']?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                                      -->              
                        
                                      <div class="col-sm-12 col-md-12">
                            <div class="form-group">
                                <label class="form-label">Prerequisite<span class="form-required">*</span></label>
                                <select id="requiredCourse" name="requiredCourse[]" class="form-control multiselect" multiple>
                                <option value="">Please Select</option>
                                 
                                    <?php
                                      foreach($allcourses as $key => $category){
                                    ?>
                                    <option value="<?=$key?>"
                                    <?php 
                                    if (in_array($key, $course['requiredCourse'])) {
                                      echo "selected";
                                  }
                                    ?>
                                    
                                    ><?=$category['title']?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                         <div class="col-sm-6 col-md-6">
                            <div class="form-group">
                                <label class="form-label">Category<span class="form-required">*</span></label>
                                <select id="categoryId" name="categoryId[]" class="form-control multiselect" multiple required="">
                                  
                                 
                                    <?php
                                      foreach($categories as $key => $category){
                                    ?>
                                    <option value="<?=$key?>"  
                                    <?php 
                                    if (in_array($key, $course['categoryId'])) {
                                      echo "selected";
                                  }
                                    ?>
                                     ><?=$category['title']?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
              
                        <div class="col-sm-6 col-md-6">
                            <div class="form-group">
                                <label class="form-label">Feature Image</label>
 
                                 <input type="file" name="image" class="form-control" accept="image/*" placeholder="Video" > 
                            </div>
                        </div>

                        <div class="col-sm-12 col-md-12">
                            <div class="form-check">
                                <input class="form-check-input"
                                
                                <?php if($course['isPro']==true){
                                  echo 'checked';
                                } ?>
                                type="checkbox" value="yes" id="isPro" name="isPro">
                                <label class="form-check-label" for="isPro">
                                    <strong style="color:black">isPro</strong>
                                </label>
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-12 mt-3" id="radiosSec">

                            <div class="form-check form-check-inline">
                                <input class="form-check-input"
                                <?php if($course['allowedFor']=="All Teams"){
                                  echo 'checked';
                                } ?>
                                
                                type="radio" name="allowedFor" id="allTeams" value="All Teams" onclick="showTeams()" checked>
                                <label class="form-check-label" for="inlineRadio1">All Teams</label>
                            </div>
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" <?php if($course['allowedFor']=="Specific Teams"){
                                  echo 'checked';
                                } ?> type="radio" name="allowedFor" id="specificTeams" value="Specific Teams" onclick="showTeams()">
                                <label class="form-check-label" for="inlineRadio2">Specific Teams</label>
                            </div>

                        </div>
                        <div class="col-sm-12 col-md-12 mt-3" 
                        <?php if($course['allowedFor']=="All Teams"){?>
                                 

                        style="display: none;"
                        <?php  } ?>                        
                        id="teamsSec">

                            <div class="form-group">
                                <label class="form-label">Teams<span class="form-required">*</span></label>
                                <select id="allowedTeams" name="allowedTeams[]" class="form-control multiselect" multiple>
                                    <?php
                                      foreach($teams as $key => $team){
                                    ?>
                                    <option value="<?=$key?>"
                                    <?php 
                                    if (in_array($key, $course['allowedTeams'])) {
                                      echo "selected";
                                  }
                                    ?>
                                    ><?=$team['name']?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>

                    </div>

                </div>

            </div>
        </section>
        <section class="content">
            <div class="container-fluid">
                <div class="card-footer text-right">
                    <button type="submit" id="submit" class="btn btn-primary"> <?php echo (isset($vehicledetails) && isset($course)) ? 'Edit Course' : 'Edit Course' ?></button>
                </div>
            </div>
        </section>
    </form>
<script>
    function showRadios() {

$("#teamsSec").hide();
if (document.getElementById('isPro').checked) {
    $("#radiosSec").show();
    $("#specificTeams").prop('checked', false);
    $("#allTeams").prop('checked', true);
} else {
    $("#radiosSec").hide();
}
}

function showTeams() {

if (document.getElementById('specificTeams').checked) {
    $("#teamsSec").show();
} else {
    $("#teamsSec").hide();
}
}

 </script>   