<?php
//$this->load->library('ForeignExchange');
//$fx = new ForeignExchange('BDT', 'USD');

if ($course_type == 'draft') {
    if ($draft_courses) {
        ?>
        <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 ($course_value->course_price_currency == 1) {
                                
                                //echo 'BDT ' . $course_value->course_price . ' / USD ' . $this->tt_currency->set($course_value->course_price, 'BDT', 'USD')->convert_currency()->get();
                                echo 'BDT ' . $course_value->course_price;
                            } else if ($course_value->course_price_currency == 2) {
                                
                                //echo 'BDT ' . $this->tt_currency->set($course_value->course_price, 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $course_value->course_price;
                                echo ' USD ' . $course_value->course_price;
                            }
                        } else {
                            echo 'Call +8801712742217 for Price';
                        }
                        ?>
                    </div>
                    <div class="col-sm-2" style="padding-top: 10px">
                        <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>
                        <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)" 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>
                    </div>
                </div>
                <div class="col-sm-12"><br></div>
                <?php
            }
            ?>
        </div>
        <?php
    } else {?>
        <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 '1' ?>')"
                               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
    }
}
if ($course_type == 'submit') {
    if ($submit_courses) {
        ?>
        <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 ($course_value->course_price_currency == 1) {
                                
                                //echo 'BDT ' . $course_value->course_price . ' / USD ' . $this->tt_currency->set($course_value->course_price, 'BDT', 'USD')->convert_currency()->get();
                                echo 'BDT ' . $course_value->course_price;
                            } else if ($course_value->course_price_currency == 2) {
                                
                                //echo 'BDT ' . $this->tt_currency->set($course_value->course_price, 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $course_value->course_price;
                                echo ' USD ' . $course_value->course_price;
                            }
                        } else {
                            echo 'Call +8801712742217 for Price';
                        }
                        ?>
                    </div>
                    <div class="col-sm-2" style="padding-top: 10px">
                        <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>
                        <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)" 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>
                    </div>
                </div>
                <div class="col-sm-12"><br></div>
                <?php
            }
            ?>
        </div>
        <?php
    } else {?>
        <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 '1' ?>')"
                               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
    }
}
if ($course_type == 'active') {
    if ($active_courses) {
        ?>
        <div class="col-sm-12 padding-zero">
            <?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 'Call +8801712742217 for Price';
                        }
                        ?>
                    </div>
                    <div class="col-sm-2" style="padding-top: 10px">
                        <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>
                        <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)" 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>
                    </div>
                </div>
                <div class="col-sm-12"><br></div>
                <?php
            }
            ?>
        </div>
        <?php
    } else {
        ?>
        <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 '1' ?>')"
                               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
    }
}