<!DOCTYPE html>
<html lang="en">
    <head>
        <title><?=$course_name;?></title>
        <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />


        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

        <link rel="stylesheet" href="<?php echo base_url() ?>assets/fullcalendar/fullcalendar.min.css" />
        <script src="<?php echo base_url() ?>assets/fullcalendar/lib/moment.min.js"></script>
        <script src="<?php echo base_url() ?>assets/fullcalendar/fullcalendar.min.js"></script>
        <script src="<?php echo base_url() ?>assets/fullcalendar/gcal.js"></script>


    </head>
    <body>

    <div class="container">
    <div class="row">
    <div class="col-md-12">
<br>
  <h3>
    <?=$course_name;?> Class List <a href="<?=$_SERVER['HTTP_REFERER']?>">
    <img src="<?=base_url('assets/adminlte/arrow-arrow-pointing-left-bullet-png-free-63488.png');?>" style='height:30px;width:30px;    margin-top: -17px;'>
    </img></a>
  </h3>

    <div id="calendar">

    </div>

    </div>
    </div>
    </div>
    <?php
      $last     = $this->uri->total_segments();
      $courseid = $this->uri->segment($last);
      date_default_timezone_set('Asia/Kolkata');
    ?>


    <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document" style="min-width:1000px;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close" ><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel" style="color:red;">Class Detail  </h4>
      </div>
      <!-- <div class="modal-body"> -->
      <?php echo form_open("", array("class" => "form-horizontal")) ?>
      <div class="col-md-12" style="margin-top:30px;">
        <div class="col-md-6">
            <div class="form-group">
                    <label for="p-in" class="col-md-4 label-heading">Class id</label>
                    <div class="col-md-8 ui-front">
                        <input type="text" class="form-control" name="name" value="" id="class_name" disabled>
                    </div>
            </div>

            <div class="form-group">
                    <label for="p-in" class="col-md-4 label-heading">Class Name</label>
                    <div class="col-md-8 ui-front">
                        <input type="text" class="form-control" name="class" value="" id="class" disabled>
                    </div>
            </div>

            <div class="form-group">
                    <label for="p-in" class="col-md-4 label-heading">Faculty</label>
                    <div class="col-md-8 ui-front">
                        <input type="text" class="form-control" name="faculty" value="" id="faculty" disabled>
                    </div>
            </div>

            <div class="form-group">
                    <label for="p-in" class="col-md-4 label-heading">Class Start</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control" name="start_date" id="start_date" disabled>
                    </div>
            </div>
            <!-- <div class="form-group">
                    <label for="p-in" class="col-md-4 label-heading">Class Name</label>
                    <div class="col-md-8 ui-front">
                        <input type="text" class="form-control" name="category" value="" id="category">
                    </div>
            </div> -->
          </div>
          <div class="col-md-6">
            <div class="form-group">
                    <label for="p-in" class="col-md-4 label-heading">Course</label>
                    <div class="col-md-8 ui-front">
                        <input type="text" class="form-control" name="description" id="description" disabled>
                    </div>
            </div>
            <div class="form-group">
                    <label for="p-in" class="col-md-4 label-heading">subject</label>
                    <div class="col-md-8 ui-front">
                        <input type="text" class="form-control" name="subject" value="" id="subject" disabled>
                    </div>
            </div>
            <div class="form-group">
                    <label for="p-in" class="col-md-4 label-heading">Day</label>
                    <div class="col-md-8 ui-front">
                        <input type="text" class="form-control" name="day" value="" id="day" disabled>
                    </div>
            </div>
            <div class="form-group">
                    <label for="p-in" class="col-md-4 label-heading">Class End</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control" name="end_date" id="end_date" disabled>
                    </div>
            </div>
                <input type="hidden" name="eventid" id="event_id" value="0" />
          </div>
        </div>
        <?php echo form_close() ?>
      <!-- </div> -->
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript">
$(document).ready(function() {
    var date_last_clicked = null;
    $('#calendar').fullCalendar({
        eventSources: [
           {
           events: function(start, end, timezone, callback) {
                $.ajax({
                    url: '<?php echo site_url()?>admin/course/Course/get_events',
                    dataType: 'json',
                    data: {
                        // our hypothetical feed requires UNIX timestamps
                        start: start.unix(),
                        end: end.unix(),
                        course_id: <?=$courseid;?>
                    },
                    success: function(msg) {
                        var events = msg.events;
                        callback(events);
                    }
                });
              }
            },
        ],
        dayClick: function(date, jsEvent, view) {
            date_last_clicked = $(this);
          //  $(this).css('background-color', '#bed7f3');
            //$('#addModal').modal();
        },
       eventClick: function(event, jsEvent, view) {
          $('#name').val(event.title);
          $('#class_name').val(event.class_name);
          $('#description').val(event.description);
          $('#day').val(event.day);
          $('#faculty').val(event.faculty);
          $('#category').val(event.category);
          $('#class').val(event.class);
          $('#subject').val(event.subject);
        //  $('#start_date').val(moment(event.start).format('YYYY/MM/DD HH:mm'));
        $('#start_date').val(moment(event.start).format('DD-MM-YYYY hh:mm a'));
          if(event.end) {
            //$('#end_date').val(moment(event.end).format('YYYY/MM/DD HH:mm'));
            $('#end_date').val(moment(event.end).format('DD-MM-YYYY hh:mm a'));
          } else {
            //$('#end_date').val(moment(event.start).format('YYYY/MM/DD HH:mm'));
            $('#end_date').val(moment(event.start).format('DD-MM-YYYY hh:mm a'));
          }
          $('#event_id').val(event.id);
          $('#editModal').modal();
       },
    });
});
</script>
    </body>
</html>
