<?php 
 session_start();
 ob_start();
 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">
    <!-- 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">
    <!-- iCheck -->
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <link href="assets/css/style2.css" rel="stylesheet" />
    <script>
    function transfer_all(){
             var taskfrom = $('#taskfrom').val();
             var taskto = $('#taskto').val();
             
             if(taskfrom == ''){
                alert("Select Employee");   	
             } else if(taskto == ''){
             	alert("Select Employee");
             } else {                    
                  $.ajax({
                    type: "POST",
                    url: "ajaxmarket.php",
                     data: {
                          transfer_all    : 1,
                          taskfrom        : taskfrom,
                          taskto          : taskto                         
                     },
                     cache: true,
                     success: function(res23)
                     {
                     	    alert("Todo Transfer Completed");
                     	   	$('#taskfrom').val('');
                     	   	$('#taskto').val('');
                     	   window.location.href='index.php';
                           	                    
                      }
                   }); 
    	    }
        }
    </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 Manager 
          <small>- Control panel</small> 
          </h1>  
          <ol class="breadcrumb">
          <li><a href="../index.php"><i class="fa fa-dashboard"></i> Main Home</a></li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
        <!-- Small boxes (Stat box) -->
        <!-- small box -->
             <div class="col-lg-4">
                  <div class="panel panel-default">
                  	<?php
                  	$sqq = mysqli_query($con, "SELECT id FROM `employee_registration` WHERE `status`='1' ");
                  	$total_sta = mysqli_num_rows($sqq);
                  	?>
                       <div class="panel-heading">
                            <i class="fa fa-bell fa-fw"></i> Notifications Panel <span style="color: red;">( Staff - <?php echo $total_sta; ?>)</span>
                        </div>
                        <div class="panel-body" style=" min-height: 330px;">
                            <div class="list-group">
                           <?php
                          
                            $sjsel1 = mysqli_query($con, "SELECT DISTINCT `t_to` FROM `p_task` ");
						    while($sjrs1 = mysqli_fetch_array($sjsel1)){
						   	$empto = $sjrs1['t_to'];
							$sjsel2 = mysqli_query($con, "SELECT emp_name FROM `employee_registration` WHERE `id`='$empto' AND `status`='1' ");
							$stff_count = mysqli_num_rows($sjsel2);
							if($stff_count != '0'){
							
							$sjrs2 = mysqli_fetch_array($sjsel2);  
							
							$sjsel3 = mysqli_query($con, "SELECT COUNT(`tid`) AS tottask FROM `p_task` WHERE `t_to`='$empto' AND `t_status`='0'");
							$sjrs3  = mysqli_fetch_array($sjsel3);
							
							$sjsel4 = mysqli_query($con, "SELECT COUNT(`tid`) AS tottask FROM `p_task` WHERE `t_to`='$empto' AND `t_status`='1'");
							$sjrs4  = mysqli_fetch_array($sjsel4);
							 $ttoday = date('Y-m-d'); 
							$sjsel5 = mysqli_query($con, "SELECT COUNT(`tid`) AS tottask FROM `p_task` WHERE `t_to`='$empto' AND `t_status`='0' AND `t_dat`='$ttoday'");
							$sjrs5  = mysqli_fetch_array($sjsel5);
							
							$sjsel6 = mysqli_query($con, "SELECT COUNT(`tid`) AS tothold FROM `p_task` WHERE `t_to`='$empto' AND `t_status`!='1' AND `t_status`='3' ");
							$sjrs6  = mysqli_fetch_array($sjsel6);
							
							$sjsel7 = mysqli_query($con, "SELECT COUNT(`tid`) AS tothold FROM `p_task` WHERE `t_to`='$empto' AND `t_status`!='1' AND `remind_set`!='' ");
							$sjrs7  = mysqli_fetch_array($sjsel7);
							
                           ?> 	
                                <a href="task_register.php?tfrom=&tto=<?php echo $empto; ?>&tstatus=All" class="list-group-item">
                                    <?php echo $sjrs2['emp_name']; ?> 
                                    <span class="pull-right text-muted small">
                                    	<!--<small class="label label-danger" ><?php echo $sjrs3['tottask']; ?></small> -->
                                    	<small class="label" style="background: #DAA520;" >
                                    	<?php echo $sjrs3['tottask']; ?></small>
                                    	
                                    	<small class="label" style="background: red;" >
                                    	<?php echo $sjrs4['tottask']; ?></small>  
                                    	
                                    	<small class="label" style="background: #FF1493;" >
                                    	<?php echo $sjrs5['tottask']; ?></small>
                                    	
                                    	<small class="label" style="background: #2E8B57;" >
                                    	<?php echo $sjrs6['tothold']; ?></small>
                                    	
                                    	<small class="label" style="background: #8B4513;" >
                                    	<?php echo $sjrs7['tothold']; ?></small>
                                    	  
                                    </em>
                                    </span>
                                </a>
                            <?php }  } ?>  
                                
                            </div>
                        </div>
                        
                    </div>
                  
		
		<div style="width: 10px; height: 10px; background: #DAA520;float: left;margin-left: 4px;" ></div><span style="float: left; line-height: 10px;"> &nbsp; Open</span>       
		<div style="width: 10px; height: 10px; background: red;float: left;margin-left: 27px;" ></div><span style="float: left; line-height: 10px;"> &nbsp; Closed</span> 
		<div style="width: 10px; height: 10px; background: #FF1493;float: left; margin-left: 27px;" ></div><span style="float: left;line-height: 10px;"> &nbsp; Todays Todo</span> 
		<br>
		<div style="width: 10px; height: 10px; background: #2E8B57;float: left; margin-left: 4px;" ></div><span style="float: left;line-height: 10px;"> &nbsp; Hold</span>
		
		<div style="width: 10px; height: 10px; background: #8B4513;float: left; margin-left: 29px;" ></div><span style="float: left;line-height: 10px;"> &nbsp; Reminder</span>
		
		<br>
          </div>
        
     <?php
     $sq1 = mysqli_query($con, "SELECT COUNT(*) AS tottask FROM `p_task` ");
     $rs1 = mysqli_fetch_array($sq1);
     ?>   
        <div class="row" style="  margin-top: 25px; ">
        	
               <div class="col-md-3 col-sm-3 col-xs-6">
                    <div class="dashboard-div-wrapper bk-clr-one">
                       <i  class="fa fa-desktop dashboard-div-icon" ></i>
                       <div class="progress progress-striped active">
  <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%">
  </div>
  </div>
                       <h5>Total Task (<b><?php echo $rs1['tottask']; ?></b>)</h5>
                    </div>
                </div>
        <?php
     $ttoday = date('Y-m-d');   
     $sq2 = mysqli_query($con, "SELECT COUNT(*) AS todaytask FROM `p_task` WHERE `t_dat`='$ttoday' ");
     $rs2 = mysqli_fetch_array($sq2);
     ?>         
                
                 <div class="col-md-3 col-sm-3 col-xs-6" >
                    <div class="dashboard-div-wrapper bk-clr-two">
                        <i  class="fa fa-edit dashboard-div-icon" ></i>
                        <div class="progress progress-striped active">
  <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width: 70%">
  </div>
                           
</div>
                         <h5>Todays Follow ups (<b><?php echo $rs2['todaytask']; ?></b>)</h5>
                    </div>
                </div>
     <?php           
          $sq3 = mysqli_query($con, "SELECT COUNT(*) AS pendtask FROM `p_task` WHERE `t_status`='0' ");
          $rs3 = mysqli_fetch_array($sq3);
     ?>		      
                 <div class="col-md-3 col-sm-3 col-xs-6">
                    <div class="dashboard-div-wrapper bk-clr-three">
                        <i  class="fa fa-file-pdf-o dashboard-div-icon" ></i>
                        <div class="progress progress-striped active">
  <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
  </div>
                           
</div>
                         <h5>Pending Task (<b><?php echo $rs3['pendtask']; ?></b>)</h5>
                    </div>
                </div>
                <?php           
          $sq4 = mysqli_query($con, "SELECT COUNT(*) AS clostask FROM `p_task` WHERE `t_status`='1' ");
          $rs4 = mysqli_fetch_array($sq4);
     ?>	
                <div class="col-md-3 col-sm-3 col-xs-6" >
                    <div class="dashboard-div-wrapper bk-clr-four">
                        <i  class="fa fa-users dashboard-div-icon" ></i>
                        <div class="progress progress-striped active">
  <div class="progress-bar progress-bar-primary" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%">
  </div>
                           
</div>
                         <h5>Closed Task (<b><?php echo $rs4['clostask']; ?></b>)</h5>
                    </div>
                </div>
                
         <?php           
          $sq5 = mysqli_query($con, "SELECT COUNT(*) AS remtask FROM `p_task` WHERE `t_status`!='1' AND `remind_set`!='' ");
          $rs5 = mysqli_fetch_array($sq5);
         ?>        
                <div class="col-md-3 col-sm-3 col-xs-6" >
                    <div class="dashboard-div-wrapper bk-clr-five">
                        <i  class="fa fa-bell-o dashboard-div-icon" ></i>
                        <div class="progress progress-striped active">
  <div class="progress-bar progress-bar-primary" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%">
  </div>
                         </div>
                         <h5>Reminders (<b><?php echo $rs5['remtask']; ?></b>)</h5>
                    </div>
                </div>
                
          <?php           
          $sq6 = mysqli_query($con, "SELECT COUNT(*) AS holdtask FROM `p_task` WHERE `t_status`='3' AND `t_status`!='1' ");
          $rs6 = mysqli_fetch_array($sq6);
         ?>  
               
                  <div class="col-md-3 col-sm-3 col-xs-6" >
                    <div class="dashboard-div-wrapper bk-clr-six">
                        <i  class="fa fa-lock dashboard-div-icon" ></i>
                        <div class="progress progress-striped active">
  <div class="progress-bar progress-bar-primary" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%">
  </div>
                         </div>
                         <h5>Hold Task (<b><?php echo $rs6['holdtask']; ?></b>)</h5>
                    </div>
                </div>
                
                
                
                <div class="col-lg-6">
                  <div class="panel panel-default">
                     <div class="panel-heading">
                            <i class="fa fa-bell fa-fw"></i> Transfer 
                        </div>
                        <div class="panel-body" style=" min-height: 100px;">
                            <div class="list-group"> 
                
                     
  <div class="col-md-5"  style=" padding-left: 2px; padding-right: 0px; ">			
 <div class="form-group">
  <select class="form-control" id="taskfrom" name="taskfrom" >
  	<option value=""> Transfer 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_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-5"  style=" padding-left: 2px; padding-right: 0px; ">			
 <div class="form-group">
  <select class="form-control" id="taskto" name="taskto" >
  	<option value="">Transfer 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 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="Transfer" onclick="transfer_all();" style=" float: right;margin-right: 5px; " /> 
 </div>
 </div>          
                
                
                   </div></div></div></div>
                
                
                
                
                
                
                
                
              </div>
        
        
        
        
        
        
        
        
     
          <!-- Main row -->



        </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>
    <!-- Morris.js charts -->
    <script src="<?php echo $sujpath; ?>dist/js/app.min.js"></script>
  </body>
</html>
