<?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';

// }

$staff_task_id=$_GET['id'];

?>

<!DOCTYPE html>

<html>



<head>

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title>Individual Task Detail</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">

    <!-- 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 show_rating(value) {

        task_status = value.split("-");

        if (task_status[0] == "complete") {

            document.getElementById("rate").style.display = 'block';

            document.getElementById("due").style.display = 'none';

        }

        else {

            document.getElementById("rate").style.display = 'none';

        }

    }

    function complete_date(value) {

        // alert('hi');

        complt_date = value.split("-");

        // alert('complt_date'+ complt_date);

        added_date = document.getElementById("added_date").value;

        // alert('added_date'+ added_date);

        if (complt_date < added_date) {

            // document.getElementById("rate").style.display = 'block';

            // document.getElementById("due").style.display = 'none';

            alert('Something wrong ! Complete Date Should Be Greater Than Added Date');

            window.location.reload();

        }

        else {

           return true;

        }

    }

    function hold_status(status) {

        priority = document.getElementById("priority").value;

        document.getElementById("rate").style.display = 'none';

        var status_data = "action=hold&status=" + status + "&priority=" + priority;

        // alert(status);

        $.ajax({

            url: "tk_staff_ajax.php", type: "post", data: status_data, cache: false,

            success: function (retstatus) {

                // alert(retstatus);

                document.getElementById("hold_sta").innerHTML = retstatus;

                $('.datepicker').datepicker({ changeMonth: true, changeYear: true, format: 'dd/mm/yyyy', startDate: '-0d', showButtonPanel: true, closeText: 'Clear' });

            }

        });

    }

    function validations(valid) {

        tasks_id = document.getElementById("task_ids1").value;

        admin_ids = document.getElementById("admin_ids").value;

        var valid_data = "action=validation&valid=" + valid + "&tasks_id=" + tasks_id+ "&admin_id=" + admin_ids;

        // alert('task_id='+tasks_id);

        // alert(valid);

        $.ajax({

            url: "tk_staff_ajax.php", type: "post", data: valid_data, cache: false,

            success: function (retvalid) {

                alert("Status Successfully Updated as " + valid);

                setTimeout('document.location.href="tk_individual_task_detail.php?id=<?= $staff_task_id ?>";', 200);

            }

        });

    }

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

                <div>

                    <!-- <a href="tk_dashboard.php"> Back</a> -->

                    <h2>

                        Details

                    </h2>

                </div>

                <ol class="breadcrumb">

                    <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>

                    <li class="active">Dashboard</li>

                </ol>

            </section>

            <section class="invoice">

                <div class="box box-default">

                    <div class="row">

                        <div class="col-xs-12">

                            <?php

                             if($_REQUEST['id']!='')

                             {

                                 $record_id=$_REQUEST['id'];

                                 $task_detail_data="select * from tk_individual_task where staff_task_id='".$record_id."' ";

                                 $ptr_detail=mysql_query($task_detail_data);

                                 $data=mysql_fetch_array($ptr_detail);

                                 $cm_id=$data['cm_id'];

                                 $staff_id1=$data['staff_id'];

                                //  $cmplt_date=$data['staff_complete_date'];

                                //  $complete_dates=date("Y-m-d",strtotime( $cmplt_date));

                             }

                             $sel_dept="SELECT dept_id FROM `dept_employee` WHERE 1 and staff_id='".$data['staff_id'] ."'";

                            $ptr_dept=mysql_query($sel_dept);

                            $data_dept=mysql_fetch_array($ptr_dept);



                            $select_manager="SELECT * FROM `dept_employee` WHERE 1 and status='manager' and dept_id='".$data_dept['dept_id']."'";

                            $ptr_manager=mysql_query($select_manager);

                            $data_manager=mysql_fetch_array($ptr_manager);

                            if(isset($_REQUEST['submit']))
                            {
                                $count=$data['deadline_count'];
                                $point=$data['points'];
                                $staff_id=$data['staff_id'];
                                $due_date=$_POST['due_date'];
                                $new_date=explode("/",$due_date);
                                $due_date_fromat=$new_date[2].''.$new_date[1].''.$new_date[0];
                                $admin_id =$_SESSION['admin_id'];
                                $admin_name="select name from site_setting where 1 and admin_id='".$admin_id."'";
                                $ptr_admin_name=mysql_query($admin_name);
                                $fetch_admin_name=mysql_fetch_array($ptr_admin_name);
                                $status=$_POST['optradio']; 
                                $complete=$_POST['compl_date'];
                                $new_compl_date=explode("/",$complete);
                                $complt_date_fromat=$new_compl_date[2].''.$new_compl_date[1].''.$new_compl_date[0];
                                $complt_dates=$new_compl_date[2].'-'.$new_compl_date[1].'-'.$new_compl_date[0];
                                    $data_date= $complt_date_fromat;
                                if($status=='complete')
                                    {
                                        $rating=trim($_POST['rating']);
                                    }
                                else{
                                        $rating='';
                                    }
                                $staff_status=$_POST['staff_status'];
                                $unhalt_date=$_POST['unhalt_date'];
                                $priority=$_POST['priority'];
                                $up_deadline=$_POST['up_deadline_date'];
                                $new_date1=explode("/",$up_deadline);
                                $up_deadline_date=$new_date1[2].'-'.$new_date1[1].'-'.$new_date1[0];
                                        $rate_p="select rating_point from tk_quality_work_point where rating ='".$rating."'";
                                        $ptr_rate_p=mysql_query($rate_p);
                                        $data_rate_p=mysql_fetch_array($ptr_rate_p);
                                        $rating_point='';
                                        if($status=='complete'){
                                        $rating_point=$data_rate_p['rating_point'];
                                        }
                                        elseif($status=='in_complete'){
                                            $rating_point=0;
                                        }
                                    $comment='';
                                    $type='';
                                    $actual_dead_line=date("Y-m-d",strtotime($data['due_date']));
                                    if($_POST['comment']!='') {
                                        $comment=addslashes($_POST['comment']);
                                        $type='comment';
                                          }
                                    elseif( $due_date!=''){
                                        $comment=''.$fetch_admin_name['name'].' changed due date from '.$actual_dead_line.' to- '.$due_date.''; 
                                        $type='due_date_change';
                                    }
                                    elseif($status!='' && $_POST['optradio']!='in_progress'){
                                        if($status=='halt'){
                                            $comment=''.$fetch_admin_name['name'].' mark status as - '.$status.' and set deadline from '.$data['due_date'].' to '. $up_deadline_date.' and priority from '.$data['priority'].' to '.$priority.' and un_holt date is '.$unhalt_date.'';
                                            $type='status_as_halt';
                                        }
                                        else{
                                            $comment=''.$fetch_admin_name['name'].' changed task status as - '.$status.'';
                                            $type='status_change';
                                        }
                                        }
                                    elseif($staff_status!=''){
                                            $comment=''.$fetch_admin_name['name'].' marked my side task status as - '.$staff_status.'';
                                            $type='staff_status';
                                        }
                                    $points='';
                                    $dat1=date("Y-m-d");
                                    if($actual_dead_line< $dat1 ){
                                        $deadline_count=$count+1;
                                    }
                                    else{
                                        $deadline_count=$count;
                                    }
                                    if($status=='complete') {
                                        $p='2';
                                        if($complt_dates <= $actual_dead_line  ){
                                            $points=$point;
                                        }
                                        elseif($count == 2 && $complt_dates > $actual_dead_line) {
                                            $points=$point/$p;
                                            }
                                        elseif($count == 3 && $complt_dates > $actual_dead_line) {
                                            $points=0;
                                            }
                                        elseif($count > 3 && $complt_dates > $actual_dead_line) {
                                            $points='-'.$point;
                                            }        
                                        elseif($complt_dates > $actual_dead_line){
                                            $points=$point/$p;
                                            }
                                        else{
                                            $points=$point;
                                            }
                                    }
                                    elseif($status=='in_complete')
                                         {
                                        $points='-'.$point;
                                        }
                                        $staff_names=$_POST['staff_names'];
                                        $sel_cm="select cm_id from site_setting where admin_id='".$staff_names."'";
                                        $ptr_cm=mysql_query($sel_cm);
                                        $data_cm=mysql_fetch_array( $ptr_cm);
                                        $cm_ids= $data_cm['cm_id'];
                                if($comment !="")
                                {
                                    $task_details="insert into individual_task_details(`staff_task_id`,`comment`,`type`,`admin_id`,`cm_id`,`added_date`) values('".$staff_task_id."','".$comment."','".$type."','".$admin_id."','".$_SESSION['cm_id']."','".date('Y-m-d H:i:s')."')";
                                    $ptr_data=mysql_query($task_details);
                                    if($ptr_data)
                                    {
                                        ?>
                                        <script>setTimeout('document.location.href="tk_individual_task_detail.php?id=<?= $staff_task_id ?>";', 100);</script>
                                        <?php
                                    } 
                                }
                                if($due_date_fromat !="")
                                {
                                $update_status="update tk_individual_task set `due_date`='".$due_date_fromat."',`dd_change_admin_id`='".$admin_id."',`deadline_count`='".$deadline_count."' where staff_task_id='".$staff_task_id."'";
                                $ptr_ins_t=mysql_query($update_status); 
                                if($ptr_ins_t)
                                    {
                                        ?>
                                        <script>setTimeout('document.location.href="tk_individual_task_detail.php?id=<?= $staff_task_id ?>";', 100);</script>
                                        <?php
                                    } 
                                }
                                if($status !="" && $unhalt_date !='' && $up_deadline_date!='' && $priority !='' )
                                {
                                   $update_status_halt="update tk_individual_task set `status`='".$status."',`unhold_date`='".$unhalt_date."',`priority`='".$priority."',`due_date`='".$up_deadline_date."' where staff_task_id='".$staff_task_id."'";
                                    $ptr_ins_halt=mysql_query($update_status_halt); 
                                    if($ptr_ins_halt)
                                    {
                                        ?>
                                        <script>setTimeout('document.location.href="tk_individual_task_detail.php?id=<?= $staff_task_id ?>";', 100);</script>
                                        <?php
                                    }
                                }
                                if($staff_names !="" && $cm_ids !=''  )
                                {
                                    $update_staff="update tk_individual_task set `staff_id`='".$staff_names."',`cm_id`='".$cm_ids."' where staff_task_id='".$staff_task_id."'";
                                    $ptr_update_staff=mysql_query($update_staff); 
                                    if($ptr_update_staff)
                                    {
                                        ?>
                                            <script>setTimeout('document.location.href="tk_individual_task_detail.php?id=<?= $staff_task_id ?>";', 100);</script>
                                        <?php
                                    }
                                }
                                if($status !="" )
                                {
                                        $update_status="update tk_individual_task set `status`='".$status."',`earn_points`='".$points."',`rating`='".$rating."',`rating_point`='".$rating_point."',`sta_updated_admin_id`='".$admin_id."',`sta_complete_date`='".$data_date."' where staff_task_id='".$staff_task_id."'";
                                        $ptr_ins_t=mysql_query($update_status); 
                                        if($status=='complete' || $status=='in_complete'){
                                                  $ins_per="insert into tk_employee_performance (`staff_task_id`,`staff_id`,`earn_points`,`rating_point`,`date`,`cm_id`,`admin_id`)values('".$staff_task_id."','".$staff_id."','".$points."','".$rating_point."','".$data_date."','".$cm_id."','".$admin_id."')";
                                            $ptr_p=mysql_query($ins_per);
                                        }
                                }
                                if($status=='complete')
                                {
                                    ?>
                                    <div class="alert alert-success alert-dismissible">
                                        <button type="button" class="close" data-dismiss="alert"
                                            aria-hidden="true">&times;</button>
                                        <h4><i class="icon fa fa-ban"></i> Alert!</h4>
                                        <p> Record Updated Successfully.</p>
                                    </div>
                                    <script>setTimeout('document.location.href="tk_individual_task_detail.php?id=<?= $staff_task_id ?>";', 500);</script>
                                    <?php
                                }
                                if($staff_status!="")
                                {
                                    $update_staff_status="update tk_individual_task set `staff_status`='".$staff_status."',`staff_complete_date`='".date('Y-m-d H:i:s')."' where staff_task_id='".$staff_task_id."'";
                                    $ptr_ins_staff=mysql_query($update_staff_status); 
                                    if ($ptr_ins_staff) {
                                        ?>
                                        <script>setTimeout('document.location.href="tk_individual_task_detail.php?id=<?= $staff_task_id ?>";', 500);</script>
                                        <?php
                                    }
                                }
                            }

                            ?>

                        </div>
                        <div>
                            <form name="task_form" method="post">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="table-responsive">
                                            <table class="table no-margin" style="text-align: center; border: 0px solid lightgray; border-collapse: collapse; width: 100%;">
                                                <thead>
                                                    <tr>
                                                        <th style="text-align:center;border: 1px solid lightgray;">Task</th>
                                                        <th style="text-align:center;border: 1px solid lightgray;">Assign By</th>
                                                        <th style="text-align:center;border: 1px solid lightgray;">Assign To</th>
                                                        <th style="text-align:center;border: 1px solid lightgray;">Priority</th>
                                                        <th style="text-align:center;border: 1px solid lightgray;">Actual Dead Line</th>
                                                        <th style="text-align:center;border: 1px solid lightgray;">Task Category </th>
                                                        <th style="text-align:center;border: 1px solid lightgray;" >Task Time</th>
                                                        <th style="text-align:center;border: 1px solid lightgray;">Task point </th>
                                                        <th style="text-align:center;border: 1px solid lightgray;">Task Repeate</th>
                                                        <th style="text-align:center;border: 1px solid lightgray;" >Todays Work Assign Hours
                                                        </th>
                                                        <?php
                                                        if($_SESSION['type']=='S' || $edit_access=='yes' && $data['status']!='complete'  )
                                                        {
                                                            ?>
                                                            <th style="text-align:center;border: 1px solid lightgray;">Re-Assign To </th>
                                                            <?php
                                                        }
                                                        if($data['assign_type']=='meeting' || $data['assign_type']=='staff_discussion' )
                                                        {
                                                            ?>
                                                            <th style="text-align:center;border: 1px solid lightgray;">
                                                                <?php echo ucwords($data['assign_type'] )?> Staff </strong>
                                                            </th>
                                                            <?php
                                                        }
                                                        ?>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>
                                                        <td style="text-align:center;border: 1px solid lightgray;">
                                                            <?php echo ucwords($data['task_name']); ?>
                                                        </td>
                                                        <td style="text-align:center;border: 1px solid lightgray;">
                                                            <?php
                                                            $staff_name="select name from site_setting where 1 and admin_id='".$data['assign_by']."'";
                                                            $ptr_data_staff=mysql_query($staff_name);
                                                            $fetch_staff_name=mysql_fetch_array($ptr_data_staff); 
                                                            echo ucfirst($fetch_staff_name['name']);
                                                            ?>
                                                        </td>
                                                        <td style="text-align:center;border: 1px solid lightgray;">
                                                            <?php
                                                            $staff_name1="select name from site_setting where 1 and admin_id='".$data['staff_id']."'";
                                                            $ptr_data_staff1=mysql_query($staff_name1);
                                                            $fetch_staff_name1=mysql_fetch_array($ptr_data_staff1);
                                                            echo ucfirst($fetch_staff_name1['name']);
                                                            ?>
                                                        </td>
                                                        <td style="text-align:center;border: 1px solid lightgray;">
                                                            <?php echo ucfirst($data['priority']);?>
                                                            <input type="hidden" value="<?php echo $data['priority']; ?>" id="priority" />
                                                        </td>
                                                        <td style="text-align:center;border: 1px solid lightgray;"> 
                                                            <span style="color:blue;">
                                                                <?php 
                                                                if($data['due_date']!='')
                                                                {
                                                                    $date1=date("d-m-Y");
                                                                    $due_Date = date("d-m-Y", strtotime($data['due_date']));
                                                                    if($due_Date < $date1 )
                                                                    {
                                                                        ?>
                                                                        <span style="color:red;">
                                                                            <?php  echo $due_Date;?>
                                                                        </span>
                                                                        <?php
                                                                    }
                                                                    else
                                                                    {
                                                                        ?>
                                                                        <span style="color:blue;">
                                                                            <?php  echo $due_Date;?>
                                                                        </span>
                                                                        <?php
                                                                    }
                                                                }
                                                                ?>
                                                            </span>
                                                        </td>
                                                        <td style="text-align:center;border: 1px solid lightgray;">
                                                            <?php echo ucfirst($data['assign_type']); ?>
                                                        </td>
                                                        <td colspan="" style="text-align:center;border: 1px solid lightgray;">
                                                            <?php 
                                                                $hour=$data['hours'];
                                                                $time1= convertToHoursMins($hour, '%02d hour %02d min');
                                                                echo $time1; 
                                                            ?>
                                                        </td>
                                                        <td style="text-align:center;border: 1px solid lightgray;">
                                                            <?php  
                                                            
                                                            echo ucwords($data['points']); 
                                                            ?>
                                                        </td>
                                                        <td style="text-align:center;border: 1px solid lightgray;">
                                                            <?php
                                                            $repeat="select repetation_type from tk_task_repetation_type where type_id='".$data['repetation_id']."' ";
                                                            $ptr_repeat=mysql_query($repeat);
                                                            $data_repeat=mysql_fetch_array($ptr_repeat);
                                                                if($data['repetation_id']==0){
                                                                    echo 'Repeated';
                                                                }
                                                                else{
                                                                echo ucwords($data_repeat['repetation_type']);
                                                                }
                                                            ?>
                                                        </td>
                                                        <td style="text-align:center;border: 1px solid lightgray;" colspan="">
                                                            <?php
                                                                $task_hours="select sum(hours)as task_hour from tk_individual_task where 1 and Validation='valid' and staff_id='".$data['staff_id']."'and DATE(date)='".date("Y-m-d")."' order by added_date DESC";
                                                                $ptr_task_hours=mysql_query($task_hours);
                                                                $data_hour=mysql_fetch_array($ptr_task_hours);
                                                                $task_time=$data_hour['task_hour'];

                                                                $sel_student_batch="select distinct(c_b_id) from batch_timetable where staff_id='".$data['staff_id']."' and date='".date("Y-m-d")."'";
                                                                $ptr_student_batch=mysql_query($sel_student_batch);
                                                                $tot_batch_id=mysql_num_rows($ptr_student_batch);
                                                                $batch_time= $tot_batch_id*2.5;
                                                                $hour=  $batch_time*60 ;

                                                                $tot_id=0;
                                                                '<br/>' .  $sel_student_batch="select distinct(followup_id) from followup_details where 1 and response!='1' and admin_id='".$data['staff_id']."' and DATE(followup_date )='".date('Y-m-d')."'";
                                                                $ptr_student_batch=mysql_query($sel_student_batch);
                                                                if($tot_batch_id=mysql_num_rows($ptr_student_batch)){
                                                                    $tot_id= $tot_batch_id*3;
                                                                }
                                                                $tot_enq=0;
                                                                $sel_student_enq="select distinct(followup_id) from followup_details where 1 and response='1' and admin_id='".$data['staff_id']."' and DATE(followup_date )='".date('Y-m-d')."'";
                                                                $ptr_student_enq=mysql_query($sel_student_enq);
                                                                if($tot_student_enq=mysql_num_rows($ptr_student_enq)){
                                                                    $tot_enq= $tot_student_enq*45;
                                                                }
                                                                $tot_times= $tot_enq+ $tot_id;

                                                                $tot_time= $task_time+ $hour+$tot_times;
                                                                $tot_hours= convertToHoursMins($tot_time, '%02d hour %02d min');
                                                                echo  $tot_hours;
                                                            ?>
                                                        </td>
                                                        <?php
                                                    if($_SESSION['type']=='S' || $edit_access=='yes' && $data['status']!='complete' )
                                                    {
                                                        ?>
                                                        <td style="text-align:center;border: 1px solid lightgray;">
                                                            <select class="form-control select2" style="width:150px" id="staff_names" name="staff_names">
                                                                <option value="">Assinged To</option>
                                                                <?php
                                                                    $categary="select admin_id,name from site_setting where 1 and system_status='Enabled'
                                                                    order by name ASC"; 
                                                                    $c_query=mysql_query($categary);
                                                                    while($data_c=mysql_fetch_array($c_query))
                                                                    {
                                                                        echo '<option value="'.$data_c['admin_id'].'">'.ucfirst($data_c['name']). '</option>';
                                                                    }
                                                                ?>
                                                            </select>
                                                        </td>
                                                        <?php
                                                    }
                                                    ?>
                                                    <?php
                                                        if($data['assign_type']=='meeting' || $data['assign_type']=='staff_discussion' )
                                                        {
                                                            ?>
                                                            <td style="text-align:center;border: 1px solid lightgray;">
                                                                <?php
                                                                    $sel_cnt="select count(staff_id) as tot_staff from tk_individual_task where ref_id='".$data['ref_id']."'";
                                                                    $ptr_cnt=mysql_query($sel_cnt);
                                                                    $data_cnt=mysql_fetch_array($ptr_cnt);
                                                                    ?>
                                                                <button type="button" class="btn btn-default" data-toggle="modal" data-target="#<?php echo $data['ref_id']?>"style="width:50px;"><?php echo $data_cnt['tot_staff'];?></button>
                                                                <div class="modal fade" id="<?php echo $data['ref_id'];?>">
                                                                    <div class="modal-dialog" style="width:300px;">
                                                                        <div class="modal-content">
                                                                            <div class="modal-header">
                                                                                <h4 class="modal-title">
                                                                                    <span style="color:blue">
                                                                                        <?php echo ucwords($data['task_name']) ?>
                                                                                    </span>- Collabraters
                                                                                    <p>
                                                                                        [<?php echo ucwords($data['assign_type']) ?>]
                                                                                    </p>
                                                                                </h4>
                                                                            </div>
                                                                            <div class="modal-body">
                                                                                <div class="box box-default">
                                                                                    <div class="direct-chat-messages" style="background-color::gray;">
                                                                                        <?php
                                                                                            $sel_id="select staff_id from tk_individual_task where ref_id='".$data['ref_id']."'";
                                                                                            $ptr_id=mysql_query($sel_id);
                                                                                            $i=1;
                                                                                            while($data_id=mysql_fetch_array($ptr_id))
                                                                                            {
                                                                                                $sel_name="select name from site_setting where 1 and admin_id='".$data_id['staff_id']."'";
                                                                                                $ptr_name=mysql_query($sel_name);
                                                                                                $data_name=mysql_fetch_array($ptr_name);
                                                                                                ?>
                                                                                                <p style="text-align:left;">
                                                                                                    <?php echo ucfirst($i++.' . '.$data_name['name']);?>
                                                                                                </p>
                                                                                                <?php
                                                                                            }
                                                                                        ?>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </td>
                                                            <?php
                                                        }
                                                        ?>
                                                    </tr>
                                                </tbody>
                                            </table><br>
                                            <table class="table no-margin" style="text-align: left; border: 0px solid lightgray; border-collapse: collapse; width: 100%;">
                                                <tr>
                                                    <td width="40%">
                                                        <p><strong>Description :</strong></p>
                                                        <p class="text-muted well well-sm no-shadow" style="margin-top: 10px;">
                                                            <?php echo strip_tags(ucwords($data['description'])); ?>
                                                        </p>
                                                        <div>
                                                            <div style="margin-bottom: 10px;">
                                                                <a href="tk_add_individual_task.php" title="Add Task" style="display: inline-block; padding: 4px 12px; background-color: #007bff;color: white; border-radius: 5px; text-align: center; text-decoration: none; font-weight: bold; font-size: 16px; border: none;box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Optional shadow for better appearance */transition: background-color 0.3s, box-shadow 0.3s;" onmouseover="this.style.backgroundColor='#0056b3';" onmouseout="this.style.backgroundColor='#007bff';">Add New Task</a>
                                                            </div>
                                                            <div style="margin-bottom: 10px;">
                                                                <strong>Added Date : </strong><span style="color:blue"><?php echo  date("d-m-Y H:i",strtotime($data['added_date']))?></span>
                                                            </div>
                                                            <div style="margin-bottom: 10px;">
                                                                <?php if($data['staff_complete_date']!='') {?><strong> Staff Complete Date : </strong><span><?php echo  date("d-m-Y H:i",strtotime($data['staff_complete_date'])) ?></span> <?php } ?>
                                                                <input type="hidden" name="added_date" id="added_date" value="<?php echo date("d/m/Y",strtotime($data['added_date'])) ;?>">
                                                            </div>
                                                        </div>
                                                        <?php
                                                        if($data['status']!='complete')
                                                        {
                                                            if(($_SESSION['type']=='S' ||  $edit_access=='yes')&& $_SESSION['admin_id']!=$data['staff_id'] )
                                                            {
                                                                ?>
                                                                <div><strong>Validation :</strong>&nbsp;&nbsp;
                                                                    <span>
                                                                        <label>Valid
                                                                            <input type="radio" name="validation" value="valid"
                                                                                onchange="validations(this.value)" <?php
                                                                                if($_POST['validation']=="valid" ) echo 'checked="checked"' ;
                                                                                else if($data['Validation']=="valid" ) echo 'checked="checked"'
                                                                                ; ?> >
                                                                        </label>&nbsp;&nbsp;
                                                                        <label>In-Valid
                                                                            <input type="radio" name="validation" value="in_valid"
                                                                                onchange="validations(this.value)" <?php
                                                                                if($_POST['validation']=="in_valid" ) echo 'checked="checked"' ;
                                                                                else if($data['Validation']=="in_valid" )
                                                                                echo 'checked="checked"' ; ?> >

                                                                        </label>
                                                                        <input type="hidden" name="task_id1" id="task_ids1" value="<?php echo $record_id;?>">
                                                                        <input type="hidden" name="admin" id="admin_ids" value="<?php echo $_SESSION['admin_id'];?>">
                                                                    </span>&nbsp;&nbsp;
                                                                    <div>
                                                                        <?php
                                                                        $sel_valid_name="select name from site_setting where admin_id='".$data['validation_admin']."'";
                                                                        $pt_name=mysql_query($sel_valid_name);
                                                                        $data_validation=mysql_fetch_array($pt_name);
                                                                        if($data['Validation']=="valid")
                                                                        {
                                                                            echo 'Valid by- '.Ucwords($data_validation['name']);
                                                                        }
                                                                        else if($data['Validation']=="in_valid"){
                                                                            echo 'Invalid by- '.Ucwords($data_validation['name']);
                                                                        }
                                                                        else{
                                                                            echo ucfirst($data['Validation']);
                                                                        }
                                                                        ?>
                                                                    </div>&nbsp;&nbsp;
                                                                    <span>
                                                                        <?php if($data['Validation']=="in_valid") 
                                                                        {
                                                                            ?>
                                                                            <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#reason_invalid">
                                                                            Invalid Reason</button>
                                                                            <?php 
                                                                        }
                                                                        if(isset($_REQUEST['submit_reason']))
                                                                        {
                                                                            $task_ids=$record_id;
                                                                            $reason=$_POST['reason'];
                                                                            $admin_id =$_SESSION['admin_id'];
                                                                            if($reason!='')
                                                                            {
                                                                                $insert_project="insert into tk_task_validation(`staff_task_id`,`reasons`,`added_date`,`admin_id`) values('".$task_ids."','".$reason."','".date('Y-m-d : H:i:s')."','".$admin_id."')";
                                                                                $ptr_ins=mysql_query($insert_project);
                                                                            }
                                                                        }
                                                                        ?>
                                                                        <div class="modal fade" id="reason_invalid">
                                                                            <div class="modal-dialog" style="width:300px;">
                                                                                <div class="modal-content">
                                                                                    <div class="modal-header">
                                                                                        <h4 class="modal-title">
                                                                                            <span style="color:blue">
                                                                                                Add Task Invalid Reasons
                                                                                            </span>
                                                                                        </h4>
                                                                                    </div>
                                                                                    <div class="modal-body">
                                                                                        <div class="box box-warning">
                                                                                            <div class="form-group">
                                                                                                <textarea type="" class="form-control" name="reason" id="reason" value=""
                                                                                                        placeholder="Add Reason"></textarea>
                                                                                            </div>
                                                                                            <div class="form-group">
                                                                                                <div class="">
                                                                                                    <input type="submit" name="submit_reason" value="Submit" class="btn btn-block btn-success">
                                                                                                </div>
                                                                                            </div>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </span>
                                                                </div>
                                                                <?php 
                                                            }
                                                        }
                                                        ?>
                                                    </td>
                                                    <td width="40%">
                                                        <?php
                                                        if (isset($_REQUEST['Complete'])) {
                                                            $t_admin_id = $_SESSION['admin_id'];
                                                            $t_task_id = $_POST['tasks_ids'];
                                                            $ratings = $_POST['t_rating'];
                                                            $t_rating = array_values(array_filter($ratings, function($ratings) {
                                                                return !empty($ratings);
                                                            }));
                                                            '<br>'.$rating_cnt = count($t_rating);
                                                            '<br>'.$task_cnt = count($t_task_id);
                                                            if($task_cnt!=$rating_cnt){
                                                                $rating_error="Please select the rating for all checked tasks.";    
                                                            }
                                                            else
                                                            {
                                                                for ($j = 0; $j < $task_cnt; $j++) 
                                                                {
                                                                    $sel_task_det = "SELECT * FROM tk_individual_task WHERE staff_task_id = '" .$t_task_id[$j]. "'";
                                                                    $ptr_task_det = mysql_query($sel_task_det);
                                                                    $data_task_det = mysql_fetch_array($ptr_task_det);
                                                            
                                                                    $counts = $data_task_det['deadline_count'];
                                                                    $task_point = $data_task_det['points'];
                                                                    $t_status = 'complete';
                                                                    $complt_date12 = date('Y-m-d');
                                                                    $p = '2';
                                                                    $t_points = '';
                                                            
                                                                    if ($complt_date12 <= $data_task_det['due_date']) {
                                                                        $t_points = $task_point;
                                                                    } elseif ($counts == 2 && $complt_date12 > $data_task_det['due_date']) {
                                                                        $t_points = $task_point / $p;
                                                                    } elseif ($counts == 3 && $complt_date12 > $data_task_det['due_date']) {
                                                                        $t_points = 0;
                                                                    } elseif ($counts > 3 && $complt_date12 > $data_task_det['due_date']) {
                                                                        $t_points = '-' . $task_point;
                                                                    } else {
                                                                        $t_points = $task_point / $p;
                                                                    }
                                                            
                                                                    '<br>'.$rate_t = "SELECT rating_point FROM tk_quality_work_point WHERE rating = '" .$t_rating[$j]. "'";
                                                                    $ptr_rate_t = mysql_query($rate_t);
                                                                    $data_rate_t = mysql_fetch_array($ptr_rate_t);
                                                                    $t_rating_point = $data_rate_t['rating_point'];
                                                            
                                                                    $update_status = "UPDATE tk_individual_task SET status = '" .$t_status. "', earn_points = '" .$t_points . "', rating = '" .$t_rating[$j]. "', rating_point = '" .$t_rating_point . "', sta_updated_admin_id = '" .$t_admin_id . "', sta_complete_date = '" .$complt_date12. "' WHERE staff_task_id = '" .$t_task_id[$j]. "'";
                                                                    $ptr_ins_t = mysql_query($update_status);
                                                            
                                                                    // if ($t_status == 'complete') {
                                                                        $ins_per = "INSERT INTO tk_employee_performance (staff_task_id, staff_id, earn_points, rating_point, date, cm_id, admin_id) VALUES ('" .$t_task_id[$j] . "', '" .$data_task_det['staff_id']. "', '" .$t_points. "', '" .$t_rating_point. "', '" .$complt_date12. "', '" .$data_task_det['cm_id']. "', '" .$t_admin_id. "')";
                                                                        $ptr_p = mysql_query($ins_per);
                                                                    // }                                        
                                                                    $admins_name = "SELECT name FROM site_setting WHERE admin_id='" .$t_admin_id . "'";
                                                                    $ptrs_admin_name = mysql_query($admins_name);
                                                                    $fetchs_admin_name = mysql_fetch_array($ptrs_admin_name);
                                                                    $comments = $fetchs_admin_name['name'] . ' changed task status as - ' . $t_status;
                                                                    $type1 = 'status_change';
                                                                    if ($comments != "") {
                                                                        $task_comment = "INSERT INTO individual_task_details (staff_task_id, comment, type, admin_id, cm_id, added_date) 
                                                                        VALUES ('" .$t_task_id[$j]. "',  '" .$comments. "',  '" .$type1. "',  '" .$t_admin_id . "',  '" .$_SESSION['cm_id']. "', '" . date('Y-m-d : H:i:s') . "')";
                                                                        $ptr_commnt = mysql_query($task_comment);
                                                                    }
                                                                }
                                                                if($ptr_ins_t)
                                                                {
                                                                    ?>
                                                                    <div class="alert alert-success alert-dismissible">
                                                                        <button type="button" class="close" data-dismiss="alert"
                                                                            aria-hidden="true">&times;</button>
                                                                        <h4><i class="icon fa fa-ban"></i> Alert!</h4>
                                                                        <p> Record Updated Successfully.</p>
                                                                    </div>
                                                                    <script>setTimeout('document.location.href="tk_individual_task_detail.php?id=<?= $staff_task_id ?>";', 500);</script>
                                                                    <?php
                                                                }
                                                            }
                                                        }                                        
                                                        ?>
                                                        <?php
                                                        if($_SESSION['type']=='S' || $edit_access=='yes'){
                                                            $staff_task2=$data['staff_id'];
                                                        }
                                                        else{
                                                            $staff_task2=$_SESSION['admin_id'];
                                                        }
                                                        $select_task = "SELECT * FROM tk_individual_task WHERE staff_id = '" .$staff_task2. "' AND Validation = 'valid' AND (status != 'complete' AND status != 'cancel') ORDER BY staff_task_id ASC";
                                                        $ptr_task = mysql_query($select_task);
                                                        $tot_task = mysql_num_rows($ptr_task);
                                                        if($tot_task)
                                                        {
                                                            ?>
                                                            <div class="box box-default collapsed-box box-success" style="min-width:565px">
                                                                <div class="box-header with-border" style="height:70px">
                                                                    <h3 type="button" class="btn btn-box-tool box-title" data-widget="collapse">Pending Task <?php
                                                                        if($_SESSION['type']=='S'  || $edit_access=='yes'){
                                                                            echo ucfirst($fetch_staff_name1['name']); 
                                                                        }
                                                                        ?>
                                                                         <span data-toggle="tooltip" title="<?php echo $tot_task; ?> New Pending Task" class="badge bg-red"><?php echo $tot_task; ?></span>&nbsp;&nbsp;&nbsp;</h3>
                                                                    <!-- <div class="box-tools pull-left">
                                                                        <button type="button" class="btn btn-box-tool" data-widget="collapse">
                                                                        <?php
                                                                        if($_SESSION['type']=='S'  || $edit_access=='yes'){
                                                                            echo ucfirst($fetch_staff_name1['name']); 
                                                                        }
                                                                        ?>
                                                                         <span data-toggle="tooltip" title="<?php echo $tot_task; ?> New Pending Task" class="badge bg-red"><?php echo $tot_task; ?></span>
                                                                        </button>
                                                                    </div> -->
                                                                    <!-- &nbsp;&nbsp;&nbsp;&nbsp;<span data-toggle="tooltip" title="<?php echo $tot_task; ?> New Pending Task" class="badge bg-red"><?php echo $tot_task; ?></span>&nbsp;&nbsp;
                                                                    &nbsp;&nbsp;&nbsp;&nbsp; -->
                                                                    <span style="color:blue" id="checkedCount"></span>
                                                                    <p class="form-group" style="color:red" id="Complete_error"></p>
                                                                    <p style="color:red"><?php echo $rating_error?></p>
                                                                    
                                                                </div>
                                                                <div class="box-body">
                                                                    <div class="direct-chat-messages">
                                                                        <table class="table no-margin" style="text-align:center">
                                                                            <thead>
                                                                                <tr>
                                                                                    <th style="text-align:center">Sr.No.</th>
                                                                                    <?php
                                                                                    if($_SESSION['type']=='S'  || $edit_access=='yes')
                                                                                    {
                                                                                    ?>
                                                                                    <th style="text-align:center">Check</th>
                                                                                    <th style="text-align:center">Rating</th>
                                                                                    <?php
                                                                                    }
                                                                                    ?>
                                                                                    <th style="text-align:center">Task</th>
                                                                                    <th style="text-align:center">Assign By</th>
                                                                                    <th style="text-align:center">Dead Line</th>
                                                                                    <th style="text-align:center">Details</th>
                                                                                </tr>
                                                                            </thead>
                                                                            <tbody>
                                                                                <?php
                                                                                $l = 1;
                                                                                while ($data_task = mysql_fetch_array($ptr_task)) 
                                                                                {
                                                                                    $staff = "SELECT name FROM site_setting WHERE admin_id = '" . mysql_real_escape_string($data_task['assign_by']) . "'";
                                                                                    $ptr_staffs = mysql_query($staff);
                                                                                    $data_staffs = mysql_fetch_array($ptr_staffs);
                                                                                    if($data_task['staff_status']=='complete')
                                                                                    {
                                                                                        $bg_color='style="background-color:rgb(172,225,175);"';
                                                                                    }
                                                                                    elseif($data_task['staff_status']=='in_progress')
                                                                                    {
                                                                                        $bg_color='style="background-color:rgb(252,255,164);"';
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        $bg_color='';
                                                                                    }
                                                                                    ?>
                                                                                    <tr <?php echo $bg_color; ?>>
                                                                                        <td>
                                                                                            <?php echo $l++; ?>
                                                                                        </td>
                                                                                        <?php
                                                                                        if($_SESSION['type']=='S'  || $edit_access=='yes'){
                                                                                            ?>
                                                                                            <td>
                                                                                                <input type="checkbox" value="<?php echo $data_task['staff_task_id']; ?>" name="tasks_ids[]" class="taskcheckbox" onclick="countCheckedTasks()">
                                                                                            </td>
                                                                                            <td>
                                                                                                <select style="width:70px;" class="taskRating" name="t_rating[]" id="t_rating_<?php echo $data_task['staff_task_id']; ?>" onchange="countCheckedTasks()">
                                                                                                    <option value="">Select</option>
                                                                                                    <?php
                                                                                                    $rate = "SELECT * FROM tk_quality_work_point";
                                                                                                    $ptr_rate = mysql_query($rate);
                                                                                                    while ($data_rate = mysql_fetch_array($ptr_rate)) {
                                                                                                        echo '<option value="' . $data_rate['rating'] . '">' . ucfirst($data_rate['rating']) . '</option>';
                                                                                                    }
                                                                                                    ?>
                                                                                                </select>
                                                                                            </td>
                                                                                            <?php
                                                                                        }
                                                                                        ?>
                                                                                        <td><?php echo ucwords($data_task['task_name']); ?></td>
                                                                                        <td><?php echo ucwords($data_staffs['name']); ?></td>
                                                                                        <td>
                                                                                            <?php
                                                                                            $current_date = date("d-m-Y");
                                                                                            $dues_date = date("d-m-Y", strtotime($data_task['due_date']));
                                                                                            if ($current_date > $dues_date) {
                                                                                                echo '<span style="color:red;">' . $dues_date . '</span>';
                                                                                            } else {
                                                                                                echo '<span style="color:blue;">' . $dues_date . '</span>';
                                                                                            }
                                                                                            ?>
                                                                                        </td>
                                                                                        <td>
                                                                                            <a href="tk_individual_task_detail.php?id=<?php echo $data_task['staff_task_id']; ?>" target="_blank"><i class="fa fa-file"></i></a>
                                                                                        </td>
                                                                                    </tr>
                                                                                    <?php
                                                                                }
                                                                                if($_SESSION['type']=='S'  || $edit_access=='yes')
                                                                                {
                                                                                ?>
                                                                                    <tr>
                                                                                        <td colspan="3">
                                                                                            <div class="form-group" id="Complete" style="display:none">
                                                                                                <input type="submit" name="Complete" value="Mark Complete" class="btn btn-block btn-success">
                                                                                            </div>
                                                                                        </td>
                                                                                    </tr>
                                                                                    <?php
                                                                                }
                                                                                    ?>
                                                                            </tbody>
                                                                        </table>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <?php
                                                        }
                                                        ?>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div><hr>
                                    </div>
                                </div>
                                <!--===========================================================================================================-->
                                <div class="row">
                                    <div class="col-md-6">
                                        <?php
                                            $sel_task_status="select status,sta_updated_admin_id,sta_complete_date,rating,staff_status from tk_individual_task where staff_task_id='".$data['staff_task_id']."'";
                                            $ptr_data_sta=mysql_query($sel_task_status);
                                            $fetch_details_status=mysql_fetch_array($ptr_data_sta);
                                            $staff_name_status="select name from site_setting where 1 and admin_id='".$fetch_details_status['sta_updated_admin_id']."'";
                                            $ptr_data_staff_status=mysql_query($staff_name_status);
                                            $fetch_staff_name_status=mysql_fetch_array($ptr_data_staff_status);
                                        ?>
                                        <div class="form-group">
                                            <?php
                                            if($data['staff_id']==$_SESSION['admin_id'] && $data['status']!='complete')
                                            { 
                                                ?>
                                                <div class="form-group">
                                                    <label>My Task Status : </label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="staff_status" id="staff_status1" <?php
                                                            if($fetch_details_status['staff_status']=='complete' )
                                                            echo 'checked="checked"' ; ?>
                                                        value="complete" >Complete</label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="staff_status" id="staff_status" <?php
                                                            if($fetch_details_status['staff_status']=='in_progress' )
                                                            echo 'checked="checked"' ; ?>
                                                        value="in_progress" >In_Progress</label>
                                                </div>
                                                <?php
                                            }
                                            ?>
                                        </div>
                                        <?php
                                        if($_SESSION['type']=='S'  || $edit_access=='yes' || $data_manager['staff_id']==$_SESSION['admin_id'] && $_SESSION['admin_id']!=$data['staff_id']  || $data['task_type']=='system' )
                                        {
                                            ?>
                                            <div class="form-group">
                                                <label>Status : </label>
                                                <?php
                                                if($data['status']!='complete'  && $data['Validation']== "valid")
                                                {
                                                    ?>
                                                    <div>
                                                        <label class="radio-inline">
                                                        <input type="radio" name="optradio" id="" <?php
                                                            if($fetch_details_status['status']=='complete' )
                                                            echo 'checked="checked"' ; ?>
                                                        value="complete" onChange="show_rating(this.value)"
                                                        >Complete</label>
                                                        <label class="radio-inline">
                                                        <input type="radio" name="optradio" id="" <?php
                                                            if($fetch_details_status['status']=='in_progress' )
                                                            echo 'checked="checked"' ; ?>
                                                        value="in_progress"
                                                        onChange="show_rating(this.value),hold_status(this.value)">In_Progress</label>
                                                        <label class="radio-inline"><input type="radio" name="optradio" id=""
                                                            <?php if($fetch_details_status['status']=='in_complete' )
                                                            echo 'checked="checked"' ; ?>
                                                        value="in_complete"
                                                        onChange="show_rating(this.value),hold_status(this.value)">In-Complete</label>
                                                        <label class="radio-inline"><input type="radio" name="optradio"
                                                            id="task_hold_staus" <?php
                                                            if($fetch_details_status['status']=='halt' )
                                                            echo 'checked="checked"' ; ?>
                                                        value="halt"
                                                        onChange="show_rating(this.value),hold_status(this.value)">Halt</label>
                                                        <label class="radio-inline"><input type="radio" name="optradio" id=""
                                                            <?php if($fetch_details_status['status']=='cancel' )
                                                            echo 'checked="checked"' ; ?>
                                                        value="cancel"
                                                        onChange="show_rating(this.value),hold_status(this.value)">Cancel</label>
                                                    </div>
                                                    <?php
                                                }
                                                else
                                                {
                                                    ?>
                                                    <span>
                                                        <?php  echo ucfirst($fetch_details_status['status']);?>
                                                    </span>
                                                    <?php
                                                    $due_Date=$data['due_date'];
                                                    $complete_Date=$fetch_details_status['sta_complete_date'];
                                                    $due_Date12 =date("Y-m-d",strtotime($due_Date));
                                                    $complete_Date12 =date("Y-m-d",strtotime( $complete_Date));
                                                    if($complete_Date12 > $due_Date12)
                                                    {
                                                        ?>
                                                        <span class="label label-danger" style="margin-left:20px;">
                                                        <?php
                                                        echo 'Over Due';
                                                    }
                                                    ?>
                                                        </span>
                                                    <?php
                                                } 
                                                ?>
                                            </div>
                                            <div class="form-group" id="rate" <?php
                                                if($fetch_details_status['status']=='complete')
                                                echo 'style="display:block"' ;else echo 'style="display:none"' ;?>>
                                                <label>Rating : </label>
                                                <?php
                                                if($data['status']!='complete' )
                                                {
                                                    ?>
                                                    <div>
                                                        <p class="text-muted well well-sm no-shadow" style="margin-top: 10px;">
                                                            <?php
                                                            if($data['deadline_count']==1)
                                                            {
                                                                $rate="select * from tk_quality_work_point";
                                                                $ptr_rate=mysql_query($rate);
                                                                while($data_rate=mysql_fetch_array($ptr_rate))
                                                                {
                                                                    $sel='';
                                                                    if($data_rate['rating']=='good')
                                                                    {
                                                                        $sel='checked="checked"';
                                                                    }
                                                                    ?>
                                                                    <label class="radio-inline">
                                                                        <input type="radio" name="rating" id="" <?php echo $sel; ?>
                                                                        <?php
                                                                        if($fetch_details_status['rating']=='excellent' ) echo 'checked="checked"';
                                                                        ?>
                                                                        value="
                                                                        <?php echo $data_rate['rating'] ; ?>">
                                                                        <?php echo ucfirst($data_rate['rating']); ?>
                                                                    </label>
                                                                    <?php
                                                                }
                                                            }
                                                            else
                                                            {
                                                                $rate1="select * from tk_quality_work_point where rating !='excellent'";
                                                                $ptr_rate1=mysql_query($rate1);
                                                                while($data_rate1=mysql_fetch_array($ptr_rate1))
                                                                {
                                                                    $sel='';
                                                                    if($data_rate1['rating']=='good')
                                                                    {
                                                                        $sel='checked="checked"';
                                                                    }
                                                                    ?>
                                                                            <label class="radio-inline">
                                                                                <input type="radio" name="rating" id="" <?php echo $sel; ?>
                                                                                <?php
                                                                            if($fetch_details_status['rating']=='excellent' ) echo 'checked="checked"' ;
                                                                            ?>
                                                                                value="
                                                                                <?php echo $data_rate1['rating'] ; ?>">
                                                                                <?php echo ucfirst($data_rate1['rating']); ?>
                                                                            </label>
                                                                            <?php
                                                                }
                                                            }
                                                            ?>
                                                        </p>
                                                    </div>
                                                    <label>
                                                    Task Complete Date : 
                                                    </label>
                                                    <div class="input-group date">  
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-calendar"></i>
                                                        </div>
                                                        <input type="text" class="form-control pull-left" onChange="complete_date(this.value)"  readonly="readonly" name="compl_date" id="datepicker1" style="width:150px" value="<?php echo date("d/m/Y")?>"
                                                                    placeholder="Task Complete Date">
                                                    </div>
                                                    <?php
                                                }
                                                else
                                                {
                                                    ?>
                                                        <span style="color:blue">
                                                            <strong><?php echo ucfirst($fetch_details_status['rating']); ?></strong>
                                                        </span>
                                                    <?php
                                                }
                                                ?>
                                            </div>
                                            <div id="hold_sta" style="display:block"></div>
                                            <?php
                                            if($data['status']!='complete' )
                                            {
                                                ?>
                                                <div class="form-group" id="due">
                                                    <label>Change Dead Line : </label>
                                                    <div class="input-group date">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-calendar"></i>
                                                        </div>
                                                        <input type="text" class="form-control pull-left" name="due_date"
                                                            id="datepicker" style="width:210px" value=""
                                                            placeholder="Update Due Date">
                                                    </div>
                                                </div>
                                                <?php
                                            } 
                                        } 
                                        ?>
                                        <div>
                                            <?php 
                                                $staff_due_date="select name from site_setting where 1 and admin_id='".$data['dd_change_admin_id']."'";
                                                $ptr_data_duedate=mysql_query($staff_due_date);
                                                $fetch_name=mysql_fetch_array($ptr_data_duedate);      
                                                if($data['due_date_change']!='')
                                                {
                                                    ?>
                                                    <span><b>
                                                        <?php $due_Date_up = date("d-m-Y", strtotime($data['due_date_change']));
                                                        echo $fetch_name['name'];?>
                                                    </b></span>
                                                    <span> Changed Dead Line As: </span><span style="color:Blue;"><b>
                                                        <?php echo $due_Date_up;?>
                                                    </b></span>
                                                    <?php
                                                }  
                                                ?>
                                        </div>
                                        <br>
                                        <div>
                                            <?php
                                            if( $fetch_details_status['status']!='' && $fetch_details_status['status']!='in_progress')
                                            {
                                                ?>
                                                <span><b>
                                                    <?php 
                                                        echo ucfirst($fetch_staff_name_status['name']);?>
                                                </b></span>
                                                <span> Marked Task Status As </span>
                                                <?php if($fetch_details_status['status']=='complete') 
                                                { 
                                                    ?>
                                                    <span class="label label-success">
                                                        <?php echo ucfirst($fetch_details_status['status']);?>
                                                    </span>
                                                    <?php
                                                } 
                                                if($fetch_details_status['status']=='in_progress') 
                                                { 
                                                    ?>
                                                    <span class="label label-warning">
                                                        <?php echo ucfirst($fetch_details_status['status']);?>
                                                    </span>
                                                    <?php
                                                } 
                                                if($fetch_details_status['status']=='in_complete') 
                                                { 
                                                  ?>
                                                    <span class="label label-danger">
                                                        <?php echo ucfirst($fetch_details_status['status']);?>
                                                    </span>
                                                    <?php
                                                } 
                                                if($fetch_details_status['status']=='cancel') 
                                                { 
                                                    ?>
                                                    <span class="label label-default">
                                                        <?php echo ucfirst($fetch_details_status['status']);?>
                                                    </span>
                                                    <?php
                                                }
                                                if($fetch_details_status['status']=='halt') 
                                                { 
                                                    ?>
                                                    <span class="label label-primary">
                                                        <?php echo ucfirst($fetch_details_status['status']);?>
                                                    </span>
                                                    <?php
                                                }
                                                ?>
                                                <div> Rating :<span style="color:blue"> <strong>
                                                        <?php echo ucfirst($fetch_details_status['rating']); ?>
                                                    </strong></span>
                                                </div>
                                                <?php
                                            }  
                                            ?>
                                        </div>
                                    </div>                                
                                    <div class="col-md-6">
                                        <i class="fa  fa-comments-o"></i>
                                        <?php
                                        $sel_task_Details="select comment,admin_id,detail_id,type,added_date from individual_task_details where staff_task_id='".$data['staff_task_id']."' order by detail_id ASC";
                                        $ptr_data_d=mysql_query($sel_task_Details);     
                                        $records=mysql_num_rows($ptr_data_d);
                                        if($records)
                                        {
                                            ?>
                                            <div class="direct-chat-messages" style="text-align:left">
                                                <?php                                           
                                                while( $fetch_details_data=mysql_fetch_array($ptr_data_d))
                                                {
                                                    $staff_name_com="select name,photo from site_setting where 1 and admin_id='".$fetch_details_data['admin_id']."'";
                                                    $ptr_staff_com=mysql_query($staff_name_com);
                                                    $fetch_staff_com=mysql_fetch_array($ptr_staff_com);
                                                    if($fetch_details_data['comment']!='')
                                                    {
                                                        $add_date=date("d-m-Y H:i",strtotime($fetch_details_data['added_date']));
                                                        ?>
                                                        <div>
                                                            <span><img
                                                                    src="../faculty_login/staff_photo/<?php echo $fetch_staff_com['photo'];?>"
                                                                    width="20px" ; height="20px" ;></span>
                                                            <strong>
                                                                <?php echo ucfirst($fetch_staff_com['name']);?>
                                                            </strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">
                                                                <?php echo $add_date ;?>
                                                            </span>
                                                        </div>
                                                        <div style="margin-left:50px;">
                                                                <li><em>
                                                                    <?php echo strip_tags(ucwords($fetch_details_data['comment']));?>
                                                                </em></li>
                                                        </div><br>
                                                        <?php
                                                    }
                                                } 
                                                ?>
                                            </div>
                                            <?php
                                        }
                                        ?>
                                    </div>
                                </div>                                    
                                <div class="col-xs-12">
                                    <?php
                                    if($data['status']!='complete')
                                    {
                                        ?>
                                        <div class="form-group">
                                            <textarea class="form-control" name="comment" rows="2" <?php echo
                                                $comment_Err ;?>
                                            placeholder="Ask Quetions or Post Update..."></textarea>
                                        </div>
                                        <div class="form-group">
                                                <input type="submit" name="submit" value="Save Change"
                                                    class="btn btn-block btn-success">
                                        </div>
                                        <?php
                                    }
                                    ?>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </section>
        </div>
        <?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 -->

    <link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">

    <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 delete_staff(staff_id, tm_id) {

            var staff_data = "action=delete_staff&staff_id=" + staff_id + "&tm_id=" + tm_id;

            // alert(staff_data);

            $.ajax({

                url: "ajax_task.php", type: "post", data: staff_data, cache: false,

                success: function (staffData) {

                    alert(staffData);

                    document.getElementById("st_id" + staff_id).innerHTML = '';

                }

            });

        }
function countCheckedTasks() {
    const checkboxes = document.querySelectorAll('.taskcheckbox');
    const taskRatings = document.querySelectorAll('.taskRating');
    let count = 0;
    let count_rating = 0;
    checkboxes.forEach(function(checkbox) {
        if (checkbox.checked) {
            count++;
        }
    });
    taskRatings.forEach(function(select) {
        if (select.value !== "") { 
            count_rating++;
        }
    });
    document.getElementById('checkedCount').innerHTML = 'Checked Tasks: <span data-toggle="tooltip" class="badge bg-green">' + count + '</span>';
    let remain = count - count_rating;
    if (count === count_rating && count > 0) {
        document.getElementById('Complete').style.display = 'block';
        document.getElementById('Complete_error').style.display = 'none';
    } else {
        document.getElementById('Complete').style.display = 'none';
        if (remain > 0) {
            document.getElementById('Complete_error').style.display = 'block';
            document.getElementById('Complete_error').innerHTML = 'Please select the rating for all checked tasks. <span data-toggle="tooltip" class="badge bg-brown">' + remain + '</span> task(s) remain to have a rating selected. The "Complete" button will be shown at the bottom once all ratings are selected.';

        } else {
            document.getElementById('Complete_error').style.display = 'none';
        }
    }
}


    </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: '-1d',

                endDate: '+0d',

                Default: true,

                todayHighlight: true

            })

            //  $('#datepicker2').datepicker({

            //     autoclose: true,

            //     format: 'dd/mm/yyyy',

            //     Default: true,

            //     todayHighlight: true

            // })

            $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({

                checkboxClass: 'icheckbox_minimal-blue',

                radioClass: 'iradio_minimal-blue'

            })

            //Red color scheme for iCheck

            $('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({

                checkboxClass: 'icheckbox_minimal-red',

                radioClass: 'iradio_minimal-red'

            })

            //Flat red color scheme for iCheck

            $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({

                checkboxClass: 'icheckbox_flat-green',

                radioClass: 'iradio_flat-green'

            })

            $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({

                checkboxClass: 'icheckbox_flat-green',

                radioClass: 'iradio_flat-yellow'

            })



            //Colorpicker

            $('.my-colorpicker1').colorpicker()

            //color picker with addon

            $('.my-colorpicker2').colorpicker()



            //Timepicker

            $('.timepicker').timepicker({

                showInputs: false

            })

        })

    </script>

</body>



</html>