<?php $__env->startSection('content_header'); ?>
    <?php echo notifyCss(); ?>
    <?php echo notifyJs(); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <div class="row">
        <div class="col-12">
            <div class="card card-primary">
                <div class="card-header">
                    <h3 class="card-title">View Schedule</h3>
                </div>
                <?php echo $__env->make('notify::messages', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                <!-- /.card-header -->
                <!-- form start -->
                <form id="userregform" class="form-horizontal" action="#" method="post" autocomplete="off" enctype="multipart/form-data">
                  <?php echo e(csrf_field()); ?>

                  <div class="card-body">
                      <div class="col-12">
                          <div class="form-group row">
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Organisation</label><br>
                                  <?php echo e($schedules->organisation->organisation_name); ?>

                                  <input type="hidden" name="schedule_id" id="schedule_id" value="<?php echo e($schedules->id); ?>">
                              </div>
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Department</label><br>
                                  <?php if(isset($schedules->department_id)): ?>
                                    <?php echo e($schedules->department->department_name); ?>

                                  <?php endif; ?>
                              </div>
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Section</label><br>
                                  <?php if(isset($schedules->section_id)): ?>
                                    <?php echo e($schedules->section->section_name); ?>

                                  <?php endif; ?>
                              </div>
                              <div class="col-3">
                                <label for="exampleInputEmail1">Material Type</label><br>
                                  <?php echo e($schedules->material_type->material_type_name); ?>

                              </div>
                          </div>
                          <div class="form-group row">
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Training Title</label><br>
                                  <?php echo e($schedules->training_title); ?>

                              </div>
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Venue</label><br>
                                  <?php echo e($schedules->venue); ?>

                              </div>
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Training Period</label><br>
                                  <?php
                                    $period_from = $schedules->period_from;
                                    $period_to = $schedules->period_to;
                                    if($period_from)
                                    {
                                        $period_from = date("d-M-Y", strtotime($period_from));
                                    }
                                    if($period_to)
                                    {
                                        $period_to = date("d-M-Y", strtotime($period_to));
                                    }
                                    echo $period_from." to ".$period_to;
                                  ?> 
                                  
                              </div>
                              <div class="col-3">
                                <label for="exampleInputEmail1">Min & Max seats for training</label><br>
                                  <?php
                                    $min_seat_training = $schedules->min_seat_training;
                                    $max_seat_training = $schedules->max_seat_training;
                                    
                                    echo $min_seat_training." & ".$max_seat_training;
                                  ?> 
                              </div>
                          </div>
                          <div class="form-group row">
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Roles</label><br>
                                  <?php echo e($schedules->training_title); ?>

                              </div>
                          </div>
                          <div class="form-group row">
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Whether Registration is Needed?</label><br>
                                  <?php if($schedules->registration_status==1): ?>
                                    <?php
                                      echo "Yes";
                                    ?>
                                  <?php else: ?>
                                    <?php
                                      echo "No";
                                    ?>
                                  <?php endif; ?>
                              </div>
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Question and Answers for Training</label><br>
                                  <?php if($schedules->question_answer_status==1): ?>
                                    <?php
                                      echo "Yes";
                                    ?>
                                  <?php else: ?>
                                    <?php
                                      echo "No";
                                    ?>
                                  <?php endif; ?>
                              </div>
                              <div class="col-3">
                                  <label for="exampleInputEmail1">Reviews and Feedback Needed?</label><br>
                                  <?php if($schedules->review_status==1): ?>
                                    <?php
                                      echo "Yes";
                                    ?>
                                  <?php else: ?>
                                    <?php
                                      echo "No";
                                    ?>
                                  <?php endif; ?>                                  
                              </div>
                              <div class="col-3">
                                <label for="exampleInputEmail1">Training Certificates Needed?</label><br>
                                  <?php if($schedules->training_certificates==1): ?>
                                    <?php
                                      echo "Yes";
                                    ?>
                                  <?php else: ?>
                                    <?php
                                      echo "No";
                                    ?>
                                  <?php endif; ?>   
                              </div>
                          </div>
                          <div id="listroledata" style="padding: 10px;">
                              <table class="table table-hover table-bordered table-striped datatable" id="dept_details" width="100%">
                                  <thead>
                                      <tr class="success">
                                        <th width="10%">Slno</th>
                                        <th>Participant Name</th>
                                        <th>
                                          <button data-toggle="modal" data-target='#ParticipantModal' class="btn btn-warning btn-sm pull-right" type="button" onclick=getModalParticipant(<?php echo e($schedules->id); ?>);>Add New Participant</button>
                                        </th>
                                      </tr>
                                  </thead>
                                  <tbody>
                                    <?php
                                      $n= 0;
                                    ?>
                                    <?php if(isset($schedules->schedule_participants)): ?>
                                      <?php $__currentLoopData = $schedules->schedule_participants; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $schedule_participant): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php
                                          $n++;
                                        ?>
                                        <tr>
                                          <td><?php echo e($n); ?></td>
                                          <td><?php echo e($schedule_participant->users->name); ?></td>
                                          <td>
                                            <?php if($schedule_participant->mail_send_flag==1): ?>
                                              <?php
                                                echo "Mail Send."
                                              ?>
                                            <?php else: ?>
                                              <?php
                                                echo "Mail Not Send."
                                              ?>
                                            <?php endif; ?>
                                          </td>
                                        </tr>
                                      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php else: ?>
                                      <tr>
                                        <td colspan="3" style=" text-align: center;">
                                            <span style="color: red;">No Participants are assigned yet !!!</span>
                                        </td>
                                      </tr>
                                    <?php endif; ?>
                                  </tbody>
                              </table>
                          </div>                        
                      </div>
                  </div>
                  <!-- /.card-body -->
                </form>
            </div>
        </div>        
    </div>
    <div class="modal fade" id="ParticipantModal" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document" style="max-width: 750px !important;" >
        <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>
            </div>
            <div class="card-body">
              <h4 class="modal-title" id="myModalLabel">Add New Participant</h4>
              <form action="<?php echo e(url('/participant_add_training')); ?>" method="post" enctype="multipart/form-data" id="tapal_forward">
                <div class="modal-body">
                    <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
                    <input type="hidden" name="schedule_id_new" id="schedule_id_new" class="form-control" value="">
                    <div id="modal_particiapant_div">
                      <div class="form-group row">
                        <div class="col-6">
                            <label for="exampleInputEmail1">Organisation</label>
                            <select name="organisation_id" id="organisation_id" class="form-control" required onchange="load_department(this.value);load_user();">
                                <option value="">Select Organisation</option>
                                <?php $__currentLoopData = $organisations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $organisation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($organisation->id); ?>"><?php echo e($organisation->organisation_name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                      </div>
                      <div class="form-group row">
                        <div class="col-6">
                            <label for="exampleInputEmail1">Department</label>
                            <select name="department_id" id="department_id" class="form-control" onchange="load_section(this.value);load_user();">
                                <option value="">Select Department</option>
                            </select>
                        </div>
                      </div>
                      <div class="form-group row">
                        <div class="col-6">
                            <label for="exampleInputEmail1">Section</label>
                            <select name="section_id" id="section_id" class="form-control" onchange="load_user();">
                                <option value="">Select Section</option>
                            </select>
                        </div>
                      </div>
                      <div class="form-group row">
                        <div class="col-6">
                            <label for="exampleInputEmail1">Participants</label>
                            <select name="user_id" id="user_id" class="form-control" required class="form-control">
                              <option value="">Select Participants</option>
                            </select>
                        </div>
                      </div>
                    </div>
                  <!--modal body close-->
                </div>
                <div class="modal-footer">
                  <div class="row">
                    <div class="col-md-3">
                      <button id="add_participant" type="submit" class="btn btn-info"  >Add</button>
                    </div>
                  </div>
                </div>
              </form>
            </div>
        </div>
      </div>
      <!--panel body close-->
    </div>
    <script type="text/javascript">
      function getModalParticipant(id)
      {
        document.getElementById("schedule_id_new").value=id;
      }
      function load_department(organisation_id)
      {
          $.ajax({
             type:'GET',
             url: "<?php echo url('get_department/"+organisation_id+"'); ?>",
             success:function(data)
             {
                $('#department_id').empty();
                $('#department_id').append("<option value=''>Select Department</option>");
                $.each(data, function(key, element) {
                    $('#department_id').append("<option value='" + key +"'>" + element + "</option>");
                }); 
             }
          });
      }
      function load_section(department_id)
      {
          $.ajax({
             type:'GET',
             url: "<?php echo url('get_section/"+department_id+"'); ?>",
             success:function(data)
             {
                $('#section_id').empty();
                $('#section_id').append("<option value=''>Select Section</option>");
                $.each(data, function(key, element) {
                    $('#section_id').append("<option value='" + key +"'>" + element + "</option>");
                }); 
             }
          });
      }
      function load_user()
      {
        var department_id= "";
        var section_id = "";
        var organisation_id ="";
        var schedule_id = document.getElementById("schedule_id").value;
        organisation_id = document.getElementById("organisation_id").value;
        department_id = document.getElementById("department_id").value;
        section_id = document.getElementById("section_id").value;
        var id = organisation_id+"~"+department_id+"~"+section_id+"~"+schedule_id;
        //alert(id);
          $.ajax({
             type:'GET',
             url: "<?php echo url('get_participants/"+id+"'); ?>",
             success:function(data)
             {
                $('#user_id').empty();
                $('#user_id').append("<option value=''>Select Participants</option>");
                $.each(data, function(key, element) {
                    $('#user_id').append("<option value='" + key +"'>" + element + "</option>");
                }); 
             }
          });
      }
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('adminlte::page', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH E:\xampp7.3\htdocs\kmportal\resources\views/Training/view_schedule.blade.php ENDPATH**/ ?>