<?php
$person_id = $this->session->userdata('person_id');
$person_role = $this->session->userdata('person_role');
?>
<div class="col-sm-10 " style="padding-left: 0px">
    <div class="col-sm-3 form-group">
        <div class="gray col-sm-12">
            <h3 style="text-align: left !important;padding-left: 20px;font-size: 18px">Select Course</h3>
            <div class="checkbox checkbox-success" style="margin-left: 20px;margin-bottom: 0px">
                <input type="checkbox" name="all_course" id="allCourse">
                <label for="all_course" style="font-size: 16px;color: #666">View all course</label>
            </div>



            <?php
            foreach ($parent_topic as $topic_value) {
                ?>
                <div class="panel panel-default" style="background: none;border: none;box-shadow: none;margin-bottom: 10px">
                    <div class="panel-heading" style="background: none;color: #000;border: none;padding: 10px 20px 0px 20px;">
                        <h4 class="panel-title">
                            <a data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $topic_value->topic_id ?>" style="color: #666;font-size: 15px"> <i class="fa fa-book" style="color: #80c12c;font-size: 20px;padding-right: 8px"> </i> <?php echo $topic_value->topic_name ?> </a>
                        </h4>
                    </div>
                    <div id="collapse<?php echo $topic_value->topic_id ?>" class="panel-collapse collapse" style="background: none">
                        <div class="" style="text-align: justify;padding: 0 20px">
                            <span id="childTopic">
                                <?php
                                $i = 0;
                                foreach ($child_topic[$topic_value->topic_id] as $child_topic_value) {
                                    ++$i;
                                    ?>
                                    <div class="checkbox checkbox-success">
                                        <input type="checkbox" name="course" class="course_checkbox" id="courseTopic<?php echo $child_topic_value->topic_id ?>">
                                        <label for="course"><?php echo $child_topic_value->topic_name ?></label>
                                    </div>
                                    <?php
                                }
                                echo '</span>';

                                if ($other_topic[$topic_value->topic_id]) {
                                    ?>
                                    <div class="checkbox checkbox-success">
                                        <input type="checkbox" name="course" class="course_checkbox" id="otherTopic<?php echo $topic_value->topic_id ?>">
                                        <label for="course"><?php echo 'Other' ?></label>
                                    </div>
                                    <?php
                                }
                                if ($i < $total_child_topic[$topic_value->topic_id]) {
                                    ?>
                                    <a style="padding-left: 10px;" 
                                       id="moreChildTopic<?php echo $topic_value->topic_id ?>" 
                                       href="javascript:void(0)" onclick="moreChildTopic('<?php echo $topic_value->topic_id ?>')">more</a>
                                       <?php
                                   }
                                   ?>
                        </div>
                    </div>
                </div>
                <?php
            }

            if ($other_parent_topic) {
                ?>
                <div class="checkbox checkbox-success" style="margin-left: 20px;margin-bottom: 0px">
                    <input type="checkbox" class="course_checkbox" name="other_parent_topic" id="other_parent_topic">
                    <label for="other_parent_topic" style="font-size: 16px;color: #666">Other courses</label>
                </div>
                <?php
            }
            ?>

            <input type="hidden" id="moreTopicUrl" value="<?php echo base_url('more-child-topic'); ?>">
            <input type="hidden" id="viewCoursesUrl" value="<?php echo base_url('view-courses'); ?>">
            <input type="hidden" id="ratingCourseUrl" value="<?php echo base_url('save-course-rating'); ?>">
            <input type="hidden" id="baseUrl" value="<?php echo base_url(); ?>">
        </div>
        <div class="col-sm-12 form-group"></div>





        <div class="col-sm-12 form-group"></div>
        <div class="white  col-sm-12" style="padding: 20px !important">
            <div class="checkbox checkbox-success">
                <input type="checkbox" name="upcomming_course" class="course_checkbox" id="upcomming_course" value="1">
                <label for="Upcomming Course">Upcoming Course</label>
            </div>
            <div class="checkbox checkbox-success">
                <input type="checkbox" name="rated_course" class="course_checkbox" id="rated_course" value="1">
                <label for="Most Rated Course">Most Rated Course</label>
            </div>
        </div>



        <div class="col-sm-12 form-group"></div>
        <div class="gray  col-sm-12" style="padding: 20px !important">
            <h3>Skill Level</h3>
            <div class="checkbox checkbox-success">
                <input type="checkbox" name="skill_level" class="course_checkbox" id="skillLevel0" value="0">
                <label for="Any">Any</label>
            </div>
            <div class="checkbox checkbox-success">
                <input type="checkbox" name="skill_level" class="course_checkbox" id="skillLevel1" value="1">
                <label for="Basic">Basic</label>
            </div>
            <div class="checkbox checkbox-success">
                <input type="checkbox" name="skill_level" class="course_checkbox" id="skillLevel2" value="2">
                <label for="Intermediate">Intermediate</label>
            </div>
            <div class="checkbox checkbox-success">
                <input type="checkbox" name="skill_level" class="course_checkbox" id="skillLevel3" value="3">
                <label for="Advanced">Advanced</label>
            </div>
        </div>
        <div class="col-sm-12 form-group"></div>




        <div class="gray  col-sm-12" style="padding: 20px !important">
            <div class="checkbox checkbox-success">
                <input type="checkbox" name="priority_level" class="course_checkbox"
                       id="priorityLevel1" value="1">
                <label for="New">New</label>
            </div>
            <div class="checkbox checkbox-success">
                <input type="checkbox" name="priority_level" class="course_checkbox"
                       id="priorityLevel2" value="2">
                <label for="Popular">Popular</label>
            </div>
        </div>
        <div class="col-sm-12 form-group"></div>



       <!-- <div class="white  col-sm-12" style="padding: 20px !important">
            <div class="checkbox checkbox-success">
                <input type="checkbox" name="course_type" class="course_checkbox"
                       id="courseType" value="2">
                <label for="Free Course">Course</label>
            </div>
        </div> -->
        <div class="col-sm-12 form-group"></div>
    </div>


    <div class="col-sm-9  form-group">
        <div style="padding: 0px;opacity: 1; display: none" id="loading_image">
            <img src="<?php echo base_url() ?>image/course-loader.gif" 
                 height="60" width="60" style="margin: 20% 45%;">
        </div>
        <div class="col-sm-12 gray  form-group">
            <div id="course_view" style="margin-left: 9px;">
                <div id="view_without_paginzation">
                    <?php
                    $i = 0;
                    foreach ($all_course as $course_value) {
                        ++$i;
                        ?>
                        <div class="<?php
                        echo ($i % 2 == 0) ? 'row white' : 'row gray';
                        ?>">
                            <div class="col-sm-6 form-group" style="text-align: left !important">
                                <a href="<?php echo base_url() . $course_value->url; ?>" id="courseNameView<?php echo $course_value->url ?>" target="_blank" class="red">
                                    <?php
                                    if (strlen($course_value->course_name) < 16) {
                                        echo $course_value->course_name;
                                    } else {
                                        echo character_limiter($course_value->course_name, 40);
                                    }
                                    echo '</a>';
                                    if (strlen($course_value->course_name) >= 16) {
                                        ?>
                                        <span id="moreCourseName<?php echo $course_value->url ?>" style="cursor: pointer">more</span>
                                        <?php
                                    }
                                    ?>
                                    <input type="hidden" id="hiddenCourseName<?php echo $course_value->url ?>" value="<?php echo $course_value->course_name ?>">
                                    <br>

                                    By- 
                                    <?php
                                    if(isset($course_creator_info[$course_value->course_id]->person_role)){
                                    if ($course_creator_info[$course_value->course_id]->person_role == 6 || $course_creator_info[$course_value->course_id]->person_role == 1) {
                                        echo '<span class="green">Talha Training</span>';
                                    } else if ($course_creator_info[$course_value->course_id]->person_role == 3) {
                                        ?>
                                        <a href="<?php echo base_url() . $course_creator_info[$course_value->course_id]->url . '/profile' ?>" target="_blank">
                                            <?php
                                                //echo $course_creator_info[$course_value->course_id]->person_first_name . ' ' . $course_creator_info[$course_value->course_id]->person_last_name;
                                                if (strlen($course_creator_info[$course_value->course_id]->person_first_name) && strlen($course_creator_info[$course_value->course_id]->person_last_name) < 40) {
                                                    echo $course_creator_info[$course_value->course_id]->person_first_name . ' ' . $course_creator_info[$course_value->course_id]->person_last_name;
                                                } else {
                                                    echo substr($course_creator_info[$course_value->course_id]->person_first_name, 0, 30) . ' ' . substr($course_creator_info[$course_value->course_id]->person_last_name, 0, 20) . '.' . ' ' . '.' . ' ' . '.';
                                                }
                                            
                                            ?>
                                        </a>
                                        <?php
                                    } else if ($course_creator_info[$course_value->course_id]->person_role == 4) {
                                        ?>
                                        <a href="<?php echo base_url() . $course_creator_info[$course_value->course_id]->url . '/profile' ?>" target="_blank">
                                            <?php
                                                //echo $course_creator_info[$course_value->course_id]->person_first_name . ' ' . $course_creator_info[$course_value->course_id]->person_last_name;
                                                if (strlen($course_creator_info[$course_value->course_id]->person_first_name) && strlen($course_creator_info[$course_value->course_id]->person_last_name) < 40) {
                                                    echo $course_creator_info[$course_value->course_id]->person_first_name . ' ' . $course_creator_info[$course_value->course_id]->person_last_name;
                                                } else {
                                                    echo substr($course_creator_info[$course_value->course_id]->person_first_name, 0, 30) . ' ' . substr($course_creator_info[$course_value->course_id]->person_last_name, 0, 20) . '.' . ' ' . '.' . ' ' . '.';
                                                }
                                            ?>
                                        </a>
                                        <?php
                                        }
                                    }else{
                                        echo '<span class="green">Talha Training</span>';
                                    }
                                    ?>            
                            </div>

                          <!--  <div class="col-sm-2 form-group text-left" style="padding-left:0;">
                                <?php
                                //if ($course_value->course_type == 1) {
                                    //if ($course_price_info[$course_value->course_id]->price_currency == 1) {
                                       // echo 'BDT ' . round($course_price_info[$course_value->course_id]->price);
                                   // } elseif ($course_price_info[$course_value->course_id]->price_currency == 2) {
                                       // echo 'USD ' . round($course_price_info[$course_value->course_id]->price);
                                   // }
                               // } elseif ($course_value->course_type == 2) {
                                   // echo 'Call +8801712742217 for Price';
                               // }
                                ?>
                            </div> -->



                            <div class="col-sm-1 padding-zero form-group" style="text-align: left !important">
                                <?php
                                switch ($course_value->course_level) {
                                    case 0:
                                        ?>
                                        <span title="Any">
                                            <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                                            <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                                            <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                                        </span>
                                        <?php
                                        break;
                                    case 1:
                                        ?>
                                        <span title="Basic">
                                            <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                                            <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                                            <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                                        </span>
                                        <?php
                                        break;
                                    case 2:
                                        ?>
                                        <span title="Intermediate">
                                            <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                                            <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                                            <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                                        </span>
                                        <?php
                                        break;
                                    case 3:
                                        ?>
                                        <span title="Advanced">
                                            <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                                            <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                                            <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                                        </span>
                                        <?php
                                        break;
                                }
                                ?>
                            </div>



                            <?php
                            if ($person_id) {
                                if (in_array($person_role, Array(3, 4, 5))) {
                                    ?>
                                    <div class="col-sm-3 form-group" style="text-align: left !important;padding: 5px">
                                        <div id="ratingValue<?php echo $course_value->url ?>" class="rating-star">
                                            <div class="rating-star-value" id="ratingDiv<?php echo $course_value->url ?>" style="width: <?php echo round(($course_value->course_rating * 100) / 5) ?>%"></div>
                                            <div class="rating-star-bg"></div>
                                        </div>
                                    </div>
                                <?php } else {
                                    ?>
                                    <div class="col-sm-3 form-group" style="text-align: left !important;padding: 5px">
                                        <div  class="rating-star">
                                            <div class="rating-star-value" style="width: <?php echo round(($course_value->course_rating * 100) / 5) ?>%"></div>
                                            <div class="rating-star-bg"></div>
                                        </div>
                                    </div>
                                    <?php
                                }
                            } else {
                                ?>
                                <div class="col-sm-3 form-group" style="text-align: left !important;padding: 5px">
                                    <div  class="rating-star">
                                        <div class="rating-star-value" style="width: <?php echo round(($course_value->course_rating * 100) / 5) ?>%"></div>
                                        <div class="rating-star-bg"></div>
                                    </div>
                                </div>
                            <?php }
                            ?>




                            <div class="col-sm-2 form-group" style="padding-left:0;" style="text-align: left !important">
                                <a href="<?php echo base_url() . 'course/' . $course_value->url . '/registration'; ?>" 
                                   data-toggle="tooltip" title="Get Enrollment in this Course" data-placement="top">
                                    <img src="<?php echo base_url() ?>image/registration-icon.png">
                                </a>
                            </div>
                        </div>
                        <input type="hidden" id="courseRating<?php echo $course_value->url ?>" value="<?php echo round(($course_value->course_rating * 100) / 5) ?>">
                        <?php
                    }
                    echo '</div>';
                    echo $pagination_link;
                    ?>
                </div>

            </div>
        </div>
    </div>

    <script type="text/javascript" src="<?php echo base_url() ?>front_end_resource/course/course_view.js"></script>
