<div class="col-sm-12 gray text-center" >
    <?php foreach ($created_batch_info as $created_batch) { ?>
        <div class="col-sm-9 text-left" style="padding: 20px">
            <address>
                <span style="font-weight: normal;margin-right: 50px">Batch Name : <?php echo $created_batch->course_batch_name; ?></span>
                <br>
                <span style="font-weight: normal;margin-right: 50px">Batch No : 
                    <?php
                    echo $this->batch_model->show_batch_no($created_batch->course_id, $created_batch->course_batch_id);
                    ?>                                             
                </span>
                <br>
                <span style="font-weight: normal;margin-right: 53px">Course Tile : 
                    <a href="<?php echo base_url() . $created_batch->url; ?>"  target="_blank">
                        <?php echo $created_batch->course_name; ?>
                    </a>
                </span><br>
                <span style="font-weight: normal;margin-right: 6px">Number of student : 
                    <?php
                    $student_id = $student_number_in_batch[$created_batch->course_batch_id]->student_id;
                    $student_id_array = explode(',', $student_id);
                    echo $count_student = count(array_filter($student_id_array));
                    ?>                                                                                         
                </span> <br>
                <span style="font-weight: normal;margin-right: 68px">Start date :<?php echo $created_batch->course_batch_start_date; ?> </span><br>
                <span style="font-weight: normal;margin-right: 58px">Finish date : <?php echo $created_batch->course_batch_finish_date; ?> </span><br>
                <span style="font-weight: normal;margin-right: 115px">By :
                    <a href="<?php echo base_url() . $batch_created_by[$created_batch->person_id]->url . '/profile'; ?>" target="_blank">
                        <?php 
                            //echo $batch_created_by[$created_batch->person_id]->person_first_name . ' ' . $batch_created_by[$created_batch->person_id]->person_last_name;
                            if(strlen($batch_created_by[$created_batch->person_id]->person_first_name) && strlen($batch_created_by[$created_batch->person_id]->person_last_name) < 20){
                                  echo $batch_created_by[$created_batch->person_id]->person_first_name . ' ' . $batch_created_by[$created_batch->person_id]->person_last_name;
                                }
                                else{
                                  echo substr($batch_created_by[$created_batch->person_id]->person_first_name, 0, 30).' '.substr($batch_created_by[$created_batch->person_id]->person_last_name, 0, 20).'...';
                                }  
                        ?>
                    </a>
                </span> </br>
                <span style="font-weight: normal;margin-right: 115px">Resource Person :
                    <a href="<?php echo base_url() . $batch_resource_person[$created_batch->resource_person_id]->url . '/profile'; ?> " target="_blank">
                        <?php 
                            //echo $batch_resource_person[$created_batch->resource_person_id]->person_first_name . ' ' . $batch_resource_person[$created_batch->resource_person_id]->person_last_name;
                            if(strlen($batch_resource_person[$created_batch->resource_person_id]->person_first_name) && strlen($batch_resource_person[$created_batch->resource_person_id]->person_last_name) < 20){
                                echo $batch_resource_person[$created_batch->resource_person_id]->person_first_name . ' ' . $batch_resource_person[$created_batch->resource_person_id]->person_last_name;
                                }
                                else{
                                    echo substr($batch_resource_person[$created_batch->resource_person_id]->person_first_name, 0, 30).' '.substr($batch_resource_person[$created_batch->resource_person_id]->person_last_name, 0, 20).'...';
                                } 
                        ?>
                    </a>
                </span>
                <br>
            </address>
        </div>
        <div class="col-sm-3" style="padding-top: 10px">                                       
            <a href="<?php echo base_url(); ?>edit-batch/<?php echo $created_batch->course_batch_id . '/' . 'created'; ?>">
                <i class="fa fa-edit" title="Edit"></i>
            </a>&nbsp;&nbsp;&nbsp;                                        
            <a href="javascript:void(0);" data-toggle="modal" data-target="#deleteBatchAlert<?php echo $created_batch->course_batch_id; ?>"  >
                <i class="fa fa-trash-o" title="Delete"></i>
            </a>&nbsp;&nbsp;&nbsp;
            <a href="javascript:void(0);" data-toggle="modal" data-target="#cancelBatchAlert<?php echo $created_batch->course_batch_id; ?>" >
                <i class="fa fa-remove" title="Cancel Class"></i>
            </a>&nbsp;&nbsp;&nbsp;

            <?php if (!$course_registrated_student[$created_batch->course_id]) { ?>
                <a href="javascript:void(0);" data-toggle="modal" data-target="#viewRegisteredStudentModal<?php echo $created_batch->course_batch_id; ?>" >
                    <i class="fa fa-user-plus" title="Manage batch student"></i>
                </a>&nbsp;&nbsp;&nbsp;
            <?php } else { ?>

                <a href="<?php echo base_url() . $created_batch->url . '/view-registered-student'; ?>" target="_blank">
                    <i class="fa fa-user-plus" title="Manage batch student"></i>
                </a>&nbsp;&nbsp;&nbsp;
            <?php } ?>

            <?php if ($count_student == 0) { ?>
                <a href="javascript:void(0);" data-toggle="modal" data-target="#viewassignStudentModal<?php echo $created_batch->course_batch_id; ?>" >
                    <i class="fa fa-users" title="Batch student"></i>
                </a>&nbsp;&nbsp;&nbsp;
            <?php } else { ?>
                <a href="<?php echo base_url() .'view-assigned-student/'. $this->utility_model->encode_id($created_batch->course_batch_id  , '/', 'Tt'); ?>" target="_blank">
                    <i class="fa fa-users" title="Batch student"></i>
                </a>&nbsp;&nbsp;&nbsp;
            <?php } ?>     
        </div>  
<!--        <div class="modal" style="" id="deleteBatchAlert<?php //echo $created_batch->course_batch_id; ?>" 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 really want to cancel this batch ?</h4>
                    </div>
                    <div class="modal-footer">
                        <div  class="col-sm-12">               
                            <button onclick="deleteBatch('<?php //echo $created_batch->course_batch_id; ?>', '<?php //echo base_url(); ?>delete-batch')" 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>      

        <div class="modal" style="" id="cancelBatchAlert<?php //echo $created_batch->course_batch_id; ?>" 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 really want to cancel this batch ?</h4>
                    </div>
                    <div class="modal-footer">
                        <div  class="col-sm-12">               
                            <button onclick="cancelBatch('<?php //echo $created_batch->course_batch_id; ?>', '<?php //echo base_url(); ?>cancel-batch')" 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>  
        <div class="modal" style="" id="viewassignStudentModal<?php //echo $created_batch->course_batch_id; ?>" 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: 350px">           
                    <div class="modal-body">
                        <h4 class="text-center">Please assign registered students first</h4>
                    </div>
                    <div class="modal-footer">
                        <div  class="col-sm-12">     
                            <button type="button" style="margin-left: 110px" class="btn btn-danger col-sm-2 col-sm-offset-4" data-dismiss="modal">OK</button>
                        </div>
                    </div>            
                </div>
            </div>
        </div>

        <div class="modal" style="" id="viewRegisteredStudentModal<?php //echo $created_batch->course_batch_id; ?>" 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: 350px">           
                    <div class="modal-body">
                        <h4 class="text-center">There is no registered students in this course</h4>
                    </div>
                    <div class="modal-footer">
                        <div  class="col-sm-12">     
                            <button type="button" style="margin-left: 110px" class="btn btn-danger col-sm-2 col-sm-offset-4" data-dismiss="modal">OK</button>
                        </div>
                    </div>            
                </div>
            </div>
        </div>-->
    
    <div class="modal" style="" id="deleteBatchAlert<?php echo $created_batch->course_batch_id; ?>" 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'>Are you really want to cancel this batch </span>
                </div>
                <div class='modal-footer'>
                    <div  class='col-sm-12 text-center'>  
                        <span class='col-sm-3 col-sm-offset-3'>
                            <button type='button' class='btn btn-danger  col-sm-12' data-dismiss='modal' style='font-size: 14px;'>No</button>
                        </span> 
                        <span class='col-sm-3'>
                            <button onclick="deleteBatch('<?php echo $created_batch->course_batch_id; ?>', '<?php echo base_url(); ?>delete-batch')" class='btn btn-success col-sm-12' data-dismiss='modal'>Yes</button>
                        </span>

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

     <div class="modal" style="" id="cancelBatchAlert<?php echo $created_batch->course_batch_id; ?>" 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'>Are you really want to cancel this batch </span>
                </div>
                <div class='modal-footer'>
                    <div  class='col-sm-12 text-center'>  
                        <span class='col-sm-3 col-sm-offset-3'>
                            <button type='button' class='btn btn-danger  col-sm-12' data-dismiss='modal' style='font-size: 14px;'>No</button>
                        </span> 
                        <span class='col-sm-3'>
                            <button onclick="cancelBatch('<?php echo $created_batch->course_batch_id; ?>', '<?php echo base_url(); ?>cancel-batch')" class='btn btn-success col-sm-12' data-dismiss='modal'>Yes</button>
                        </span>

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

<div class="modal" style="" id="viewassignStudentModal<?php echo $created_batch->course_batch_id; ?>" 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'>Please assign registered students first</span>
        </div>
        <div class='modal-footer'>
            <div  class='col-sm-12 text-center'>  
                <span class='col-sm-3 col-sm-offset-3'>
                    <button type='button' style="margin-left: 40px" class='btn btn-danger  col-sm-12' data-dismiss='modal' style='font-size: 14px;'>OK</button>
                </span> 
            </div>
        </div>            
    </div>
 </div>
</div>

<div class="modal" style="" id="viewRegisteredStudentModal<?php echo $created_batch->course_batch_id; ?>" 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 registered students in this course</span>
        </div>
        <div class='modal-footer'>
            <div  class='col-sm-12 text-center'>  
                <span class='col-sm-3 col-sm-offset-3'>
                    <button type='button' style="margin-left: 40px" class='btn btn-danger  col-sm-12' data-dismiss='modal' style='font-size: 14px;'>OK</button>
                </span> 
            </div>
        </div>            
    </div>
 </div>
</div>

    <?php } ?>
</div>
<div class="col-sm-12"><br></div>
<!-----------------------------------Created batch start Pagination------------------------------------------>

<?php
$total_page = ceil($total_created_batch->total_batch / 5);
if ($total_page > 1) {
    ?>
    <nav class="course-pagination">
        <ul class="pagination">
            <?php
            if ($page > 2) {
                ?>
                <li>
                    <a href="javascript:void(0)" 
                       onclick="batchPagination('<?php echo base_url() . 'batch-pagination'; ?>', 'created', '<?php echo 1 ?>')"
                       aria-label="Previous">
                        <span aria-hidden="true" title="First Page">««</span>
                    </a>
                </li>
                <li>
                    <a href="javascript:void(0)" 
                       onclick="batchPagination('<?php echo base_url() . 'batch-pagination'; ?>', 'created', '<?php echo ($page - 1) ?>')"
                       aria-label="Previous">
                        <span aria-hidden="true" title="Previous Page">«</span>
                    </a>
                </li>
            <?php } elseif ($page > 1) { ?>
                <li>
                    <a href="javascript:void(0)" 
                       onclick="batchPagination('<?php echo base_url() . 'batch-pagination'; ?>', 'created', '<?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="batchPagination('<?php echo base_url() . 'batch-pagination'; ?>', 'created', '<?php echo ($i + 1) ?>')" ><?php echo $i + 1 ?></a></li>
                    <?php
                }
                if ($total_page != $page) {
                    ?>
                <li>
                    <a href="javascript:void(0)" 
                       onclick="batchPagination('<?php echo base_url() . 'batch-pagination'; ?>', 'created', '<?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="batchPagination('<?php echo base_url() . 'batch-pagination'; ?>', 'created', '<?php echo $total_page ?>')"
                       aria-label="Next">
                        <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                    </a>
                </li>
            <?php }
            ?>
        </ul>
    </nav>
<?php } ?> 