<?php defined('BASEPATH') or exit('No direct Access is Allowed'); ?>

<?php
  $last     = $this->uri->total_segments();
  $courseid = $this->uri->segment($last);

?>
<div class="content-wrapper">
  <section class="content">
  <div class="row">
    <div class="col-xs-12">
	    <!-- <div class="box">
        <div class="box-body table-responsive no-padding">
           <div class="border_full">
              <h3 class="full_h3">Course Info
                <a href="<?=site_url('admin/account/Account');?>" class="course_lists pull-right btn btn-sm btn-social" style="background-color: #ffffff;"><i class="fa fa-list text-green"></i> Account List</a>
                <a href="<?=site_url('admin/account/Account/teacher_wallet');?>" class="course_lists pull-right btn btn-sm btn-social" style="background-color: #ffffff;"><i class="fa fa-edit text-green"></i>Teacher Wallet</a>
                  <a href="<?=site_url('admin/account/Account/student_wallet');?>" class="course_lists pull-right btn btn-sm btn-social" style="background-color: #ffffff;"><i class="fa fa-edit text-green"></i>Student Wallet</a>
              </h3>
              <div class="table-responsive1">
                <table class="table table-bordered table-responsive" id="">
                  <thead>
                    <tr>
                      <th>Student Name</th>
                      <th>Course Name</th>
                      <th>Faculty</th>
                      <th>Total Course Enrolled</th>
                      <th>Total Class Enrolled</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td><?php echo strtoupper($list[0]->student_name);?></td>
                      <td><?php echo strtoupper($list[0]->course_name);?></td>
                      <td><?php echo ucwords($list[0]->faculty); ?></td>
                      <td><?php $a= explode(',',$course_count);echo count(array_unique($a)); ?></td>
                      <td><?php echo ucwords($class_count); ?></td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
         </div>
		 </div> -->

    <div class="box">
      <div class="box-body table-responsive no-padding">
        <div class="border_full">
          <h3 class="full_h3">Course Class List [<?=$list[0]->course_name;?>]
            <a href="<?=site_url('admin/course/Course');?>" class="course_lists pull-right btn btn-sm btn-social" style="background-color: #ffffff;"><i class="fa fa-list text-green"></i> Course List</a>
            <a href="#" class="btn btn-sm btn-social btn-github button_collapse pull-right">
            <i class="fa fa-fw fa-search  text-green "></i>Search</a>
              <a href="<?=site_url('admin/course/Course/create');?>" class="course_lists pull-right btn btn-sm btn-social" style="background-color: #ffffff;"><i class="fa fa-edit text-green"></i>Add New course</a>

          </h3>
          <div  id="reportsummary">
            <div id="tableContainer2" class="container-tb">
              <table class="table-hover">
              <thead>
                <tr>
                  <th>Sr.</th>
                  <th>Class id</th>
                  <th>Class Date</th>
                  <th>Class Start</th>
                  <th>Class Close</th>
                  <th>Day</th>
                  <th>Faculty</th>
                  <th>Duration (Min)</th>
                  <th>Class Amount</th>
                  <th>Current/Loss/Expected Earnings</th>
                  <th>Current/left/Desired Strength</th>
                  <th>Admin/class Status</th>
                  <th>Add/Edit Student</th>
                  <th>Modify/Cancel/Download</th>
                  <th>Detail</th>
                </tr>
              </thead>
              <tbody  style="font-size: 12px;">
                <?php if( count($list) ):$sn=1;
                  $count = $this->uri->segment(4);
                    foreach($list as $lists ): ?>
                    <?php
                      $todays_date       =   date("Y-m-d H:i");

                      // $asia_calcutta_date = DateTime::createFromFormat('Y-m-d H:i',$todays_date,new DateTimeZone('Asia/Calcutta'));
                      // $acst_date = clone $asia_calcutta_date; // we don't want PHP's default pass object by reference here
                      // $acst_date->setTimeZone(new DateTimeZone('Asia/Hong_Kong'));

                      //echo 'UTC:  ' . $asia_calcutta_date->format('Y-m-d g:i A');  // UTC:  2011-04-27 2:45 AM
                      //echo 'ACST: ' . $acst_date->format('Y-m-d g:i A'); // ACST: 2011-04-27 12:15 PM
                      //echo $todays_date;die;
                      $today             =   strtotime($todays_date);
                      $starts            =   strtotime($lists->class_date.' '.$lists->class_start_time);
                      $ends              =   strtotime($lists->class_date.' '.$lists->class_end_time);
                      //$time1             =   $starts - (10 * 60);
                      //$less_10_min_start_time = date("Y-m-d H:i", $time1);
                      //$stars             =    strtotime($less_10_min_start_time);

                      ?>
                      <tr <?php if(($today>=$starts)||($lists->method=="cancel")||($lists->class_status=="cancel")){?> style="color:red;"<?php }?>>
                        <td><?php echo  $sn; ?></td>
                        <td><?php echo  $lists->class_name; ?></td>
                        <td><?php echo  strtoupper(date("d-M-Y",strtotime($lists->class_date)));?></td>
                        <td><?php echo  strtoupper(date("g:i a",strtotime($lists->class_date.' '.$lists->class_start_time)));?></td>
                        <td><?php echo  strtoupper(date("g:i a",strtotime($lists->class_date.' '.$lists->class_end_time)));?></td>
                        <td><?php echo  strtoupper(date("l",strtotime($lists->class_date)));?></td>
                        <td><?php echo  strtoupper($lists->facultyuserid." | ".$lists->faculty);?></td>
                        <td><?php if($lists->class_extended_min!=""){echo $lists->class_duration_min+$lists->class_extended_min."'";}else{echo $lists->class_duration_min."'";}?></td>
                        <td><i class="fa fa-fw fa-inr text-green"></i> <?php echo  $lists->class_amount;?></td>
                        <td><i class="fa fa-fw fa-inr text-red"></i> <?php echo  $lists->earning_from_class." / ".($lists->class_amount*$lists->attendee_limit-$lists->earning_from_class)." / ".($lists->class_amount*$lists->attendee_limit);?></td>
                        <td><?php echo  $lists->current_class_strength." / ".($lists->attendee_limit-$lists->current_class_strength)." / ".$lists->attendee_limit; ?></td>
                        <td><?php echo  $lists->class_status." / ".$lists->method;;?></td>

                        <td>
                          <?php if(($today>=$starts)||($lists->method=="cancel")||($lists->class_status=="cancel")){?>
                            <?php echo anchor("admin/course/Course/add_student_to_specific_class/{$lists->id}",'<i class="fa fa-fw fa-user-plus text-orange"></i>',['title'=>'Cant add student to class / class over / class cancel','class'=>'btn btn-sm btn-default','disabled'=>'disabled']); ?>
                          <?php }else{?>
                          <?php echo anchor("admin/course/Course/add_student_to_specific_class/{$lists->id}",'<i class="fa fa-fw fa-user-plus text-orange"></i>',['title'=>'Add More Student to class','class'=>'btn btn-sm btn-default']); ?>
                        <?php }?>
                        </td>
                        <td>
                          <?php if(($today>=$starts)||($lists->method=="cancel")||($lists->class_status=="cancel")){?>
                          <?php echo anchor("admin/course/Course/modify_course_class/{$lists->id}",'<i class="fa fa-fw fa-edit text-orange"></i>',['title'=>'You cant modify this class / class over / class cancel','class'=>'btn btn-sm btn-default','disabled'=>'disabled']); ?>
                          <?php }else{?>
                          <?php echo anchor("admin/course/Course/modify_course_class/{$lists->id}",'<i class="fa fa-fw fa-edit text-orange"></i>',['title'=>'Modify Classes','class'=>'btn btn-sm btn-default']); ?>
                          <?php }?>
                          <?php if(($today>=$starts)||($lists->method=="cancel")||($lists->class_status=="cancel")){?>
                          <?php echo anchor("admin/course/Course/cancel_course_class/{$lists->id}",'<i class="fa fa-fw fa-trash text-red"></i>',['title'=>'Class cancelled / class over / class cancel','class'=>'btn btn-sm btn-default','disabled'=>'disabled']); ?>
                          <?php }else{?>
                          <?php echo anchor("admin/course/Course/cancel_course_class/{$lists->id}",'<i class="fa fa-fw fa-trash text-red"></i>',['title'=>'Cancel Class','class'=>'btn btn-sm btn-default']); ?>
                          <?php }?>
                          <?php if(($today>=$starts)&&($lists->method!="cancel")||($lists->class_status!="cancel")){?>
                          <?php echo anchor("admin/course/Course/class_download_recording/{$lists->id}",'<i class="fa fa-fw fa-cloud-download text-green"></i>',['title'=>'Downloading Available','class'=>'btn btn-sm btn-default']); ?>
                          <?php }else{?>
                          <?php echo anchor("admin/course/Course/class_download_recording/{$lists->id}",'<i class="fa fa-fw fa-cloud-download text-green"></i>',['title'=>'Downloading not Available Yet','class'=>'btn btn-sm btn-default','disabled'=>'disabled']); ?>
                          <?php }?>
                        <td>
                          <a class="popper" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modal-default" data-popbox="hello1" Onclick="hello1(<?=$lists->id?>)" >
                            <span class="label label-info label-mini" style="background: linear-gradient(45deg,#FFa500,#ff869a);cursor:pointer;">Class Detail</span>
                          </a>
                        </td>
                      </tr>
                    <?php $sn++;?>
                    <?php endforeach; ?>
                  <?php else : ?>
                  <tr>
                  <td><strong>No record found</strong></td>
                  </tr>
                <?php endif; ?>
              </tbody>
              </table>
            </div>
          </div>
        <?php $count++; //echo  $link; ?>
        </div>
      </div>
    </div>
  </div>
</div>
</section>
</div>
<div class='wrap'>
  <div class='content content_pop'>
    <div class="col-md-12">
      <?=form_open('admin/Adminlte/course_list_search');?>
      <div class="">
        <div class="col-md-2 padding_20 emp_style">
          <select id='sel_category' class="form-control input-sm" name="category">
            <option value="" >Select Category</option>
            <?php
            foreach($category as $category1){
            echo "<option value='".$category1['id']."'>".strtoupper($category1['category_code'])." | ".strtoupper($category1['category'])."</option>";
            }
            ?>
          </select>
        </div>
        <div class="col-md-2  padding_20 emp_style">
          <select id='sel_class' class="form-control input-sm" name="class" >
            <option value="" >Select class</option>
          </select>
        </div>
        <div class="col-md-2 padding_20 emp_style">
          <select id='sel_subject' class="form-control input-sm" name="subject" >
            <option value="" >Select subject</option>
          </select>
        </div>
        <div class="col-md-2 padding_20 emp_style">
          <select id='sel_course_list' class="form-control input-sm" name="course" >
            <option value="" >Select course</option>
          </select>
        </div>
        <div class="col-md-2 padding_20">
          <?=form_dropdown('subject_code',$subject_code ,set_value('subject_code',$data_taskpo['subject_code']),['class'=>'form-control input-sm select2 select2-hidden-accessible',
          "tabindex"=>"-1","aria-hidden"=>"true","style"=>"width: 100%;"]);?>
        </div>
        <div class="col-md-2  padding_20 emp_style">
          <?php $options=array(''=>'Search Type','and'=>'And','or'=>'OR');?>
          <?=form_dropdown('seach_term',$options,set_value('seach_term','and'),['class'=>'form-control input-sm','style'=>'']);?>
        </div>
        <div class="col-md-2  padding_20 emp_style">
          <?php $options=array(''=>'Order By','ASC'=>'Ascending','DESC'=>'Descending','RANDOM'=>'Random');?>
          <?=form_dropdown('order_by',$options,set_value('order_by','ASC'),['class'=>'form-control input-sm']);?>
        </div>
      </div>
      <div class="btn_mrgin1">
        <?=form_submit('search','search',['class'=>'btn btn-primary btn_mrgin btn-sm']);?>
      </div>
      <?php echo form_close();?>
    </div>
  </div>
</div>

<!--  ------->

<div class="modal fade" id="modal-default" style="width:100%;">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">×</span></button>
        <h4 class="modal-title">Class Detail</h4>
      </div>
      <div class="modal-body">
        <!-- <p>One fine body…</p> -->
        <div id="hello1" class="content content_pop"></div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default pull-right" data-dismiss="modal">Close</button>
        <!-- <button type="button" class="btn btn-primary">Save changes</button> -->
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>

<script type="text/javascript">
  function hello1(id){ //alert(id);
    $.ajax({
           type: "POST",
           url: "<?php echo site_url('admin/course/Course/course_class_student_list')?>/" + id,
           data:{action:'call_this'},
           success:function(html) {
             $('#hello1').empty();
             $('#hello1').append(html);
           }
        });
    }
</script>
