<script>
    function create_xmlhttp() {
        var xmlhttp = false;
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
            xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
    }
</script>
<div class="col-sm-10">
    <div class="row gray">
        <div class="col-sm-12">
            <div class="col-sm-12">
                <div class="col-sm-3" style="padding:5px;">
                    <h3 class="padding-zero" style="padding:0px; margin:0px">
                        My Batch
                    </h3>
                </div>
                <div class="col-sm-6">
                    <form action="javascript:void(0)" method="post">
                        <div class="input-group">
                            <input type="text" 
                                   class="form-control"
                                   oninput="getValueForSearch(this.value)"
                                   placeholder="Search here..." 
                                   aria-describedby="basic-addon1">
                            <span class="input-group-addon" id="basic-addon1"><i class="fa fa-search"></i></span>
                        </div>
                    </form>
                </div>
            </div>
            <div class="col-sm-12"><hr></div>
            <div class="col-sm-12"><hr></div>
        </div>

        <div class="col-sm-12">
            <ul class="nav nav-tabs">
                <li class="active"><a data-toggle="tab" href="javascript:;#created" onclick="set_batch_status('created')">Create(<?php echo $total_created_batch; ?>)</a></li>
                <li><a data-toggle="tab" href="javascript:;#running" onclick="set_batch_status('running')">Running(<?php echo $total_running_batch; ?>)</a></li>
                <li><a data-toggle="tab" href="javascript:;#finished" onclick="set_batch_status('finished')">Finished (<?php echo $total_finished_batch; ?>)</a></li>
                <li><a data-toggle="tab" href="javascript:;#canceled" onclick="set_batch_status('canceled')">Cancel(<?php echo $total_canceled_batch; ?>)</a></li>
            </ul>
        </div>
        <div class="col-sm-12">
            <div class="tab-content">
                <div id="created" class="tab-pane fade 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-9 text-left"> Batch Details </div>
                        <div class="col-sm-3">Action</div>
                    </div>
                    <div class="col-sm-12"><br></div>

                    <?php
                    if ($created_batch) {
                        $i = 1;
                        $security_salt = '#' . rand(1, 99999);

                        foreach ($created_batch as $value) {
                            $s_id = $value->course_batch_id . $security_salt;
                            $e_id = $this->encrypt->encode($s_id);
                            $e_id = str_replace("/", "%F2", $e_id);
                            ?>
                            <div id="actions_for<?php echo $value->course_batch_id; ?>">
                                <div class="col-sm-12 <?php
                                if ($i % 2 == 0) {
                                    echo 'gray';
                                } else {
                                    echo 'white';
                                }
                                ?>" >
                                    <div class="col-sm-12 gray text-center" >
                                        <div class="col-sm-9 text-left" style="padding: 20px">
                                            <address>
                                                <span style="font-weight: bold;margin-right: 50px">Batch Name : </span>
                                                <?php echo $value->course_batch_name; ?><br>

                                                <span style="font-weight: bold;margin-right: 53px">Course Tile : </span>
                                                <a href="<?php echo base_url() . $value->url; ?>"  target="_blank">
                                                    <?php echo $value->course_name; ?>
                                                </a><br>

                                                <?php
                                                $student_id = explode(',', $value->student_id);
                                                ?>
                                                <span style="font-weight: bold;margin-right: 6px">Number of student : </span>
                                                <a href="<?php echo base_url() . 'super-admin/batch-assigned-student/' . $value->url . '/' . $e_id; ?>">
                                                    <?php
                                                    if ($value->student_id) {
                                                        echo count($student_id);
                                                    } else {
                                                        echo 0;
                                                    }
                                                    ?>
                                                </a><br>

                                                <span style="font-weight: bold;margin-right: 68px">Start date : </span>
                                                <?php
                                                if ($value->course_start_date != '') {
                                                    echo date('d F, Y', strtotime($value->course_batch_start_date));
                                                }
                                                ?><br>

                                                <span style="font-weight: bold;margin-right: 58px">Finish date : </span>
                                                <?php
                                                if ($value->course_start_date != '') {
                                                    echo date('d F, Y', strtotime($value->course_batch_finish_date));
                                                }
                                                ?><br>

                                                <span style="font-weight: bold;margin-right: 115px">By : </span>
                                                <a href="<?php echo base_url() . $resource_person_info[$value->course_batch_id]->url . '/profile'; ?>" target="_blank">
                                                    <?php echo $resource_person_info[$value->course_batch_id]->person_first_name . ' ' . $resource_person_info[$value->course_batch_id]->person_last_name; ?>
                                                </a>
                                                <br>
                                            </address>
                                        </div>

                                        <div class="col-sm-3" style="padding-top: 10px">

                                            <a href="<?php echo base_url() . 'super-admin/edit-batch/' . $value->course_batch_id; ?>">
                                                <i class="fa fa-edit" title="Edit"></i>
                                            </a>&nbsp;&nbsp;&nbsp;

                                            <a href="javascript:;" 
                                               onclick="return checkForAction('<?php echo base_url() . 'super-admin/delete-course-batch/' . $value->course_batch_id; ?>', 'Delete', <?php echo $value->course_batch_id; ?>)">
                                                <i class="fa fa-trash-o" title="Delete"></i> 
                                            </a>&nbsp;&nbsp;&nbsp;

                                            <a href="javascript:;" 
                                               onclick="return checkForAction('<?php echo base_url() . 'super-admin/cancel-course-batch/' . $value->course_batch_id; ?>', 'Cancel', <?php echo $value->course_batch_id; ?>)">
                                                <i class="fa  fa-remove" title="Cancel Class"></i>
                                            </a>&nbsp;&nbsp;&nbsp;

                                            <a href="<?php echo base_url() . 'super-admin/course-registered-student/' . $value->url . '/1/' . $e_id; ?>" >
                                                <i class="fa fa-user-plus" title="Manage batch student"></i>
                                            </a>&nbsp;&nbsp;&nbsp;

                                            <a href="<?php echo base_url() . 'super-admin/batch-assigned-student/' . $value->url . '/' . $e_id; ?>" >
                                                <i class="fa fa-users" title="Batch student"></i>
                                            </a>&nbsp;&nbsp;&nbsp;

                                        </div>

                                    </div>
                                    <div class="col-sm-12"><br></div>
                                </div>
                            </div>
                            <?php
                            $i++;
                        }
                    } else {
                        echo 'Created batch not foud';
                    }
                    ?>

                    <!--------------------Created batch start Pagination---------------------------->
                    <div class="col-sm-12">
                        <?php $total_page = ceil($total_created_batch / $per_page_view); ?>
                        <div class="col-sm-12 form-group">
                            <?php
                            if ($total_page > 1) {
                                ?>
                                <nav class="course-pagination">
                                    <ul class="pagination">
                                        <?php
                                        if ($page > 2) {
                                            ?>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/created-batch/1'; ?>', 'created')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/created-batch' . '/' . ($page - 1); ?>', 'created')" 
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                        <?php } elseif ($page > 1) { ?>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/created-batch' . '/' . ($page - 1); ?>', 'created')"  
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                            <?php
                                        }
                                        $count_page = 0;
                                        if ($total_page < 10) {
                                            for ($i = $page; $total_page >= $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/created-batch' . '/' . $i; ?>', 'created')">
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else if ($page + 10 <= $total_page) {
                                            $count_page = $page + 10;
                                            for ($i = $page; $count_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/created-batch' . '/' . $i; ?>', 'created')" >
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else {
                                            for ($i = $total_page - 10; $total_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i + 1) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href="javascript:;"  onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/created-batch' . '/' . ($i + 1); ?>', 'created')" > 
                                                            <?php echo ($i + 1) ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        }

                                        if ($total_page > $page + 10) {
                                            ?>
                                            <li>
                                                <a href="javascript:;" onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/created-batch' . '/' . ($page + 1); ?>', 'created')" aria-label="Next">
                                                    <span aria-hidden="true" title="Next Page">&raquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:;" onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/created-batch' . '/' . $total_page; ?>', 'created')" aria-label="Next">
                                                    <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                                </a>
                                            </li>
                                        <?php } ?>
                                    </ul>
                                </nav>
                            <?php } ?>
                        </div>
                    </div>
                </div>


                <div id="running" class="tab-pane fade">
                    <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-9 text-left"> Batch Details </div>

                        <div class="col-sm-3">Action</div>
                    </div>
                    <div class="col-sm-12"><br></div> 
                    <?php
                    if ($running_batch) {
                        $i = 1;
                        $security_salt = '#' . rand(1, 99999);
                        foreach ($running_batch as $value) {
                            $s_id = $value->course_batch_id . $security_salt;
                            $e_id = $this->encrypt->encode($s_id);
                            $e_id = str_replace("/", "%F2", $e_id);
                            ?>
                            <div id="actions_for<?php echo $value->course_batch_id; ?>">
                                <div class="col-sm-12 <?php
                                if ($i % 2 == 0) {
                                    echo 'gray';
                                } else {
                                    echo 'white';
                                }
                                ?>" >

                                    <div class="col-sm-12 gray text-center" >
                                        <div class="col-sm-9 text-left" style="padding: 20px">
                                            <address>
                                                <span style="font-weight: bold;margin-right: 50px">Batch Name : </span>
                                                <?php echo $value->course_batch_name; ?><br>

                                                <span style="font-weight: bold;margin-right: 53px">Course Tile : </span>
                                                <a href="<?php echo base_url() . $value->url; ?>"><?php echo $value->course_name; ?>
                                                </a><br>

                                                <?php
                                                $student_id = explode(',', $value->student_id);
                                                ?>                                
                                                <span style="font-weight: bold;margin-right: 6px">Number of student : </span>
                                                <a href="<?php echo base_url() . 'super-admin/batch-assigned-student/' . $value->url . '/' . $e_id; ?>">
                                                    <?php
                                                    if ($value->student_id) {
                                                        echo count($student_id);
                                                    } else {
                                                        echo 0;
                                                    }
                                                    ?>
                                                </a><br>

                                                <span style="font-weight: bold;margin-right: 68px">Start date : </span>
                                                <?php
                                                if ($value->course_start_date != '') {
                                                    echo date('d F, Y', strtotime($value->course_batch_start_date));
                                                }
                                                ?><br>

                                                <span style="font-weight: bold;margin-right: 58px">Finish date : </span>
                                                <?php
                                                if ($value->course_start_date != '') {
                                                    echo date('d F, Y', strtotime($value->course_batch_finish_date));
                                                }
                                                ?><br>

                                                <span style="font-weight: bold;margin-right: 115px">By : </span>
                                                <a href="<?php echo base_url() . $resource_person_info[$value->course_batch_id]->url . '/profile'; ?>" target="_blank">
                                                    <?php echo $resource_person_info[$value->course_batch_id]->person_first_name . ' ' . $resource_person_info[$value->course_batch_id]->person_last_name; ?>
                                                </a>
                                                <br>
                                            </address>
                                        </div>

                                        <div class="col-sm-3" style="padding-top: 10px">

                                            <a href="<?php echo base_url() . 'super-admin/edit-batch/' . $value->course_batch_id; ?>">
                                                <i class="fa fa-edit" title="Edit"></i>
                                            </a>&nbsp;&nbsp;

                                            <a href="<?php echo base_url() . 'super-admin/course-registered-student/' . $value->url . '/1/' . $e_id; ?>" >
                                                <i class="fa fa-user-plus" title="Manage batch student"></i>
                                            </a>&nbsp;&nbsp;&nbsp;

                                            <a href="<?php echo base_url() . 'super-admin/batch-assigned-student/' . $value->url . '/' . $e_id; ?>" >
                                                <i class="fa fa-users" title="Batch student"></i>
                                            </a>&nbsp;&nbsp;&nbsp;

                                        </div>

                                    </div>
                                    <div class="col-sm-12"><br></div>
                                </div>
                            </div>
                            <?php
                            $i++;
                        }
                    } else {
                        echo 'Running batch not foud';
                    }
                    ?>

                    <!--------------------Created batch start Pagination---------------------------->
                    <div class="col-sm-12">
                        <?php $total_page = ceil($total_running_batch / $per_page_view); ?>
                        <div class="col-sm-12 form-group">
                            <?php
                            if ($total_page > 1) {
                                ?>
                                <nav class="course-pagination">
                                    <ul class="pagination">
                                        <?php
                                        if ($page > 2) {
                                            ?>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/running-batch/1'; ?>', 'running')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/running-batch' . '/' . ($page - 1); ?>', 'running')" 
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                        <?php } elseif ($page > 1) { ?>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/running-batch' . '/' . ($page - 1); ?>', 'running')"  
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                            <?php
                                        }
                                        $count_page = 0;
                                        if ($total_page < 10) {
                                            for ($i = $page; $total_page >= $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/running-batch' . '/' . $i; ?>', 'running')">
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else if ($page + 10 <= $total_page) {
                                            $count_page = $page + 10;
                                            for ($i = $page; $count_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/running-batch' . '/' . $i; ?>', 'running')" >
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else {
                                            for ($i = $total_page - 10; $total_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i + 1) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href="javascript:;"  onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/running-batch' . '/' . ($i + 1); ?>', 'running')" > 
                                                            <?php echo ($i + 1) ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        }

                                        if ($total_page > $page + 10) {
                                            ?>
                                            <li>
                                                <a href="javascript:;" onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/running-batch' . '/' . ($page + 1); ?>', 'running')" aria-label="Next">
                                                    <span aria-hidden="true" title="Next Page">&raquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:;" onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/running-batch' . '/' . $total_page; ?>', 'running')" aria-label="Next">
                                                    <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                                </a>
                                            </li>
                                        <?php } ?>
                                    </ul>
                                </nav>
                            <?php } ?>
                        </div>
                    </div>
                </div>
                <div id="finished" class="tab-pane fade">
                    <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-9 text-left"> Batch Details </div>
                        <div class="col-sm-3">Action</div>
                    </div>
                    <div class="col-sm-12"><br></div> 
                    <?php
                    if ($finished_batch) {
                        $i = 1;
                        $security_salt = '#' . rand(1, 99999);
                        foreach ($finished_batch as $value) {
                            $s_id = $value->course_batch_id . $security_salt;
                            $e_id = $this->encrypt->encode($s_id);
                            $e_id = str_replace("/", "%F2", $e_id);
                            ?>
                            <div id="actions_for<?php echo $value->course_batch_id; ?>">
                                <div class="col-sm-12 <?php
                                if ($i % 2 == 0) {
                                    echo 'gray';
                                } else {
                                    echo 'white';
                                }
                                ?>" >

                                    <div class="col-sm-12 gray text-center" >
                                        <div class="col-sm-9 text-left" style="padding: 20px">
                                            <address>
                                                <span style="font-weight: bold;margin-right: 50px">Batch Name : </span>
                                                <?php echo $value->course_batch_name; ?><br>

                                                <span style="font-weight: bold;margin-right: 53px">Course Tile : </span>
                                                <a href="<?php echo base_url() . $value->url; ?>"><?php echo $value->course_name; ?>
                                                </a><br>

                                                <?php
                                                $student_id = explode(',', $value->student_id);
                                                ?>                                
                                                <span style="font-weight: bold;margin-right: 6px">Number of student : </span>
                                                <a href="<?php echo base_url() . 'super-admin/batch-assigned-student/' . $value->url . '/' . $e_id; ?>">
                                                    <?php
                                                    if ($value->student_id) {
                                                        echo count($student_id);
                                                    } else {
                                                        echo 0;
                                                    }
                                                    ?>
                                                </a><br>

                                                <span style="font-weight: bold;margin-right: 68px">Start date : </span>
                                                <?php
                                                if ($value->course_start_date != '') {
                                                    echo date('d F, Y', strtotime($value->course_batch_start_date));
                                                }
                                                ?><br>

                                                <span style="font-weight: bold;margin-right: 58px">Finish date : </span>
                                                <?php
                                                if ($value->course_start_date != '') {
                                                    echo date('d F, Y', strtotime($value->course_batch_finish_date));
                                                }
                                                ?><br>

                                                <span style="font-weight: bold;margin-right: 115px">By : </span>
                                                <a href="<?php echo base_url() . $resource_person_info[$value->course_batch_id]->url . '/profile'; ?>" target="_blank">
                                                    <?php echo $resource_person_info[$value->course_batch_id]->person_first_name . ' ' . $resource_person_info[$value->course_batch_id]->person_last_name; ?>
                                                </a>
                                                <br>
                                            </address>
                                        </div>

                                        <div class="col-sm-3" style="padding-top: 10px">

                                            <a href="<?php echo base_url() . 'super-admin/batch-assigned-student/' . $value->url . '/' . $e_id; ?>" >
                                                <i class="fa fa-users" title="Batch student"></i>
                                            </a>&nbsp;&nbsp;&nbsp;

                                        </div>

                                    </div>
                                    <div class="col-sm-12"><br></div>
                                </div>
                            </div>
                            <?php
                            $i++;
                        }
                    } else {
                        echo 'Finished batch not foud';
                    }
                    ?>

                    <!--------------------Created batch start Pagination---------------------------->
                    <div class="col-sm-12">
                        <?php $total_page = ceil($total_finished_batch / $per_page_view); ?>
                        <div class="col-sm-12 form-group">
                            <?php
                            if ($total_page > 1) {
                                ?>
                                <nav class="course-pagination">
                                    <ul class="pagination">
                                        <?php
                                        if ($page > 2) {
                                            ?>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/finished-batch/1'; ?>', 'finished')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/finished-batch' . '/' . ($page - 1); ?>', 'finished')" 
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                        <?php } elseif ($page > 1) { ?>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/finished-batch' . '/' . ($page - 1); ?>', 'finished')"  
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                            <?php
                                        }
                                        $count_page = 0;
                                        if ($total_page < 10) {
                                            for ($i = $page; $total_page >= $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/finished-batch' . '/' . $i; ?>', 'finished')">
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else if ($page + 10 <= $total_page) {
                                            $count_page = $page + 10;
                                            for ($i = $page; $count_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/finished-batch' . '/' . $i; ?>', 'finished')" >
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else {
                                            for ($i = $total_page - 10; $total_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i + 1) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href="javascript:;"  onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/finished-batch' . '/' . ($i + 1); ?>', 'finished')" > 
                                                            <?php echo ($i + 1) ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        }

                                        if ($total_page > $page + 10) {
                                            ?>
                                            <li>
                                                <a href="javascript:;" onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/finished-batch' . '/' . ($page + 1); ?>', 'finished')" aria-label="Next">
                                                    <span aria-hidden="true" title="Next Page">&raquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:;" onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/finished-batch' . '/' . $total_page; ?>', 'finished')" aria-label="Next">
                                                    <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                                </a>
                                            </li>
                                        <?php } ?>
                                    </ul>
                                </nav>
                            <?php } ?>
                        </div>
                    </div>

                </div>
                <div id="canceled" class="tab-pane fade">
                    <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-9 text-left"> Batch Details </div>

                        <div class="col-sm-3">Action</div>
                    </div>
                    <div class="col-sm-12"><br></div> 
                    <?php
                    if ($canceled_batch) {
                        $i = 1;
                        $security_salt = '#' . rand(1, 99999);
                        foreach ($canceled_batch as $value) {
                            $s_id = $value->course_batch_id . $security_salt;
                            $e_id = $this->encrypt->encode($s_id);
                            $e_id = str_replace("/", "%F2", $e_id);
                            ?>
                            <div id="actions_for<?php echo $value->course_batch_id; ?>">
                                <div class="col-sm-12 <?php
                                if ($i % 2 == 0) {
                                    echo 'gray';
                                } else {
                                    echo 'white';
                                }
                                ?>" >

                                    <div class="col-sm-12 gray text-center" >
                                        <div class="col-sm-9 text-left" style="padding: 20px">
                                            <address>
                                                <span style="font-weight: bold;margin-right: 50px">Batch Name : </span>
                                                <?php echo $value->course_batch_name; ?><br>

                                                <span style="font-weight: bold;margin-right: 53px">Course Tile : </span>
                                                <a href="<?php echo base_url() . $value->url; ?>"><?php echo $value->course_name; ?>
                                                </a><br>

                                                <?php
                                                $student_id = explode(',', $value->student_id);
                                                ?>                                
                                                <span style="font-weight: bold;margin-right: 6px">Number of student : </span>
                                                <a href="<?php echo base_url() . 'super-admin/batch-assigned-student/' . $value->url . '/' . $e_id; ?>">
                                                    <?php
                                                    if ($value->student_id) {
                                                        echo count($student_id);
                                                    } else {
                                                        echo 0;
                                                    }
                                                    ?>
                                                </a><br>

                                                <span style="font-weight: bold;margin-right: 68px">Start date : </span>
                                                <?php
                                                if ($value->course_start_date != '') {
                                                    echo date('d F, Y', strtotime($value->course_batch_start_date));
                                                }
                                                ?><br>

                                                <span style="font-weight: bold;margin-right: 58px">Finish date : </span>
                                                <?php
                                                if ($value->course_start_date != '') {
                                                    echo date('d F, Y', strtotime($value->course_batch_finish_date));
                                                }
                                                ?><br>

                                                <span style="font-weight: bold;margin-right: 115px">By : </span>
                                                <a href="<?php echo base_url() . $resource_person_info[$value->course_batch_id]->url . '/profile'; ?>" target="_blank">
                                                    <?php echo $resource_person_info[$value->course_batch_id]->person_first_name . ' ' . $resource_person_info[$value->course_batch_id]->person_last_name; ?>
                                                </a>
                                                <br>
                                            </address>
                                        </div>

                                        <div class="col-sm-3" style="padding-top: 10px">

                                            <a href="<?php echo base_url() . 'super-admin/edit-batch/' . $value->course_batch_id; ?>">
                                                <i class="fa fa-edit" title="Edit"></i>
                                            </a>&nbsp;&nbsp;

                                            <a href="javascript:;" 
                                               onclick="return checkForAction('<?php echo base_url() . 'super-admin/delete-course-batch/' . $value->course_batch_id; ?>', 'Delete', <?php echo $value->course_batch_id; ?>)">
                                                <i class="fa fa-trash-o" title="Delete"></i> 
                                            </a>&nbsp;&nbsp;&nbsp;

                                            <a href="<?php echo base_url() . 'super-admin/batch-assigned-student/' . $value->url . '/' . $e_id; ?>" >
                                                <i class="fa fa-users" title="Batch student"></i>
                                            </a>&nbsp;&nbsp;&nbsp;

                                        </div>
                                    </div>
                                    <div class="col-sm-12"><br></div>
                                </div>
                            </div>
                            <?php
                            $i++;
                        }
                    } else {
                        echo 'Canceled batch not foud';
                    }
                    ?>

                    <!--------------------Created batch start Pagination---------------------------->
                    <div class="col-sm-12">
                        <?php $total_page = ceil($total_canceled_batch / $per_page_view); ?>
                        <div class="col-sm-12 form-group">
                            <?php
                            if ($total_page > 1) {
                                ?>
                                <nav class="course-pagination">
                                    <ul class="pagination">
                                        <?php
                                        if ($page > 2) {
                                            ?>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/canceled-batch/1'; ?>', 'canceled')"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/canceled-batch' . '/' . ($page - 1); ?>', 'canceled')" 
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                        <?php } elseif ($page > 1) { ?>
                                            <li>
                                                <a href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/canceled-batch' . '/' . ($page - 1); ?>', 'canceled')"  
                                                   aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                            <?php
                                        }
                                        $count_page = 0;
                                        if ($total_page < 10) {
                                            for ($i = $page; $total_page >= $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/canceled-batch' . '/' . $i; ?>', 'canceled')">
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else if ($page + 10 <= $total_page) {
                                            $count_page = $page + 10;
                                            for ($i = $page; $count_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href='javascript:;' onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/canceled-batch' . '/' . $i; ?>', 'canceled')" >
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else {
                                            for ($i = $total_page - 10; $total_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i + 1) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                        href="javascript:;"  onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/canceled-batch' . '/' . ($i + 1); ?>', 'canceled')" > 
                                                            <?php echo ($i + 1) ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        }

                                        if ($total_page > $page + 10) {
                                            ?>
                                            <li>
                                                <a href="javascript:;" onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/canceled-batch' . '/' . ($page + 1); ?>', 'canceled')" aria-label="Next">
                                                    <span aria-hidden="true" title="Next Page">&raquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="javascript:;" onclick="pagination('<?php echo base_url() . 'super-admin/manage-batch/canceled-batch' . '/' . $total_page; ?>', 'canceled')" aria-label="Next">
                                                    <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                                </a>
                                            </li>
                                        <?php } ?>
                                    </ul>
                                </nav>
                            <?php } ?>
                        </div>
                    </div>

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

<script>
    var baseURL = '<?php echo base_url(); ?>';
    var tabID = '<?php echo $this->session->userdata('batch_status_type') ?>';
    var paginationURL = baseURL + 'super-admin/manage-batch/' + tabID + '-batch/1';

    function checkForAction(url, action, ID) {
        swal({
            title: "",
            text: "Are you sure you want to " + action + " this Schedule?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: '#DD6B55',
            confirmButtonText: "Yes",
            cancelButtonText: "No",
            closeOnConfirm: true,
            closeOnCancel: true},
        function (isConfirm) {
            if (isConfirm) {
                serverPage = url;
                var xmlhttp = create_xmlhttp();
                xmlhttp.open("GET", serverPage);
                xmlhttp.onreadystatechange = function ()
                {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
                        _("actions_for" + ID).innerHTML = xmlhttp.responseText;
                        location.reload();
                    }
                }
                xmlhttp.send(null);
            }
        });
    }

    function pagination(url, objID) {
        serverPage = url;
        paginationURL = url;
        var xmlhttp = create_xmlhttp();
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
            {
                _(objID).innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.send(null);
    }

    function getValueForSearch(input) {
        input = input.replace(/  +/g, ' ');
        var searchValue;
        if (input == null) {
            pagination(paginationURL, tabID);
            searchValue = 'null';
        } else if (input === '') {
            pagination(paginationURL, tabID);
            searchValue = 'null';
        } else {
            searchValue = input;
            var xhr = create_xmlhttp();
            var formdata = new FormData();
            formdata.append("search_value", searchValue);
            xhr.addEventListener("load", function () {
                _(tabID).innerHTML = xhr.responseText;
            }, false);
            xhr.open("POST", "<?php echo base_url() . 'super-admin/search-batch'; ?>");
            xhr.send(formdata);
        }
    }

    function set_batch_status(batch_type) {
        tabID = batch_type;
        var xhr = create_xmlhttp();
        var formdata = new FormData();
        formdata.append("batch_status_type", batch_type);
        xhr.addEventListener("load", function () {
            paginationURL = '<?php echo base_url(); ?>super-admin/manage-batch/' + tabID + '-batch/1';
        }, false);
        xhr.open("POST", "<?php echo base_url() . 'super-admin/set-batch-type'; ?>");
        xhr.send(formdata);
    }

</script>