<?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>Timesheet</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>
<?php
 function convertToHoursMins($time, $format = '%02d:%02d') {
    if ($time < 1) {
        return;
    }
    $hours = floor($time / 60);
    $minutes = ($time % 60);
    return sprintf($format, $hours, $minutes);
}
?>
<script>
    function select_staff(branch1) {
        var branch_data1 = "action=admin&branch_name1=" + branch1;
        // alert(branch);
        $.ajax({
            url: "tk_staff_ajax.php", type: "post", data: branch_data1, cache: false,
            success: function (retadmin) {
                // alert(retstaff);
                document.getElementById("staff_name1").innerHTML = retadmin;

            }
        });
    }
</script>
<?php
$sep_url_string='';
$sep_url= explode("?",$_SERVER['REQUEST_URI']);
if($sep_url[1] !='')
{
	$sep_url_string="?".$sep_url[1];
}
?>
<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>
                    Timesheet
                </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>
                                            <td>
                                              <?php if($_SESSION['type']=='S' || $_SESSION['branch_access']=='yes')
                                              {
                                                ?>
                                                <select class="form-control select2" id="branch_name" style="width:150px" name="branch_name">
                                                    <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>
                                                <?php
                                              }
                                              else
                                              {
                                                ?>
                                                <input type="hidden" name="branch_name" id="branch_name"
                                                      value="<?php echo $_SESSION['branch_name']; ?>" />
                                                <?php
                                              }
                                              ?>
                                            </td>
                                            <?php 
                                            if($manager_access=='manager' || $_SESSION['type']!='S' || $edit_access!='yes')
                                            {
                                                ?>
                                                <td>
                                                    <select class="form-control select2" id="dept" style="width:200px"
                                                        name="dept" ;>
                                                        <option value="">Select Department</option>
                                                        <?php 
                                                        if($_SESSION['type']=='S' || $edit_access!='yes')
                                                        {
                                                            $sel_dept="select dept_id,dept_name from emp_dept where 1"; 
                                                        }
                                                        else if($manager_access=='manager')
                                                        {
                                                            $sel_dept="select dept_id,dept_name from emp_dept where ".$dept_string.""; 
                                                        }
                                                        $ptr_dept=mysql_query($sel_dept);
                                                        while($data_dept=mysql_fetch_array($ptr_dept))
                                                        {
                                                            $sel='';
                                                            if($data_dept['dept_id']==$_GET['dept'])
                                                            {
                                                            $sel='selected="selected"';
                                                            }
                                                            echo '<option '.$sel.' value="'.$data_dept['dept_id'].'" >'.$data_dept['dept_name'].'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <?php
                                            }
                                            ?>                                            
                                            <td width="">
                                                <input type="text" name="start_date" class="input_text datepicker"
                                                    placeholder="Select Date" id="datepicker" title="Task Date"
                                                    value="<?php echo $_GET['start_date'] ;?>"  style="width:150px">
                                            </td>
                                            <!-- <td width="5px"></td> -->
                                            <td>
                                                <input type="image" src="images/search.jpg" name="search" value="search"
                                                    style="height:32px;">
                                            </td>
                                        </tr>
                                    </form>
                                <tr>
                                <?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;
                                    $dates=" and DATE(added_date )='".date('Y-m-d',strtotime($frm_dates))."'";
                                    $date=" and DATE(followup_date )='".date('Y-m-d',strtotime($frm_dates))."'";
                                }
                                else{
                                    $dates=" and DATE(added_date )='".date('Y-m-d')."'";
                                    $date=" and DATE(followup_date )='".date('Y-m-d')."'";
                                    $start_date=date('Y-m-d');
                                    // $dates=" and DATE(added_date )='2023-06-08'";
                                    // $date=" and DATE(followup_date )='2023-06-09'";
                                }
                                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=2';
                                }
                                // $search=$_REQUEST['staff_name'];
                                if($_REQUEST['dept']!='')
                                {
                                  $depa_array=array();
                                  $p=0;
                                  $tot_staff='';
                                  $sel_depa="SELECT * FROM emp_dept where 1 and dept_id='".$_REQUEST['dept']."' ";
                                  $ptr_depa=mysql_query($sel_depa);
                                  while($data_depat=mysql_fetch_array($ptr_depa))
                                  {
                                    '<br>'.$sel_sept_staff="SELECT * FROM dept_employee where 1 and dept_id='".$data_depat['dept_id']."' ";
                                      $ptr_sept_staff=mysql_query($sel_sept_staff);
                                      $l=0;
                                      $tot_staff=mysql_num_rows($ptr_sept_staff);
                                      while($data_sept_staff=mysql_fetch_array($ptr_sept_staff))
                                      {
                                          $depa_array[$l][$p]= $data_sept_staff['staff_id'];
                                          $l++;
                                      }
                                      $p++;
                                  }
                                  // array_multisort($staff_array, SORT_ASC,SORT_NUMERIC);
                                  $array_result = [];
                                  foreach ($depa_array as $sub_Array) {
                                      foreach ($sub_Array as $values) {
                                          $array_result[] = $values;
                                      }
                                  }
                                  // '<br><pre>'; print_r($array_result); echo '</pre> <br> <br>'; 
                                  $deptatment = "staff_id=" . implode(" or staff_id=", $array_result);
                                  $deptatments = "admin_id=" . implode(" or admin_id=", $array_result);
                                  if($tot_staff){
                                    $search_dept="and(". $deptatments.")";
                                    $search_depts="and(". $deptatments.")";
                                  }
                                  else{
                                    $search_dept="and admin_id='0'";
                                    $search_depts="and admin_id='0'";
                                  }
                                }
                                else{
                                  $search_dept="";
                                  $search_depts="and (".$admins.")";
                                }
                                $i=1;
                                if($_REQUEST['keyword121']!="keyword121")
                                $search=trim($_REQUEST['keyword121']);
                                if($search)
                                {
                                  $task_search=" and (task_name like '%".$search."%' || priority like '%".$search."%' || status like '%".$search."%')";
                                }
                                else
                                {
                                  $task_search="";
                                }
                                if (($_SESSION['type'] == 'S' || $edit_access == 'yes') && $_REQUEST['dept'] == '') {
                                    $sel_staff = "select admin_id, name, type from site_setting where 1 and system_status='Enabled' " . $search_cm_id . " order by name asc";
                                    $collasp = 'panel-collapse collapse out';
                                } else if (($manager_access == 'manager' || $_SESSION['type'] == 'S' || $edit_access == 'yes') && $_REQUEST['dept'] != '') {
                                    $sel_staff = "select admin_id, name, type from site_setting where 1 " . $search_depts . " and system_status='Enabled' " . $search_cm_id . " order by name asc";
                                    $collasp = 'panel-collapse collapse out';
                                } else {
                                    $sel_staff = "select admin_id, name, type from site_setting where 1 and system_status='Enabled' and admin_id='" . $_SESSION['admin_id'] . "'";
                                    $collasp = 'panel-collapse collapse in';
                                }                                
                                // echo $sel_staff;
                                $ptr_staff=mysql_query( $sel_staff);
                                $i=1;
                                ?>
                                <div class="box-body">
                                        <table class="table no-margin" style="text-align:center">
                                            <thead>
                                                <tr>
                                                    <td colspan="12">
                                                        <h4>
                                                        <?php
                                                        if($_SESSION['type']=='S'  || $edit_access=='yes')
                                                        {
                                                            ?>
                                                            <strong>Branch : <span style="color:blue;">
                                                            <?php  if($_REQUEST['branch_name']!='')echo ucfirst($_GET['branch_name']); else echo 'Pune';?></strong></span>
                                                            <?php
                                                        }
                                                        ?>
                                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Date : <span style="color:blue;">
                                                            <?php if($_REQUEST['start_date']!='') echo  date("d-m-Y",strtotime($start_date)); else echo date('d-m-Y');  ?></span></b>
                                                        </h4>
                                                    </td>
                                                </tr>
                                                <tr style="background-color:rgb(192,192,192)">
                                                    <th style="text-align:center;width:100px">Sr.No.</th>
                                                    <th style="text-align:left;">Staff Name</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                $bgColorCounter=1;
                                                $tot_hour=0;
                                                while($data_staff=mysql_fetch_array( $ptr_staff))
                                                {
                                                    if($bgColorCounter%2==0){
                                                        $bgcolor='style="background-color:rgb(220,220,220)"';
                                                    }
                                                    else{
                                                        $bgcolor="";    
                                                    }    
                                                    $tot_times=0;
                                                    $hour=0;
                                                    ?>
                                                    <tr <?php $bgcolor ?> >
                                                        <td style="width:100px">
                                                            <?php echo $i ?>
                                                        </td>
                                                        <td>
                                                            <div>
                                                                <div style="display:flex">
                                                                    <strong>
                                                                        <?php echo strip_tags(ucwords($data_staff['name']))?>
                                                                    </strong>
                                                                </div>
                                                                <?php
                                                                '<br/>'. $my_task="select * from tk_individual_task where 1 and staff_id='".$data_staff['admin_id']."' ".$dates."";
                                                                $ptr_task=mysql_query($my_task);
                                                                ?>
                                                                <div class="box-header">
                                                                    <h4 class="box-title">
                                                                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne<?php echo $data_staff['admin_id']?>">
                                                                        View/Close Timesheet
                                                                    </a>
                                                                    </h4>
                                                                </div>
                                                                <div id="collapseOne<?php echo $data_staff['admin_id']?>" class=" <?php echo $collasp ?>">
                                                                    <div class="box-body">
                                                                        <table class="table no-margin" style="text-align:center; background-color:#f9f9f9; border: 1px solid #ddd; border-radius: 5px;">
                                                                            <thead>
                                                                                <tr>
                                                                                    <h4 style="color:red">
                                                                                        <?php echo strip_tags(ucwords($data_staff['name']))?>&nbsp;&nbsp;&nbsp;<span style="color:blue;">
                                                                                        <?php if($_REQUEST['start_date']!='') echo  date("d-m-Y",strtotime($start_date)); else echo date('d-m-Y');  ?></span>&nbsp;&nbsp;&nbsp;
                                                                                        <?php
                                                                                        // if($_SESSION['admin_id']=='283')
                                                                                        // {
                                                                                            ?>
                                                                                            <span><a href="tk_task_exel.php?staff_id=<?php echo $data_staff['admin_id']; ?>&start_date=<?php echo $start_date ?>"><img src="images/excel.png" height="30px" Title="Export Timesheet" width="30px"/></a></span>
                                                                                            <?php
                                                                                        // }
                                                                                        ?>
                                                                                    </h4>
                                                                                </tr>
                                                                                <tr style="background-color:#f1f1f1; border-bottom: 2px solid #ccc;">
                                                                                    <th style="text-align:center; padding: 8px;">Sr.No.</th>
                                                                                    <th style="text-align:center; padding: 8px;">Task Name</th>
                                                                                    <th style="text-align:center; padding: 8px;">Task Time</th>
                                                                                    <th style="text-align:center; padding: 8px;">Task Point</th>
                                                                                    <th style="text-align:center; padding: 8px;">Task Details</th>
                                                                                    <th style="text-align:center; padding: 8px;">Staff Status</th>
                                                                                    <th style="text-align:center; padding: 8px;">Added Date</th>
                                                                                    <th style="text-align:center; padding: 8px;">Due Date</th>
                                                                                    <th style="text-align:center; padding: 8px;">Status</th>
                                                                                    <th style="text-align:center; padding: 8px;">Complete/In-Complete Date</th>
                                                                                    <th style="text-align:center; padding: 8px;">Complete By</th>
                                                                                    <th style="text-align:center; padding: 8px;">Validation</th>
                                                                                </tr>
                                                                            </thead>
                                                                            <tbody>
                                                                                <?php
                                                                                $t_no=1;
                                                                                $task_hours=0;
                                                                                while($data_task=mysql_fetch_array($ptr_task))
                                                                                {
                                                                                    $add1="select name from site_setting where 1 and admin_id='".$data_task['sta_updated_admin_id']."'";
                                                                                    $ptr1=mysql_query($add1);
                                                                                    $data1=mysql_fetch_array($ptr1);
                                                                                    if($data_task['sta_complete_date']!=''){
                                                                                        $cmpDate=date("d-m-Y", strtotime( $data_task['sta_complete_date']));
                                                                                    }
                                                                                    else{
                                                                                        $cmpDate='-';
                                                                                    }
                                                                                    ?>
                                                                                    <tr style="background-color: #ffffff; border-bottom: 1px solid #ddd;">
                                                                                        <td style="padding: 8px;"><?php echo $t_no++?></td>
                                                                                        <td style="padding: 8px;">
                                                                                            <a href="tk_individual_task_detail.php?id=<?php echo $data_task['staff_task_id']; ?>" target="_blank"><?php echo ucwords($data_task['task_name']) ?></a>
                                                                                        </td>
                                                                                        <td style="padding: 8px;"><?php echo $tot_hours= convertToHoursMins($data_task['hours'], '%02d hour %02d min'); $task_hours+=$data_task['hours']; ?></td>
                                                                                        <td style="padding: 8px;"><?php  echo $data_task['points']?></td>
                                                                                        <td style="padding: 8px;"><?php echo strip_tags(ucwords($data_task['description'])); ?></td>
                                                                                        <td style="padding: 8px;"><?php echo ucwords($data_task['staff_status']) ?></td>
                                                                                        <td style="padding: 8px;"><?php echo date("d-m-Y", strtotime( $data_task['added_date'])) ?></td>
                                                                                        <td style="padding: 8px;"><?php echo date("d-m-Y", strtotime( $data_task['due_date'])) ?></td>
                                                                                        <td style="padding: 8px;"><?php echo ucwords($data_task['status']) ?></td>
                                                                                        <td style="padding: 8px;"><?php echo $cmpDate ?></td>
                                                                                        <td style="padding: 8px;"><?php echo ucfirst($data1['name']);?></td>
                                                                                        <td style="padding: 8px;"><?php echo ucwords($data_task['Validation']) ?></td>
                                                                                    </tr>
                                                                                    <?php
                                                                                }
                                                                                $tot_id=0;
                                                                                '<br/>'.$sel_student_batch="select distinct(followup_id) from followup_details where 1 and response!='1' and admin_id='".$data_staff['admin_id']."' ".$dates."";
                                                                                $ptr_student_batch=mysql_query($sel_student_batch);
                                                                                if($tot_call_id=mysql_num_rows($ptr_student_batch))
                                                                                {
                                                                                    $tot_id= $tot_call_id*3;
                                                                                    $calling_point=number_format($tot_id*0.208, 2);
                                                                                    ?>
                                                                                    <tr style="background-color: #e0ffff; border-bottom: 1px solid #ddd;">
                                                                                        <td style="padding: 8px;"><?php echo $t_no++?></td>
                                                                                        <td style="padding: 8px;"> Calling [<?php echo $tot_call_id?>]</td>
                                                                                        <td style="padding: 8px;"><?php echo convertToHoursMins($tot_id, '%02d hour %02d min'); ?></td>
                                                                                        <td style="padding: 8px;"><?php echo $calling_point ?></td>
                                                                                        <td style="padding: 8px;">Doing Followup Calls</td>
                                                                                        <td style="padding: 8px;">Complete</td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;">Complete</td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;"><?php echo ucwords($data_staff['name'])?></td>
                                                                                        <td style="padding: 8px;">Valid</td>
                                                                                    </tr>
                                                                                    <?php
                                                                                }
                                                                                $tot_enq=0;
                                                                                $sel_student_enq="select distinct(followup_id) from followup_details where 1 and response='1' and admin_id='".$data_staff['admin_id']."' ".$dates."";
                                                                                $ptr_student_enq=mysql_query($sel_student_enq);
                                                                                if($tot_student_enq=mysql_num_rows($ptr_student_enq))
                                                                                {
                                                                                    $tot_enq= $tot_student_enq*45;
                                                                                    $inquiry_point=number_format($tot_enq*0.208, 2);
                                                                                    ?>
                                                                                    <tr style="background-color: #f0fff0; border-bottom: 1px solid #ddd;">
                                                                                        <td style="padding: 8px;"><?php echo $t_no++?></td>
                                                                                        <td style="padding: 8px;"> Inquiry [<?php echo $tot_student_enq?>]</td>
                                                                                        <td style="padding: 8px;"><?php echo convertToHoursMins($tot_enq, '%02d hour %02d min'); ?></td>
                                                                                        <td style="padding: 8px;"><?php echo $inquiry_point ?></td>
                                                                                        <td style="padding: 8px;">Taking Walk-In Inquiry</td>
                                                                                        <td style="padding: 8px;">Complete</td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;">Complete</td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;"><?php echo ucwords($data_staff['name'])?></td>
                                                                                        <td style="padding: 8px;">Valid</td>
                                                                                    </tr>
                                                                                    <?php
                                                                                }
                                                                                $hour=0;
                                                                                $sel_student_batch="select distinct(c_b_id) from batch_timetable where staff_id='".$data_staff['admin_id']."' ".$dates."";
                                                                                $ptr_student_batch=mysql_query($sel_student_batch);
                                                                                if($tot_batch_id=mysql_num_rows($ptr_student_batch))
                                                                                {
                                                                                    $batch_time= $tot_batch_id*2.5;
                                                                                    $hour=  $batch_time*60 ;
                                                                                    $batch_point=number_format($hour*0.221, 2);
                                                                                    ?>
                                                                                    <tr style="background-color: #f5f5dc; border-bottom: 1px solid #ddd;">
                                                                                        <td style="padding: 8px;"><?php echo $t_no++?></td>
                                                                                        <td style="padding: 8px;"> Batch</td>
                                                                                        <td style="padding: 8px;"><?php echo convertToHoursMins($hour, '%02d hour %02d min'); ?></td>
                                                                                        <td style="padding: 8px;"><?php echo $batch_point?></td>
                                                                                        <td style="padding: 8px;">Taking Assign Batch </td>
                                                                                        <td style="padding: 8px;">Complete</td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;">Complete</td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;"><?php echo ucwords($data_staff['name'])?></td>
                                                                                        <td style="padding: 8px;">Valid</td>
                                                                                    </tr>
                                                                                    <?php
                                                                                }
                                                                                $lead_time=0;
                                                                                $sel_minute="select minutes from pm_sales_kpi where action_name='add_lead'";
                                                                                $ptr_mintute=mysql_query($sel_minute);
                                                                                $data_minute=mysql_fetch_array($ptr_mintute);
                                                                                $lead_min=$data_minute['minutes'];
                                                                                $sel_lead="select distinct(inquiry_id) from inquiry where 1 ".$dates." and admin_id='".$data_staff['admin_id']."'";
                                                                                $ptr_lead=mysql_query($sel_lead);
                                                                                $lead_record=mysql_num_rows($ptr_lead);
                                                                                if($lead_record){
                                                                                    $lead_time=$lead_record*$lead_min;
                                                                                    $lead_point=number_format($lead_time*0.208, 2);
                                                                                    ?>
                                                                                    <tr style="background-color: #e6e6fa; border-bottom: 1px solid #ddd;">
                                                                                        <td style="padding: 8px;"><?php echo $t_no++?></td>
                                                                                        <td style="padding: 8px;"> Leads [<?php echo $lead_record?>]</td>
                                                                                        <td style="padding: 8px;"><?php echo convertToHoursMins($lead_time, '%02d hour %02d min'); ?></td>
                                                                                        <td style="padding: 8px;"><?php echo $lead_point ?></td>
                                                                                        <td style="padding: 8px;">Adding Leads In system</td>
                                                                                        <td style="padding: 8px;">Complete</td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;">Complete</td>
                                                                                        <td style="padding: 8px;"><?php echo date('Y-m-d',strtotime($start_date))?></td>
                                                                                        <td style="padding: 8px;"><?php echo ucwords($data_staff['name'])?></td>
                                                                                        <td style="padding: 8px;">Valid</td>
                                                                                    </tr>
                                                                                    <?php
                                                                                }
                                                                                $total_hours=$task_hours+$tot_id+$tot_enq+$hour+$lead_time;
                                                                                if($total_hours > 0){
                                                                                ?>
                                                                                <tr style="background-color:#f1f1f1;">
                                                                                    <td colspan='8' style="text-align:center; padding: 8px;">
                                                                                        <h4>Total Time </h4>
                                                                                    </td>
                                                                                    <td colspan='4' style="text-align:center; padding: 8px;">
                                                                                        <h4><?php echo convertToHoursMins($total_hours, '%02d hour %02d min'); ?></h4>
                                                                                    </td>
                                                                                </tr>
                                                                                <?php
                                                                                }
                                                                                ?>
                                                                            </tbody>
                                                                        </table>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <?php
                                                    $bgColorCounter++;
                                                    $i++;
                                                }
                                                ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </tr>
                            </table>
                        </div>
                            <!-- /.box -->
                        </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
            })


            //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>