<?php
$person_id = $this->session->userdata('person_id');
$person_role = $this->session->userdata('person_role');
?>
<div class="col-sm-10">
    <div class="row ">
        <div class="col-sm-12 ">
            <div class="col-sm-12 gray_ttc">
                <div class="col-sm-12 ">
                    <div class="col-sm-12">
                        <h3>
                            <?php
                            if ($status == 1) {
                                echo 'Upcomming Class';
                            } else if ($status == 2) {
                                echo 'Current Class';
                            } else if ($status == 3) {
                                echo 'Previous Class';
                            }
                            ?>
                        </h3>
                        <hr>
                    </div>

                    <div class="col-sm-12" style="padding: 0">
                        <div class="col-sm-12 gray_ttc text-left" style="border-bottom: 2px solid #8CC73F;padding-top: 10px;padding-bottom: 10px;font-weight: bold">
                            <div class="col-sm-7">Class Details</div>
                            <div class="col-sm-5">Action</div>

                        </div>
                        <div class="col-sm-12"><br></div>
                        <div class="col-sm-12">
                            <h4>
                                <?php
                                if ($classroom_status_message != '') {
                                    echo $classroom_status_message;
                                    echo '<hr><br>';
                                }
                                ?>
                            </h4>

                        </div>
                        <?php
                        $classroom_status = array('Not Started', 'Running', 'End', 'Unexpected End', 'Not Held', 'Canceled', 'Archived', 'Draft');
                        foreach ($all_classes as $class_value) {
                            ++$i;
                            ?>
                            <div class="col-sm-12 <?php
                            if ($i % 2 == 0) {
                                echo 'white';
                            } else {
                                echo 'gray';
                            }
                            ?> ">
                                <div class="col-xs-7  col-sm-9 text-left">
                                    <address>
                                        <span class="row col-sm-12">   
                                            <span class="col-sm-4" style="padding:0">Course Name</span>
                                            <span class="col-sm-1" style="padding:0">: </span>
                                            <span class="col-sm-6" style="padding:0">
                                                <a href="<?php echo base_url() . $course_info[$class_value->classroom_id]->url ?>" target="blank">
                                                    <?php echo $class_value->course_name; ?>                                            
                                                </a>
                                            </span>
                                        </span>
                                        <span class="row col-sm-12">   
                                            <span class="col-sm-4" style="padding:0">Classroom Title</span>
                                            <span class="col-sm-1" style="padding:0">: </span>
                                            <span class="col-sm-6" style="padding:0"><?php echo $class_value->classroom_title; ?> </span>
                                        </span>
                                        <span class="row col-sm-12">   
                                            <span class="col-sm-4" style="padding:0">Class Status</span>
                                            <span class="col-sm-1" style="padding:0">: </span>
                                            <span class="col-sm-6" style="padding:0">
                                                <?php
                                                if ($class_value->classroom_status == 0) {
                                                    $todays_date1 = date('Y-m-d H:i', (time() - $this->session->userdata('time_offset')));
                                                    if ($class_value->class_start_time > $todays_date1) {
                                                        if ($person_info->person_time_zone != '') {
                                                            $todays_date = new DateTime($todays_date1, new DateTimeZone($person_info->person_time_zone));
                                                            $class_start_time1 = date('Y-M-d H:i:s', (strtotime($class_value->class_start_time)));
                                                            $class_start_time = new DateTime($class_start_time1, new DateTimeZone($person_info->person_time_zone));
                                                            $interval = $class_start_time->diff($todays_date);
                                                            echo 'Start In ' . $this->cf->format_interval($interval);
                                                        } else {
                                                            echo $classroom_status[$class_value->classroom_status];
                                                        }
                                                    } else {
                                                        echo 'Not Started';
                                                    }
                                                } else {
                                                    echo $classroom_status[$class_value->classroom_status];
                                                }
                                                ?>                                        
                                            </span>
                                        </span>
                                        <span class="row col-sm-12">   
                                            <span class="col-sm-4" style="padding:0">Resource Person</span>
                                            <span class="col-sm-1" style="padding:0">: </span>
                                            <span class="col-sm-6" style="padding:0">
                                                <?php echo $resource_person_info[$class_value->classroom_id]->person_first_name . ' ' . $resource_person_info[$class_value->classroom_id]->person_last_name; ?>                                        
                                            </span>
                                        </span>
                                        <span class="row col-sm-12">
                                            <span class="col-sm-4" style="padding:0">Presented by</span>
                                            <span class="col-sm-1" style="padding:0">: </span>
                                            <span class="col-sm-6" style="padding:0">
                                                <?php
                                                if ($resource_person_info[$class_value->classroom_id]->resource_person_type == 3) {
                                                    ?>
                                                    <a href="<?php echo base_url() . $organization_info[$class_value->classroom_id]->url ?>">
                                                        <?php echo $organization_info[$class_value->classroom_id]->person_first_name . ' ' . $organization_info[$class_value->classroom_id]->person_last_name; ?>
                                                    </a>
                                                    <?php
                                                } else if ($resource_person_info[$class_value->classroom_id]->resource_person_type == 1) {
                                                    echo 'Talha Training';
                                                } else {
                                                    ?>
                                                    <a href="<?php echo base_url() . $resource_person_info[$class_value->classroom_id]->url ?>">
                                                        <?php echo $resource_person_info[$class_value->classroom_id]->person_first_name . ' ' . $resource_person_info[$class_value->classroom_id]->person_last_name; ?>
                                                    </a>
                                                    <?php
                                                }
                                                ?>
                                            </span>
                                        </span>
                                        <span class="row col-sm-12">   
                                            <span class="col-sm-4" style="padding:0">Duration</span>
                                            <span class="col-sm-1" style="padding:0">: </span>
                                            <span class="col-sm-6" style="padding:0"><?php echo $class_value->class_duration; ?></span>
                                        </span>
                                    </address>
                                </div>


                                <?php
                                if ($status == 1) {
                                    ?>
                                    <div class="col-xs-5  col-sm-3 text-left" style="padding: 20px 0 0 0">
                                        <?php
                                        if ($resource_person_info[$class_value->classroom_id]->resource_person_type == 1) {
                                            ?>
                                            <a href="<?php echo base_url() . 'edit-classroom-schedule/' . $class_value->url ?>"><i class="fa fa-edit" title="Edit"></i></a>&nbsp;&nbsp;&nbsp;
                                            <span>&nbsp;&nbsp;</span>
                                        <?php } ?>
                                        <a href="javascript:void(0)" onclick="checkClassroomAction('<?php echo base_url() . 'check-backend-classroom-action' ?>', 'Delete', '<?php echo $class_value->classroom_id; ?>')">
                                            <i class="fa fa-trash-o" title="Delete"></i>
                                        </a>&nbsp;&nbsp;&nbsp;

                                        <span>&nbsp;&nbsp;</span>
                                        <a href="javascript:void(0)" onclick="checkClassroomAction('<?php echo base_url() . 'check-backend-classroom-action' ?>', 'Cancel', '<?php echo $class_value->classroom_id; ?>')">
                                            <i class="fa  fa-times" title="Cancel Class"></i>
                                        </a>&nbsp;&nbsp;&nbsp;


                                        <a href="<?php echo base_url() . 'backend-assigned-student/' . $class_value->url; ?>">
                                            <i class="fa fa-users" title="Assigned Student"></i>
                                        </a>&nbsp;
                                        <span>&nbsp;</span>
                                        <a href="<?php echo base_url() . 'backend-assign-student/' . $class_value->url; ?>">
                                            <i class="fa fa-user-plus" title="Assign Student"></i>
                                        </a>&nbsp;
                                        <span>&nbsp;</span>
                                    </div>
                                    <?php
                                } else if ($status == 2) {
                                    if ($class_value->classroom_status == 0) {
                                        ?>
                                        <div class="col-xs-5  col-sm-3 text-left" style="padding: 20px 0 0 0">
                                            <span>&nbsp;&nbsp;</span>
                                            <a href="javascript:void(0)" onclick="checkClassroomAction('<?php echo base_url() . 'check-backend-classroom-action' ?>', 'Cancel', '<?php echo $class_value->classroom_id; ?>')">
                                                <i class="fa  fa-times" title="Cancel Class"></i>
                                            </a>&nbsp;&nbsp;&nbsp;

                                            <span>&nbsp;&nbsp;</span>
                                            <a href="javascript:void(0)" onclick="checkClassroomAction('<?php echo base_url() . 'check-backend-classroom-action' ?>', 'Cancel', '<?php echo $class_value->classroom_id; ?>')">
                                                <i class="fa  fa-play-circle-o" title="Play Class"></i>
                                            </a>&nbsp;&nbsp;&nbsp;
                                        </div>
                                        <?php
                                    } else {
                                        ?>
                                        <div class="col-xs-5  col-sm-3 text-left" style="padding: 20px 0 0 0">
                                            <span>&nbsp;&nbsp;</span>
                                            <a href="javascript:void(0)" onclick="checkClassroomAction('<?php echo base_url() . 'check-backend-classroom-action' ?>', 'Cancel', '<?php echo $class_value->classroom_id; ?>')">
                                                <i class="fa  fa-play-circle-o" title="Play Class"></i>
                                            </a>&nbsp;&nbsp;&nbsp;
                                        </div>
                                        <?php
                                    }
                                } else if ($status == 3) {
                                    if (($class_value->classroom_status == 4) || ($class_value->classroom_status == 5) || $class_value->classroom_status == 7) {
                                        ?>
                                        <div class="col-xs-5  col-sm-3 text-left" style="padding: 20px 0 0 0">
                                            <span>&nbsp;&nbsp;</span>
                                            <a href="javascript:void(0)" onclick="checkClassroomAction('<?php echo base_url() . 'check-backend-classroom-action' ?>', 'Delete', '<?php echo $class_value->classroom_id; ?>')">
                                                <i class="fa fa-trash-o" title="Delete"></i>
                                            </a>&nbsp;&nbsp;&nbsp;
                                        </div>
                                        <?php
                                    }
                                }
                                ?>
                            </div>
                            <div class="col-sm-12"><br></div>
                            <?php
                        }
                        ?>
                    </div>

                    <div class="col-sm-12"><br></div>


                    <div class="col-sm-12 " style="padding: 0">

                    </div>
                </div>
            </div>
            <div class="col-sm-12"><br></div>
            <div class="col-sm-12 gray" >
                <div class="col-sm-12 " >
                    <label><a href="dashboard.html">Dashboard </a> ->> <a href="<?php echo base_url() . 'super-admin/' . $this->session->userdata('active_sub_manu') . '-class/' ?>"> <?php echo $this->session->userdata('active_sub_manu'); ?> Class</a> </label>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="<?php echo base_url()?>back_end_resource/classroom/classroom.js"></script>
<script>