<?php
$person_id = $this->session->userdata('user_id');
$person_role = $this->session->userdata('person_role');
$course_id = $this->session->userdata("course_id");
$course_tab_session = $this->session->userdata("course_tab");
?>
<div class="col-sm-8">
    <div class="row gray">
        <div class="col-sm-12">
            <h3>
                <a href="<?php echo base_url() . 'user/add-course'; ?>"> <span class="pull-right">Add Course</span></a>
            </h3>
            <ul class="nav nav-tabs">
                <li <?php
                if ($course_tab == 'draft') {
                    echo 'class="active"';
                }
                ?>><a data-toggle="tab" href="#draft_course">Draft<?php
                            if ($draft_courses) {
                                echo ' (' . $total_draft_courses->total . ')';
                            }
                            ?></a></li>
                <li <?php
                if ($course_tab == 'submission') {
                    echo 'class="active"';
                }
                ?>><a data-toggle="tab" href="#submission_course">Submissions<?php
                            if ($submit_courses) {
                                echo ' (' . $total_submit_courses->total . ')';
                            }
                            ?></a></li>
                <li <?php
                if ($course_tab == 'active') {
                    echo 'class="active"';
                }
                ?>><a data-toggle="tab" href="#active_course">Active<?php
                            if ($active_courses) {
                                echo ' (' . $total_active_courses->total . ')';
                            }
                            ?></a></li>
            </ul>
        </div>
        <!--------------------view all Courses--------------->
        <div class="col-sm-12">
            <div class="tab-content">
                <!--------------------view all Draft Courses--------------->
                <div id="draft_course" class="tab-pane fade <?php
                if ($course_tab == 'draft') {
                    echo 'in active';
                }
                ?>">
                    <div class="col-sm-12 gray_ttc text-center" style="border-bottom: 2px solid #8CC73F;padding-top: 10px;padding-bottom: 10px;font-weight: bold">
                        <div class="col-sm-2">Image</div>
                        <div class="col-sm-5">Title</div>
                        <div class="col-sm-3">Price</div>
                        <div class="col-sm-2">Action</div>
                    </div>
                    <div class="col-sm-12"><br></div> 
                    <div class="col-sm-12" id="view_draft_course">
                        <?php
                        if ($course_id != '' && $course_tab_session == 'draft') {
                            $course_information = $this->user_course_model->get_course_information_with_url_by_course_id($course_id);
                            if(isset($course_information)){
                                $sess_price_info = $this->price_model->get_single_price_information(1, $course_information->course_id);
                            
                            ?>
                            <div class="col-sm-12 gray text-center" style="background-color: #D3EDB0;">
                                <div class="col-sm-2" style="width:100px;">
                                    <img src="<?php echo base_url() ?>image/no_image_course.png" class="img-responsive" 
                                         class="img-responsive" 
                                         style="margin: 0 auto; max-height: 60px; cursor: pointer;" 
                                         alt="image">
                                </div>
                                <div class="col-sm-5" style="padding-top: 10px ">
                                    <a href="<?php echo base_url() . $course_information->url; ?>" target="_blank">
                                        <?php echo $course_information->course_name; ?></a>
                                </div>
                                <div class="col-sm-3" style="padding-top: 10px">
                                    <?php
                                    if ($course_information->course_type == 1) {
                                        if ($sess_price_info->price_currency == 1) {
                                            //echo 'BDT ' . $sess_price_info->price . ' / USD ' . $this->tt_currency->set($sess_price_info->price, 'BDT', 'USD')->convert_currency()->get();
                                            echo 'BDT ' . $sess_price_info->price;
                                        } else if ($sess_price_info->price_currency == 2) {
                                            //echo 'BDT ' . $this->tt_currency->set($sess_price_info->price, 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $sess_price_info->price;
                                            echo ' USD ' . $sess_price_info->price;
                                        }
                                    } else {
                                        echo 'Free';
                                    }
                                    ?>
                                </div>
                                <div class="col-sm-2" style="padding-top: 10px">
                                    <a href="<?php echo base_url() . 'user/edit-course/' . $course_information->url; ?>"><i class="fa fa-edit" title="Edit"></i></a>&nbsp;
                                    <span>&nbsp;</span>
                                    <a href="<?php echo base_url() . 'user/course/add-work-file/' . $course_information->url; ?>"><i class="glyphicon glyphicon-saved" title="work file"></i></a>&nbsp;
                                    <span>&nbsp;</span>
                                    <a href="<?php echo base_url() . 'user/course/view-work-file/' . $course_information->url; ?>"><i class="glyphicon glyphicon-open" title="work file"></i></a>&nbsp;
                                    <span>&nbsp;</span>
                                    <!--<a href="<?php //echo base_url() . 'invite-learners/' . $course_information->url; ?>"><i class="fa fa-envelope-o" title="Invite to Learners"></i></a>&nbsp;
                                    <span>&nbsp;</span>-->
                                    <a href="javascript:void(0)" data-toggle="modal" data-target="#courseDelete<?php echo $course_information->url; ?>"><i class="fa fa-trash-o" title="Delete"></i></a>
                                    <span>&nbsp;</span>
                                    <!--<a href="<?php echo base_url() . $course_information->url . '/view-registered-student'; ?>">
                                        <i class="fa fa-th" title="View registered student"></i>
                                    </a><span>&nbsp;</span>-->

                                    <!------------- view batch area ---------------->   
                                    <?php if ($person_role == 3) { ?>
                                        <!--<a href="<?php //echo base_url() . 'view-teacher-batch/' . $course_information->url; ?>">-->
                                        <?php } else if ($person_role == 4) { ?>
                                            <!--<a href="<?php //echo base_url() . 'view-organization-batch/' . $course_information->url; ?>">-->
                                            <?php } ?>                                               
                                            <!--<i class="fa fa-ge" title="View Batch"></i>
                                        </a><span>&nbsp;</span>-->

                                        <a href="<?php echo base_url() . $course_information->url . '/create-certificate'; ?>">
                                            <i class="fa fa-certificate" title="Create Certificate"></i>
                                        </a><span>&nbsp;</span>
                                        <!------- end view batch area ----------->
                                </div>
                            </div>
                            <div class="modal" style="" id="courseDelete<?php echo $course_information->url; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                                <?php
                                $status_message7 = 'Are you sure you want to Delete this Course?';
                                $status_function_name7 = 'deleteCourse(&quot;' . base_url('user/delete-course') . '&quot;,&quot;' . $course_information->url . '&quot;)';
                                $this->cf->get_status_modal($status_function_name7, $status_message7);
                                ?>
                            </div>
                            <div class="col-sm-12"><br></div>
                            <?php
                            }
                        }

                        if ($draft_courses) {
//                            echo '<pre>';
//                            print_r($person_id);
//                            exit();
                            ?>
                            <div class="col-sm-12 padding-zero">
                                <?php
                                foreach ($draft_courses as $course_value) {
                                    ?>
                                    <div class="col-sm-12 gray text-center">
                                        <div class="col-sm-2" style="width:100px;">
                                            <img src="<?php echo base_url() ?>image/no_image_course.png" class="img-responsive" 
                                                 class="img-responsive" 
                                                 style="margin: 0 auto; max-height: 60px; cursor: pointer;" 
                                                 alt="image">
                                        </div>
                                        <div class="col-sm-5" style="padding-top: 10px ">
                                            <a href="<?php echo base_url() . $course_value->url; ?>" target="_blank">
                                                <?php echo $course_value->course_name; ?></a>
                                        </div>
                                        <div class="col-sm-3" style="padding-top: 10px">
                                            <?php
                                            if ($course_value->course_type == 1) {
                                                if ($price_info[$course_value->course_id]->price_currency == 1) {
                                                    //echo 'BDT ' . $price_info[$course_value->course_id]->price . ' / USD ' . $this->tt_currency->set($price_info[$course_value->course_id]->price, 'BDT', 'USD')->convert_currency()->get();
                                                    echo 'BDT ' . $price_info[$course_value->course_id]->price ;
                                                } else if ($price_info[$course_value->course_id]->price_currency == 2) {
                                                    //echo 'BDT ' . $this->tt_currency->set($price_info[$course_value->course_id]->price, 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $price_info[$course_value->course_id]->price;
                                                    echo ' USD ' . $price_info[$course_value->course_id]->price;
                                                }
                                            } else {
                                                echo 'Free';
                                            }
                                            ?>
                                        </div>
                                        <div class="col-sm-2" style="padding-top: 10px">
                                        <?php if($course_value->course_resource_person_edit == 1 || $course_value->person_id == $person_id){ ?>
                                            <a href="<?php echo base_url() . 'user/edit-course/' . $course_value->url; ?>"><i class="fa fa-edit" title="Edit"></i></a>&nbsp;
                                            <span>&nbsp;</span>
                                        <?php } ?>
                                            <a href="<?php echo base_url() . 'user/course/add-work-file/' . $course_value->url; ?>"><i class="glyphicon glyphicon-saved" title="Add work file"></i></a>&nbsp;
                                            <span>&nbsp;</span>
                                            <a href="<?php echo base_url() . 'user/course/view-work-file/' . $course_value->url; ?>"><i class="glyphicon glyphicon-open" title="View work file"></i></a>&nbsp;
                                            <span>&nbsp;</span>
                                            <!--<a href="<?php echo base_url() . 'invite-learners/' . $course_value->url; ?>"><i class="fa fa-envelope-o" title="Invite to Learners"></i></a>&nbsp;
                                            <span>&nbsp;</span>-->
                                            <a href="javascript:void(0)" data-toggle="modal" data-target="#courseDelete<?php echo $course_value->url; ?>"><i class="fa fa-trash-o" title="Delete"></i></a>
                                            <span>&nbsp;</span>
                                            <!--<a href="<?php echo base_url() . $course_value->url . '/view-registered-student'; ?>">
                                                <i class="fa fa-th" title="View registered student"></i>
                                            </a><span>&nbsp;</span>-->

                                            <!------------- view batch area ---------------->   
                                            <?php if ($person_role == 3) { ?>
                                                <!--<a href="<?php //echo base_url() . 'view-teacher-batch/' . $course_value->url; ?>">-->
                                                <?php } else if ($person_role == 4) { ?>
                                                    <!--<a href="<?php //echo base_url() . 'view-organization-batch/' . $course_value->url; ?>">-->
                                                    <?php } ?>                                               
                                                    <!--<i class="fa fa-ge" title="View Batch"></i>
                                                </a><span>&nbsp;</span>-->
                                                <!------- end view batch area ----------->                                                
                                                <a href="<?php echo base_url() . $course_value->url . '/create-certificate'; ?>">
                                                    <i class="fa fa-certificate" title="Create Certificate"></i>
                                                </a><span>&nbsp;</span>

                                        </div>
                                    </div>
                                    <div class="modal" style="" id="courseDelete<?php echo $course_value->url; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                                        <?php
                                        $status_message7 = 'Are you sure you want to Delete this Course?';
                                        $status_function_name7 = 'deleteCourse(&quot;' . base_url('user/delete-course') . '&quot;,&quot;' . $course_value->url . '&quot;)';
                                        $this->cf->get_status_modal($status_function_name7, $status_message7);
                                        ?>
                                    </div>
                                    <div class="col-sm-12"><br></div>

                                    <?php
                                }
                                ?>
                            </div>
                            <?php
                        } else {
                            if ($course_id == '') {?>
                                <p>Change the world with your teaching magic! <a href="<?php echo base_url().'user/add-course'?>" target="_blank">Create Course</a></p>
                            <?php                            
                            }
                        }
                        ?>

                        <?php
                        $total_page = ceil($total_draft_courses->total / 10);
                        if ($total_page > 1) {
                            ?>
                            <div class="col-sm-12 " style="padding: 0">
                                <nav class="course-pagination">
                                    <ul class="pagination">
                                        <?php
                                        if ($page > 2) {
                                            ?>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'draft', '<?php echo '0' ?>')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'draft', '<?php echo ($page - 1) ?>')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                        <?php } elseif ($page > 1) { ?>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'draft', '<?php echo ($page - 1) ?>')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                            <?php
                                        }
                                        for ($i = 0; $total_page > $i; $i++) {
                                            ?>
                                            <li><a href="javascript:void(0)"
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'draft', '<?php echo ($i + 1) ?>')" ><?php echo $i + 1 ?></a></li>
                                                <?php
                                            }
                                            if ($total_page != $page) {
                                                ?>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'draft', '<?php echo ($page + 1) ?>')"
                                                   aria-label="Next">
                                                    <span aria-hidden="true" title="Next Page">&raquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'draft', '<?php echo $total_page ?>')"
                                                   aria-label="Next">
                                                    <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                                </a>
                                            </li>
                                        <?php } ?>
                                    </ul>
                                </nav>
                            </div>
                        <?php } ?>

                    </div>
                </div>

                <!--------------------view all Submission Courses--------------->
                <div id="submission_course" class="tab-pane fade <?php
                if ($course_tab == 'submission') {
                    echo 'in active';
                }
                ?>">
                    <div class="col-sm-12 gray_ttc text-center" style="border-bottom: 2px solid #8CC73F;padding-top: 10px;padding-bottom: 10px;font-weight: bold">
                        <div class="col-sm-2">Image</div>
                        <div class="col-sm-5">Title</div>
                        <div class="col-sm-3">Price</div>
                        <div class="col-sm-2">Action</div>
                    </div>
                    <div class="col-sm-12"><br></div> 
                    <div class="col-sm-12" id="view_submit_course">

                        <?php
                        if ($course_id != '' && $course_tab_session == 'submission') {
                            $course_information = $this->user_course_model->get_course_information_with_url_by_course_id($course_id);
                            $sess_price_info = $this->price_model->get_single_price_information(1, $course_information->course_id);
                            ?>
                            <div class="col-sm-12 gray text-center" style="background-color: #D3EDB0;">
                                <div class="col-sm-2" style="width:100px;">
                                    <img src="<?php echo base_url() ?>image/no_image_course.png" class="img-responsive" 
                                         class="img-responsive" 
                                         style="margin: 0 auto; max-height: 60px; cursor: pointer;" 
                                         alt="image">
                                </div>
                                <div class="col-sm-5" style="padding-top: 10px ">
                                    <a href="<?php echo base_url() . $course_information->url; ?>" target="_blank">
                                        <?php echo $course_information->course_name; ?></a>
                                </div>
                                <div class="col-sm-3" style="padding-top: 10px">
                                    <?php
                                    if ($course_information->course_type == 1) {
                                        if ($sess_price_info->price_currency == 1) {
                                            echo 'BDT ' . $sess_price_info->price;
                                            //echo 'BDT ' . $sess_price_info->price . ' / USD ' . $this->tt_currency->set($sess_price_info->price, 'BDT', 'USD')->convert_currency()->get();
                                        } else if ($sess_price_info->price_currency == 2) {
                                            //echo 'BDT ' . $this->tt_currency->set($sess_price_info->price, 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $sess_price_info->price;
                                            echo ' USD ' . $sess_price_info->price;
                                        }
                                    } else {
                                        echo 'Free';
                                    }
                                    ?>
                                </div>
                                <div class="col-sm-2" style="padding-top: 10px">
                                    <a href="<?php echo base_url() . 'user/edit-course/' . $course_information->url; ?>"><i class="fa fa-edit" title="Edit"></i></a>&nbsp;
                                    <span>&nbsp;</span>
                                    <a href="<?php echo base_url() . 'user/course/add-work-file/' . $course_information->url; ?>"><i class="glyphicon glyphicon-saved" title="Add work file"></i></a>&nbsp;
                                    <span>&nbsp;</span>
                                    <a href="<?php echo base_url() . 'user/course/view-work-file/' . $course_information->url; ?>"><i class="glyphicon glyphicon-open" title="View work file"></i></a>&nbsp;
                                    <span>&nbsp;</span>
                                    <!--<a href="<?php //echo base_url() . 'invite-learners/' . $course_information->url; ?>"><i class="fa fa-envelope-o" title="Invite to Learners"></i></a>&nbsp;
                                    <span>&nbsp;</span>-->
                                    <a href="javascript:void(0)" data-toggle="modal" data-target="#courseDelete<?php echo $course_information->url; ?>"><i class="fa fa-trash-o" title="Delete"></i></a>
                                    <span>&nbsp;</span>
                                    <!--<a href="<?php //echo base_url() . $course_information->url . '/view-registered-student'; ?>">
                                        <i class="fa fa-th" title="View registered student"></i>
                                    </a><span>&nbsp;</span>-->

                                    <!------------- view batch area ---------------->   
                                    <?php if ($person_role == 3) { ?>
                                        <!--<a href="<?php //echo base_url() . 'view-teacher-batch/' . $course_information->url; ?>">-->
                                        <?php } else if ($person_role == 4) { ?>
                                            <!--<a href="<?php //echo base_url() . 'view-organization-batch/' . $course_information->url; ?>">-->
                                            <?php } ?>                                               
                                            <!--<i class="fa fa-ge" title="View Batch"></i>
                                        </a><span>&nbsp;</span>-->
                                        <!------- end view batch area ----------->

                                        <a href="<?php echo base_url() . $course_information->url . '/create-certificate'; ?>">
                                            <i class="fa fa-certificate" title="Create Certificate"></i>
                                        </a><span>&nbsp;</span>
                                </div>
                                <div class="modal" style="" id="courseDelete<?php echo $course_information->url; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                                    <?php
                                    $status_message7 = 'Are you sure you want to Delete this Course?';
                                    $status_function_name7 = 'deleteCourse(&quot;' . base_url('user/delete-course') . '&quot;,&quot;' . $course_information->url . '&quot;)';
                                    $this->cf->get_status_modal($status_function_name7, $status_message7);
                                    ?>
                                </div>
                            </div>
                            <div class="col-sm-12"><br></div>
                            <?php
                        }
                        if ($submit_courses) {
//                            echo '<pre>';
//                            print_r($submit_courses);
//                            exit();
                            ?>
                            <div class="col-sm-12 padding-zero">
                                <?php
                                foreach ($submit_courses as $course_value) {
                                    ?>
                                    <div class="col-sm-12 gray text-center">
                                        <div class="col-sm-2" style="width:100px;">
                                            <img src="<?php echo base_url() ?>image/no_image_course.png" class="img-responsive" 
                                                 class="img-responsive" 
                                                 style="margin: 0 auto; max-height: 60px; cursor: pointer;" 
                                                 alt="image">
                                        </div>
                                        <div class="col-sm-5" style="padding-top: 10px ">
                                            <a href="<?php echo base_url() . $course_value->url; ?>" target="_blank">
                                                <?php echo $course_value->course_name; ?></a>
                                        </div>
                                        <div class="col-sm-3" style="padding-top: 10px">
                                            <?php                                                         
                                            if ($course_value->course_type == 1) {
                                                if ($price_info[$course_value->course_id]->price_currency == 1) {
                                                    //echo 'BDT ' . $price_info[$course_value->course_id]->price . ' / USD ' . $this->tt_currency->set($price_info[$course_value->course_id]->price, 'BDT', 'USD')->convert_currency()->get();
                                                    echo 'BDT ' . $price_info[$course_value->course_id]->price;
                                                } else if ($price_info[$course_value->course_id]->price_currency == 2) {
                                                    //echo 'BDT ' . $this->tt_currency->set($price_info[$course_value->course_id]->price, 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $price_info[$course_value->course_id]->price;
                                                    echo ' USD ' . $price_info[$course_value->course_id]->price;
                                                }
                                            } else {
                                                echo 'Free';
                                            }
                                            ?>
                                        </div>
                                        <div class="col-sm-2" style="padding-top: 10px">
                                        <?php if($course_value->course_resource_person_edit == 1 || $course_value->person_id == $person_id){ ?>
                                            <a href="<?php echo base_url() . 'user/edit-course/' . $course_value->url; ?>"><i class="fa fa-edit" title="Edit"></i></a>&nbsp;
                                            <span>&nbsp;</span>
                                        <?php } ?>
                                            <a href="<?php echo base_url() . 'user/course/add-work-file/' . $course_value->url; ?>"><i class="glyphicon glyphicon-saved" title="Add work file"></i></a>&nbsp;
                                            <span>&nbsp;</span>
                                            <a href="<?php echo base_url() . 'user/course/view-work-file/' . $course_value->url; ?>"><i class="glyphicon glyphicon-open" title="View work file"></i></a>&nbsp;
                                            <span>&nbsp;</span>
                                            <!--<a href="<?php echo base_url() . 'invite-learners/' . $course_value->url; ?>"><i class="fa fa-envelope-o" title="Invite to Learners"></i></a>&nbsp;
                                            <span>&nbsp;</span>-->
                                            <a href="javascript:void(0)" data-toggle="modal" data-target="#courseDelete<?php echo $course_value->url; ?>">
                                                <i class="fa fa-trash-o" title="Delete"></i></a>
<!--                                            <a href="javascript:void(0)" onclick="checkForLinkAction('<?php //echo base_url() . 'delete-course/' . $course_value->url; ?>', 'Delete', 'Do you want to delete this course')">
                                                <i class="fa fa-trash-o" title="Delete"></i></a>&nbsp;-->
                                            <span>&nbsp;</span>
                                            <!--<a href="<?php echo base_url() . $course_value->url . '/view-registered-student'; ?>">
                                                <i class="fa fa-th" title="View registered student"></i>
                                            </a><span>&nbsp;</span>-->

                                            <!------------- view batch area ---------------->   
                                            <?php if ($person_role == 3) { ?>
                                                <!--<a href="<?php //echo base_url() . 'view-teacher-batch/' . $course_value->url; ?>">-->
                                                <?php } else if ($person_role == 4) { ?>
                                                    <!--<a href="<?php //echo base_url() . 'view-organization-batch/' . $course_value->url; ?>">-->
                                                    <?php } ?>                                               
                                                    <!--<i class="fa fa-ge" title="View Batch"></i>
                                                </a><span>&nbsp;</span>-->
                                                <!------- end view batch area ----------->

                                                <a href="<?php echo base_url() . $course_value->url . '/create-certificate'; ?>">
                                                    <i class="fa fa-certificate" title="Create Certificate"></i>
                                                </a><span>&nbsp;</span>
                                        </div>
                                        <div class="modal" style="" id="courseDelete<?php echo $course_value->url; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                                            <?php
                                            $status_message7 = 'Are you sure you want to Delete this Course?';
                                            $status_function_name7 = 'deleteCourse(&quot;' . base_url('user/delete-course') . '&quot;,&quot;' . $course_value->url . '&quot;)';
                                            $this->cf->get_status_modal($status_function_name7, $status_message7);
                                            ?>
                                        </div>
                                    </div>
                                    <div class="col-sm-12"><br></div>
                                    <?php
                                }
                                ?>
                            </div>
                            <?php
                        } else {
                            if ($course_id == '') {
                                ?>
                                <p>Change the world with your teaching magic! <a href="<?php echo base_url().'user/add-course'?>" target="_blank">Create Course</a></p>
                            <?php                            
                            }
                        }
                        ?>

                        <?php
                        $total_submit = ceil($total_submit_courses->total / 10);
                        if ($total_submit > 1) {
                            ?>
                            <div class="col-sm-12 " style="padding: 0">
                                <nav class="course-pagination">
                                    <ul class="pagination">
                                        <?php
                                        if ($page > 2) {
                                            ?>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'submit', '<?php echo '0' ?>')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'submit', '<?php echo ($page - 1) ?>')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                        <?php } elseif ($page > 1) { ?>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'submit', '<?php echo ($page - 1) ?>')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                            <?php
                                        }
                                        for ($i = 0; $total_submit > $i; $i++) {
                                            ?>
                                            <li><a href="javascript:void(0)"
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'submit', '<?php echo ($i + 1) ?>')" ><?php echo $i + 1 ?></a></li>
                                                <?php
                                            }
                                            if ($total_submit != $page) {
                                                ?>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'submit', '<?php echo ($page + 1) ?>')"
                                                   aria-label="Next">
                                                    <span aria-hidden="true" title="Next Page">&raquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'submit', '<?php echo $total_submit ?>')"
                                                   aria-label="Next">
                                                    <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                                </a>
                                            </li>
                                        <?php } ?>
                                    </ul>
                                </nav>
                            </div>
                        <?php } ?>
                    </div>
                </div>
                <!--------------------view all Active Courses--------------->
                <div id="active_course" class="tab-pane fade <?php
                if ($course_tab == 'active') {
                    echo 'in active';
                }
                ?>">
                    <div class="col-sm-12 gray_ttc text-center" style="border-bottom: 2px solid #8CC73F;padding-top: 10px;padding-bottom: 10px;font-weight: bold">
                        <div class="col-sm-2">Image</div>
                        <div class="col-sm-5">Title</div>
                        <div class="col-sm-3">Price</div>
                        <div class="col-sm-2">Action</div>
                    </div>
                    <div class="col-sm-12"><br></div> 
                    <div class="col-sm-12" id="view_active_course">
                        <?php
                        if ($course_id != '' && $course_tab_session == 'active') {
                            $course_information = $this->user_course_model->get_course_information_with_url_by_course_id($course_id);
                            $sess_price_info = $this->price_model->get_single_price_information(1, $course_information->course_id);
                            ?>
                            <div class="col-sm-12 gray text-center" style="background-color: #D3EDB0;">
                                <div class="col-sm-2" style="width:100px;">
                                    <img src="<?php echo base_url() ?>image/no_image_course.png" class="img-responsive" 
                                         class="img-responsive" 
                                         style="margin: 0 auto; max-height: 60px; cursor: pointer;" 
                                         alt="image">
                                </div>
                                <div class="col-sm-5" style="padding-top: 10px ">
                                    <a href="<?php echo base_url() . $course_information->url; ?>" target="_blank">
                                        <?php echo $course_information->course_name; ?></a>
                                </div>
                                <div class="col-sm-3" style="padding-top: 10px">
                                    <?php
                                    if ($course_information->course_type == 1) {
                                        if ($sess_price_info->price_currency == 1) {
                                            //echo 'BDT ' . $sess_price_info->price . ' / USD ' . $this->tt_currency->set($sess_price_info->price, 'BDT', 'USD')->convert_currency()->get();
                                            echo 'BDT ' . $sess_price_info->price;
                                        } else if ($sess_price_info->price_currency == 2) {
                                            //echo 'BDT ' . $this->tt_currency->set($sess_price_info->price, 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $sess_price_info->price;
                                            echo ' USD ' . $sess_price_info->price;
                                        }
                                    } else {
                                        echo 'Free';
                                    }
                                    ?>
                                </div>
                                <div class="col-sm-2" style="padding-top: 10px">
                                    <a href="<?php echo base_url() . 'user/edit-course/' . $course_information->url; ?>"><i class="fa fa-edit" title="Edit"></i></a>
                                    <span>&nbsp;</span>
                                    <a href="<?php echo base_url() . 'user/course/add-work-file/' . $course_information->url; ?>"><i class="glyphicon glyphicon-saved" title="Add work file"></i></a>&nbsp;
                                    <span>&nbsp;</span>
                                    <a href="<?php echo base_url() . 'user/course/view-work-file/' . $course_information->url; ?>"><i class="glyphicon glyphicon-open" title="View work file"></i></a>&nbsp;
                                    <span>&nbsp;</span>
                                    <a href="<?php echo base_url() . 'invite-learners/' . $course_information->url; ?>"><i class="fa fa-envelope-o" title="Invite to Learners"></i></a>
                                    <span>&nbsp;</span>
                                    <!--<a href="javascript:void(0)" data-toggle="modal" data-target="#courseDelete<?php echo $course_information->url; ?>"><i class="fa fa-trash-o" title="Delete"></i></a>
                                    <span>&nbsp;</span>-->
                                    <a href="<?php echo base_url() . $course_information->url . '/view-registered-student'; ?>">
                                        <i class="fa fa-th" title="View registered student"></i>
                                    </a><span>&nbsp;</span>

                                    <!------------- view batch area ---------------->   
                                    <?php if ($person_role == 3) { ?>
                                        <a href="<?php echo base_url() . 'view-teacher-batch/' . $course_information->url; ?>">
                                        <?php } else if ($person_role == 4) { ?>
                                            <a href="<?php echo base_url() . 'view-organization-batch/' . $course_information->url; ?>">
                                            <?php } ?>                                               
                                            <i class="fa fa-ge" title="View Batch"></i>
                                        </a><span>&nbsp;</span>
                                        <!------- end view batch area ----------->
                                        <?php
                                        $assigned_student = $this->batch_model->get_assigned_student($course_information->course_id);
                                        $assigned_student_array = array_unique(explode(',', $assigned_student));
                                        $register_student = $this->batch_model->get_register_student($course_information->course_id);
                                        $register_student_array = array_unique(explode(',', $register_student));
                                        $unasigned_student = array_diff($register_student_array, $assigned_student_array);
                                        ?>
                                        <!------------- view un assigned student ---------------->                                       
                                        <?php if (count($unasigned_student) == 0) { ?>
                                            <a href="javascript:void(0);" data-toggle="modal" data-target="#viewunassignStudentModal<?php echo $course_information->url; ?>" >
                                                <i class="fa fa-eye" title="Unassigned Student"></i>
                                            </a>&nbsp;&nbsp;&nbsp;
                                        <?php } else { ?>
                                            <a href="<?php echo base_url() . 'unassigned-student/' . $course_information->url; ?>">
                                                <i class="fa fa-eye" title="Unassigned Student"></i>
                                            </a>&nbsp;&nbsp;&nbsp;
                                        <?php } ?>  
                                        <span>&nbsp;</span>
                                        <!------- end view un assigned student ----------->  
                                        <!------------- view not eligible student ---------------->  
                                        <a href="<?php echo base_url() . 'user/not-eligible-list/' . $course_information->url ?>" target="_blank">
                                            <i class="fa fa-eye-slash" title="Not eligible"></i>
                                        </a>
                                        <!------- end not eligible student ----------->

                                        <a href="<?php echo base_url() . $course_information->url . '/create-certificate'; ?>">
                                            <i class="fa fa-certificate" title="Create Certificate"></i>
                                        </a><span>&nbsp;</span>
                                </div>
                            </div>
                            <div class="col-sm-12"><br></div>
                            <?php
                        }
                        if ($active_courses) {
//                            echo '<pre>';
//                            print_r($active_courses);
//                            exit();
                            ?>
                            <div class="col-sm-12 padding-zero text-center">
                                <?php
                                foreach ($active_courses as $course_value) {
                                    ?>
                                    <div class="col-sm-12 gray text-center">
                                        <div class="col-sm-2" style="width:100px;">
                                            <img src="<?php echo base_url() ?>image/no_image_course.png" class="img-responsive" 
                                                 class="img-responsive" 
                                                 style="margin: 0 auto; max-height: 60px; cursor: pointer;" 
                                                 alt="image">
                                        </div>
                                        <div class="col-sm-5" style="padding-top: 10px ">
                                            <a href="<?php echo base_url() . $course_value->url; ?>" target="_blank">
                                                <?php echo $course_value->course_name; ?></a>
                                        </div>
                                        <div class="col-sm-3" style="padding-top: 10px">
                                            <?php
                                            if ($course_value->course_type == 1) {
                                                if ($price_info[$course_value->course_id]->price_currency == 1) {
                                                    //echo 'BDT ' . $price_info[$course_value->course_id]->price . ' / USD ' . $this->tt_currency->set($price_info[$course_value->course_id]->price, 'BDT', 'USD')->convert_currency()->get();
                                                    echo 'BDT ' . $price_info[$course_value->course_id]->price;
                                                } else if ($price_info[$course_value->course_id]->price_currency == 2) {
                                                    //echo 'BDT ' . $this->tt_currency->set($price_info[$course_value->course_id]->price, 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $price_info[$course_value->course_id]->price;
                                                    echo ' USD ' . $price_info[$course_value->course_id]->price;
                                                }
                                            } else {
                                                echo 'Free';
                                            }
                                            ?>
                                        </div>
                                        <div class="col-sm-2" style="padding-top: 10px">
                                        <?php if($course_value->course_resource_person_edit == 1 || $course_value->person_id == $person_id){ ?>    
                                            <a href="<?php echo base_url() . 'user/edit-course/' . $course_value->url; ?>"><i class="fa fa-edit" title="Edit"></i></a>
                                            <span>&nbsp;</span>
                                        <?php } ?>
                                            <a href="<?php echo base_url() . 'user/course/add-work-file/' . $course_value->url; ?>"><i class="glyphicon glyphicon-saved" title="Add work file"></i></a>&nbsp;
                                            <span>&nbsp;</span>
                                            <a href="<?php echo base_url() . 'user/course/view-work-file/' . $course_value->url; ?>"><i class="glyphicon glyphicon-open" title="view work file"></i></a>&nbsp;
                                            <span>&nbsp;</span>
                                            <a href="<?php echo base_url() . 'invite-learners/' . $course_value->url; ?>"><i class="fa fa-envelope-o" title="Invite to Learners"></i></a>
                                            <span>&nbsp;</span>
                                            <a href="<?php echo base_url() . $course_value->url . '/view-registered-student'; ?>">
                                                <i class="fa fa-th" title="View registered student"></i>
                                            </a><span>&nbsp;</span>

                                            <!------------- view batch area ---------------->   
                                            <?php if ($person_role == 3) { ?>
                                                <a href="<?php echo base_url() . 'view-teacher-batch/' . $course_value->url; ?>">
                                                <?php } else if ($person_role == 4) { ?>
                                                    <a href="<?php echo base_url() . 'view-organization-batch/' . $course_value->url; ?>">
                                                    <?php } ?>                                               
                                                    <i class="fa fa-ge" title="View Batch"></i>
                                                </a><span>&nbsp;</span>
                                                <!------- end view batch area ----------->

                                                <!------------- view un assigned student ---------------->                                       
                                                <?php if (count($unasigned_student_active[$course_value->course_id]) == 0) { ?>
                                                    <a href="javascript:void(0);" data-toggle="modal" data-target="#viewunassignStudentModal<?php echo $course_value->url; ?>" >
                                                        <i class="fa fa-eye" title="Unassigned Student"></i>
                                                    </a>
                                                <?php } else { ?>
                                                    <a href="<?php echo base_url() . 'unassigned-student/' . $course_value->url; ?>">
                                                        <i class="fa fa-eye" title="Unassigned Student"></i>
                                                    </a>
                                                <?php } ?>  
                                                <span>&nbsp;</span>
                                                <!------- end view un assigned student ----------->  
                                                <!------------- view not eligible student ---------------->  
                                                <a href="<?php echo base_url() . 'user/not-eligible-list/' . $course_value->url ?>" target="_blank">
                                                    <i class="fa fa-eye-slash" title="Not eligible"></i>
                                                </a><span>&nbsp;</span>                                                                                              
                                                <!------- end not eligible student ----------->

                                                <a href="<?php echo base_url() . $course_value->url . '/create-certificate'; ?>">
                                                    <i class="fa fa-certificate" title="Create Certificate"></i>
                                                </a><span>&nbsp;</span>

                                        </div>
                                        
                                        <!------- unassigned student ----------->
                                        <style>
                                            @media screen and (min-width:768px){
                                                .kajol{
                                                    margin-left:125px;
                                                }
                                            }
                                        </style>
                                        
                                        
                                      <div class="modal" style="" id="viewunassignStudentModal<?php echo $course_value->url; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                                        <div class='modal-dialog'>
                                            <div class='modal-content' style='top: 180px;border: 5px solid #80c12c;border-top: 20px solid #80c12c !important;margin: 0 auto;max-width: 400px'>           
                                                <div class='modal-body text-center' style='padding-bottom: 0px;'>
                                                    <span class='text-center'>There is no unassigned student in this course</span>
                                                </div>
                                                <div class='modal-footer'>
                                                    <div  class='col-sm-12 text-center'>  
                                                        	
                                                        <span class='col-sm-3'>
                                                            <button  class='btn btn-danger kajol col-sm-12' data-dismiss='modal'>OK</button>
                                                        </span>										

                                                    </div>
                                                </div>            
                                            </div>
                                        </div>
                                      </div>
<!--                                        <div class="modal" style="" id="viewunassignStudentModal<?php //echo $course_value->url; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <div class="modal-content" style="top:80px; border: 5px solid #80c12c; border-top: 20px solid #80c12c !important;margin: 0 auto;width: 350px">           
                                                    <div class="modal-body" style="padding:20px 0px 0px 0px !important; text-align:center !important">
                                                        <h4   style="text-align:center !important">There is no unassigned student in this course</h4>
                                                    </div>
                                                    <div class="modal-footer" style="padding:5px 0px 30px 0px !important">
                                                        <div  class="col-sm-12" style="padding:0px">     
                                                            <button type="button" style="margin-left: 120px;" class="btn btn-danger col-sm-2 col-sm-offset-4" data-dismiss="modal">OK</button>
                                                        </div>
                                                    </div>            
                                                </div>
                                            </div>
                                        </div>-->

                                        <!------------------not eligible modal------------------>

                                        <div class="modal" style="" id="notEligible<?php echo $course_value->url; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <div class="modal-content" style="top: 180px;border: 5px solid #80c12c;border-top: 20px solid #80c12c !important;margin: 0 auto;width: 450px">           
                                                    <div class="modal-body">
                                                        <h4 style="text-align: center !important">Are you sure you want to make not eligible this student?</h4>
                                                    </div>
                                                    <div class="modal-footer">
                                                        <div  class="col-sm-12">               
                                                            <button onclick="makeNotEligible('<?php echo $course_value->url; ?>', '<?php echo base_url(); ?>not-eligible')" style="margin-left: 90px" type="button" class="btn btn-success  col-sm-2" data-dismiss="modal">Yes</button>
                                                            <button type="button" style="margin-left: 20px" class="btn btn-danger col-sm-2 col-sm-offset-4" data-dismiss="modal">No</button>
                                                        </div>
                                                    </div>            
                                                </div>
                                            </div>
                                        </div> 
                                        <!------------------not eligible modal------------------>                                        
                                        <div class="modal" style="" id="courseDelete<?php echo $course_value->url; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                                            <?php
                                            $status_message7 = 'Are you sure you want to Delete this Course?';
                                            $status_function_name7 = 'deleteCourse(&quot;' . base_url('user/delete-course') . '&quot;,&quot;' . $course_value->url . '&quot;)';
                                            $this->cf->get_status_modal($status_function_name7, $status_message7);
                                            ?>
                                        </div>
                                    </div>
                                    <div class="col-sm-12"><br></div>
                                    <?php
                                }
                                ?>
                            </div>
                            <?php
                        } else {
                            if ($course_id == '') {
                                ?>
                                <p>Change the world with your teaching magic! <a href="<?php echo base_url().'user/add-course'?>" target="_blank">Create Course</a></p>
                            <?php                            
                            }
                        }
                        ?>

                        <?php
                        $total_active_course = ceil($total_active_courses->total / 10);
                        if ($total_active_course > 1) {
                            ?>
                            <div class="col-sm-12 " style="padding: 0">
                                <nav class="course-pagination">
                                    <ul class="pagination">
                                        <?php
                                        if ($page > 2) {
                                            ?>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'active', '<?php echo '0' ?>')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'active', '<?php echo ($page - 1) ?>')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                        <?php } elseif ($page > 1) { ?>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'active', '<?php echo ($page - 1) ?>')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                            <?php
                                        }
                                        for ($i = 0; $total_active_course > $i; $i++) {
                                            ?>
                                            <li><a href="javascript:void(0)"
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'active', '<?php echo ($i + 1) ?>')" ><?php echo $i + 1 ?></a></li>
                                                <?php
                                            }
                                            if ($total_active_course != $page) {
                                                ?>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'active', '<?php echo ($page + 1) ?>')"
                                                   aria-label="Next">
                                                    <span aria-hidden="true" title="Next Page">&raquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:void(0)" 
                                                   onclick="coursePagination('<?php echo base_url() . 'user/course-pagination'; ?>', 'active', '<?php echo $total_active_course ?>')"
                                                   aria-label="Next">
                                                    <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                                </a>
                                            </li>
                                        <?php } ?>
                                    </ul>
                                </nav>
                            </div>
                        <?php }
                        ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php
$this->session->unset_userdata('course_tab');
$this->session->unset_userdata('course_id');
?>
<script type="text/javascript" src="<?php echo base_url() ?>front_end_resource/course/front_end/course.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>front_end_resource/course/front_end/batch.js"></script>
