<?php 
    include 'inc_classes.php'; 
    include "admin_authentication.php";
    include "include/headHeader.php";
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Dashboard</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">
    <!-- Morris chart -->
    <link rel="stylesheet" href="bower_components/morris.js/morris.css">
    <!-- Morris charts -->
    <link rel="stylesheet" href="../../bower_components/morris.js/morris.css">
    <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:// -->
    <!-- Google Font -->
    <link rel="stylesheet"
        href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
    <style>
        /* span {
            margin-left: 20%;
            text-align: center;
        } */

        .form-control {
            margin-left: 20px;
        }
    </style>
</head>
<?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"; ?>
        <?php include "include/menu_left.php"; ?>
        <div class="content-wrapper">
            <section class="content-header">
                <h1>
                    Dashboard
                </h1>
                <ol class="breadcrumb">
                    <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                    <li class="active">Dashboard</li>
                </ol>
            </section>
            <!-- ================= boxes starts================ -->
            <!-- ================= boxes end================ -->
            <!-- main body code start -->
            <section class="content">
                <?php include "include/tk_header_box.php"; ?>
                <div class="row">
                    <div class="col-md-9">
                        <!-- Custom Tabs -->
                        <div class="nav-tabs-custom">
                            <ul class="nav nav-tabs">
                                <li class="dropdown active">
                                    <a class="dropdown-toggle" data-toggle="dropdown" href="#"> Task List <span class="caret"></span></a>
                                    <ul class="dropdown-menu">
                                        <li class="active"><a href="#tab_4" data-toggle="tab">Upcoming Task</a></li>
                                        <li><a href="#tab_11" data-toggle="tab">Canceled Task</a></li>
                                        <li><a href="#tab_12" data-toggle="tab">Halt Task</a></li>
                                        <li><a href="#tab_13" data-toggle="tab">In-Complete Task</a></li>
                                        <li><a href="#tab_6" data-toggle="tab">Completed Today's Task</a></li>
                                        <li><a href="#tab_15" data-toggle="tab">Invalid Task</a></li>
                                    </ul>
                                </li>
                                <li><a href="#tab_7" data-toggle="tab">Assigned By Me</a></li>
                                
                                <?php if($_SESSION['type'] == 'S' || $edit_access == 'yes' || $manager_access == 'manager'): ?>
                                    <li><a href="#tab_8" data-toggle="tab">Staff Assigned Task</a></li>
                                    <li><a href="#tab_14" data-toggle="tab">Staff Completed Task</a></li>
                                <?php endif; ?>
                                
                                <li><a href="#tab_9" data-toggle="tab">Validation Pending</a></li>
                                <li><a href="#tab_16" data-toggle="tab">In-Complete Task</a></li>
                                
                                <li>
                                <a href="tk_add_individual_task.php" title="Add Task" style="display: inline-block; padding: 5px 10px; 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 Task</a>

                                    <!-- <a href="tk_task_exel.php?staff_id=<?php echo $_SESSION['admin_id']; ?>&start_date=<?php echo date('Y-m-d') ?>" title="Export Timesheet" style="display: inline-block; padding: 6px 10px; background-color: #28a745; color: white; border-radius: 5px; text-align: center; text-decoration: none;font-weight: bold;">Download Today's Timesheet
                                        <img src="images/excel.png" height="25px" width="25px" alt="Export Timesheet" 
                                            style="margin-left:2px; vertical-align: middle;" />
                                    </a> -->
                                </li>

                            </ul>

                            <div class="tab-content">
                                <!-- =================================================== Personal Task ================================== -->
                                <!-- ==================================Personal upcoming Task============================================ -->
                                <div class="tab-pane active" id="tab_4">
                                    <div class="box-header with-border">
                                    <?php
                                        $dats=date("Y-m-d");
                                        $my_upc_task="select * from tk_individual_task where 1 and staff_id='".$_SESSION['admin_id']."'and (status !='complete'and status !='halt' and status !='cancel')  and Validation='valid' and task_type='adhoc_task' and DATE(added_date)<='".$dats."' and DATE(added_date)>='2023-06-24' order by staff_task_id ASC";  
                                        $ptr_upc_task=mysql_query($my_upc_task);
                                        $no_of_records=mysql_num_rows($ptr_upc_task);
                                        ?>
                                        <h3 style="color:blue" class="box-title"><strong> Upcoming Task Name </strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_records; ?> new upcoming task" class="badge bg-teal"><?php echo $no_of_records ?></span></h3>
                                        <div class="direct-chat-messages" style="height:400px">
                                            <div class="box-body">
                                                <div class="table-responsive">
                                                    <?php
                                                    if($no_of_records)
                                                    {
                                                        ?>
                                                        <table class="table no-margin">
                                                            <thead>
                                                                <tr>
                                                                    <th>Task Name</th>
                                                                    <th>Assinged BY</th>
                                                                    <th>Created Date</th>
                                                                    <th>Dead Line</th>
                                                                    <th>Status</th>
                                                                    <th>Details</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php 
                                                                $bgColorCounter=1;
                                                                while($my_task=mysql_fetch_array($ptr_upc_task))
                                                                {
                                                                    if($my_task['staff_status']=='complete')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(172,225,175);"';
                                                                    }
                                                                    elseif($my_task['staff_status']=='in_progress')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(252,255,164);"';
                                                                    }
                                                                    elseif($bgColorCounter%2==0)
                                                                    {
                                                                        $bg_color='style="background-color:rgb(244,240,236)"';
                                                                    }
                                                                    else
                                                                    {
                                                                        $bg_color='';
                                                                    }
                                                                    $dat_d = date("Y-m-d");
                                                                    $Date12= strtotime($dat_d);
                                                                    $task_d = $my_task['due_date'];
                                                                    $due_Dates =strtotime( $task_d);
                                                                    if($due_Dates >= $Date12 && $my_task['status']!='in_complete')
                                                                    {
                                                                        ?>
                                                                        <tr <?php echo $bg_color; ?>>
                                                                            <td> 
                                                                                <b>
                                                                                    <?php echo ucwords($my_task['task_name']);?>
                                                                                </b><br>
                                                                                <?php
                                                                                    $hours=$my_task['hours'];
                                                                                    $time1= convertToHoursMins($hours, '%02d hour %02d min');
                                                                                    echo $time1.'<br>';
                                                                                    echo 'Points- '.$my_task['points'].'<br>';
                                                                                    echo 'Priority- '.ucfirst($my_task['priority']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$my_task['assign_by']."'";
                                                                                $ptr_data_staff_c=mysql_query($staff_name_c);
                                                                                $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                                                echo ucfirst($fetch_staff_name_c['name']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $add_task_Date = date("d-m-Y H:i", strtotime($my_task['added_date']));
                                                                                echo $add_task_Date ;
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $due_d_Date = date("d-m-Y", strtotime($my_task['due_date']));
                                                                                echo $due_d_Date ;
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                    echo ucfirst($my_task['status']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <strong>
                                                                                    <a href="tk_individual_task_detail.php?id=<?= $my_task['staff_task_id'] ?>" value=""> Details </a>
                                                                                </strong>
                                                                            </td>
                                                                        </tr>
                                                                        <?php
                                                                    }
                                                                    elseif($due_Dates < $Date12 || $my_task['status']=='in_complete')
                                                                    {
                                                                        $text_color='style="text-color:red"'
                                                                        ?>
                                                                        <tr <?php echo $bg_color; ?>>
                                                                            <td style="color:red;">
                                                                                <b>
                                                                                    <?php echo ucwords($my_task['task_name']);?>
                                                                                </b><br>
                                                                                <?php
                                                                                $hours=$my_task['hours'];
                                                                                $time1= convertToHoursMins($hours, '%02d hour %02d min');
                                                                                echo $time1.'<br>';
                                                                                echo 'Points- '.$my_task['points'].'<br>';
                                                                                echo 'Priority- '.ucfirst($my_task['priority']);
                                                                                ?>
                                                                            </td>
                                                                            <td style="color:red;">
                                                                                <?php
                                                                                $staff_name1="select name from site_setting where 1 and admin_id='".$my_task['assign_by']."'";
                                                                                $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="color:red;">
                                                                                <?php
                                                                                $add_task_Date = date("d-m-Y H:i", strtotime($my_task['added_date']));
                                                                                echo $add_task_Date ;
                                                                            ?>
                                                                            </td>
                                                                            <td style="color:red;">
                                                                                <?php
                                                                                $dats=date("d-m-Y");
                                                                                $dds= strtotime($dats);
                                                                                $task_dats = $my_task['due_date'];
                                                                                $last_Dates1 =strtotime( $task_dats);
                                                                                $task_d_Dates = date("d-m-Y", strtotime($my_task['due_date']));
                                                                                if($last_Dates1 < $dds)
                                                                                {
                                                                                    ?>
                                                                                    <p style="color:red;"><?php echo $task_d_Dates ;?></p>
                                                                                    <?php
                                                                                }
                                                                                else
                                                                                {
                                                                                    ?>
                                                                                    <p style="color:blue;">
                                                                                        <?php
                                                                                        echo $task_d_Dates ;
                                                                                        ?>
                                                                                    </p>
                                                                                    <?php
                                                                                } 
                                                                                ?>
                                                                            </td>
                                                                            <td style="color:red;">
                                                                                <?php
                                                                                echo ucfirst($my_task['status']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <strong>
                                                                                    <a
                                                                                        href="tk_individual_task_detail.php?id=<?= $my_task['staff_task_id'] ?>"
                                                                                        value=""> Details </a>
                                                                                </strong>
                                                                            </td>
                                                                        </tr>
                                                                        <?php
                                                                    }
                                                                    $bgColorCounter++;

                                                                }
                                                                ?>
                                                            </tbody>
                                                        </table>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?>
                                                        <div>
                                                            <h4 style="background-color:;text-align:center"> No Record
                                                                Avialable According To Your Creteria</h4>
                                                        </div>
                                                        <?php
                                                    }
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- ======================================In- Completed Task ================================== -->
                                <div class="tab-pane" id="tab_16">
                                    <div class="box-header with-border">
                                    <?php
                                        $dats=date("Y-m-d");
                                        if($_SESSION['type']=='S' || $edit_access=='yes')
                                        {
                                            $my_inc_task="select * from tk_individual_task where 1 and status ='in_complete' and Validation='valid' and task_type='adhoc_task' order by staff_task_id ASC";
                                        }
                                        else if($manager_access=='manager')
                                        {
                                            $my_inc_task="select * from tk_individual_task where 1 and status ='in_complete' and Validation='valid' and (".$string.") and task_type='adhoc_task' order by staff_task_id ASC";
                                        }
                                        else{
                                            $my_inc_task="select * from tk_individual_task where 1 and staff_id='".$_SESSION['admin_id']."' and status ='in_complete' and Validation='valid' and task_type='adhoc_task' order by staff_task_id ASC"; 
                                        } 
                                        $ptr_inc_task=mysql_query($my_inc_task);
                                        $no_of_inc_records=mysql_num_rows($ptr_inc_task);
                                        ?>
                                        <h3 style="color:blue" class="box-title"><strong> In-Complete Task </strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_inc_records; ?> In-Complete Task " class="badge bg-red"><?php echo $no_of_inc_records ?></span></h3>
                                        <div class="direct-chat-messages" style="height:400px">
                                            <div class="box-body">
                                                <div class="table-responsive">
                                                    <?php
                                                    if($no_of_inc_records)
                                                    {
                                                        ?>
                                                        <table class="table no-margin">
                                                            <thead>
                                                                <tr>
                                                                    <th>Task Name</th>
                                                                    <th>Assinged To</th>
                                                                    <th>Assinged BY</th>
                                                                    <th>Created Date</th>
                                                                    <th>Dead Line</th>
                                                                    <th>Status</th>
                                                                    <th>Details</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php 
                                                                $bgColorCounter=1;
                                                                while($my_inc_task=mysql_fetch_array($ptr_inc_task))
                                                                {
                                                                    if($my_inc_task['staff_status']=='complete')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(172,225,175);"';
                                                                    }
                                                                    elseif($my_inc_task['staff_status']=='in_progress')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(252,255,164);"';
                                                                    }
                                                                    elseif($bgColorCounter%2==0)
                                                                    {
                                                                        $bg_color='style="background-color:rgb(244,240,236)"';
                                                                    }
                                                                    else
                                                                    {
                                                                        $bg_color='';
                                                                    }
                                                                    $dat_d = date("Y-m-d");
                                                                    $Date12= strtotime($dat_d);
                                                                    $task_d = $my_inc_task['due_date'];
                                                                    $due_Dates =strtotime( $task_d);
                                                                    // elseif($due_Dates < $Date12 || $my_task['status']=='in_complete')
                                                                    // {
                                                                        $text_color='style="text-color:red"'
                                                                        ?>
                                                                        <tr <?php echo $bg_color; ?>>
                                                                            <td style="color:red;">
                                                                                <b>
                                                                                    <?php echo ucwords($my_inc_task['task_name']);?>
                                                                                </b><br>
                                                                                <?php
                                                                                $hours=$my_inc_task['hours'];
                                                                                $time1= convertToHoursMins($hours, '%02d hour %02d min');
                                                                                echo $time1.'<br>';
                                                                                echo 'Points- '.$my_inc_task['points'].'<br>';
                                                                                echo 'Priority- '.ucfirst($my_inc_task['priority']);
                                                                                ?>
                                                                            </td>
                                                                            <td style="color:red;">
                                                                                <?php
                                                                                $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$my_inc_task['staff_id']."'";
                                                                                $ptr_data_staff_c=mysql_query($staff_name_c);
                                                                                $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                                                echo ucfirst($fetch_staff_name_c['name']);
                                                                                ?>
                                                                            </td>
                                                                            <td style="color:red;">
                                                                                <?php
                                                                                $staff_name1="select name from site_setting where 1 and admin_id='".$my_inc_task['assign_by']."'";
                                                                                $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="color:red;">
                                                                                <?php
                                                                                $add_task_Date = date("d-m-Y H:i", strtotime($my_inc_task['added_date']));
                                                                                echo $add_task_Date ;
                                                                            ?>
                                                                            </td>
                                                                            <td style="color:red;">
                                                                                <?php
                                                                                $dats=date("d-m-Y");
                                                                                $dds= strtotime($dats);
                                                                                $task_dats = $my_inc_task['due_date'];
                                                                                $last_Dates1 =strtotime( $task_dats);
                                                                                $task_d_Dates = date("d-m-Y", strtotime($my_inc_task['due_date']));
                                                                                if($last_Dates1 < $dds)
                                                                                {
                                                                                    ?>
                                                                                    <p style="color:red;"><?php echo $task_d_Dates ;?></p>
                                                                                    <?php
                                                                                }
                                                                                else
                                                                                {
                                                                                    ?>
                                                                                    <p style="color:blue;">
                                                                                        <?php
                                                                                        echo $task_d_Dates ;
                                                                                        ?>
                                                                                    </p>
                                                                                    <?php
                                                                                } 
                                                                                ?>
                                                                            </td>
                                                                            <td style="color:red;">
                                                                                <?php
                                                                                echo ucfirst($my_inc_task['status']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <strong>
                                                                                    <a
                                                                                        href="tk_individual_task_detail.php?id=<?= $my_inc_task['staff_task_id'] ?>"
                                                                                        value=""> Details </a>
                                                                                </strong>
                                                                            </td>
                                                                        </tr>
                                                                        <?php
                                                                    // }
                                                                    $bgColorCounter++;

                                                                }
                                                                ?>
                                                            </tbody>
                                                        </table>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?>
                                                        <div>
                                                            <h4 style="background-color:;text-align:center"> No Record
                                                                Avialable According To Your Creteria</h4>
                                                        </div>
                                                        <?php
                                                    }
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- ================================ Personal Cancle Task ===================================== -->
                                <div class="tab-pane" id="tab_11">
                                    <div class="box-header with-border">
                                        <?php
                                        $Date12 = date("Y-m-d");
                                        $my_cancle_task1="select * from tk_individual_task where 1 and assign_by='".$_SESSION['admin_id']."'and status ='cancel' and Validation='valid' and task_type='adhoc_task' order by added_date DESC";
                                        $ptr_cancle_task1=mysql_query($my_cancle_task1);
                                        $no_of_cancle_records=mysql_num_rows($ptr_cancle_task1);
                                        ?>
                                        <h3 style="color:blue" class="box-title"><strong> Cancel Task Name </strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_cancle_records; ?> Cancel task" class="badge bg-purple"><?php echo $no_of_cancle_records ?></span></h3>
                                        <div class="direct-chat-messages"  style="height:400px">
                                            <div class="box-body">
                                                <div class="table-responsive">
                                                    <?php
                                                    if($no_of_cancle_records)
                                                    {
                                                        ?>
                                                        <table class="table no-margin">
                                                            <thead>
                                                                <tr>
                                                                    <th>Task Name</th>
                                                                    <?php
                                                                    if($_SESSION['type']=='S' || $edit_access=='yes')
                                                                    {
                                                                        ?>
                                                                        <th>Assinged To</th>
                                                                        <th>Assinged By</th>
                                                                        <?php
                                                                    }
                                                                    ?>
                                                                    <th>Created Date</th>
                                                                    <th>Dead Line</th>
                                                                    <th>Details</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php 
                                                                $bgColorCounter=1;
                                                                while($my_cancle_task=mysql_fetch_array($ptr_cancle_task1))
                                                                {
                                                                    if($my_cancle_task['staff_status']=='complete')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(172,225,175);"';
                                                                    }
                                                                    elseif($my_cancle_task['staff_status']=='in_progress')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(252,255,164);"';
                                                                    }
                                                                    elseif($bgColorCounter%2==0)
                                                                    {
                                                                        $bg_color='style="background-color:rgb(244,240,236)"';
                                                                    }
                                                                    else
                                                                    {
                                                                    $bg_color='';
                                                                    }
                                                                    ?>
                                                                    <tr <?php echo $bg_color; ?>>
                                                                        <td>
                                                                            <?php echo ucwords($my_cancle_task['task_name']);?>
                                                                        </td>
                                                                        <?php
                                                                        if($_SESSION['type']=='S' || $edit_access=='yes')
                                                                        {
                                                                            ?>
                                                                            <td>
                                                                                <?php
                                                                                $staff_names1="select name,photo from site_setting where 1 and admin_id='".$my_cancle_task['staff_id']."'";
                                                                                $ptr_staff=mysql_query($staff_names1);
                                                                                $fetch_staff_names1=mysql_fetch_array($ptr_staff);
                                                                                echo ucfirst($fetch_staff_names1['name']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $admin_name1="select name,photo from site_setting where 1 and admin_id='".$my_cancle_task['assign_by']."'";
                                                                                $ptr_admin_name1=mysql_query($admin_name1);
                                                                                $fetch_admin_name1=mysql_fetch_array($ptr_admin_name1);
                                                                                echo ucfirst($fetch_admin_name1['name']);
                                                                                ?>
                                                                            </td>
                                                                            <?php
                                                                        }
                                                                        ?>
                                                                        <td>
                                                                            <?php
                                                                                $add_task_Date = date("d-m-Y H:i", strtotime($my_cancle_task['added_date']));
                                                                                echo $add_task_Date ;
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                                $due_d_Date = date("d-m-Y", strtotime($my_cancle_task['due_date']));
                                                                                echo $due_d_Date ;
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <strong>
                                                                                <a href="tk_individual_task_detail.php?id=<?= $my_cancle_task['staff_task_id'] ?>"
                                                                                    value="">Details</a>
                                                                            </strong>
                                                                        </td>
                                                                    </tr>
                                                                    <?php
                                                                    $bgColorCounter++;
                                                                }
                                                                ?>
                                                            </tbody>
                                                        </table>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?>
                                                        <div>
                                                            <h4 style="background-color:;text-align:center"> No Record
                                                                Avialable According To Your Creteria</h4>
                                                        </div>
                                                        <?php
                                                    }
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- ================================ Personal Halt Task ===================================== -->
                                <div class="tab-pane" id="tab_12">
                                    <div class="box-header with-border">
                                        <?php
                                        $Date12 = date("Y-m-d");
                                        $my_halt_task3="select * from tk_individual_task where 1 and staff_id='".$_SESSION['admin_id']."'and status ='halt' and Validation='valid' and task_type='adhoc_task' order by added_date DESC";
                                        $ptr_halt_task=mysql_query($my_halt_task3);
                                        $no_of_halt_records=mysql_num_rows($ptr_halt_task);
                                        ?>
                                        <h3 style="color:blue" class="box-title"><strong> Halt Task Name </strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_halt_records; ?> Halt task" class="badge bg-gray"><?php echo $no_of_halt_records ?></span></h3>
                                        <div class="direct-chat-messages" style="height:400px">
                                            <div class="box-body">
                                                <div class="table-responsive">
                                                    <?php
                                                    if($no_of_halt_records)
                                                    {
                                                        ?>
                                                        <table class="table no-margin">
                                                            <thead>
                                                                <tr>
                                                                    <th>Task Name</th>
                                                                    <?php
                                                                    if($_SESSION['type']=='S' || $edit_access=='yes')
                                                                    {
                                                                        ?>
                                                                        <th>Assinged To</th>
                                                                        <th>Assinged By</th>
                                                                        <?php
                                                                    }
                                                                    ?>
                                                                    <th>Created Date</th>
                                                                    <th>Dead Line</th>
                                                                    <th>Details</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php 
                                                                $bgColorCounter=1;
                                                                while($my_halt_task=mysql_fetch_array($ptr_halt_task))
                                                                {
                                                                    if($my_halt_task['staff_status']=='complete')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(172,225,175);"';
                                                                    }
                                                                    elseif($my_halt_task['staff_status']=='in_progress')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(252,255,164);"';
                                                                    }
                                                                    elseif($bgColorCounter%2==0)
                                                                    {
                                                                        $bg_color='style="background-color:rgb(244,240,236)"';
                                                                    }
                                                                    else
                                                                    {
                                                                        $bg_color='';
                                                                    }
                                                                    ?>
                                                                    <tr <?php echo $bg_color; ?>>
                                                                        <td>
                                                                            <?php echo ucwords($my_halt_task['task_name']);?>
                                                                        </td>
                                                                        <?php
                                                                        if($_SESSION['type']=='S' || $edit_access=='yes')
                                                                        {
                                                                            ?>
                                                                            <td>
                                                                                <?php
                                                                                $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$my_halt_task['staff_id']."'";
                                                                                $ptr_data_staff_c=mysql_query($staff_name_c);
                                                                                $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                                                echo ucfirst($fetch_staff_name_c['name']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                            <?php
                                                                            $admin_name="select name,photo from site_setting where 1 and admin_id='".$my_halt_task['assign_by']."'";
                                                                            $ptr_admin_name=mysql_query($admin_name);
                                                                            $fetch_admin_name=mysql_fetch_array($ptr_admin_name);
                                                                            echo ucfirst($fetch_admin_name['name']);
                                                                            ?>
                                                                            </td>
                                                                            <?php
                                                                        }
                                                                        ?>
                                                                        <td>
                                                                            <?php
                                                                            $add_task_Date = date("d-m-Y H:i", strtotime($my_halt_task['added_date']));
                                                                            echo $add_task_Date ;
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $dat1=date("d-m-Y");
                                                                            $dd1= strtotime($dat1);
                                                                            $task_dat = $my_halt_task['due_date'];
                                                                            $last_Dates =strtotime( $task_dat);
                                                                            $task_d_Date1 = date("d-m-Y", strtotime($my_halt_task['due_date']));
                                                                            if($last_Dates < $dd1)
                                                                            {
                                                                                ?>
                                                                                <p style="color:red;">
                                                                                    <?php echo $task_d_Date1 ;?>
                                                                                </p>
                                                                                <?php
                                                                            } 
                                                                            else
                                                                            {
                                                                                ?>
                                                                                <p style="color:blue;">
                                                                                <?php echo $task_d_Date1 ;?>
                                                                                </p>        
                                                                                <?php
                                                                            } 
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <strong>
                                                                                <a href="tk_individual_task_detail.php?id=<?= $my_halt_task['staff_task_id'] ?>"
                                                                                    value="">Details</a>
                                                                            </strong>
                                                                        </td>
                                                                    </tr>
                                                                    <?php
                                                                    $bgColorCounter++;
                                                                }
                                                                ?>
                                                            </tbody>
                                                        </table>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?>
                                                        <div>
                                                            <h4 style="background-color:;text-align:center"> No Record
                                                                Avialable According To Your Creteria</h4>
                                                        </div>
                                                        <?php
                                                    }
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- ================================= Personal In-complete Task ====================================== -->
                                <div class="tab-pane" id="tab_13">
                                    <div class="box-header with-border">
                                        <?php
                                            $Date12 = date("Y-m-d");
                                            $my_incmplt_task3="select * from tk_individual_task where 1 and staff_id='".$_SESSION['admin_id']."'and status ='in_complete' and Validation='valid' and task_type='adhoc_task' order by added_date DESC";
                                            $ptr_incmplt_task=mysql_query($my_incmplt_task3);
                                            $no_of_incmplt_records=mysql_num_rows($ptr_incmplt_task);
                                            ?>
                                        <h3 style="color:blue" class="box-title"><strong>In-Complete Task</strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_incmplt_records; ?> In-complete Task" class="badge bg-red"><?php echo $no_of_incmplt_records ?></span></h3>
                                        <div class="direct-chat-messages" style="height:400px">
                                            <div class="box-body">
                                                <div class="table-responsive">
                                                    <?php
                                                    if($no_of_incmplt_records)
                                                    {
                                                        ?>
                                                        <table class="table no-margin">
                                                            <thead>
                                                                <tr>
                                                                    <th>Task Name</th>
                                                                    <?php
                                                                    if($_SESSION['type']=='S' || $edit_access=='yes')
                                                                    {
                                                                        ?>
                                                                        <th>Assinged To</th>
                                                                        <th>Assinged By</th>
                                                                        <?php
                                                                    }
                                                                    ?>
                                                                    <th>Created Date</th>
                                                                    <th>Dead Line</th>
                                                                    <th>Details</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php 
                                                                $bgColorCounter=1;
                                                                while($data_incmplt=mysql_fetch_array($ptr_incmplt_task))
                                                                {
                                                                    if($data_incmplt['staff_status']=='complete')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(172,225,175);"';
                                                                    }
                                                                    elseif($data_incmplt['staff_status']=='in_progress')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(252,255,164);"';
                                                                    }
                                                                    elseif($bgColorCounter%2==0)
                                                                    {
                                                                        $bg_color='style="background-color:rgb(244,240,236)"';
                                                                    }
                                                                    else
                                                                    {
                                                                        $bg_color='';
                                                                    }
                                                                    ?>
                                                                    <tr <?php echo $bg_color; ?>>
                                                                        <td>
                                                                            <?php echo ucwords($data_incmplt['task_name']);?>
                                                                        </td>
                                                                        <?php
                                                                        if($_SESSION['type']=='S' || $edit_access=='yes')
                                                                        {
                                                                            ?>
                                                                            <td>
                                                                                <?php
                                                                                $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$data_incmplt['staff_id']."'";
                                                                                $ptr_data_staff_c=mysql_query($staff_name_c);
                                                                                $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                                                echo ucfirst($fetch_staff_name_c['name']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $staff="select name,photo from site_setting where 1 and admin_id='".$data_incmplt['assign_by']."'";
                                                                                $ptr_staff_c=mysql_query($staff);
                                                                                $fetch_staff=mysql_fetch_array($ptr_staff_c);
                                                                                echo ucfirst($fetch_staff['name']);
                                                                                ?>
                                                                            </td>
                                                                            <?php
                                                                        }
                                                                        ?>
                                                                        <td>
                                                                            <?php
                                                                            $add_task_Date = date("d-m-Y H:i", strtotime($data_incmplt['added_date']));
                                                                            echo $add_task_Date ;
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $dat1=date("d-m-Y");
                                                                            $dd1= strtotime($dat1);
                                                                            $task_dat = $data_incmplt['due_date'];
                                                                            $last_Dates =strtotime( $task_dat);
                                                                            $task_d_Date1 = date("d-m-Y", strtotime($data_incmplt['due_date']));
                                                                            if($last_Dates < $dd1)
                                                                            {
                                                                                ?>
                                                                                <p style="color:red;">
                                                                                    <?php echo $task_d_Date1 ;?>
                                                                                </p>
                                                                                <?php
                                                                            }
                                                                            else
                                                                            {
                                                                                ?>
                                                                                <p style="color:blue;">
                                                                                    <?php
                                                                                    echo $task_d_Date1 ;
                                                                                    ?>
                                                                                </p>
                                                                                <?php
                                                                            } 
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <strong>
                                                                                <a href="tk_individual_task_detail.php?id=<?= $data_incmplt['staff_task_id'] ?>"
                                                                                    value="">Details</a>
                                                                            </strong>
                                                                        </td>
                                                                    </tr>
                                                                    <?php
                                                                    $bgColorCounter++;
                                                                }
                                                                ?>
                                                            </tbody>
                                                        </table>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?>
                                                        <div>
                                                            <h4 style="background-color:;text-align:center"> No Record
                                                                Avialable According To Your Creteria</h4>
                                                        </div>
                                                        <?php
                                                    }
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- =========================================personal completed task ============================================== -->
                                <div class="tab-pane" id="tab_6">
                                    <div class="box-header with-border">
                                        <?php
                                        $my_cmp_task="select * from tk_individual_task where 1 and staff_id='".$_SESSION['admin_id']."'and status ='complete' and Validation='valid' and task_type='adhoc_task' and DATE(sta_complete_date)='".date("Y-m-d")."' order by added_date DESC"; 
                                        $ptr_cmp_task=mysql_query($my_cmp_task);
                                        $no_of_records_c=mysql_num_rows($ptr_cmp_task);
                                        ?>
                                        <h3 style="color:blue" class="box-title"><strong>Todays Complete Task</strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_records_c; ?> Complete Task" class="badge bg-green"><?php echo $no_of_records_c ?></span></h3>
                                        <div class="direct-chat-messages" style="height:400px">
                                            <div class="box-body">
                                                <div class="table-responsive">
                                                    <?php
                                                    if($no_of_records_c)
                                                    {
                                                        ?>
                                                        <table class="table no-margin">
                                                            <thead>
                                                                <tr>
                                                                    <th>Task Name</th>
                                                                    <?php
                                                                    if($_SESSION['type']=='S' || $edit_access=='yes')
                                                                    {
                                                                        ?>
                                                                        <th>Assinged To</th>
                                                                        <?php
                                                                    }
                                                                    ?>
                                                                    <th>Created Date</th>
                                                                    <th colspan="2">Completed Date</th>
                                                                    <th>Details</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php 
                                                                while($complete_task=mysql_fetch_array($ptr_cmp_task))
                                                                {
                                                                    ?>
                                                                    <tr>
                                                                        <td>
                                                                            <?php echo ucwords($complete_task['task_name']);?>
                                                                        </td>
                                                                        <?php
                                                                        if($_SESSION['type']=='S' || $edit_access=='yes')
                                                                        {
                                                                            ?>
                                                                            <td>
                                                                                <?php
                                                                                $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$complete_task['staff_id']."'";
                                                                                $ptr_data_staff_c=mysql_query($staff_name_c);
                                                                                $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                                                echo ucfirst($fetch_staff_name_c['name']);
                                                                                ?>
                                                                            </td>
                                                                            <?php
                                                                        }
                                                                        ?>
                                                                        <td>
                                                                            <?php
                                                                            $add_task_Date = date("d-m-Y H:i", strtotime($complete_task['added_date']));
                                                                            echo $add_task_Date ;
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $due_Date=$complete_task['due_date'];
                                                                            $complete_Date=$complete_task['sta_complete_date'];
                                                                            $due_Date12 = date("Y-m-d",strtotime($due_Date));
                                                                            $complete_Date12 =date("Y-m-d",strtotime( $complete_Date));
                                                                            $complete_d = date("d-m-Y", strtotime($complete_task['sta_complete_date']));
                                                                            echo $complete_d;
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            if($complete_Date12 > $due_Date12)
                                                                            {
                                                                                ?>
                                                                                <p class="label label-danger"
                                                                                    style="margin-left:1px;">
                                                                                    <?php echo 'Over Due';?>
                                                                                </p>
                                                                                <?php
                                                                            }
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <strong>
                                                                                <a href="tk_individual_task_detail.php?id=<?= $complete_task['staff_task_id'] ?>"
                                                                                    value="">Details</a>
                                                                            </strong>
                                                                        </td>
                                                                    </tr>
                                                                    <?php
                                                                }
                                                                ?>
                                                            </tbody>
                                                        </table>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?>
                                                        <div>
                                                            <h4 style="background-color:;text-align:center"> No Record
                                                                Avialable According To Your Creteria</h4>
                                                        </div>
                                                        <?php
                                                    }
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!--====================================================== Assign by me task ================================================ -->
                                <div class="tab-pane" id="tab_7">
                                    <div class="box-header with-border">
                                        <?php
                                        $Date12 = date("Y-m-d");
                                        $my_assignme_task="select * from tk_individual_task where 1 and assign_by='".$_SESSION['admin_id']."'and (status !='complete' and status !='halt' and status !='cancel' and status !='in_complete') and Validation='valid' and task_type='adhoc_task' order by added_date DESC";       
                                        $ptr_assign_me_task=mysql_query($my_assignme_task);
                                        $no_of_assignme_records=mysql_num_rows($ptr_assign_me_task);
                                        ?>
                                        <h3 style="color:blue" class="box-title"><strong> Assinged By Me </strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_assignme_records; ?> Assign by me task" class="badge bg-blue"><?php echo $no_of_assignme_records ?></span></h3>
                                        <div class="direct-chat-messages" style="height:400px">
                                            <div class="box-body">
                                                <div class="table-responsive">
                                                    <?php
                                                    if($no_of_assignme_records)
                                                    {
                                                        ?>
                                                        <table class="table no-margin">
                                                            <thead>
                                                                <tr>
                                                                    <th>Task Name</th>
                                                                    <th>Assinged To</th>
                                                                    <th>Created Date</th>
                                                                    <th>Dead Line</th>
                                                                    <th>Details</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php
                                                                $bgColorCounter=1;
                                                                while($data_assign_me_task=mysql_fetch_array($ptr_assign_me_task))
                                                                {
                                                                    if($data_assign_me_task['staff_status']=='complete')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(172,225,175);"';
                                                                    }
                                                                    elseif($data_assign_me_task['staff_status']=='in_progress')
                                                                    {
                                                                        $bg_color='style="background-color:rgb(252,255,164);"';
                                                                    }
                                                                    elseif($bgColorCounter%2==0)
                                                                    {
                                                                        $bg_color='style="background-color:rgb(244,240,236)"';
                                                                    }
                                                                    else
                                                                    {
                                                                        $bg_color='';
                                                                    }
                                                                    ?>
                                                                    <tr <?php echo $bg_color; ?>>
                                                                        <td>
                                                                            <b>
                                                                                <?php echo ucwords($data_assign_me_task['task_name']);?>
                                                                            </b><br>
                                                                            <?php
                                                                            $hours=$data_assign_me_task['hours'];
                                                                            $time1= convertToHoursMins($hours, '%02d hour %02d min');
                                                                            echo $time1.'<br>';
                                                                            echo 'Points- '.$data_assign_me_task['points'].'<br>';
                                                                            echo 'Priority- '.ucfirst($data_assign_me_task['priority']);
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$data_assign_me_task['staff_id']."'";
                                                                            $ptr_data_staff_c=mysql_query($staff_name_c);
                                                                            $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                                            echo ucfirst($fetch_staff_name_c['name']);
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $add_task_Date = date("d-m-Y H:i", strtotime($data_assign_me_task['added_date']));
                                                                            echo $add_task_Date ;
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $date=date("d-m-Y");
                                                                            $due_date1=$data_assign_me_task['due_date'];
                                                                            $date1=strtotime($date);
                                                                            $due_date=strtotime($due_date1);
                                                                            $due_d_Date = date("d-m-Y", strtotime($data_assign_me_task['due_date']));
                                                                            if($date1 > $due_date)
                                                                            {
                                                                                ?>
                                                                                <p style="color:red;">
                                                                                    <?php
                                                                                    echo $due_d_Date ;
                                                                                    ?>
                                                                                </p>
                                                                                <?php
                                                                            }
                                                                            else
                                                                            {
                                                                                ?>
                                                                                <p style="color:blue;">
                                                                                    <?php
                                                                                    echo $due_d_Date ;
                                                                                    ?>
                                                                                </p>
                                                                                <?php
                                                                            }
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <strong>
                                                                                <a href="tk_individual_task_detail.php?id=<?= $data_assign_me_task['staff_task_id'] ?>"
                                                                                    value="">Details</a>
                                                                            </strong>
                                                                        </td>
                                                                    </tr>
                                                                    <?php
                                                                    $bgColorCounter++;
                                                                }
                                                                ?>
                                                            </tbody>
                                                        </table>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?>
                                                        <div>
                                                            <h4 style="background-color:;text-align:center"> No Record
                                                                Avialable According To Your Creteria</h4>
                                                        </div>
                                                        <?php
                                                    }
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!--===================================STAFF Assigned Task============================================-->
                                <?php
                                if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
                                {
                                    ?>
                                    <div class="tab-pane" id="tab_8">
                                        <div class="box-header with-border">
                                            <?php
                                            if($_SESSION['type']=='S' || $edit_access=='yes')
                                            {
                                                $my_staff_assign_task="select * from tk_individual_task where 1 and assign_by!='".$_SESSION['admin_id']."' and (status !='complete' and status !='halt' and status !='cancel' and status !='in_complete') and Validation='valid' and task_type='adhoc_task' order by added_date DESC";
                                            }
                                            else if($manager_access=='manager')
                                            {
                                                $my_staff_assign_task="select * from tk_individual_task where 1 and assign_by!='".$_SESSION['admin_id']."' and (status !='complete' and status !='halt' and status !='cancel' and status !='in_complete')and (".$string.") and Validation='valid' and task_type='adhoc_task' order by added_date DESC";
                                            }
                                            $ptr_assign_task=mysql_query($my_staff_assign_task);
                                            $no_of_assign_records=mysql_num_rows($ptr_assign_task);
                                            ?>
                                            <h3 style="color:blue" class="box-title"><strong> Staff Assigned Task</strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_assign_records; ?> Staff Assigned Task" class="badge bg-orange"><?php echo $no_of_assign_records ?></span></h3>
                                            <div class="direct-chat-messages" style="height:400px">
                                                <div class="box-body">
                                                    <div class="table-responsive">
                                                        <?php
                                                        if($no_of_assign_records)
                                                        {
                                                            ?>
                                                            <table class="table no-margin">
                                                                <thead>
                                                                    <tr>
                                                                        <th>Task Name</th>
                                                                        <th>Assinged To</th>
                                                                        <th>Assinged By</th>
                                                                        <th>Created Date</th>
                                                                        <th>Dead Line</th>
                                                                        <th>Details</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody>
                                                                    <?php
                                                                    $bgColorCounter=1;
                                                                    while($assign_task=mysql_fetch_array($ptr_assign_task))
                                                                    {
                                                                        if($assign_task['staff_status']=='complete')
                                                                        {
                                                                            $bg_color='style="background-color:rgb(172,225,175);"';
                                                                        }
                                                                        elseif($assign_task['staff_status']=='in_progress')
                                                                        {
                                                                            $bg_color='style="background-color:rgb(252,255,164);"';
                                                                        }
                                                                        elseif($bgColorCounter%2==0)
                                                                        {
                                                                            $bg_color='style="background-color:rgb(244,240,236)"';
                                                                        }
                                                                        else
                                                                        {
                                                                            $bg_color='';
                                                                        }
                                                                        ?>
                                                                        <tr <?php echo $bg_color; ?>>
                                                                            <td> 
                                                                                <b>
                                                                                    <?php echo ucwords($assign_task['task_name']);?>
                                                                                </b><br>
                                                                                <?php
                                                                                $hours=$assign_task['hours'];
                                                                                $time1= convertToHoursMins($hours, '%02d hour %02d min');
                                                                                echo $time1.'<br>';
                                                                                echo 'Points- '.$assign_task['points'].'<br>';
                                                                                echo 'Priority- '.ucfirst($assign_task['priority']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$assign_task['staff_id']."'";
                                                                                $ptr_data_staff_c=mysql_query($staff_name_c);
                                                                                $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                                                echo ucfirst($fetch_staff_name_c['name']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $staff_names="select name,photo from site_setting where 1 and admin_id='".$assign_task['assign_by']."'";
                                                                                $ptr_staff_names=mysql_query($staff_names);
                                                                                $fetch_staff_names=mysql_fetch_array($ptr_staff_names);
                                                                                echo ucfirst($fetch_staff_names['name']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                    $add_task_Date = date("d-m-Y H:i", strtotime($assign_task['added_date']));
                                                                                    echo $add_task_Date ;
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $date=date("d-m-Y");
                                                                                $due_date1=$assign_task['due_date'];
                                                                                $date1=strtotime($date);
                                                                                $due_date=strtotime($due_date1);
                                                                                $due_d_Date = date("d-m-Y", strtotime($assign_task['due_date']));
                                                                                if($date1 > $due_date)
                                                                                {
                                                                                    ?>
                                                                                    <p style="color:red;">
                                                                                        <?php
                                                                                        echo $due_d_Date ;
                                                                                        ?>
                                                                                    </p>
                                                                                    <?php
                                                                                }
                                                                                else
                                                                                {
                                                                                    ?>
                                                                                    <p style="color:blue;">
                                                                                        <?php
                                                                                        echo $due_d_Date ;
                                                                                        ?>
                                                                                    </p>
                                                                                    <?php
                                                                                }
                                                                                ?><br>
                                                                            </td>
                                                                            <td>
                                                                                <strong>
                                                                                <a href="tk_individual_task_detail.php?id=<?= $assign_task['staff_task_id'] ?>"
                                                                                value="">Details</a></strong>
                                                                            </td>
                                                                        </tr>
                                                                        <?php
                                                                        $bgColorCounter++;
                                                                    }
                                                                    ?>
                                                                </tbody>
                                                            </table>
                                                            <?php
                                                        }
                                                        else
                                                        {
                                                            ?>
                                                            <div>
                                                                <h4 style="background-color:;text-align:center"> No Record
                                                                    Avialable According To Your Creteria</h4>
                                                            </div>
                                                            <?php
                                                        }
                                                        ?>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <?php
                                }
				                ?>
                                <!-- ===================================================== Staff Side Complete Task ===================================== -->
                                <?php
                                if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
                                {
						            ?>
                                    <div class="tab-pane" id="tab_14">
                                        <div class="box-header with-border">
                                            <?php
                                            if($_SESSION['type']=='S' || $edit_access=='yes')
                                            {

                                                $staff_cmplt_task="select * from tk_individual_task where 1 and (status !='complete' and status !='halt' and status !='cancel' ) and Validation='valid' and task_type='adhoc_task' and staff_status='complete' and added_date > '2023-06-24' order by staff_complete_date ASC";

                                            }
                                            else if($manager_access=='manager')
                                            {
                                                $staff_cmplt_task="select * from tk_individual_task where 1 and (status !='complete' and status !='halt' and status !='cancel' ) and (".$string." ) and Validation='valid' and task_type='adhoc_task' and staff_status='complete' and added_date > '2023-06-24' order by staff_complete_date ASC";
                                            }
                                            $ptr_staff_cmplt_task=mysql_query($staff_cmplt_task);
                                            $no_of_cpmlt_records=mysql_num_rows($ptr_staff_cmplt_task);
                                            ?>
                                            <h3 style="color:blue" class="box-title"><strong> Staff Assigned Completed Task</strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_cpmlt_records; ?> Staff Completed Task" class="badge bg-green"><?php echo $no_of_cpmlt_records ?></span></h3>
                                            <div class="direct-chat-messages" style="height:400px">
                                                <div class="box-body">
                                                    <div class="table-responsive">
                                                        <?php
                                                        if($no_of_cpmlt_records)
                                                        {
                                                            ?>
                                                            <table class="table no-margin">
                                                                <thead>
                                                                    <tr>
                                                                        <th>Task Name</th>
                                                                        <th>Assinged To</th>
                                                                        <th>Assinged By</th>
                                                                        <th>Staff Complete Date</th>
                                                                        <th>Created Date</th>
                                                                        <th>Dead Line</th>
                                                                        <th>Details</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody>
                                                                    <?php
                                                                    $bgColorCounter=1;
                                                                    while($data_staff_task=mysql_fetch_array($ptr_staff_cmplt_task))
                                                                    {
                                                                        if($data_staff_task['staff_status']=='complete')
                                                                        {
                                                                            $bg_color='style="background-color:rgb(172,225,175);"';
                                                                        }
                                                                        elseif($data_staff_task['staff_status']=='in_progress')
                                                                        {
                                                                            $bg_color='style="background-color:rgb(252,255,164);"';
                                                                        }
                                                                        elseif($bgColorCounter%2==0)
                                                                        {
                                                                            $bg_color='style="background-color:rgb(244,240,236)"';
                                                                        }
                                                                        else
                                                                        {
                                                                            $bg_color='';
                                                                        }
                                                                        ?>
                                                                        <tr <?php echo $bg_color; ?>>
                                                                            <td> 
                                                                                <b>
                                                                                    <?php echo ucwords($data_staff_task['task_name']);?>
                                                                                </b><br>
                                                                                <?php
                                                                                $hours=$data_staff_task['hours'];
                                                                                $time1= convertToHoursMins($hours, '%02d hour %02d min');
                                                                                echo $time1.'<br>';
                                                                                echo 'Points- '.$data_staff_task['points'].'<br>';
                                                                                echo 'Priority- '.ucfirst($data_staff_task['priority']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$data_staff_task['staff_id']."'";
                                                                                $ptr_data_staff_c=mysql_query($staff_name_c);
                                                                                $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                                                echo ucfirst($fetch_staff_name_c['name']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $staff_names="select name,photo from site_setting where 1 and admin_id='".$data_staff_task['assign_by']."'";
                                                                                $ptr_staff_names=mysql_query($staff_names);
                                                                                $fetch_staff_names=mysql_fetch_array($ptr_staff_names);
                                                                                echo ucfirst($fetch_staff_names['name']);
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $staff_complete_date = date("d-m-Y H:i", strtotime($data_staff_task['staff_complete_date']));
                                                                                echo $staff_complete_date ;
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $add_task_Date = date("d-m-Y H:i", strtotime($data_staff_task['added_date']));
                                                                                echo $add_task_Date ;
                                                                                ?>
                                                                            </td>
                                                                            <td>
                                                                                <?php
                                                                                $date=date("d-m-Y");
                                                                                $due_date1=$data_staff_task['due_date'];
                                                                                $date1=strtotime($date);
                                                                                $due_date=strtotime($due_date1);
                                                                                $due_d_Date = date("d-m-Y", strtotime($data_staff_task['due_date']));
                                                                                if($date1 > $due_date)
                                                                                {
                                                                                    ?>
                                                                                    <p style="color:red;">
                                                                                        <?php
                                                                                        echo $due_d_Date ;
                                                                                        ?>
                                                                                    </p>
                                                                                    <?php
                                                                                }
                                                                                else
                                                                                {
                                                                                    ?>
                                                                                    <p style="color:blue;">
                                                                                        <?php
                                                                                        echo $due_d_Date ;
                                                                                        ?>
                                                                                    </p>
                                                                                    <?php
                                                                                }
                                                                                ?><br>
                                                                            </td>
                                                                            <td>
                                                                                <strong>
                                                                                    <a href="tk_individual_task_detail.php?id=<?= $data_staff_task['staff_task_id'] ?>"
                                                                                        value="">Details</a>
                                                                                </strong>
                                                                            </td>
                                                                        </tr>
                                                                        <?php
                                                                        $bgColorCounter++;
                                                                    }
                                                                    ?>
                                                                </tbody>
                                                            </table>
                                                            <?php
                                                        }
                                                        else
                                                        {
                                                            ?>
                                                            <div>
                                                                <h4 style="background-color:;text-align:center"> No Record
                                                                    Avialable According To Your Creteria</h4>
                                                            </div>
                                                            <?php
                                                        }
                                                        ?>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <?php
                                }
				                ?>
                                <!-- =========================================Validation Pending Task task ============================================== -->
                                <?php                       
                                if(isset($_REQUEST['submit_valiadtion']))
                                {
                                    $task_ids=$_POST['task_id1'];
                                    $validation=$_POST['validation'];
                                    $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);
                                    }
                                    if($validation!='')
                                    {
                                        $update_status="update tk_individual_task set `Validation`='".$validation."',`validation_admin`='".$_SESSION['admin_id']."'where staff_task_id='".$task_ids."'";
                                        $ptr_update=mysql_query($update_status);
                                    }
                                    if($ptr_update)
                                    {
                                        ?>
                                            <script>setTimeout('document.location.href="tk_dashboard.php"', 200);</script>
                                        <?php
                                    }
                                }
                                ?>
                                <div class="tab-pane" id="tab_9">
                                    <div class="box-header with-border">
                                    <?php
                                        if($_SESSION['type']=='S' || $edit_access=='yes')
                                        { 
                                            $pending_task1="select * from tk_individual_task where 1 and Validation='pending' and task_type='adhoc_task' and status='in_progress' order by added_date DESC";
                                        }
                                        else if($manager_access=='manager')
                                        {
                                            $pending_task1="select * from tk_individual_task where 1 and (".$string.") and Validation='pending' and task_type='adhoc_task' and status='in_progress' order by added_date DESC";
                                        }
                                        else
                                        {
                                            $pending_task1="select * from tk_individual_task where 1 and staff_id='".$_SESSION['admin_id']."'and Validation='pending' and task_type='adhoc_task' and status='in_progress' order by added_date DESC";
                                        }
                                        $ptr_pending_task=mysql_query($pending_task1);
                                        $no_of_records1=mysql_num_rows($ptr_pending_task);
                                        ?>
                                        <h3 style="color:blue" class="box-title"><strong>Validation Pending Task</strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_records1; ?> Validation Pending Task" class="badge bg-red"><?php echo $no_of_records1 ?></span></h3>&nbsp;&nbsp;&nbsp;&nbsp;
                                        <div class="direct-chat-messages" style="height:400px">
                                            <div class="box-body">
                                                <div class="table-responsive">
                                                    <?php
                                                    if($no_of_records1)
                                                    {
                                                        ?>
                                                        <table class="table no-margin">
                                                            <thead>
                                                                <tr>
                                                                    <th>Task Name</th>
                                                                    <?php
                                                                    if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
														            {
                                                                        ?>
                                                                        <th>Assinged To</th>
                                                                        <?php  
                                                                    }
                                                                    ?>
                                                                    <th>Assinged BY</th>
                                                                    <th>Created Date</th>
                                                                    <th>Dead Line</th>
                                                                    <th>Validation</th>
                                                                    <?php
                                                                    if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
                                                                    {
                                                                        ?>
                                                                        <th>Details</th>
                                                                        <?php  
                                                                    }
                                                                    ?>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php
                                                                $bgColorCounter=1;
                                                                while($data_valid=mysql_fetch_array($ptr_pending_task))
                                                                {
                                                                    if($bgColorCounter%2==0)
                                                                    {
                                                                        $bg_color='style="background-color:rgb(244,240,236)"';
                                                                    }
                                                                    else
                                                                    {
                                                                        $bg_color='';
                                                                    }
                                                                    ?>
                                                                    <tr <?php echo $bg_color;?>>
                                                                        <td>
                                                                            <?php echo ucfirst($data_valid['task_name']);  ?>
                                                                        </td>
                                                                        <?php
                                                                        if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
                                                                        {
                                                                            ?>
                                                                            <td>
                                                                                <?php
                                                                                $staff_name_v="select name,photo from site_setting where 1 and admin_id='".$data_valid['staff_id']."'";
                                                                                $ptr_data_staff_v=mysql_query($staff_name_v);
                                                                                $fetch_staff_name_v=mysql_fetch_array($ptr_data_staff_v);
                                                                                echo ucfirst($fetch_staff_name_v['name']);
                                                                                ?>
                                                                            </td>
                                                                            <?php  
                                                                        }
                                                                        ?>
                                                                        <td>
                                                                            <?php
                                                                            $staff_name_v1="select name,photo from site_setting where 1 and admin_id='".$data_valid['assign_by']."'";
                                                                            $ptr_data_staff_v1=mysql_query($staff_name_v1);
                                                                            $fetch_staff_name_v1=mysql_fetch_array($ptr_data_staff_v1);
                                                                            echo ucfirst($fetch_staff_name_v1['name']);
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $add_task_Date = date("d-m-Y H:i", strtotime($data_valid['added_date']));
                                                                            echo $add_task_Date ;
                                                                            ?>
                                                                        </td>
                                                                        <?php
                                                                        $date0=date("d-m-Y");
                                                                        $due_date1=$data_valid['due_date'];
                                                                        $date1=strtotime($date0);
                                                                        $due_date=strtotime($due_date1);
                                                                        $due_d_Date = date("d-m-Y", strtotime($data_valid['due_date']));
                                                                        if($date1 > $due_date)
                                                                        {
																            ?>
                                                                            <td style="color:red;">
                                                                                <?php
																                echo $due_d_Date ;
                                                                                ?>
                                                                            </td>
                                                                            <?php
															            }
															            else
															            {
                                                                            ?>
                                                                            <td style="color:blue;">
                                                                                <?php
																                echo $due_d_Date ;
																                ?>
                                                                            </td>
                                                                            <?php
															            }
                                                                        ?>
                                                                        <td>
                                                                            <?php 
                                                                            echo '<div style="color:red;">'.ucwords($data_valid['Validation']).'</div>';
                                                                            ?>
                                                                        </td>
                                                                        <?php
                                                                        if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
                                                                        {
                                                                            ?>
                                                                            <td>
                                                                                <strong>
                                                                                    <a href="tk_individual_task_detail.php?id=<?= $data_valid['staff_task_id'] ?>"
                                                                                    value="">Details</a>
                                                                                </strong>&nbsp;&nbsp;&nbsp;&nbsp;
                                                                                <a href="tk_add_individual_task.php?id=<?=$data_valid['staff_task_id']?>"><i
                                                                                class="fa fa-edit"></i></a>
                                                                            </td>
                                                                            <?php 
                                                                        }
                                                                        ?>
                                                                    </tr>
                                                                    <?php
                                                                    $bgColorCounter++;
                                                                }
                                                                ?>
                                                            </tbody>
                                                        </table>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?>
                                                        <div>
                                                            <h4 style="background-color:;text-align:center"> No Record
                                                                Avialable According To Your Creteria</h4>
                                                        </div>
                                                        <?php
                                                    }
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- ==================================In Valid Task ===================================== -->
                                <div class="tab-pane" id="tab_15">
                                    <div class="box-header with-border">
                                        <?php
                                        $dat=date("Y-m-d");
                                        $upto_date=date("Y-m-d",strtotime('-50day'));
                                        if($_SESSION['type']=='S' || $edit_access=='yes')
                                        {
                                            $my_upc_tasks="select * from tk_individual_task where 1  and  Validation='in_valid' and task_type='adhoc_task' and DATE(date)>'".$upto_date."'  order by added_date DESC";
                                        }
                                        else if($manager_access=='manager')
                                        {
                                            $my_upc_tasks="select * from tk_individual_task where 1  and  Validation='in_valid' and task_type='adhoc_task' and (".$string." ) and DATE(date)>'".$upto_date."'  order by added_date DESC";
                                        }
                                        else{
                                            $my_upc_tasks="select * from tk_individual_task where 1  and  Validation='in_valid' and task_type='adhoc_task' and assign_by='".$_SESSION['admin_id']."' and DATE(date)>'".$upto_date."'  order by added_date DESC";
                                        }
                                        $ptr_upc_tasks=mysql_query($my_upc_tasks);
                                        $no_of_records12=mysql_num_rows($ptr_upc_tasks);
                                        ?>
                                        <h3 style="color:blue" class="box-title"><strong>Invalid Task</strong>&nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_records12; ?> Invalid Task" class="badge bg-red"><?php echo $no_of_records12 ?></span></h3>
                                        <?php if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager'){ ?>
                                        <div class="direct-chat-messages" style="height:400px">
                                            <?php } ?>
                                            <div class="box-body">
                                                <div class="table-responsive">
                                                    <?php
                                                    if($no_of_records12)
                                                    {
                                                        ?>
                                                        <table class="table no-margin">
                                                            <thead>
                                                                <tr>
                                                                    <th>Task Name</th>
                                                                    <th>Assinged To</th>
                                                                    <th>Assinged By</th>
                                                                    <th>Created Date</th>
                                                                    <th>Dead Line</th>
                                                                    <th>Validation</th>
                                                                    <?php 
                                                                    if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
                                                                    { 
                                                                        ?>
                                                                        <th>Details</th>
                                                                        <?php
                                                                    }
                                                                    else
                                                                    {
                                                                        ?>
                                                                        <th>Invalid Reason</th>
                                                                        <?php
                                                                    } ?>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php
                                                                $bgColorCounter=1;
                                                                while($invalid_task=mysql_fetch_array($ptr_upc_tasks))
                                                                {
                                                                    if($bgColorCounter%2==0)
                                                                    {
                                                                        $bg_color='style="background-color:rgb(244,240,236)"';
                                                                    }
                                                                    else
                                                                    {
                                                                        $bg_color='';
                                                                    }
                                                                    ?>
                                                                    <tr <?php echo $bg_color;?>>
                                                                        <td> 
                                                                            <b>
                                                                                <?php echo ucwords($invalid_task['task_name']);?>
                                                                            </b><br>
                                                                            <?php
                                                                            $hours=$invalid_task['hours'];
                                                                            $time1= convertToHoursMins($hours, '%02d hour %02d min');
                                                                            echo $time1.'<br>';
                                                                            echo 'Points- '.$invalid_task['points'].'<br>';
                                                                            echo 'Priority- '.ucfirst($invalid_task['priority']);
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$invalid_task['staff_id']."'";
                                                                            $ptr_data_staff_c=mysql_query($staff_name_c);
                                                                            $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                                            echo ucfirst($fetch_staff_name_c['name']);
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $staff_names="select name,photo from site_setting where 1 and admin_id='".$invalid_task['assign_by']."'";
                                                                            $ptr_staff_names=mysql_query($staff_names);
                                                                            $fetch_staff_names=mysql_fetch_array($ptr_staff_names);
                                                                            echo ucfirst($fetch_staff_names['name']);
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $add_task_Date = date("d-m-Y H:i", strtotime($invalid_task['added_date']));
                                                                            echo $add_task_Date ;
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $date=date("d-m-Y");
                                                                            $due_date1=$invalid_task['due_date'];
                                                                            $date1=strtotime($date);
                                                                            $due_date=strtotime($due_date1);
                                                                            $due_d_Date = date("d-m-Y", strtotime($invalid_task['due_date']));
                                                                            if($date1 > $due_date)
                                                                            {
                                                                                ?>
                                                                                <p style="color:red;">
                                                                                    <?php
                                                                                    echo $due_d_Date ;
                                                                                    ?>
                                                                                </p>
                                                                                <?php
                                                                            }
                                                                            else
                                                                            {
                                                                                ?>
                                                                                <p style="color:blue;">
                                                                                    <?php
                                                                                    echo $due_d_Date ;
                                                                                    ?>
                                                                                </p>
                                                                                <?php
                                                                            }
                                                                            ?><br>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            $sel_valid_name="select name from site_setting where admin_id='".$invalid_task['validation_admin']."'";
                                                                            $pt_name=mysql_query($sel_valid_name);
                                                                            $data_validation=mysql_fetch_array($pt_name);
                                                                            echo '<strong>'.ucwords($invalid_task['Validation']).'</strong> By '.Ucwords($data_validation['name']); ;
                                                                            ?>
                                                                        </td>
                                                                        <td>
                                                                            <?php
                                                                            if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager')
                                                                            {
                                                                                ?>
                                                                                <strong>
                                                                                    <a href="tk_individual_task_detail.php?id=<?= $invalid_task['staff_task_id'] ?>"
                                                                                        value="">Details</a>
                                                                                </strong>
                                                                                <?php
                                                                            }
                                                                            else
                                                                            {
                                                                                ?>
                                                                                <!-- <button type="button" class="btn btn-warning" data-toggle="modal"
                                                                                    data-target="#<?php echo $invalid_task['staff_task_id'];?>">
                                                                                    Reasons
                                                                                </button> -->
                                                                                
                                                                                <label><?php echo ucwords($invalid_task['Validation']);?></label><br>
                                                                                <?php
                                                                                $sel_reason="select reasons,admin_id from tk_task_validation where staff_task_id='".$invalid_task['staff_task_id']."'";
                                                                                $ptr_reason=mysql_query($sel_reason);
                                                                                $no_records=mysql_num_rows($ptr_reason);
                                                                                if($no_records)
                                                                                {
                                                                                    ?>
                                                                                <span>Reasons </span><br>
                                                                                <?php
                                                                                    while($data_reason=mysql_fetch_array($ptr_reason))
                                                                                    {
                                                                                        $add="select name from site_setting where 1 and admin_id='".$data_reason['admin_id']."'";
                                                                                        $ptr=mysql_query($add);
                                                                                        $data2=mysql_fetch_array($ptr);
                                                                                        if($data_reason['reasons']!='')
                                                                                        {
                                                                                            // echo '<div><b>'.ucfirst($data2['name']).'</b></div>';
                                                                                            echo '<li>'.ucwords($data_reason['reasons']).'</li>';
                                                                                        }
                                                                                    }
                                                                                }
                                                                                else{
                                                                                    echo '<span style="color:green;text-align:center">No Invalid Reason</span>';
                                                                                }
                                                                            }
                                                                            ?>
                                                                            <div class="modal fade" id="<?php echo $invalid_task['staff_task_id'];?>">
                                                                                <div class="modal-dialog" style="width:300px;">
                                                                                    <div class="modal-content">
                                                                                        <div class="modal-header">
                                                                                            <h4 class="modal-title">
                                                                                                <span style="color:blue">
                                                                                                    Task Invalid Reasons
                                                                                                </span>
                                                                                            </h4>
                                                                                        </div>
                                                                                        <div class="modal-body">
                                                                                            <div class="box box-warning">
                                                                                                <?php
                                                                                                // $sel_reason="select reasons,admin_id from tk_task_validation where staff_task_id='".$invalid_task['staff_task_id']."'";
                                                                                                // $ptr_reason=mysql_query($sel_reason);
                                                                                                // $no_records=mysql_num_rows($ptr_reason);
                                                                                                // if($no_records)
                                                                                                // {
                                                                                                //     ?>
                                                                                                <!-- // <label>Reasons </label><br> -->
                                                                                                 <?php
                                                                                                //     while($data_reason=mysql_fetch_array($ptr_reason))
                                                                                                //     {
                                                                                                //         $add="select name from site_setting where 1 and admin_id='".$data_reason['admin_id']."'";
                                                                                                //         $ptr=mysql_query($add);
                                                                                                //         $data2=mysql_fetch_array($ptr);
                                                                                                //         if($data_reason['reasons']!='')
                                                                                                //         {
                                                                                                //             echo '<div><b>'.ucfirst($data2['name']).'</b></div>';
                                                                                                //             echo '<li>'.ucwords($data_reason['reasons']).'</li>';
                                                                                                //         }
                                                                                                //     }
                                                                                                // }
                                                                                                // else{
                                                                                                //     echo '<span style="color:green;text-align:center">No Invalid Reason</span>';
                                                                                                // }
                                                                                            ?>
                                                                                            </div>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                    <?php
                                                                    $bgColorCounter++;
                                                                }
                                                                ?>
                                                            </tbody>
                                                        </table>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?>
                                                        <div>
                                                            <h4 style="background-color:;text-align:center"> No Record
                                                                Avialable According To Your Creteria</h4>
                                                        </div>
                                                        <?php
                                                    }
                                                    ?>
                                                </div>
                                            </div>
                                        <?php 
                                        if($_SESSION['type']=='S' || $edit_access=='yes' || $manager_access=='manager'){
                                        ?>
                                        </div>
                                        <?php
                                        }
                                        ?>
                                    </div>
                                </div>
                                <!--=================END Staff Assigned Task==================-->
                            </div>
                            <!-- /.tab-content -->
                        </div>
                        <!-- nav-tabs-custom -->
                    </div>
                    <!-- end of task code -->
                    <!--=============================== ===================== To Do List start ===================== =====================================-->
                    <div class="col-md-3">
                        <div class="box box-primary">
                            <div class="box-header">
                                <i class="ion ion-clipboard"></i>
                                <h3 class="box-title">To Do List</h3>
                            </div>
                            <div class="box-body">
                                <div class="row">
                                    <div class="col-sm-12">
                                        <form name="task_form" method="post">
                                            <div class="form-group">
                                                <input type="text" name="task_name" class="form-control" style="width:250px;" required placeholder="Task Name" />
                                            </div>
                                            <div class="form-group">
                                                <input type="text" name="due_date" id="datepicker" class="form-control" style="width:250px;"  placeholder="Due Date" required />
                                            </div>
                                            <div class="form-group">
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" name="submit" value="Submit" class="btn btn-success" style="width: 90%;">Submit</button>
                                            </div>
                                        </form>
                                        <div class="direct-chat-messages" style="margin-top: 20px;height:290px">
                                        <h4><b>Work List</b></h4><hr>
                                            <ul class="todo-list">
                                                <?php
                                                if (isset($_POST['submit'])) {
                                                    $task_name = addslashes($_POST['task_name']);
                                                    $due_date = $_POST['due_date'];
                                                    $new_date = explode("/", $due_date);
                                                    $due_date_format = $new_date[2] . '-' . $new_date[1] . '-' . $new_date[0];  // Correcting the date format
                                                    $admin_id = $_SESSION['admin_id'];
                                                    
                                                    if ($task_name != "") {
                                                        $insert_task = "INSERT INTO tk_personal_task(`task_name`,`due_date`,`status`,`cm_id`,`admin_id`,`added_date`) 
                                                                        VALUES('" . $task_name . "','" . $due_date_format . "','added','" . $_SESSION['cm_id'] . "','" . $admin_id . "','" . date('Y-m-d H:i:s') . "')";
                                                        $ptr_ins_t = mysql_query($insert_task);
                                                        
                                                        if ($ptr_ins_t) {
                                                            echo "<script type='text/javascript'>
                                                                    setTimeout(function() {
                                                                        window.location.href = 'tk_dashboard.php';
                                                                    }, 100);
                                                                  </script>";
                                                        }
                                                    }
                                                }
                                            
                                                if (isset($_POST['status_change'])) {
                                                    $task_id = $_POST['task_id'];
                                                    $upd_status = "UPDATE tk_personal_task SET `status`='complete' WHERE tpt_id='" . $task_id . "'";
                                                    $ptr_upd_status = mysql_query($upd_status);
                                                    if($ptr_upd_status){
                                                        echo "<script type='text/javascript'>
                                                                    setTimeout(function() {
                                                                        window.location.href = 'tk_dashboard.php';
                                                                    }, 100);
                                                            </script>";
                                                    }
                                                }

                                                $sel_task = "SELECT tpt_id, task_name, due_date, status FROM tk_personal_task 
                                                            WHERE admin_id='" . $_SESSION['admin_id'] . "' AND status !='complete' ORDER BY due_date ASC";
                                                $ptr_sel_task = mysql_query($sel_task);
                                                $i = 1;
                                                while ($data = mysql_fetch_array($ptr_sel_task)) {
                                                    ?>
                                                    <div class="col-md-12">
                                                        <ul class="list-unstyled" style="margin-top: 10px;">
                                                            <li class="d-flex justify-content-between align-items-center mb-3">
                                                                
                                                                <!-- Task Name -->
                                                                <div class="mr-3">
                                                                    <b><?php echo ucwords($data['task_name']); ?></b>
                                                                </div>

                                                                <!-- Due Date -->
                                                                <div class="mr-3">
                                                                    <?php
                                                                    $current_date = date("d-m-Y");
                                                                    $dueDate = $data['due_date'];
                                                                    $new_current_date = strtotime($current_date);
                                                                    $new_dueDate = strtotime($dueDate);
                                                                    $due_Date = date("d-m-Y", strtotime($data['due_date']));

                                                                    if ($new_current_date > $new_dueDate) {
                                                                        echo '<span style="color: red;">' . $due_Date . '</span>';
                                                                    } else {
                                                                        echo '<span style="color: #FFD700;">' . $due_Date . '</span>';
                                                                    }
                                                                    ?>
                                                                </div>

                                                                <!-- Mark Complete Button -->
                                                                <div>
                                                                    <form name="personal_task_form" method="post">
                                                                        <input type="hidden" name="task_id" value="<?php echo $data['tpt_id']; ?>">
                                                                        <button type="submit" name="status_change" class="btn btn-success btn-xs">
                                                                            <i class="fa fa-check"></i> Mark Complete
                                                                        </button>
                                                                    </form>
                                                                </div>
                                                            </li>
                                                        </ul>
                                                    </div><hr>
                                                    <?php
                                                }
                                                ?>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- ==================================SYSTEM TASK START ========================================== -->
                <!-- <div class="row"> -->
                    <?php
                    if($_SESSION['type']=='S' || $edit_access=='yes')
                    {
                        $my_system_task="select * from tk_individual_task where 1 and task_type='system' and (status !='complete' and status !='halt' and status !='cancel') and Validation='valid' and DATE(added_date)>'2023-06-30' order by added_date DESC"; 
                    }
                    else if($manager_access=='manager')
                    {
                        $my_system_task="select * from tk_individual_task where 1 and task_type='system' and (status !='complete' and status !='halt' and status !='cancel') and Validation='valid' and (".$string.") and DATE(added_date)>'2023-06-30' order by added_date DESC"; 
                    }
                    else{
                        $where_assign=" and staff_id='".$_SESSION['admin_id']."'";	
                        $my_system_task="select * from tk_individual_task where 1 and task_type='system' and (status !='complete' and status !='halt' and status !='cancel') and Validation='valid' ".$where_assign." and DATE(added_date)>'2023-06-30' order by added_date DESC"; 
                    }
                $ptr_system_task=mysql_query($my_system_task);
                $no_of_sys_records=mysql_num_rows($ptr_system_task);
                if($no_of_sys_records)
                {
                    ?>
                    <div class="box box-info">
                        <div class="box-header with-border">
                            <h3 class="box-title"> Systems Tasks &nbsp;<span data-toggle="tooltip" title="<?php echo $no_of_sys_records; ?> New System  Task Pending" class="badge bg-red"><?php echo $no_of_sys_records; ?></span></h3>
                        </div>
                        <div class="box-body">
                            <div class="direct-chat-messages">
                                <div class="table-responsive">
                                    <table class="table no-margin" width="100%">
                                        <thead>
                                            <tr>
                                                <th width="20%">Task Name</th>
                                                <th width="35">Task Description</th>
                                                <th width="12%">Assinged To</th>
                                                <th width="8%">Created Date</th>
                                                <th width="8%"><span>Dead Line</span></th>
                                                <th width="8%">Details</th>
                                                <th width="8%">Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            $bgColorCounter=1;
                                            while($data_system_task=mysql_fetch_array($ptr_system_task))
                                            {
                                                if($bgColorCounter%2==0){
                                                    $bgcolor='style="background-color:rgb(244,240,236)"';
                                                }
                                                else
                                                {
                                                    $bgcolor="";    
                                                }  
                                                ?>
                                                <tr <?php echo $bgcolor;?>>
                                                    <td>
                                                        <?php echo ucwords($data_system_task['task_name']);?>
                                                    </td>
                                                    <td>
                                                        <?php echo ucwords($data_system_task['description']);?>
                                                    </td>
                                                    <td>
                                                        <?php
                                                        $staff_name_c="select name,photo from site_setting where 1 and admin_id='".$data_system_task['staff_id']."'";
                                                        $ptr_data_staff_c=mysql_query($staff_name_c);
                                                        $fetch_staff_name_c=mysql_fetch_array($ptr_data_staff_c);
                                                        echo ucfirst($fetch_staff_name_c['name']);
                                                        ?>
                                                    </td>
                                                    <td>
                                                        <?php
                                                            $add_task_Date=date("d-m-Y H:i", strtotime($data_system_task['added_date']));
                                                            echo $add_task_Date ;
                                                        ?>
                                                    </td>
                                                    <td>
                                                        <?php
                                                        $date=date("d-m-Y");
                                                        $due_date1=$data_system_task['due_date'];
                                                        $date1=strtotime($date);
                                                        $due_date=strtotime($due_date1);
                                                        $due_d_Date = date("d-m-Y", strtotime($data_system_task['due_date']));
                                                        if($date1 > $due_date)
                                                        {
                                                            ?>
                                                            <span style="color:red;">
                                                                <?php
                                                                    echo $due_d_Date ;
                                                                    ?>
                                                            </span>
                                                            <?php
                                                        }
                                                        else
                                                        {
                                                            ?>
                                                            <span style="color:blue;">
                                                                <?php
                                                                echo $due_d_Date ;
                                                                ?>
                                                            </span>
                                                            <?php
                                                        }
                                                        ?>
                                                    </td>
                                                    <td>
                                                        <strong>
                                                            <a target="_blank" href="tk_individual_task_detail.php?id=<?= $data_system_task['staff_task_id'] ?>"
                                                                value="">Details</a>
                                                        </strong>
                                                    </td>
                                                    <td>
                                                        <strong>
                                                            <a target="_blank" href="https://www.isasbeautyschool.org/faculty_login/<?php echo $data_system_task['url']; ?>"
                                                                value="">Action</a>
                                                        </strong>
                                                    </td>
                                                </tr>
                                                <?php
                                                $bgColorCounter++;
                                            }
                                            ?>
                                        </tbody>
                                    </table>
                                </div> 
                            </div>
                        </div>
                    </div>
                    <?php
                }
                else
                {
                    ?>
                    <!-- <div>
                        <h4 style="background-color:;text-align:center">No Record Avialable According To Your Creteria</h4>
                    </div> -->
                    <?php
                }
                ?>
            </section>
        </div>
        <?php include "include/footer-main.php"; ?>
    </div>
    <script src="bower_components/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap 3.3.7 -->
    <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- Select2 -->
    <script src="bower_components/select2/dist/js/select2.full.min.js"></script>
    <!-- InputMask -->
    <script src="plugins/input-mask/jquery.inputmask.js"></script>
    <script src="plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
    <script src="plugins/input-mask/jquery.inputmask.extensions.js"></script>
    <!-- date-range-picker -->
    <script src="bower_components/moment/min/moment.min.js"></script>
    <script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
    <!-- bootstrap datepicker -->
    <script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
    <!-- bootstrap color picker -->
    <script src="bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
    <!-- bootstrap time picker -->
    <script src="plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <!-- SlimScroll -->
    <script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
    <!-- iCheck 1.0.1 -->
    <script src="plugins/iCheck/icheck.min.js"></script>
    <!-- FastClick -->
    <script src="bower_components/fastclick/lib/fastclick.js"></script>
    <!-- AdminLTE App -->
    <script src="dist/js/adminlte.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="dist/js/demo.js"></script>
    <!-- Morris.js charts -->
    <script src="../../bower_components/raphael/raphael.min.js"></script>
    <!-- <script src="../../bower_components/morris.js/morris.min.js"></script> -->
    <!-- date-range-picker -->
    <script src="bower_components/moment/min/moment.min.js"></script>
    <script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
    <!-- bootstrap datepicker -->
    <script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
    <!-- bootstrap color picker -->
    <script src="bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
    <!-- bootstrap time picker -->
    <script src="plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <!-- Page script -->
    <script>
        $(function () {
            //Initialize Select2 Elements
            $('.select2').select2()
            //Date picker
            $('#datepicker').datepicker({
                autoclose: true,
                format: 'dd/mm/yyyy',
                startDate: '-0d',
                Default: true,
                todayHighlight: true
            })
            $('#datepicker1').datepicker({
                autoclose: true,
                format: 'dd/mm/yyyy',
                Default: true,
                todayHighlight: true
            })
            //iCheck for checkbox and radio inputs
            $('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'
            })
            //Colorpicker
            $('.my-colorpicker1').colorpicker()
            //color picker with addon
            $('.my-colorpicker2').colorpicker()
            //Timepicker
            $('.timepicker').timepicker({
                showInputs: false
            })
        })
    </script>
</body>
</html>