<?php $allowed = $this->db->get_where('academic_settings' , array('type' =>'allowed_marks'))->row()->description; ?>
<?php $running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description; ?>
<?php $company_id=1;?>
<div class="content-w">
    <div class="os-tabs-w menu-shad">
        <div class="os-tabs-controls">
          <ul class="nav nav-tabs upper">
              <?php if($status == 1):?>
            <li class="nav-item">
              <a class="nav-link" href="<?php echo base_url();?>admin/marks_upload/"><i class="os-icon picons-thin-icon-thin-0007_book_reading_read_bookmark"></i><span><?php echo get_phrase('Create Job Card');?></span></a>
            </li>
              <?php endif;?>
            <li class="nav-item">
              <a class="nav-link active" href="<?php echo base_url();?>admin/view_jobsheets/"><i class="os-icon picons-thin-icon-thin-0197_layout_grid_view"></i><span><?php echo get_phrase('Job sheets');?></span></a>
            </li>
             
          </ul>
        </div>
      </div>
  
       
  <div class="tab-pane active" id="teachers">
      <div class="col-lg-12">
      <div class="element-wrapper">
         <div class="element-box shadow lined-primary">
           <div class="table-responsive">
            <table id="dataTable12" width="100%" class="table table-striped table-lightfont">
               <thead>
                  <tr>
                     <th><?php echo "Job Id";?></th>
                     <th><?php echo "Project";?></th>
                     <th><?php echo "Customer";?></th>
                     <th><?php echo get_phrase('Date');?></th>
                     <!--<th><?php echo get_phrase('job_time_in');?></th>
                       <th><?php echo get_phrase('job_time_out');?></th>!-->
                       <th><?php echo get_phrase('total_hours');?></th>
                       <th><?php echo get_phrase('Engineer');?></th>
                       <th><?php echo "Status";?></th>
                     <th><?php echo get_phrase('options');?></th>
                  </tr>
               </thead>
               <tbody>
                   <?php // $company = $this->db->get_where('admin', array('admin_id' => $this->session->userdata('login_user_id')))->row()->client_id;?>
               <?php 
               $company = $this->db->get_where('admin', array('admin_id' => $this->session->userdata('login_user_id')))->row()->client_id;
               if(empty($company)){
               $jobs = $list_of_jobs;
               }
               else{
               //$teachers = $this->db->get_where('jobcards' , array('client_id' => $company))->result_array();
                       $jobs = $list_of_jobs;
               }
                //$this->db->order_by('jid', 'desc');
                //$teachers = $this->db->get('jobcards')->result_array();
               foreach($jobs as $row):
                   $cid=$row['client_id'];
                  $jid= $row['jid'];
                  $user_id=$row['job_user'];
               ?>
                  <tr>
                      <td><?php echo $row['jid']; ?></td>
                     <td><?php echo $row['project']; ?></td>
                   
                     <td><?php 
             $cname= $this->db->get_where('client', array('client_id' =>$cid))->row()->client_name;
             echo $cname; 
                     ?></td>
                     <td><?php echo $row['job_date']; ?></td>
                     <!-- <td><?php echo $row['job_time_in']; ?></td>
                       <td><?php echo $row['job_time_out']; ?></td>!-->
                          <td><?php echo $row['total_hours']; ?></td>
                           <td><?php
            $username= $this->db->get_where('admin', array('admin_id' =>$user_id))->row()->name;               
                           echo $username; ?></td>
                           <td><?php echo $row['status']; ?></td>
                     <td> <a onClick="return confirm('<?php echo get_phrase('confirm_delete');?>')" href="<?php echo base_url();?>admin/teachers/delete/<?php echo $row['teacher_id'];?>"><button class="btn btn-danger btn-rounded btn-sm"><i class="picons-thin-icon-thin-0056_bin_trash_recycle_delete_garbage_empty"></i> <?php echo get_phrase('delete');?></button></a>
                     
     <a target="_blank" href="<?php echo base_url();?>admin/send_email_attach/<?php echo $jid;?>"><button class="btn btn-rounded btn-success" type="submit"><i class="picons-thin-icon-thin-0333_printer"></i>  <?php echo get_phrase('print');?></button></a>
         <a href="<?php echo base_url();?>admin/jobsheet_details_update/<?php echo $jid;?>"><button class="btn btn-rounded btn-success" type="submit"><i class="picons-thin-icon-thin-0333_printer"></i>  <?php echo get_phrase('View');?></button></a>

                     </td>
                
                  </tr>
               <?php endforeach;?>
               </tbody>
            </table>
           </div>
         </div>
        </div>
      </div>
      </div>
      
                <?php //echo form_close();?>
              </div>
            
  


    <script type="text/javascript">
    function get_class_sections(class_id) 
    {
        $.ajax({
            url: '<?php echo base_url();?>teacher/get_class_section/' + class_id ,
            success: function(response)
            {
                jQuery('#section_selector_holder').html(response);
            }
        });
    }
</script>

<script type="text/javascript">
    function get_class_subject(class_id) {
        $.ajax({
            url: '<?php echo base_url(); ?>admin/get_class_subject/' + class_id,
            success: function (response)
            {
                jQuery('#subject_selector_holder').html(response);
            }
        });
    }
</script>

<script>
var numRows = 2,
  ti = 5;
var tableCount = 1;
var index = 1;

window.standBy = function() {
  var sum = 0;
  $(".Standby").each(function(index, stand) {
    sum += parseFloat($(stand).val());
  })

  $(".grandtotal").val(sum)
}

function calculate() {
  var tr = $(this).closest('tr'),
    startTime = $('.Time1').val(),
    endTime = $('.Time2').val();

  if (startTime === '' || endTime === '') {
    return;
  }

  var hours = parseInt(endTime.split(':')[0], 10) - parseInt(startTime.split(':')[0], 10);
  if (hours < 0) hours = 24 + hours;
  $(".Hours", tr).val(hours);

  if (hours >= 4) $(".Standby", tr).val("1");
  if (hours <= 4) $(".Standby", tr).val("0.5");
  //if (hours==4 && hours<8) $(".Standby").val("1");

  if (hours >= 8 && hours <= 12) $(".Standby", tr).val("1.5");

  if (hours > 12) $(".Standby", tr).val("1.5");



}
$('#table').on('input', ".Time1,.Time2", calculate);
$('#table').find(".Time1").trigger('change')


window.addTime = function() {
  tableCount++;
  $('#timeTable').clone().attr('id', "timeTable" + tableCount).appendTo('#table');
  $('#timeTable' + tableCount).find("input").val("");
  index++;
  $('#timeTable' + tableCount + ' .aa').html(tableCount);

};


$(document).on('click', 'button.removeTime', function() {
  var closestTable = $(this).closest('table');
  if (closestTable.attr('id') != "timeTable") {
    closestTable.remove();
  }
  tableCount--;
  if (tableCount < 1) {
    tableCount = 1;
  }
  return false;
});
</script>

<script>
$(document).ready(function() {
    $('#dataTable12').DataTable( {
        "order": [[ 0, "desc" ]]
    } );
} );
</script>