<?php include 'inc_classes.php'; 
include "admin_authentication.php";
// $edit_access='';
// $sel_acc="select * from edit_previleges where admin_id='".$_SESSION['admin_id']."' and privilege_id='392'";
// $ptr_access=mysql_query($sel_acc);
// if(mysql_num_rows($ptr_access))
// {
// 	$edit_access='yes';
// }
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Monhtly Performance Report</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
    <!-- daterange picker -->
    <link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">
    <!-- bootstrap datepicker -->
    <link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
    <!-- iCheck for checkboxes and radio inputs -->
    <link rel="stylesheet" href="plugins/iCheck/all.css">
    <!-- Bootstrap Color Picker -->
    <link rel="stylesheet" href="bower_components/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css">
    <!-- Bootstrap time Picker -->
    <link rel="stylesheet" href="plugins/timepicker/bootstrap-timepicker.min.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="bower_components/select2/dist/css/select2.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- paginate style -->
    <link rel="stylesheet" href="dist/css/paginate.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
    <!-- Google Font -->
    <link rel="stylesheet"
        href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<script>
    function select_staff(branch) {
        var branch_data = "action=reportstaff&branch_names=" + branch;
        // alert(branch);
        $.ajax({
            url: "tk_staff_ajax.php", type: "post", data: branch_data, cache: false,
            success: function (retadmin) {
                // alert(retadmin);
                document.getElementById("staff_name").innerHTML = retadmin;

            }
        });
    }
</script>
<?php
 function convertToHoursMins($time, $format = '%02d:%02d') {
    if ($time < 1) {
        return;
    }
    $hours = floor($time / 60);
    $minutes = ($time % 60);
    return sprintf($format, $hours, $minutes);
}
?>

<body class="hold-transition skin-blue sidebar-mini">
    <div class="wrapper">
        <?php include "include/header-main.php"; ?>
        <!-- Left side column. contains the logo and sidebar -->
        <?php include "include/menu_left.php"; ?>
        <!-- Content Wrapper. Contains page content -->
        <!-- Left side column. contains the logo and sidebar -->
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                   Monthly Performance Report
                    <!--<small>Version 2.0</small>-->
                </h1>
                <ol class="breadcrumb">
                    <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                    <li class="active">Dashboard</li>
                </ol>
            </section>
            <!-- Main content -->
            <section class="content">
                <div class="row">
                    <!-- Left col -->
                    <div class="col-md-12">
                        <!-- TABLE: LATEST ORDERS -->
                        <div class="box box-info">
                          <div class="table-responsive">
                            <table class="table no-margin" >
                                <form method="get" name="search">
                                    <tr>
                                      <?php if($_SESSION['type']=='S' || $_SESSION['branch_access']=='yes')
                                      {
                                        ?>
                                        <td>
                                            <select class="form-control select2" id="branch_name" style="width:150px"
                                                name="branch_name" onchange="select_staff(this.value)" ;>
                                                <option value="">Select Branch</option>
                                                <?php 
                                                $sel_branch="select branch_id,branch_name from branch";
                                                $ptr_sel=mysql_query($sel_branch);
                                                while($data_branch=mysql_fetch_array($ptr_sel))
                                                {
                                                  $sel='';
                                                  if($data_branch['branch_name']==$_GET['branch_name'])
                                                  {
                                                    $sel='selected="selected"';
                                                  }
                                                  echo '<option '.$sel.' value="'.$data_branch['branch_name'].'" >'.$data_branch['branch_name'].'</option>';
                                                }
                                                ?>
                                            </select>
                                        </td>
                                        <!-- <td width="5px"></td> -->
                                        <td>
                                            <div>
                                                <?php
                                                if($_REQUEST['staff_name']!='')
                                                  {
                                                    // if($manager_access=='manager')
                                                    // {
                                                    //   $sel_staffs="select admin_id,name from site_setting where branch_name='".$_GET['branch_name']."'  and (".$admins.") and system_status='Enabled' ";
                                                    // }
                                                    // else{
                                                      $sel_staffs="select admin_id,name from site_setting where branch_name='".$_GET['branch_name']."'  and system_status='Enabled' ";
                                                    // }
                                                    $ptr_que=mysql_query($sel_staffs);
                                                      ?>
                                                      <select class="form-control select2" style="width:200px" id="staff_names1" name="staff_name">
                                                          <option value="">Select Staff</option>
                                                            <?php
                                                        while($data_query=mysql_fetch_array($ptr_que))
                                                        {
                                                          $sel='';
                                                          if($data_query['admin_id']==$_GET['staff_name'])
                                                            {
                                                              $sel='selected="selected"';
                                                            }
                                                          ?>
                                                          <option <?php echo $sel;?> value="<?php echo $data_query['admin_id'] ;?>"><?php echo $data_query['name'] ;?>
                                                          </option>
                                                          <?php
                                                        }
                                                        ?>
                                                      </select>
                                                      <?php
                                                  }
                                                  else
                                                  {
                                                    ?>
                                                    <select class="form-control select2" style="width:200px" id="staff_name" name="staff_name">
                                                      <option value="">Select Staff</option>
                                                    </select>
                                                    <?php
                                                  }
                                                  ?>
                                            </div>
                                        </td>
                                        <?php
                                      }
                                      else if($manager_access=='manager' && $_SESSION['type']!='S' && $edit_access!='yes')
                                      {
                                        $sel_staffs="select admin_id,name from site_setting where branch_name='".$_SESSION['branch_name']."'  and system_status='Enabled' and (".$admins.") ";
                                        $ptr_que=mysql_query($sel_staffs);
                                          ?>
                                          <td>
                                            <select class="form-control select2" style="width:200px" id="staff_names1" name="staff_name">
                                                <option value="">Select Staff</option>
                                                  <?php
                                              while($data_query=mysql_fetch_array($ptr_que))
                                              {
                                                $sel='';
                                                if($data_query['admin_id']==$_GET['staff_name'])
                                                  {
                                                    $sel='selected="selected"';
                                                  }
                                                ?>
                                                <option <?php echo $sel;?> value="<?php echo $data_query['admin_id'] ;?>"><?php echo $data_query['name'] ;?>
                                                </option>
                                                <?php
                                              }
                                              ?>
                                            </select>
                                          </td>
                                        <?php
                                      }
                                      else
                                      {
                                        ?>
                                        <input type="hidden" name="branch_name" id="branch_name"
                                            value="<?php echo $_SESSION['branch_name']; ?>" />
                                        <?php
                                      }
                                      ?>
                                        <!-- <td width="5px"></td> -->
                                        <td>
                                            <div>
                                                <?php
                                                  $current_year=date("Y");
                                                  $last_year=date("Y")-1;
                                                ?>
                                                <select class="form-control select2" style="width:110px" id="year"
                                                    name="year">
                                                    <option value="">Select Year</option>
                                                    <option value="<?php echo $current_year ;?>" <?php if
                                                        ($_GET['year']==$current_year ) echo "selected='selected'" ;?>>
                                                        <?php echo $current_year ;?>
                                                    </option>
                                                    <option value="<?php echo $last_year ;?>" <?php if
                                                        ($_GET['year']==$last_year ) echo "selected='selected'" ;?>>
                                                        <?php echo $last_year ;?>
                                                    </option>
                                                </select>
                                            </div>
                                        </td>
                                        <!-- <td width="5px"></td> -->
                                        <td>
                                            <div>
                                              <?php
                                                $current_month=date("m");
                                                // $last_year=date("Y")-1;
                                              ?>
                                                <select class="form-control select2" style="width:110px" id="month"
                                                    name="month">
                                                    <option value="">Select Month</option>
                                                    <?php
                                                      $categary="select month_name,month_id from months order by month_id ASC";   //where cm_id='".$branch_data['cm_id']."'
                                                      $c_query=mysql_query($categary);
                                                      while($data_c=mysql_fetch_array($c_query))
                                                      {
                                                          $sel='';
                                                          if($data_c['month_id']==$_GET['month']){
                                                            $sel='selected="selected"';
                                                          }
                                                          // elseif($data_c['month_id']==$current_month){
                                                          //     $sel='selected="selected"';
                                                          // }
                                                        
                                                          echo  '<option '.$sel.'  value="'.$data_c['month_id'].'">'.ucfirst($data_c['month_name']). '</option>';
                                                      }
                                                    ?>
                                                </select>
                                            </div>
                                        </td>
                                        <!-- <td width="5px"></td> -->
                                        <td>
                                            <div>
                                                <input type="text" name="start_date" class="input_text datepicker"
                                                    placeholder="From Date" id="datepicker" title="From Date" style="width:110px"
                                                    value="<?php if($_REQUEST['start_date']) echo $_REQUEST['start_date']; else if($_REQUEST['id']!='') echo date('d/m/Y',strtotime($_REQUEST['date']));?>">
                                            </div>
                                        </td>
                                        <!-- <td width="5px"></td> -->
                                        <td>
                                            <div>
                                                <input type="text" name="end_date" class="input_text datepicker"
                                                    placeholder="To Date" id="datepicker1" title="From Date" style="width:110px"
                                                    value="<?php if($_REQUEST['end_date']) echo $_REQUEST['end_date']; else if($_REQUEST['id']!='') echo date('d/m/Y',strtotime($_REQUEST['date']));  ?>">
                                            </div>
                                        </td>
                                        <!-- <td width="5px"></td> -->
                                        <td>
                                            <input type="image" src="images/search.jpg" name="search" value="search"
                                                style="height:32px;">
                                        </td>
                                    </tr>
                                </form>
                            <tr>
                            <div class="box-body">
                                <!-- <div class="table-responsive"> -->
                                  <?php
                                  if($_REQUEST['start_date'] && $_REQUEST['start_date']!=="0000-00-00" && $_REQUEST['start_date']!="From Date")
                                  {
                                      $frm_date=explode("/",$_REQUEST['start_date']);
                                      $frm_dates=$frm_date[2]."-".$frm_date[1]."-".$frm_date[0];
                                        $start_date=$frm_dates;
                                      $date_start=date('Y-m-d',strtotime($frm_dates));
                                  }
                                  if($_REQUEST['end_date'] && $_REQUEST['end_date']!=="0000-00-00" && $_REQUEST['end_date']!="To Date")
                                  {
                                      $frms_date=explode("/",$_REQUEST['end_date']);
                                      $frms_dates=$frms_date[2]."-".$frms_date[1]."-".$frms_date[0];
                                        $end_date=$frms_dates;
                                      $date_end=date('Y-m-d',strtotime($frms_dates));
                                  }
                                  if($_REQUEST['start_date']!='' && $_REQUEST['end_date']!=''){
                                  $date='and date >="'.$date_start.'" and date <="'.$date_end.'"';
                                  $search_year='';
                                  $search_month='';
                                  }
                                  else{
                                    $date='';
                                    if($_REQUEST['year']!='')
                                  {
                                    $year=$_REQUEST['year'];
                                    $search_year="and YEAR(date)='".$year."'";
                                  }
                                  else
                                  {
                                    $search_year="and YEAR(date)='".date("Y")."'";
                                  }
                                  $current_month=date("m");
                                  if($_REQUEST['month']!='')
                                  {
                                    $month=$_REQUEST['month'];
                                    $search_month="and month(date)='".$month."'";
                                  }
                                  else
                                  {
                                    $search_month="and month(date)='".date("m")."'"; //date("m")
                                  }
                                  
                                  }
                                  if($_REQUEST['branch_name']!='')
                                  {
                                    $branch_name=$_REQUEST['branch_name'];
                                    $select_cm_id="select cm_id from site_setting where branch_name='".$branch_name."' and type='A'";
                                    $ptr_cm_id=mysql_query($select_cm_id);
                                    $data_cm_id=mysql_fetch_array($ptr_cm_id);
                                    $search_cm_id="and cm_id='".$data_cm_id['cm_id']."'";
                                  }
                                  else
                                  {
                                    $search_cm_id="and cm_id='".$_SESSION['cm_id']."'";
                                  }
                                  $staff_type='';
                                  if($_REQUEST['staff_name']!='')
                                  {
                                    $staff_id=$_REQUEST['staff_name'];
                                    $sel_type="select type from site_setting where admin_id='".$staff_id."'";
                                    $ptr_type=mysql_query( $sel_type);
                                    $data_type=mysql_fetch_array($ptr_type);
                                    $staff_type=$data_type['type'];
                                    $search_staff_id="and staff_id='".$staff_id."'";
                                  }
                                  else
                                  {
                                      $search_staff_id="and staff_id='".$_SESSION['admin_id']."'";
                                  }
                                  
                                  $i=1;
                                  ?>
                                    <table class="table no-margin" style="text-align:center">
                                      <?php
                                        $admin=$_GET['staff_name'];
                                        $sel_name="select name  from site_setting where admin_id='". $admin."'";
                                        $ptr_name=mysql_query($sel_name);
                                        $data_name=mysql_fetch_array($ptr_name);
                                        $sel_names="select name  from site_setting where admin_id='".$_SESSION['admin_id']."'";
                                        $ptr_names=mysql_query($sel_names);
                                        $data_names=mysql_fetch_array($ptr_names);
                                        $sel_mon="select month_name,month_id from months where month_id='".$_GET['month']."'";
                                        $ptr_mon=mysql_query($sel_mon);
                                        $data_mon=mysql_fetch_array($ptr_mon);
                                        $sel_mont="select month_name,month_id from months where month_id='".$current_month."'";
                                        $ptr_mont=mysql_query($sel_mont);
                                        $data_mont=mysql_fetch_array($ptr_mont);
                                      ?>
                                        <tr>
                                            <td style="text-align:left"><b>Name : </b><span style="color:blue">
                                                <?php if($_REQUEST['staff_name']!='') echo ucwords($data_name['name']); else echo $data_names['name']; ?>
                                                </span>
                                            </td>
                                            <td><b>Month : </b><span style="color:blue">
                                                    <?php if($_REQUEST['year']!='' && $_REQUEST['month']!='') echo $data_mon['month_name'].' [ '.$_GET['year'].' ] '; else echo $data_mont['month_name'].' [ '.date("Y").' ] '; ?>
                                                </span>
                                            </td>
                                        </tr>
                                    </table>
                                    <table class="table no-margin" style="text-align:center">
                                        <thead>
                                            <tr>
                                                <th style="text-align:center">Sr.No.</th>
                                                <th style="text-align:center">Date</th>
                                                <th style="text-align:center">Task point</th>
                                                <th style="text-align:center">Task Quality point</th>
                                                <th style="text-align:center">Key Performance Point</th>
                                                <?php
                                                if($_SESSION['type']=='F' || $staff_type=='F')
                                                {
                                                  ?>
                                                <th style="text-align:center">Student Feedback Point</th>
                                                <?php
                                                }
                                                ?>
                                                <?php
                                                if($_SESSION['type']=='C' || $_SESSION['type']=='A' || $staff_type=='C' || $staff_type=='A')
                                                {
                                                  ?>
                                                <th style="text-align:center">Councelling Point</th>
                                                <?php
                                                }
                                                ?>
                                                <?php
                                                if($_SESSION['type']=='A' ||  $staff_type=='A')
                                                {
                                                  ?>
                                                <th style="text-align:center">Management Approch</th>
                                                <?php
                                                }
                                                ?>
                                                <th style="text-align:center">Total Point</th>
                                                <th style="text-align:center">Hour Not Worked</th>
                                                <th style="text-align:center">Reduce Point</th>
                                                <th style="text-align:center">Final Percentage</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                          <?php
                                          if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
                                          {
                                            $my_task="select * from pm_daily_emp_performance where 1 ".$search_cm_id." ".$search_staff_id." ".$search_year."  ".$search_month." ".$date." order by date DESC ";
                                            $ptr_data=mysql_query($my_task);
                                          }
                                          else{
                                            $my_task="select * from pm_daily_emp_performance where 1 and staff_id='".$_SESSION['admin_id']."'  ".$search_year."  ".$search_month." ".$date."  order by date DESC ";
                                            $ptr_data=mysql_query($my_task);
                                          }
                                          // echo  $my_task;
                                          // $tot_count=mysql_num_rows($ptr_data);
                                          $tot_pecentage='';
                                          $k=0;
                                          while($my_data=mysql_fetch_array($ptr_data))
                                          {
                                            $add="select name from site_setting where 1 and admin_id='".$my_data['staff_id']."'";
                                            $ptr=mysql_query($add);
                                            $data_name=mysql_fetch_array($ptr);
                                            ?>
                                            <tr>
                                                <td>
                                                    <?php echo $i++ ?>
                                                </td>
                                                <td>
                                                    <a target=""
                                                        href="tk_daily_performance_report.php?id=<?= $my_data['staff_id'].'&date='.date($my_data['date']).'&branch='.$my_data['cm_id']?>" target="">
                                                        <?php echo date("d-m-Y",strtotime($my_data['date']))?>
                                                    </a>
                                                </td>
                                                <?php
                                                if( $my_data['status']=='present')
                                                {
                                                  ?>
                                                  <td>
                                                      <?php echo ($my_data['task_percentage'])?>
                                                  </td>
                                                  <td>
                                                      <?php echo $my_data['task_quality_percentage']?>
                                                  </td>
                                                  <td>
                                                      <?php echo $my_data['key_point_percentage']?>
                                                  </td>
                                                  <?php
                                                  if($_SESSION['type']=='F' || $staff_type=='F')
                                                  {
                                                    ?>
                                                  <td>
                                                      <?php echo $my_data['student_feedback_percentage']?>
                                                  </td>
                                                  <?php
                                                  }
                                                  ?>
                                                  <?php
                                                  if($_SESSION['type']=='C' || $staff_type=='C' || $_SESSION['type']=='A' || $staff_type=='A')
                                                  {
                                                    ?>
                                                  <td>
                                                      <?php echo $my_data['councelling_point']?>
                                                  </td>
                                                  <?php
                                                  }
                                                  ?>
                                                  <?php
                                                  if($_SESSION['type']=='A' || $staff_type=='A')
                                                  {
                                                  ?>
                                                  <td>
                                                      <?php echo $my_data['feedback_management_approach']?>
                                                  </td>
                                                  <?php
                                                  }
                                                  ?>
                                                  <td>
                                                      <?php echo $my_data['total_percentage']?>
                                                  </td>
                                                  <td>
                                                      <?php 
                                                        if( $my_data['hour_not_worked']!='0')
                                                        {
                                                          $not_working= $my_data['hour_not_worked'];
                                                          $tot_hour= convertToHoursMins($not_working, '%02d hour %02d min');
                                                          echo $tot_hour; 
                                                        }
                                                        else 
                                                        {
                                                          echo '0';
                                                        }
                                                      ?>
                                                  </td>
                                                  <td>
                                                      <?php echo $my_data['point_reduce']?>
                                                  </td>
                                                  <?php
                                                }
                                                else
                                                {
                                                  ?>
                                                  <td colspan="6" style="color:red">
                                                      <strong>
                                                          <?php echo ucfirst($my_data['status'])?>
                                                      </strong>
                                                  </td>
                                                  <?php
                                                }
                                                ?>
                                                <td>
                                                  <b>
                                                    <?php echo $my_data['final_percentage'];
                                                      $tot_pecentage+=$my_data['final_percentage'];
                                                    ?>
                                                  </b>
                                                </td>
                                            </tr>
                                            <?php
                                          }
                                        ?>
                                        </tbody>
                                    </table>
                                  </div>
                                  <!-- <hr> -->
                                  <?php
                                  if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
                                  {
                                  $sel_rec="select * from pm_emp_extra_performance where 1 ".$search_cm_id." ".$search_staff_id." ".$search_year."  ".$search_month." ".$date." order by date DESC ";
                                }
                                else{
                                  $sel_rec="select * from pm_emp_extra_performance where 1 and staff_id='".$_SESSION['admin_id']."'  ".$search_year."  ".$search_month." ".$date."  order by date DESC ";
                                }
                                $ptr_rec=mysql_query($sel_rec);
                                $tot_rec=mysql_num_rows( $ptr_rec);
                                if($tot_rec)
                                {
                                  ?>
                                  <div class="box-body">
                                    <h4><strong>Issues and Accolades</strong></h4>
                                  <table class="table no-margin" style="text-align:center">
                                        <thead>
                                            <tr>
                                                <th style="text-align:center">Sr.No.</th>
                                                <th style="text-align:center">Date</th>
                                                <!-- <th style="text-align:center">Type</th> -->
                                                <th style="text-align:center">Comments</th>
                                                <th style="text-align:center">Percentage</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                          <?php
                                          $d=1;
                                          $total_pecentage="";
                                          while($data_rec=mysql_fetch_array($ptr_rec))
                                          {
                                              if($data_rec['type']=='issue')
                                              {
                                                $tot_percentage='-'.$data_rec['total_percentage'];
                                              }
                                              else{
                                                $tot_percentage=$data_rec['total_percentage'];
                                              }
                                            ?>
                                            <tr>
                                                <td>
                                                    <?php echo $d++ ?>
                                                </td>
                                                <td>
                                                        <?php echo date("d-m-Y",strtotime($data_rec['date']))?>
                                                </td>
                                                <!-- <td> -->
                                                    <?php //echo ucfirst($data_rec['type'])?>
                                                <!-- </td> -->
                                                <td>
                                                    <?php echo ucwords($data_rec['comment'])?>
                                                </td>
                                                <td>
                                                    <strong><?php echo $tot_percentage;
                                                      $total_pecentage+=$tot_percentage;
                                                    ?></strong>
                                                </td>
                                            </tr>
                                            <?php
                                          }
                                        ?>
                                        </tbody>
                                    </table>
                              </div>
                              <?php
                              }
                            ?>
                            <div class="box box-default">
                                <div class="box-body">
                                    <div class="row">
                                        <div class="col-md-3">
                                            <table class="table no-margin" style="text-align:center">
                                                <tr>
                                                    <td style="text-align:right"><b>
                                                            <?php if($_REQUEST['month']!='') echo $data_mon['month_name']; else echo $data_mont['month_name']; ?>
                                                            Month Till Performance :
                                                        </b>
                                                    </td>
                                                    <?php
                                                    if($_SESSION['type']=='S'  || $edit_access=='yes' || $manager_access=='manager')
                                                    {
                                                      $my_task1="select * from pm_daily_emp_performance where 1 ".$search_cm_id." ".$search_staff_id." ".$search_year."  ".$search_month."  and status='present' ".$date."  order by date DESC ";
                                                    }
                                                    else
                                                    {
                                                        $my_task1="select id from pm_daily_emp_performance where 1 and staff_id='".$_SESSION['admin_id']."'  ".$search_year."  ".$search_month." and status='present'".$date." order by date DESC ";
                                                    }
                                                    $ptr_data1=mysql_query($my_task1);
                                                    $tot_count=mysql_num_rows($ptr_data1);
                                                    if($_REQUEST['staff_name']!=''){
                                                    $sel_sallary="select total_salary,employee_id from pr_add_salary_details where employee_id='".$staff_id."'";
                                                    }
                                                    else{
                                                      $sel_sallary="select total_salary,employee_id from pr_add_salary_details where employee_id='".$_SESSION['admin_id']."'";
                                                    }
                                                    // echo $sel_sallary;
                                                    $ptr_sallary=mysql_query($sel_sallary);
                                                    $data_sallary=mysql_fetch_array($ptr_sallary);
                                                    $my_sallary=$data_sallary['total_salary'];
                                                    $total=$tot_pecentage +$total_pecentage;
                                                    $tot_pecentage .'<br>';
                                                    '<br>'.$working_day=$tot_count;
                                                    '<br>'. $tot_point=$working_day*100;
                                                    // echo '<br>'.$tot_percentage;
                                                    $month_per=($total/$tot_point)*100;
                                                    '<br>'.round($month_per);
                                                    '<br>'.$tot_month_per=round($month_per);
                                                    '<br>'. $my_insentive="select insentive from pm_insentive_percentage where 1 and salary_from <=".$my_sallary." and salary_to >=".$my_sallary." and performance_from <=".$tot_month_per." and performance_to >=".$tot_month_per." order by pi_id ASC";
                                                    $ptr_insentive=mysql_query($my_insentive);
                                                    $data_inssentive=mysql_fetch_array($ptr_insentive);
                                                    ?>
                                                    <td style="text-align:left">
                                                      <b>
                                                          <?php  echo round($month_per); ?>
                                                      </b>%
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:right"><b>Incentive : </b></td>
                                                    <td style="text-align:left">
                                                      <b>
                                                          <?php  echo round($data_inssentive['insentive']); ?>
                                                      </b>%
                                                    </td>
                                                </tr>
                                                <!-- </tbody> -->
                                            </table>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                            </div>
                            <!-- /.box -->
                            </tr>  
                          </table>
                          <!-- </div> -->
                        </div>
                        <!-- /.col -->
                    </div>
                </div>
                <!-- /.box -->
            </section>
            <!-- /.content -->
        </div>
        <!-- /.content-wrapper -->
        <?php include "include/footer-main.php"; ?>
    </div>
    <!-- jQuery 3 -->
    <script src="bower_components/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap 3.3.7 -->
    <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- Select2 -->
    <script src="bower_components/select2/dist/js/select2.full.min.js"></script>
    <!-- InputMask -->
    <script src="plugins/input-mask/jquery.inputmask.js"></script>
    <script src="plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
    <script src="plugins/input-mask/jquery.inputmask.extensions.js"></script>
    <!-- date-range-picker -->
    <script src="bower_components/moment/min/moment.min.js"></script>
    <script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
    <!-- bootstrap datepicker -->
    <script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
    <!-- bootstrap color picker -->
    <script src="bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
    <!-- bootstrap time picker -->
    <script src="plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <!-- SlimScroll -->
    <script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
    <!-- iCheck 1.0.1 -->
    <script src="plugins/iCheck/icheck.min.js"></script>
    <!-- FastClick -->
    <script src="bower_components/fastclick/lib/fastclick.js"></script>
    <!-- AdminLTE App -->
    <script src="dist/js/adminlte.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="dist/js/demo.js"></script>
    <!-- Page script -->
    <script>
        $(function () {
            //Initialize Select2 Elements
            $('.select2').select2()
            //Date picker
            $('#datepicker').datepicker({
                autoclose: true,
                format: 'dd/mm/yyyy',
                // startDate: '-0d',
                Default: true,
                todayHighlight: true
            })
            $('#datepicker1').datepicker({
                autoclose: true,
                format: 'dd/mm/yyyy',
                // startDate: '-0d',
                Default: true,
                todayHighlight: true
            })


            //Colorpicker
            $('.my-colorpicker1').colorpicker()
            //color picker with addon
            $('.my-colorpicker2').colorpicker()

            //Timepicker
            $('.timepicker').timepicker({
                showInputs: false
            })
        })
    </script>
    <?php
	if($_SESSION['type']!='S' || $_SESSION['branch_access']!='yes'){
		?>
    <script>
        branch = document.getElementById("branch_name").value;
        select_staff(branch);
    </script>
    <?php
	}
	?>
</body>

</html>