<?php 
if(!isset($_SESSION)) 
    { 
session_start();
	}
ob_start();
error_reporting(0);
include("../../pidbco/pidbjoin.php");
$sujpath="./";
if((!isset($_SESSION['user_name'])) && ($_SESSION['user_name'] == '')){
    header("Location: ../index.php");
} 
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Projects</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.5 -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>font-awesome/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>font-awesome/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>plugins/datatables/dataTables.bootstrap.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>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="<?php echo $sujpath; ?>dist/css/skins/_all-skins.min.css">
	
   <script>
  
   
    function add_new_task(){
            var limit=10;
            var start=0;
             var taskfrom = $('#taskfrom').val();
             var taskto = $('#taskto').val();
             var taskaction = $('#taskaction').val();
             var taskstatus = $('#taskstatus').val();
             if(taskfrom == ''){
                alert("Select Employee");       
             } else if(taskto == ''){
                alert("Select Employee");
             } else if(taskaction == ''){
                alert("Enter Action");
             } else if(taskstatus == ''){
                alert("Select Status");
             } else {                    
                  $.ajax({
                    type: "POST",
                    url: "ajaxmarket.php",
                     data: {
                          add_new_taskreg : 1,
                          taskfrom        : taskfrom,
                          taskto          : taskto,
                          taskaction      : taskaction,
                          taskstatus      : taskstatus                          
                     },
                     cache: true,
                     success: function(res23)
                     {
                            $('#taskfrom').val('');
                            $('#taskto').val('');
                            $('#taskaction').val('');
                            location.reload();
                            //datat2();
                      }
                   }); 
            }
        }
              
        
        
   function edit_new_task(hidvall)
   {
	   
	   var tfrom=$("#tfrom").val();
   
   var tto=$("#tto").val();
   
   var tstatus=$("#tstatus").val();
             var taskfrom = $('#taskfrom'+hidvall).val();
             var taskto = $('#taskto'+hidvall).val();
             var taskaction = $('#taskaction'+hidvall).val();
             var taskstatus = $('#taskstatus'+hidvall).val();
             //var hidvall = $('#hidvall2').val();
             var transferto = $('#transferto'+hidvall).val();
             var taskreport = $('#taskreport'+hidvall).val();
           
             if($("#tasksign"+hidvall).is(':checked'))
                 var tasksign =1;
             else
                 var tasksign =1;
              
             if(taskfrom == ''){
                alert("Select Employee");       
             } else if(taskto == ''){
                alert("Select Employee");
             } else if(taskaction == ''){
                alert("Enter Action");
             } else if(taskstatus == ''){
                alert("Select Status");
             } else {                    
                  $.ajax({
                    type: "POST",
                    url: "ajaxmarket.php",
                     data: {
                          edit_new_taskreg : 1,
                          taskfrom         : taskfrom,
                          taskto           : taskto,
                          taskaction       : taskaction,
                          taskstatus       : taskstatus,
                          hidvall          : hidvall,
                          tasksign         : tasksign,
                          transferto       : transferto,
                          taskreport       : taskreport                          
                     },
                     cache: true,
                     success: function(res23)
                     {
                           alert("Data Updated Successfully");
						   
                           location.reload();

                      }
                   }); 
            }   
   }
        
        
   function delete_task(id)
   {
            var result = confirm("Want to delete?");
            if (result) 
            {
            $.ajax({
            type: "POST",
            url: "ajaxmarket.php",
            data: {
            btn_delete_taskk: 1,
            id:id
            },
            cache: true,
            success: function(res)
            {
                 location.reload();
                  //datat();
            }  
            });
            }
        }
        
        
        function edit_task(id)
        {
            $.ajax({
            type: "POST",
            url: "ajaxmarket.php",
            data: {
            btn_edit_market: 1,
            id:id
            },
            cache: true,
            success: function(res)
             {
                $("#marketingdiv2").load("task_register.php?idd2="+id+" #marketingdiv2"); 
                window.location.hash = '#marketingdiv2';    
             }  
            });
        }
        
        function inter_connect(idd)
        {
                                                                    var search_todo = $('#search_todo').val();
                                                                    $.ajax({
                                                                        url   :"ajaxmarket.php" ,
                                                                        type  : "POST",
                                                                        data  :
                                                                        {
                                                                            create_todoresult      : 1,
                                                                            search_todo            : search_todo,
                                                                            idd                    : idd
                                                                        },
                                                                        success:function(res13)
                                                                        {
                                                                            
                                                                            $('#report_todo_searh').html(res13);
                                                                        }
                                                                    });
        }
        
        function add_interconnect(idd){
            
            var myArray = [];
            var id = "";
            var oTable = $("#example11").dataTable();
            $(".ads_Checkbox:checked", oTable.fnGetNodes()).each(function() {
            if (id != "") {
                id = id + "," + $(this).val();
            } else {
                id = $(this).val();
            }

            }); 
            
            $.ajax({
            type: "POST",
            url: "ajaxmarket.php",
            data: {
            add_inter_conn_todo : 1,
            regno : id,
            idd   : idd
            },
            cache: true,
            success: function(res)
            {
                  //datat3();
                   window.location.href="task_register.php";
                
            
            }  
            });
        }
        function reminder_set(idd)
        {
            var reminderdat = $('#reminderdat'+idd).val();
            $.ajax({
            type: "POST",
            url: "ajaxmarket.php",
            data: {
            add_new_reminder : 1,
            reminderdat      : reminderdat,
            idd              : idd
            },
            cache: true,
            success: function(res)
            {
                alert("Reminder Set Successfully");
                window.location.href="task_register.php";   
            }  
            });
        }
        
        
function state_change(str)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("cdistrict").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajaxmarket.php?state_idd="+str,true);
xmlhttp.send();
}

        function search_task()
        {
            var searchfrom = $('#searchfrom').val();
            var searchto = $('#searchto').val();
            var srchstatus = $('#srchstatus').val();
            
            if(srchstatus == ''){
               alert("Select Status");  
            } else {    
            $.ajax({
            type: "POST",
            url: "ajaxmarket.php",
            data: {
            btn_edit_market: 1
            },
            cache: true,
            success: function(res)
            {
                //$("#example1").load("task_register.php?tfrom="+searchfrom+"&tto="+searchto+"&tstatus="+srchstatus+" #example1");
                window.location.href="task_register.php?tfrom="+searchfrom+"&tto="+searchto+"&tstatus="+srchstatus;     
            }  
            });
            }
        }
        
        
        function todo_print()
        {
        
            var searchfrom = $('#searchfrom').val();
            var searchto = $('#searchto').val();
            var srchstatus = $('#srchstatus').val();
            if(srchstatus == ''){
               alert("Select Status");  
            } else {    
            $.ajax({
            type: "POST",
            url: "ajaxmarket.php",
            data: {
            btn_edit_market: 1
            },
            cache: true,
            success: function(res)
            {
                  var url = "todo_print.php?tfrom="+searchfrom+"&tto="+searchto+"&tstatus="+srchstatus;
                  window.open(url, '_blank');
            }  
            });
            }
        }
        
        
       function status_change2(dat,idd){
                if(dat == 2){
                    document.getElementById('trans_div_vis'+idd).style.display='block';
                } else {
                   document.getElementById('trans_div_vis'+idd).style.display='none';   
                }   
       }                
    </script>
    <script>
                                                       function create_report()
                                                                {
                                                                var searchemp = $('#searchemp').val();
                                                                var searchdat = $('#searchdat').val();
                                                                    $.ajax({
                                                                        url   :"ajaxmarket.php" ,
                                                                        type  : "POST",
                                                                        data  :
                                                                        {
                                                                            create_reports     : 1,
                                                                            searchemp          : searchemp,
                                                                            searchdat          : searchdat
                                                                        },
                                                                        success:function(res13)
                                                                        {
                                                                        
                                                                            $('#report_res').html(res13);
                                                                        }
                                                                    });
                                                                    }
                                                                    
                                                              function report_sent()
                                                                {
                                                                var searchemp = $('#searchemp').val();
                                                                var searchdat = $('#searchdat').val();
                                                                var report_contnt = $('#report_contnt').val();
                                                                
                                                                var emailset1 = $('#emailset1').val();
                                                                var emailset2 = $('#emailset2').val();
                                                                var emailset3 = $('#emailset3').val();
                                                                if(report_contnt == ''){
                                                                  alert("Enter Report");    
                                                                } else if(emailset1 == ''){
                                                                  alert("Enter Email"); 
                                                                } else {
                                                                    $.ajax({
                                                                        url   :"ajaxmarket.php" ,
                                                                        type  : "POST",
                                                                        data  :
                                                                        {
                                                                            report_sent_email  : 1,
                                                                            searchemp          : searchemp,
                                                                            searchdat          : searchdat,
                                                                            report_contnt      : report_contnt,
                                                                            emailset1          : emailset1,
                                                                            emailset2          : emailset2,
                                                                            emailset3          : emailset3
                                                                        },
                                                                        success:function(res13)
                                                                        {
                                                                            
                                                                            alert("Email Sent Successfully");
                                                                            window.location.href="task_register.php";
                                                                        }
                                                                    });
                                                                   }
                                                                    }
                                                                    
                                                                    
                                                                function report_sent_save()
                                                                {
                                                                  var searchemp = $('#searchemp').val();
                                                                  var searchdat = $('#searchdat').val();
                                                                  var report_contnt = $('#report_contnt').val();
                                                                    $.ajax({
                                                                        url   :"ajaxmarket.php" ,
                                                                        type  : "POST",
                                                                        data  :
                                                                        {
                                                                            report_sent_save    : 1,
                                                                            searchemp          : searchemp,
                                                                            searchdat          : searchdat,
                                                                            report_contnt      : report_contnt
                                                                        },
                                                                        success:function(res13)
                                                                        {
                                                                            alert("Report Saved");
                                                                            window.location.href="task_register.php";
                                                                        }
                                                                    });
                                                                    }
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    
                                                                function report_print()
                                                                {
                                                                    var searchemp = $('#searchemp').val();
                                                                    var searchdat = $('#searchdat').val();
                                                                    var report_contnt = $('#report_contnt').val();
                                                                    $.ajax({
                                                                        url   :"ajaxmarket.php" ,
                                                                        type  : "POST",
                                                                        data  :
                                                                        {
                                                                            report_sent_save    : 1
                                                                        },
                                                                        success:function(res13)
                                                                        {
                                                                            var url = "task_report_print.php?emp="+searchemp+"&dat="+searchdat+"&rep="+report_contnt;
                                                                            window.open(url, '_blank');
                                                                        }
                                                                    });
                                                                    }       
                                                                    
                                                                    
                                                                    
                                                                    
                                                                                                
                                                                    
                                                                    
    function no_permission(){
        alert("Sorry, You do not have Permission..");
    }                                                               
                                                            </script>
                                                            
<link rel="stylesheet" type="text/css" href="tcal.css" />    
<script type="text/javascript" src="tcal.js"></script>
  
    
</head>
<body class="hold-transition skin-blue sidebar-mini">

  <div class="wrapper">
  <?php include("head.php");
    include("left.php"); ?> 
      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper" >
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1> Task Register
            <small>- Control panel</small>
            </h1>
			<input type="hidden" id="tfrom" value="<?php echo $_GET["tfrom"];?>">
<input type="hidden" id="tto" value="<?php echo $_GET["tto"];?>">
<input type="hidden" id="tstatus" value="<?php echo $_GET["tstatus"];?>">
          <ol class="breadcrumb">
        <div style=" float: left; ">
        <div style="width: 10px; height: 10px; background: #00FFFF;float: left;" ></div><span style="float: left; line-height: 10px;">&nbsp; Noted</span>
        
        <div style="width: 10px; height: 10px; background: #0000FF;float: left; margin-left: 14px;" ></div><span style="float: left;line-height: 10px;"> &nbsp; Replied</span>
        
        <div style="width: 10px; height: 10px; background: red;float: left;margin-left: 14px;" ></div><span style="float: left; line-height: 10px;"> &nbsp; Closed</span>
        
        <div style="width: 10px; height: 10px; background: #DAA520;float: left;margin-left: 14px;" ></div><span style="float: left; line-height: 10px;"> &nbsp; Transfer</span>
        
        <div style="width: 10px; height: 10px; background: #2E8B57;float: left;margin-left: 14px;" ></div><span style="float: left; line-height: 10px;"> &nbsp; Hold</span>
    
        </div> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
            <li class="active">Task Register</li> 
          </ol>
        </section>
  <!-- Main content -->
        <section class="content" >
   
<div class="box-body2" id="marketingdiv2" >
 <?php
      $idd2 = strip_tags(base64_decode($_GET['idd2']));
      $sq   = mysqli_query($con, "SELECT * FROM `p_task` WHERE `tid`='$idd2' " );
      $rs   = mysqli_fetch_assoc($sq);    
 ?>     
<div class="box-body">
 <div class="row" > 
 <div class="col-md-12" style="" >
 
 <div class="col-md-1"  style=" padding-left: 2px; padding-right: 0px; ">           
 <div class="form-group">
   <select name="taskfrom" id="taskfrom" class="form-control">
    <option value="">From</option>
    <?php
    $sq1 = mysqli_query($con, "SELECT * FROM `employee_registration` WHERE `status`='1' ORDER BY `emp_name` ASC ");
    while($res1 = mysqli_fetch_array($sq1)){
        if($_SESSION['us_staff'] == $res1['id']){
    ?>
    <option value="<?php echo $res1['id']; ?>" selected><?php echo $res1['emp_name']; ?></option>
    <?php } else { ?>
    <option value="<?php echo $res1['id']; ?>"><?php echo $res1['emp_name']; ?></option>
    <?php } } ?>
   </select>        
 </div></div>
 
 <div class="col-md-1"  style=" padding-left: 2px; padding-right: 0px; ">           
 <div class="form-group">
  <select class="form-control" id="taskto" name="taskto" onchange="state_change(this.value);">
    <option value="">To</option>
    <?php
    $sq1 = mysqli_query($con, "SELECT * FROM `employee_registration` WHERE `status`='1' ORDER BY `emp_name` ASC ");
    while($res1 = mysqli_fetch_array($sq1)){
        if($rs['t_to'] == $res1['id']){
    ?>
    <option value="<?php echo $res1['id']; ?>" selected><?php echo $res1['emp_name']; ?></option>
    <?php } else { ?>
    <option value="<?php echo $res1['id']; ?>"><?php echo $res1['emp_name']; ?></option>
    <?php } } ?>  
  </select> 
 </div></div>



 <div class="col-md-6" style=" padding-left: 2px; padding-right: 0px; " >
 <div class="form-group">
      <textarea name="taskaction" id="taskaction" class="form-control"  placeholder="Task Details"  <?php if($idd2 != ''){ ?> style=" height: 35px;" <?php } else { ?>  style=" height: 80px;" <?php } ?> ><?php echo $rs['t_action']; ?></textarea>
 </div></div>

 
 <div class="col-md-2"  style=" padding-left: 2px; padding-right: 0px; ">
 <div class="form-group">
  <select class="form-control" id="taskstatus" name="taskstatus" onchange="status_change2(this.value);" >
     <option value="0" <?php if($rs['t_status'] == 0){ ?> selected <?php } ?>>Open</option>
     <option value="1" <?php if($rs['t_status'] == 1){ ?> selected <?php } ?>>Closed</option>
     <option value="3" <?php if($rs['t_status'] == 3){ ?> selected <?php } ?>>Hold</option>
  </select> 
 </div></div>
 
    <div class="col-md-2"  style=" padding-left: 2px; padding-right: 0px; display: none; " >            
    <div class="form-group">
    <select name="transferto" id="transferto" class="form-control">
    <option value="">Tansfer To</option>
    <?php
    $sq1 = mysqli_query($con, "SELECT * FROM `employee_registration` WHERE `status`='1' ORDER BY `emp_name` ASC ");
    while($res1 = mysqli_fetch_array($sq1)){
        if($rs['t_trans_to'] == $res1['id']){
    ?>
    <option value="<?php echo $res1['id']; ?>" selected><?php echo $res1['emp_name']; ?></option>
    <?php } else { ?>
    <option value="<?php echo $res1['id']; ?>"><?php echo $res1['emp_name']; ?></option>
    <?php } } ?>
    </select>       
    </div></div>
 
  <?php if($idd2 != ''){ ?>
  <div class="col-md-6" style=" padding-left: 2px; padding-right: 0px; " >
  <div class="form-group">
      <textarea name="taskreport" id="taskreport" class="keyboardInput form-control"  placeholder="Report" style=" height: 40px;" ><?php echo $rs['task_report']; ?></textarea>
  </div></div>
  <?php } ?>
 

 <div class="col-md-2" style=" padding-left: 2px; padding-right: 0px; ">                    
 <div class="form-group">
    <?php if($idd2 != ''){ ?>
    <input type="checkbox" name="tasksign" id="tasksign" placeholder="Signature" style=" margin-left: 15px;" <?php if($rs['t_sign'] == 1){ ?> checked <?php } ?> />Signature
    <input type="hidden" name="hidvall" id="hidvall" value="<?php echo $rs['tid']; ?>" />
    <input type="submit" class="btn btn-primary" name="frasubmit" id="frasubmit" value="Update" onclick="edit_new_task();" style=" float: right;margin-right: 5px; " /> 
 <?php } else { ?>
    <input type="submit" class="btn btn-primary" name="frasubmit" id="frasubmit" value="Submit" onclick="add_new_task();" style=" float: left;margin-right: 5px; " />   
 <?php } ?> 
 </div>
 </div>

</div></div>

</div>
</div>
  
  
  
  
  
  
<div id="marketingdiv123">

<div class="box" >
   <div class="box-body" style=" overflow: auto;">
        <div class="box-body table-responsive no-padding" >
            

 <div class="row">  
  <div class="col-md-12" >

  <div class="col-md-2"  style=" padding-left: 2px; padding-right: 0px; ">          
  <div class="form-group">
  </div></div>

 <div class="col-md-2"  style=" padding-left: 2px; padding-right: 0px; ">           
 <div class="form-group">
   <select name="searchfrom" id="searchfrom" class="form-control" style=" height: 30px;">
    <option value="">From</option>
    <?php
    $sq1 = mysqli_query($con, "SELECT * FROM `employee_registration` WHERE `status`='1' ORDER BY `emp_name` ASC ");
    while($res1 = mysqli_fetch_array($sq1)){
        if($_GET['tfrom'] == $res1['id']){
    ?>
    <option value="<?php echo $res1['id']; ?>" selected><?php echo $res1['emp_name']; ?></option>
    <?php } else { ?>
    <option value="<?php echo $res1['id']; ?>"><?php echo $res1['emp_name']; ?></option>
    <?php } } ?>
   </select>        
 </div></div>
 <div class="col-md-2"  style=" padding-left: 2px; padding-right: 0px; ">           
 <div class="form-group">
  <select class="form-control" id="searchto" name="searchto" onchange="state_change(this.value);" style=" height: 30px;">
    <option value="">To</option>
    <?php
    $sq1 = mysqli_query($con, "SELECT * FROM `employee_registration` WHERE `status`='1' ORDER BY `emp_name` ASC ");
    while($res1 = mysqli_fetch_array($sq1)){
        if($_GET['tto'] == $res1['id']){
    ?>
    <option value="<?php echo $res1['id']; ?>" selected><?php echo $res1['emp_name']; ?></option>
    <?php } else { ?>
    <option value="<?php echo $res1['id']; ?>"><?php echo $res1['emp_name']; ?></option>
    <?php } } ?>  
  </select> 
 </div></div>  


<div class="col-md-2"  style=" padding-left: 2px; padding-right: 0px; ">            
 <div class="form-group">
  <select class="form-control" id="srchstatus" name="srchstatus" style=" height: 30px;">
  
    <option value="All" <?php if($_GET['tstatus'] == 'All'){ ?> selected <?php } ?>>All</option>
    <option value="Open" <?php if($_GET['tstatus'] == 'Open'){ ?> selected <?php } ?>>Open</option>
    <option value="Closed" <?php if($_GET['tstatus'] == 'Closed'){ ?> selected <?php } ?>>Closed</option>
    <option value="Transfer" <?php if($_GET['tstatus'] == 'Transfer'){ ?> selected <?php } ?>>Transfer</option>
    <option value="Hold" <?php if($_GET['tstatus'] == 'Hold'){ ?> selected <?php } ?>>Hold</option>
    <option value="Reminder" <?php if($_GET['tstatus'] == 'Reminder'){ ?> selected <?php } ?>>Reminder</option>  
  </select> 
 </div></div>
 <div class="col-md-1"  style=" padding-left: 2px; padding-right: 0px; ">           
 <div class="form-group">
 <input type="submit" class="btn btn-primary" name="frasubmit" id="frasubmit" value="Search" onclick="search_task();" style=" float: left;margin-right: 5px; height: 30px;" />
 </div></div>
 
 <div class="col-md-2"  >           
 <div class="form-group">
 <span style=" font-size: 16px; " >
    <i class="fa fa-book" aria-hidden="true"></i>
    <a href="" data-toggle="modal" data-target="#myModal9data" style=" cursor: pointer;">Create Report</a>
    </span> 
 </div></div>
 
 <div class="col-md-1"  >           
 <div class="form-group">
 <span style=" font-size: 16px; " >
    <i class="fa fa-print" aria-hidden="true"></i>
    <a style=" cursor: pointer;" onclick="todo_print();" >Print</a>
    </span> 
 </div></div>
    
    
 </div></div></div>
 
 
  <div class="modal fade" id="myModal9data" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document" style=" width: 800px; ">
    <div class="modal-content" style="overflow: hidden;">
      <div class="modal-header" style=" background-color: #E8E8E8;">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Search / Create Report</h4>
        </div>
        <div class="modal-body" id="myModal2" >
        <div class="row">   
            
            <div class="col-md-12" >
                
    <div class="col-md-3"  style=" padding-left: 2px; padding-right: 0px; ">                    
    <div class="form-group">
    <select name="searchemp" id="searchemp" class="form-control" style=" height: 32px;">
    <option value="">Employee</option>
    <?php
    $sq1 = mysqli_query($con, "SELECT * FROM `employee_registration` WHERE `status`='1' ORDER BY `emp_name` ASC ");
    while($res1 = mysqli_fetch_array($sq1)){
        if($rs['t_from'] == $res1['id']){
    ?>
    <option value="<?php echo $res1['id']; ?>" selected><?php echo $res1['emp_name']; ?></option>
    <?php } else { ?>
    <option value="<?php echo $res1['id']; ?>"><?php echo $res1['emp_name']; ?></option>
    <?php } } ?>
   </select>    
            </div></div>
             <div class="col-md-3"  style=" padding-left: 2px; padding-right: 0px; ">                   
            <div class="form-group">
                <input type="text" name="searchdate" id="searchdat" class="form-control tcal" placeholder="YYYY/MM/DD"/> 
                    
            </div></div>    
            <div class="col-md-2"  style=" padding-left: 2px; padding-right: 0px; ">                    
            <div class="form-group">
            <input type="submit" class="btn btn-primary" name="frasubmit" id="frasubmit" value="Search" onclick="create_report();"  />      
            </div></div>    
            </div>
            
            
       </div>
       
            
       <div id="report_res"></div>
       
       
          
       
       
       </div></div></div></div>
       
       
       
       
       
       <div class="col-md-12">
              <div class="col-md-2" style="float: right;margin-bottom: 6px;">
               <input type="text" placeholder="Search.." class="form-control" id="serc">
             </div>
             </div>

       
       

                        
     <table id="example1" class="table table-bordered table-striped" >
                    <thead >
                    <tr >
                    <th style=" display: none;"></th>
                    <th>#</th>   
                    <th>Date/Time</th>                  
                    <th>From</th>
                    <th>To</th>
                    <th>Task Details</th>
                    <th>Status</th>
                    <th></th>
                    </tr>
                    </thead>
                    <tbody id="load_data">
   
                    </tbody>
					</table>
					<table>
                    <tbody>
                      <tr>
                        <td id="load_data_message"></td>
                      </tr>
                    </tbody>
                    </table>
  
                  </div>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
    
      </div>
        
 <div class="modal fade" id="myModal9data9" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document" >
    <div class="modal-content" style="overflow: hidden;">
      <div class="modal-header" style=" background-color: #E8E8E8;">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Enter Email</h4>
        </div>
        <div class="modal-body" id="myModal2" >
        <div class="row">   
            
    
    <div class="col-md-12">
                    
    <div class="col-md-12"  style=" padding-left: 2px; padding-right: 0px; ">                   
    <div class="form-group">
      <input type="text" name="emailset1" id="emailset1" class="form-control" placeholder="Email1"/>
    </div></div>
    
    <div class="col-md-12"  style=" padding-left: 2px; padding-right: 0px; ">                   
    <div class="form-group">
    <input type="text" name="emailset2" id="emailset2" class="form-control" placeholder="Email2"/>          
    </div></div>    
    <div class="col-md-12"  style=" padding-left: 2px; padding-right: 0px; ">                   
    <div class="form-group">
         <input type="text" name="emailset3" id="emailset3" class="form-control" placeholder="Email3"/>         
    </div></div>
    
     <div class="col-md-12"  style=" padding-left: 2px; padding-right: 0px; ">                  
    <div class="form-group">
       <input type="submit" class="btn btn-primary" name="frasubmit" id="frasubmit" value="Send" onclick="report_sent();" style=" float: right; width: 100px; height: 29px; margin-top: 4px;" />            
    </div></div>
     
     </div>     
        
            
            
       </div>

       
          
       
       
       </div></div></div></div>
       
   
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document" >
    <div class="modal-content">
        <div id="fetchedit1">

      <div class="modal-header" style=" background-color: #E8E8E8;">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">#<?php echo $rstask['tid']; ?>  - Task Register</h4>
        </div>
        <div class="modal-body" id="myModal2" >
      
        <div class="row"> 
         <div class="col-md-12" style="font-size: 14px; " >
          <div class="col-md-8" ><?php echo $fromemp; ?>&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-long-arrow-right" aria-hidden="true"></i>
            &nbsp;&nbsp;&nbsp;&nbsp;<?php echo $toemp; ?>
            </div>
          <div class="col-md-4">
          <small class="label label-warning" > <?php echo $taskdate; ?> &nbsp; <?php echo $rstask['t_time']; ?></small>
           <small class="label label-danger" ><?php if($rstask['t_status'] == 1){ echo "Closed"; } else { echo "Open"; } ?></small>
          </div>
          </div>
         
       <div class="col-md-12" style="font-size: 18px; margin-top: 10px;">
       <div class="col-md-12 "  style="  padding-left: 2px; padding-right: 0px;background-color: #DCDCDC; " >         
         <div class="form-group " >
           &nbsp;&nbsp;&nbsp;
           <?php echo $rstask['t_action']; ?>
         </div></div>
         </div>
         
         <div class="col-md-12" style="font-size: 18px; margin-top: 5px;">
       <div class="col-md-12"  style="  padding-left: 2px; padding-right: 0px; " >          
         <div class="form-group">
         <?php 
         while($resw2 = mysqli_fetch_array($sqw)){
          $log_id = $resw2['log_id'];
          $sqemp = mysqli_query($con, "SELECT emp_name FROM `employee_registration` WHERE `id`='$log_id' ");
          $resemp = mysqli_fetch_array($sqemp);
            $reportemp = $resemp['emp_name'];
      
       ?>
         <div style="clear:both;"></div>
         <span style="font-style: italic;"><u><?php echo $resw2['reprt_date'].'&nbsp;'.$reportemp.' Says : &nbsp;'.$resw2['tas_report']; ?></u></span>  
         <?php } ?> 
         </div></div>
         </div>
         
         <div class="col-md-12" style="font-size: 18px; margin-top: 5px;">
       <div class="col-md-12"  style="  padding-left: 2px; padding-right: 0px; " >          
         <div class="form-group">
         <?php if($rstask['t_closedat'] != ''){ 
         
      $t_closedat = $rstask['t_closedat'];
          $exp4 = explode("-",$t_closedat);
          $yearr4 =  substr($exp4[0], 2, 4);
          $t_closedat = $exp4[2].'/'.$exp4[1].'/'.$yearr4; 
         ?>
         <div style="clear:both;"></div>
         <span style="font-style: italic;"><u><?php echo 'Report Closed by '.$toemp.' on '.$t_closedat; ?></u></span> 
         <?php } ?> 
         </div></div>
         </div>
         
         
     
     </div>  
       
       
        </div>
              <div class="modal-footer">
              </div>
            </div>
    </div>
  </div>
</div> 

  


    <div class="modal fade" id="myModaledit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document" >
    <div class="modal-content">
	<div id="fetchedit">
	<?php  echo "id".$_GET["id"];?>
      <div class="modal-header" style=" background-color: #E8E8E8;">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel"> #<?php echo $taskid; ?> - Edit Task Register</h4>
        </div>
        <div class="modal-body" id="myModal2" >
      
        <div class="row">   
          <div class="col-md-12">
 <div class="col-md-6"  style=" padding-left: 2px; padding-right: 0px; ">           
 <div class="form-group">
   <select name="taskfrom<?php echo $taskid; ?>" id="taskfrom<?php echo $taskid; ?>" class="form-control" <?php if($rstask['t_from'] != $_SESSION['us_staff']){ ?> disabled <?php } ?>>
    <option value="">From</option>
    <?php
    $sq1 = mysqli_query($con, "SELECT * FROM `employee_registration`  ORDER BY `emp_name` ASC ");
    while($res1 = mysqli_fetch_array($sq1)){
        if($rstask['t_from'] == $res1['id']){
    ?>
    <option value="<?php echo $res1['id']; ?>" selected><?php echo $res1['emp_name']; ?></option>
    <?php } else { ?>
    <option value="<?php echo $res1['id']; ?>"><?php echo $res1['emp_name']; ?></option>
    <?php } } ?>
   </select>        
 </div></div>

          
 <div class="col-md-6"  style=" padding-left: 2px; padding-right: 0px; ">           
 <div class="form-group">
  <select class="form-control" id="taskto<?php echo $rstask['tid']; ?>" name="taskto<?php echo $rstask['tid']; ?>" <?php if($rstask['t_from'] != $_SESSION['us_staff']){ ?> disabled <?php } ?>>
    <option value="">To</option>
    <?php
    $sq1 = mysqli_query($con, "SELECT * FROM `employee_registration`  ORDER BY `emp_name` ASC ");
    while($res1 = mysqli_fetch_array($sq1)){
        if($rstask['t_to'] == $res1['id']){
    ?>
    <option value="<?php echo $res1['id']; ?>" selected><?php echo $res1['emp_name']; ?></option>
    <?php } else { ?>
    <option value="<?php echo $res1['id']; ?>"><?php echo $res1['emp_name']; ?></option>
    <?php } } ?>  
  </select> 
 </div></div>
 
 </div>
 <div class="col-md-12">
      <div class="col-md-12" style=" padding-left: 2px; padding-right: 0px; " >
 <div class="form-group">
      <textarea <?php if($rstask['t_from'] != $_SESSION['us_staff']){ ?> disabled <?php } ?> name="taskaction<?php echo $rstask['tid']; ?>" id="taskaction<?php echo $rstask['tid']; ?>" class="form-control"  placeholder="Task Details"  <?php if($idd2 != ''){ ?> style=" height: 35px;" <?php } else { ?>  style=" height: 80px;" <?php } ?> ><?php echo $rstask['t_action']; ?></textarea>
 </div></div>
 </div>
 
 
    
        
 <?php 
 $task_id = $rstask['tid'];
 $sqw2 = mysqli_query($con, "SELECT * FROM `p_taswise_rep` WHERE `task_id`='$task_id'");
 while($resw2 = mysqli_fetch_array($sqw2)){
    $log_id = $resw2['log_id'];
    $sqemp = mysqli_query($con, "SELECT emp_name FROM `employee_registration` WHERE `id`='$log_id' ");
    $resemp = mysqli_fetch_array($sqemp);
    $reportemp = $resemp['emp_name'];
    ?>
    <div class="col-md-12" style="font-size: 14px; margin-top: 5px;">
    <div class="col-md-12" style=" padding-left: 2px; padding-right: 0px; " >
 
 <div style="float: left; margin-top: 3px; margin-bottom: 3px; ">   
 <small class="label label-warning" > <?php echo $resw2['reprt_date']; ?> </small> &nbsp; <?php echo $reportemp.'&nbsp;'.'Says :'; ?>   
 <?php echo $resw2['tas_report']; ?>
 </div></div></div><div style="clear:both;"></div>
<?php } ?>
 
 
 <div class="col-md-12">
      <div class="col-md-12" style=" padding-left: 2px; padding-right: 0px; " >
  <div class="form-group">
      <textarea name="taskreport<?php echo $rstask['tid']; ?>" id="taskreport<?php echo $rstask['tid']; ?>" class="keyboardInput form-control"  placeholder="Task Report" style=" height: 40px;" ></textarea>
  </div></div>
 </div>
    
         
  
 <div class="col-md-12">
  <div class="col-md-4"  style=" padding-left: 2px; padding-right: 0px; ">
  <div class="form-group">
  <select class="form-control" id="taskstatus<?php echo $rstask['tid']; ?>" name="taskstatus<?php echo $rstask['tid']; ?>" onchange="status_change2(this.value,'<?php echo $rstask['tid']; ?>');" >
     <option value="0" <?php if($rstask['t_status'] == 0){ ?> selected <?php } ?>>Open</option>
     <option value="1" <?php if($rstask['t_status'] == 1){ ?> selected <?php } ?>>Closed</option>
     <option value="2">Transfer</option>
     <option value="3" <?php if($rstask['t_status'] == 3){ ?> selected <?php } ?>>Hold</option>
  </select> 
 </div></div>
 
  
 <div class="col-md-3"  style=" padding-left: 2px; padding-right: 0px; display: none;" id="trans_div_vis<?php echo $rstask['tid']; ?>">         
    <div class="form-group">
    <select name="transferto<?php echo $rstask['tid']; ?>" id="transferto<?php echo $rstask['tid']; ?>" class="form-control">
    <option value="">Tansfer To</option>
    <?php
    $sq1 = mysqli_query($con, "SELECT * FROM `employee_registration` WHERE `status`='1' ORDER BY `emp_name` ASC ");
    while($res1 = mysqli_fetch_array($sq1)){
    ?>
    <option value="<?php echo $res1['id']; ?>"><?php echo $res1['emp_name']; ?></option>
    <?php } ?>
    </select>       
    </div></div>
    
    
  
    
    
    
 <div class="col-md-4" style=" padding-left: 2px; padding-right: 0px; ">                    
 <div class="form-group">
    <input type="checkbox" name="tasksign<?php echo $rstask['tid']; ?>" id="tasksign<?php echo $rstask['tid']; ?>" placeholder="Signature" style=" margin-left: 15px;" <?php if($rstask['t_sign'] == 1){ ?> checked <?php } ?> />Signature
    <input type="hidden" name="hidvall2" id="hidvall2" value="<?php echo $rstask['tid']; ?>" />
    <input type="submit" class="btn btn-primary" name="frasubmit" id="frasubmit" value="Update" onclick="edit_new_task('<?php echo $rstask['tid']; ?>');" style=" float: right;margin-right: 5px; " /> 
 </div>
 </div>
 
    
 </div>      
   
   
         
      
     
        </div>  
       
        </div>
		</div>
        <div class="modal-footer">
        
      </div>
    </div>
  </div>
  
  

         


    </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
    </div>
    <!-- jQuery 2.1.4 -->
    <script src="<?php echo $sujpath; ?>plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="<?php echo $sujpath; ?>bootstrap/js/bootstrap.min.js"></script>
    <!-- DataTables -->
    <script src="<?php echo $sujpath; ?>plugins/datatables/jquery.dataTables.min.js"></script>
    
    <script src="<?php echo $sujpath; ?>plugins/datatables/dataTables.bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="<?php echo $sujpath; ?>plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="<?php echo $sujpath; ?>plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="<?php echo $sujpath; ?>dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <!--<script src="<?php echo $sujpath; ?>dist/js/demo.js"></script> -->
    <!-- page script -->
    
   <script>
      //$("#example1").DataTable();
    </script>
	<script>
    
    /* $(document).ready(function() {
       
        $('#example1').dataTable({
            "columnDefs": [{
                "visible": false,
                "targets": 0
            }],
            "initComplete": function() {
                $(this).show();
            }
        });
    }); */
      
    /*function datat(){
      alert("Data Deleted Successfully.");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }*/
    /*function datat2(){
      alert("Data Added Successfully");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }*/
    /*function datat3(){
      alert("Updated Successfully");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }*/
	
	 $(document).ready(function(){
    var limit = 10; //The number of records to display per request
 var start = 0; //The starting pointer of the data
 var action = 'inactive'; //Check if current action is going on or not. If not then inactive otherwise active
load_country_data(limit,start);

$("#serc").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#example1 tr").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });

function load_country_data(limite, starte)
 {
  var tfrom=document.getElementById('tfrom').value;
  var tto=document.getElementById('tto').value;
  var tstatus=document.getElementById('tstatus').value;
  $.ajax({
   url:"newajx.php",
   type:"POST",
   data:{limite:limite, starte:starte, tfrom:tfrom, tto:tto, tstatus:tstatus},
   success:function(data)
   {
    $('#load_data').append(data);
    if(data == '')
    {
     $('#load_data_message').html("<button type='button' class='btn btn-info'>No Data Found</button>");
     action = 'active';
    }
    else
    {
     $('#load_data_message').html("<button type='button' class='btn btn-warning'>Please Wait....</button>");
     action = 'inactive';
    }
    
   }
  });
 }

 $(window).scroll(function(){
  if($(window).scrollTop() + $(window).height() > $("#load_data").height() && action == 'inactive')
  {
   action = 'active';
   start = start + limit;
   setTimeout(function(){
    load_country_data(limit, start);
   }, 1000);
  }
 });


    $('#myModaledit').on('show.bs.modal', function (e) {
		
       var taskid = $(e.relatedTarget).data('id');
		
		
        $.ajax({
            type : 'post',
            url : 'fetchforedit.php', //Here you will fetch records 
            data :  {taskid:taskid}, //Pass $id
            success : function(data){
            $("#fetchedit").html(data);//Show fetched data from database
			
            }
        });
     });
     $('#myModal').on('show.bs.modal', function (e) {
    
       var taskid = $(e.relatedTarget).data('id');
    
    var fromemp=$(e.relatedTarget).data('from');
	
    var toemp=$(e.relatedTarget).data('to');
        $.ajax({
            type : 'post',
            url : 'fetchforedit1.php', //Here you will fetch records 
            data :  {taskid:taskid,fromemp:fromemp,toemp:toemp}, //Pass $id
            success : function(data){
            $("#fetchedit1").html(data);//Show fetched data from database
      
            }
        });
     });


});
   </script>    
  </body>
</html>