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

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>my Task</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
    <!-- daterange picker -->
    <link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">
    <!-- bootstrap datepicker -->
    <link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
    <!-- iCheck for checkboxes and radio inputs -->
    <link rel="stylesheet" href="plugins/iCheck/all.css">
    <!-- Bootstrap Color Picker -->
    <link rel="stylesheet" href="bower_components/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css">
    <!-- Bootstrap time Picker -->
    <link rel="stylesheet" href="plugins/timepicker/bootstrap-timepicker.min.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="bower_components/select2/dist/css/select2.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- paginate style -->
    <link rel="stylesheet" href="dist/css/paginate.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
    <!-- Google Font -->
    <link rel="stylesheet"
        href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<style>
    th {
        text-align: center;
    }
</style>
<?php include "include/ps_pagination.php"; ?>
<body class="hold-transition skin-blue sidebar-mini">
    <div class="wrapper">
        <?php include "include/header-main.php"; ?>
        <!-- Left side column. contains the logo and sidebar -->
        <?php include "include/menu_left.php"; ?>
        <!-- Content Wrapper. Contains page content -->
        <!-- Left side column. contains the logo and sidebar -->
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    My Task
                </h1>
                <ol class="breadcrumb">
                    <li style="background-color: lightblue;">
                    <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                    <li class="active">Dashboard</li>
                </ol>
            </section>
            <section class="content">
                <div class="row">
                    <div class="col-md-12">
                        <div class="box box-info">
                            <div class="table-responsive">
                                <table class="table no-margin" >
                                    <form method="get" name="search">
                                        <tr>
                                            <td>
                                                <select class="form-control select2" style="width:200px" id="staff_names"
                                                    name="staff_names">
                                                    <option value="">Assinged By</option>
                                                    <?php
                                                        $categary="select admin_id,name from site_setting  where cm_id='".$_SESSION['cm_id']."' and system_status='Enabled' order by name ASC";  
                                                        $c_query=mysql_query($categary);
                                                        while($data_c=mysql_fetch_array($c_query))
                                                        {
                                                            $sel='';
                                                            if($data_c['admin_id']==$_GET['staff_names'])
                                                            {
                                                                $sel='selected="selected"';
                                                            }
                                                            echo  '<option '.$sel.' value="'.$data_c['admin_id'].'">'.ucfirst($data_c['name']). '</option>';
                                                        }
                                                    ?>
                                                </select>
                                            </td>
                                            <td width="10px"></td>
                                            <td>
                                                <select class="form-control select2" style="width:200px" id="task_type" name="task_type">
                                                    <option value="">Task Type</option>
                                                    <option value="system" <?php if ($_GET['task_type']=="system" )
                                                        echo "selected='selected'" ;?>>System Task
                                                    </option>
                                                    <option value="adhoc_task" <?php if
                                                        ($_GET['task_type']=="adhoc_task" ) echo "selected='selected'"
                                                        ;?>>Ad hoc Task
                                                    </option>
                                                </select>
                                            </td>
                                            <td width="10px"></td>
                                            <td>
                                                <select class="form-control select2" style="width:150px" id="status"
                                                    name="status">
                                                    <option value="">Status</option>
                                                    <option value="complete" <?php if ($_GET['status']=="complete" )
                                                        echo "selected='selected'" ;?>>Complete</option>
                                                    <option value="in_progress" <?php if ($_GET['status']=="in_progress"
                                                        ) echo "selected='selected'" ;?>>In_Progress
                                                    </option>
                                                    <option value="in_complete" <?php if ($_GET['status']=="in_complete"
                                                        ) echo "selected='selected'" ;?>>In_Complete
                                                    </option>
                                                    <option value="cancel" <?php if ($_GET['status']=="cancel" )
                                                        echo "selected='selected'" ;?>>Cancel</option>
                                                    <option value="halt" <?php if ($_GET['status']=="halt" )
                                                        echo "selected='selected'" ;?>>Halt</option>
                                                </select>
                                            </td>
                                            <td width="10px"></td>
                                            <td>
                                                <input type="text" name="start_date" class="input_text datepicker"
                                                    placeholder="Task Added Date" id="datepicker" title="Task Date"
                                                    value="<?php echo $_GET['start_date']; ?>" style="width:150px">
                                            </td>
                                            <td width="10px"></td>
                                            <td>
                                                <div class="input-group">
                                                    <input type="text" class="form-control" name="keyword1"
                                                        id="search_project" value="<?php if($_REQUEST['search']!=" search")
                                                        echo $_REQUEST['keyword1'];?>" placeholder="search_task" style="width:150px">
                                                </div>
                                            </td>
                                            <td width="10px"></td>
                                            <td>
                                                <div class="input-group-btn">
                                                    <input type="image" src="images/search.jpg" name="search"
                                                            value="search" style="height:34px;">
                                                </div>
                                            </td>
                                        </tr>
                                    </form>
                                    <tr>
                                        <div class="box-body">
                                            <!-- <div class="table-responsive"> -->
                                            <table class="table no-margin" style="text-align:center">
                                                <thead>
                                                    <tr>
                                                        <th>Sr. No.</th>
                                                        <th>Task Name</th>
                                                        <th>Description</th>
                                                        <th>Priority</th>
                                                        <th>Status</th>
                                                        <th>Added Date</th>
                                                        <th>Dead Line</th>
                                                        <th>Complete Date</th>
                                                        <th>Assinged By</th>
                                                        <th>Details</th>
                                                        <!-- <th>Action</th> -->
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php
                                                    if($_REQUEST['start_date'] && $_REQUEST['start_date']!=="0000-00-00")
                                                    {
                                                        $frm_date=explode("/",$_REQUEST['start_date']);
                                                        $frm_dates=$frm_date[2]."-".$frm_date[1]."-".$frm_date[0];
                                                        $start_date=$frm_dates;
                                                        // $date1=" and attendance_date ='".date('Y-m-d',strtotime($frm_dates))."'";
                                                        $dates=" and DATE(added_date )='".date('Y-m-d',strtotime($frm_dates))."'";
                                                    }
                                                    if($_REQUEST['staff_names']!='')
                                                    {
                                                    $admin_ids=$_REQUEST['staff_names'];
                                                    $search_admin_id="and assign_by='".$admin_ids."'";
                                                    }
                                                    else
                                                    {
                                                    $search_admin_id='';
                                                    }
                                                    if($_REQUEST['task_type']!='')
                                                    {
                                                        $task_type=$_REQUEST['task_type'];
                                                        $search_task_type="and task_type='".$task_type."'";
                                                    }
                                                    else
                                                    {
                                                        $search_task_type='and task_type="adhoc_task"';
                                                    }
                                                    if($_REQUEST['status']!='')
                                                    {
                                                        $status=$_REQUEST['status'];
                                                        $search_status="and status='".$status."'";
                                                    }
                                                    else
                                                    {
                                                        $search_status='';
                                                    }
                                                    $i=1;
                                                    if($_REQUEST['keyword1']!="keyword1")
                                                    $search=trim($_REQUEST['keyword1']);
                                                    if($search)
                                                    {
                                                        $task_search=" and (task_name like '%".$search."%' || priority like '%".$search."%' || status like '%".$search."%' ||  sta_complete_date like '%".$search."%')";
                                                    }
                                                    else
                                                    {
                                                        $task_search="";
                                                    }
                                                    $sql_query="select * from tk_individual_task where 1 ".$search_admin_id." ".$search_task_type." ".$search_status." ".$task_search." and staff_id='".$_SESSION['admin_id']."' and Validation='valid' ".$dates." order by added_date DESC ";
                                                    $no_of_records=mysql_num_rows($db->query($sql_query));
                                                    if($no_of_records)
                                                    {
                                                        $bgColorCounter=1;
                                                        $query_string='&keyword1='.$search.'&status='.$status.'&staff_names='.$admin_ids.'&task_type='.$task_type.'&start_date='.$frm_dates;
                                                        $query_string1=$query_string;
                                                        $pager = new PS_Pagination($sql_query,$_SESSION['show_records'],5,$query_string1);
                                                        $all_records= $pager->paginate();
                                                        // $query_run1=mysql_query($my_task1);
                                                        // $records=mysql_num_rows($query_run1);
                                                        // if($records)
                                                        // {
                                                        // while($fetch_my_task1=mysql_fetch_array($query_run1))
                                                        // {
                                                        while($fetch_my_task1=mysql_fetch_array($all_records))
                                                        {
                                                            if($bgColorCounter%2==0)
                                                            $bgcolor='class="grey_td"';
                                                            else
                                                            $bgcolor=""; 
                                                            include "include/paging_script.php";
                                                            ?>
                                                            <tr>
                                                                <td>
                                                                    <?php echo $sr_no?>
                                                                </td>
                                                                <td>
                                                                    <?php echo ucwords($fetch_my_task1['task_name'])?>
                                                                </td>
                                                                <td>
                                                                    <?php echo substr(ucwords($fetch_my_task1['description']),0,80)?>
                                                                </td>
                                                                <td>
                                                                    <?php echo ucfirst($fetch_my_task1['priority'])?>
                                                                </td>
                                                                <td>
                                                                    <?php if($fetch_my_task1['status']=='complete') 
                                                                            { 
                                                                            ?>
                                                                    <p class="label label-success">
                                                                        <?php echo ucfirst($fetch_my_task1['status']);?>
                                                                    </p>
                                                                    <?php
                                                                            } 
                                                                            if($fetch_my_task1['status']=='in_progress') 
                                                                            { 
                                                                            ?>
                                                                    <p class="label label-warning">
                                                                        <?php echo ucfirst($fetch_my_task1['status']);?>
                                                                    </p>
                                                                    <?php
                                                                            } 
                                                                            if($fetch_my_task1['status']=='in_complete') 
                                                                            { 
                                                                            ?>
                                                                    <p class="label label-danger">
                                                                        <?php echo ucfirst($fetch_my_task1['status']);?>
                                                                    </p>
                                                                    <?php
                                                                            } 
                                                                            if($fetch_my_task1['status']=='cancel') 
                                                                            { 
                                                                            ?>
                                                                    <p class="label label-default">
                                                                        <?php echo ucfirst($fetch_my_task1['status']);?>
                                                                    </p>
                                                                    <?php
                                                                            }
                                                                            if($fetch_my_task1['status']=='halt') 
                                                                            { 
                                                                                ?>
                                                                    <p class="label label-primary">
                                                                        <?php echo ucfirst($fetch_my_task1['status']);?>
                                                                    </p>
                                                                    <?php
                                                                            }
                                                                        ?>
                                                                </td>
                                                                <td>
                                                                    <?php
                                                                                $add_date= date("d-m-Y", strtotime($fetch_my_task1['added_date']));
                                                                                echo $add_date;
                                                                            ?>
                                                                </td>
                                                                <td>
                                                                    <?php 
                                                                                $due_date= date("d-m-Y", strtotime($fetch_my_task1['due_date']));
                                                                                echo $due_date;
                                                                            ?>
                                                                </td>
                                                                <td>
                                                                    <?php 
                                                                                $complete_date='';
                                                                                if($fetch_my_task1['status']=='complete'){
                                                                                $complete_date= date("d-m-Y", strtotime($fetch_my_task1['sta_complete_date']));
                                                                                echo $complete_date;
                                                                                }
                                                                                else{
                                                                                    // $complete_date='';
                                                                                    echo '-';
                                                                                }
                                                                            ?>
                                                                </td>
                                                                <td>
                                                                    <?php
                                                                            $add="select name from site_setting where 1 and admin_id='".$fetch_my_task1['assign_by']."'";
                                                                            $ptr=mysql_query($add);
                                                                            $data=mysql_fetch_array($ptr);
                                                                            echo ucfirst($data['name']);?>
                                                                </td>
                                                                <td>
                                                                    <a target=_blank
                                                                        href="tk_individual_task_detail.php?id=<?= $fetch_my_task1['staff_task_id'] ?>"
                                                                        target=""><i class="fa fa-file"></i></a>
                                                                </td>
                                                            </tr>
                                                            <?php
                                                            $bgColorCounter++;
                                                        }
                                                        ?>
                                                        <tr class="head_td">
                                                            <td colspan="17">
                                                                <table cellspacing="0" cellpadding="0" width="100%">
                                                                    <tr>
                                                                        <?php
                                                                if($no_of_records>10)
                                                                {
                                                                    echo '<td width="5%" align="left"> Show &nbsp;&nbsp;</td>
                                                                    <td width="20%" align="left"><select class="form-control" name="show_records" onchange="redirect(this.value)">';
                                                                    $show_records=array(0=>'10',1=>'20','50','100','200');
                                                                    for($s=0;$s<count($show_records);$s++)
                                                                    {
                                                                        if($_SESSION['show_records']==$show_records[$s])
                                                                            echo '<option selected="selected" value="'.$show_records[$s].'">'.$show_records[$s].' Records</option>';
                                                                        else
                                                                            echo '<option value="'.$show_records[$s].'">'.$show_records[$s].' Records</option>';
                                                                    }
                                                                    echo'</td></select>';
                                                                }
                                                                echo '<td width="75%" align="right">'.$pager->renderFullNav().'</td>';
                                                                ?>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                        <?php
                                                    }
                                                    else
                                                    {
                                                        ?> 
                                                        <tr ><td colspan="11"><h4 style="background-color:;text-align:center"> No Record Avialable According To Your Creteria</h4></td></tr>
                                                        <?php
                                                    }
                                                    ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
        <?php include "include/footer-main.php"; ?>
    </div>
    <!-- jQuery 3 -->
    <script src="bower_components/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap 3.3.7 -->
    <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- Select2 -->
    <script src="bower_components/select2/dist/js/select2.full.min.js"></script>
    <!-- InputMask -->
    <script src="plugins/input-mask/jquery.inputmask.js"></script>
    <script src="plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
    <script src="plugins/input-mask/jquery.inputmask.extensions.js"></script>
    <!-- date-range-picker -->
    <script src="bower_components/moment/min/moment.min.js"></script>
    <script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
    <!-- bootstrap datepicker -->
    <script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
    <!-- bootstrap color picker -->
    <script src="bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
    <!-- bootstrap time picker -->
    <script src="plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <!-- SlimScroll -->
    <script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
    <!-- iCheck 1.0.1 -->
    <script src="plugins/iCheck/icheck.min.js"></script>
    <!-- FastClick -->
    <script src="bower_components/fastclick/lib/fastclick.js"></script>
    <!-- AdminLTE App -->
    <script src="dist/js/adminlte.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="dist/js/demo.js"></script>
    <!-- Page script -->
    <script>
        $(function () {
            //Initialize Select2 Elements
            $('.select2').select2()
            //Date picker
            $('#datepicker').datepicker({
                autoclose: true,
                format: 'dd/mm/yyyy',
                // startDate: '-0d',
                Default: true,
                todayHighlight: true
            })


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

            //Timepicker
            $('.timepicker').timepicker({
                showInputs: false
            })
        })
    </script>
</body>

</html>