<?php
session_start();
error_reporting(0);
if(($_SESSION['uniqe_id']=='A') or  ($_SESSION['uniqe_id']=='S') or ($_SESSION['uniqe_id']=='D')){
		include("class.php");
	}

	
	if($_SESSION['uniqe_id']=='U' or $_SESSION['uniqe_id']==NULL)	{
		echo "<script type='text/javascript'>";
		echo "window.location='index.php'";
		echo "</script>";
	}

include_once("database_connection.php");
date_default_timezone_set('Asia/Calcutta');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ImageUpload:productivity</title>
<script language="javascript" type="text/javascript" src="datetimepicker.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--<meta http-equiv="refresh" content="120" url="ge_dashboard.php" />-->


<link href="css/ge_dashboard.css" rel="stylesheet" type="text/css">
 <link type="text/css" href="menu/menu_admin.css" rel="stylesheet" />
 <script language="JavaScript" src="newdate/calendar_us.js"></script>
  <link rel="stylesheet" href="newdate/calendar.css">
    <script type="text/javascript" src="menu/menu.js"></script>
	<style>
	.borderHeader{
	border:1px;
	border-style:solid;
	height:75px;
	background-color:white;
	text-align:center;
	width:100%;
}
.centerimage{
	margin-top:20px;
}
.pagename
{
	text-align:center;
	margin-top:-60px;
	color:#8B0000;
	height:100px;
	
	
}

.airtellogo
{
   margin-top:-42px;

}
#searchbutton  {
	background-color:#228B22;
	color:#FFF;
	padding:5px;
	border-radius:8px;
	font-weight:bold;
}
#searchbutton:hover  {
	background-color:#228B22;
	color:#FFF;
	padding:5px;
	border-radius:8px;
}
#salutation{
	margin-top:-10px;
	text-align:CENTER;

}
/*Footer Container Start*/
#footer-container { width:100%; height:25px; background:#343434; color:#FFFFFF; font-size:15px; text-align:center; padding-top:8px;}
/*Footer Container End*/
  </style>
  
</head>
<body>

<div class="borderHeader">
	<div align=left><img src="images/kmspl.PNG" /></div><div class="pagename"><h2>PRODUCTIVITY DASHBOARD IMAGE UPLOAD </h2></div>
</div>

   <div class="background"> 
   <?php
	
	if(($_SESSION['uniqe_id']=='S'))
	{
	include("menu/menu_superadmin.php");
	}
	if(($_SESSION['uniqe_id']=='A') or ($_SESSION['uniqe_id']=='T'))
	{
	include("menu/menu_admin.php");
	}
	if(($_SESSION['uniqe_id']=='D'))
	{
	include("menu/menu_deo.php");
	}
	else
	{
	}	
	?>
<form action="" method="post" id="view_dashboardscannerdate">

<?php
include("database_connection.php");

if(isset($_POST['txtsubmit']) && $_POST['txtsubmit']=='REFRESH')
  {
   $_SESSION['date']='';
   $_SESSION['app_no']=''; 
}
if(isset($_POST['txtsubmit']) && $_POST['txtsubmit']=='SEARCH')
 {
  	$date=$_POST['date'];
	$_SESSION['date']=$_POST['date'];
	$app_no=$_POST['app_no'];
	$_SESSION['app_no']=$_POST['app_no'];
	
 }
	
	?>
<table>
	<tr height="10">
	<td  height="10">&nbsp;</td>
	</tr>
	</table>
	<table bgcolor="#D2B48C" width="100%" align="center">
	
       <tr>
	   <td align="center" width="90%"><b><font size="4px; height:20px;"> Date</font>&nbsp;<input type="text"   name="date"  id="date" style="background-color:#00FFFF; width:200px; height:35px;" required 
	             value="<?php echo $_SESSION['date'] ;?>" />
		  <script language="JavaScript">

                        new tcal ({

                            // form name

                            'formname': 'view_dashboardscannerdate',

                            // input name

                            'controlname': 'date'

                        });



                    </script>
		 &nbsp;<input type="submit" name="txtsubmit"  value="SEARCH" id="searchbutton" > 
			<input type="submit" name="txtsubmit"  value="REFRESH" id="searchbutton">
			</td>
			</tr>
			
 </table>
<table>
	<tr height="10">
	<td  height="10">&nbsp;</td>
	</tr>
	</table>
<?php
if($date)
{
?>

<table  border="1"  width="90%">
<tr bgcolor="#F4A460">
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS">Image Uploaded By</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4" >08-09AM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">09-10AM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">10-11AM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">11-12PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">12-01PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">01-02PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">02-03PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">03-04PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">04-05PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">05-06PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">06-07PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">07-08PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">08-09PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">09-10PM</font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="4">TOTAL</font></b></td>

</tr>
<?php
$image_uploaddate=$date;

$sqlssrv="select distinct(image_uploadedby) from allocation_tbl where image_uploaddate='$date'  and image_uploadedby!='' order by image_uploadedby asc  " ;
$resultssrv=mysqli_query($conn,$sqlssrv);
while($datassrv=mysqli_fetch_assoc($resultssrv)) {	
		$datas[$i]['image_uploadedby']			= $datassrv['image_uploadedby'] ;
		$i++;
}


foreach($datas as $datas):  
	$image_uploadedby=$datas['image_uploadedby'];
	$sqluser="select first_name,last_name from user_tbl where user_name='$image_uploadedby'";
	$resultuser=mysqli_query($conn,$sqluser);
	$datauser=mysqli_fetch_array($resultuser);
	$image_uploadedbys=$datauser['first_name'].' '.$datauser['last_name'];
	//print_r($scanner_name);
	$sqlsrvcountssrv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$date' " ;
	$resultcountssrv=mysqli_query($conn,$sqlsrvcountssrv);
	$datacountssrv=mysqli_fetch_array($resultcountssrv);
	$ssrv=$datacountssrv[0];
	
	
    $totals=$ssrv;
    $totalst +=$totals;
	
	$time1="08:00 AM";
	$time2="08:59 AM";
	$time3="09:00 AM";
	$time4="09:59 AM";
	$time5="10:00 AM";
	$time6="10:59 AM";
	$time7="11:00 AM";
	$time8="11:59 AM";
	$time9="12:00 PM";
	$time10="12:59 PM";
	$time11="01:00 PM";
	$time12="01:59 PM";
	$time13="02:00 PM";
	$time14="02:59 PM";
	$time15="03:00 PM";
	$time16="03:59 PM";
	$time17="04:00 PM";
	$time18="04:59 PM";
	$time19="05:00 PM";
	$time20="05:59 PM";
	$time21="06:00 PM";
	$time22="06:59 PM";
	$time23="07:00 PM";
	$time24="07:59 PM";
	$time25="08:00 PM";
	$time26="08:59 PM";
	$time27="09:00 PM";
	$time28="10:00 PM";
	
   
    $total=$srv+$sbv;
    $totalt +=$total;
    $sql1srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time1' and '$time2' and image_uploadtime  not like '%PM%' " ;
	$result1srv=mysqli_query($conn,$sql1srv);
	$data1srv=mysqli_fetch_array($result1srv);
    $srv1=$data1srv[0];   
    $time8sam=$srv1;
    
     $sql2srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time3' and '$time4' and image_uploadtime  not like '%PM%' " ;
	$result2srv=mysqli_query($conn,$sql2srv);
	$data2srv=mysqli_fetch_array($result2srv);
    $srv2=$data2srv[0];    
    $time9sam=$srv2;
    
    $sql3srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time5' and '$time6' and image_uploadtime  not like '%PM%'" ;
	$result3srv=mysqli_query($conn,$sql3srv);
	$data3srv=mysqli_fetch_array($result3srv);
    $srv3=$data3srv[0];    
    $time10sam=$srv3;
    
     $sql4srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time7' and '$time8' " ;
	$result4srv=mysqli_query($conn,$sql4srv);
	$data4srv=mysqli_fetch_array($result4srv);
    $srv4=$data4srv[0];    
    $time11sam=$srv4;
    
    $sql5srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time9' and '$time10'  " ;
	$result5srv=mysqli_query($conn,$sql5srv);
	$data5srv=mysqli_fetch_array($result5srv);
    $srv5=$data5srv[0];    
    $time12sam=$srv5;
    
    $sql6srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time11' and '$time12'  " ;
	$result6srv=mysqli_query($conn,$sql6srv);
	$data6srv=mysqli_fetch_array($result6srv);
    $srv6=$data6srv[0];   
    $time1spm=$srv6;
    
    $sql7srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time13' and '$time14' " ;
	$result7srv=mysqli_query($conn,$sql7srv);
	$data7srv=mysqli_fetch_array($result7srv);
    $srv7=$data7srv[0];    
    $time2spm=$srv7;
    
    $sql8srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time15' and '$time16' " ;
	$result8srv=mysqli_query($conn,$sql8srv);
	$data8srv=mysqli_fetch_array($result8srv);
    $srv8=$data8srv[0];    
    $time3spm=$srv8;
    
    $sql9srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time17' and '$time18'   " ;
	$result9srv=mysqli_query($conn,$sql9srv);
	$data9srv=mysqli_fetch_array($result9srv);
    $srv9=$data9srv[0];    
    $time4spm=$srv9;
    
    $sql10srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time19' and '$time20'  " ;
	$result10srv=mysqli_query($conn,$sql10srv);
	$data10srv=mysqli_fetch_array($result10srv);
    $srv10=$data10srv[0];    
    $time5spm=$srv10;
    
    $sql11srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time21' and '$time22' and  image_uploadtime not like '%AM%' " ;
	$result11srv=mysqli_query($conn,$sql11srv);
	$data11srv=mysqli_fetch_array($result11srv);
    $srv11=$data11srv[0];    
    $time6spm=$srv11;
    
    $sql12srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time23' and '$time24' and  image_uploadtime not like '%AM%' " ;
	$result12srv=mysqli_query($conn,$sql12srv);
	$data12srv=mysqli_fetch_array($result12srv);
    $srv12=$data12srv[0];    
    $time7spm=$srv12;
    
    $sql13srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time25' and '$time26' and  image_uploadtime not like '%AM%' " ;
	$result13srv=mysqli_query($conn,$sql13srv);
	$data13srv=mysqli_fetch_array($result13srv);
    $srv13=$data13srv[0];    
    $time8spm=$srv13;
    
    $sql14srv="select count(id) as num from allocation_tbl where image_uploadedby='$image_uploadedby' and 
	image_uploaddate='$image_uploaddate' and image_uploadtime between '$time27' and '$time28' and  image_uploadtime not like '%AM%' " ;
	$result14srv=mysqli_query($conn,$sql14srv);
	$data14srv=mysqli_fetch_array($result14srv);
    $srv14=$data14srv[0];    
    $time9spm=$srv14;
    
    $time8samt +=$time8sam;
    $time9samt +=$time9sam;
    $time10samt +=$time10sam;
    $time11samt +=$time11sam;
    $time12samt +=$time12sam;
    $time1spmt +=$time1spm;
    $time2spmt +=$time2spm;
    $time3spmt +=$time3spm;
    $time4spmt +=$time4spm;
    $time5spmt +=$time5spm;
    $time6spmt +=$time6spm;
    $time7spmt +=$time7spm;
    $time8spmt +=$time8spm;
    $time9spmt +=$time9spm;
    
    $curtime=date('h:i A');
    $tt=strtotime($curtime);
    $t8=strtotime($time1);
    $t9=strtotime($time3);
    $t10=strtotime($time5);
    $t11=strtotime($time7);
    $t12=strtotime($time9);
    $t1=strtotime($time11);
    $t2=strtotime($time13);
    $t3=strtotime($time15);
    $t4=strtotime($time17);
    $t5=strtotime($time19);
    $t6=strtotime($time21);
    $t7=strtotime($time23);
    $t8p=strtotime($time25);
    $t9p=strtotime($time27);
    
    
    
    $bgs8="white";
    $fs8="#191970";
    
    
    $bgs9="white";
    $fs9="#191970";
    
    
    $bgs10="white";
    $fs10="#191970";
    
    
    
    $bgs11="white";
    $fs11="#191970";
    
    $bg12="white";
    $fs12="#191970";
    
    $bgs1="white";
    $fs1="#191970";
    
    $bgs2="white";
    $fs2="#191970";
   
    $bgs3="white";
    $fs3="#191970";
    
    $bgs4="white";
    $fs4="#191970";
   
    $bgs5="white";
    $fs5="#191970";
    
    $bgs6="white";
    $fs6="#191970";
    
    $bg7="white";
    $fs7="#191970";
    
    $bgs8p="white";
    $fs8p="#191970";
    
    $bgs9p="white";
    $fs9p="#191970";
    
    if($time8sam>0)
	{
	$time8sam=$time8sam;
	}
	else
	{
	$time8sam="";
	}
    if($time9sam>0)
	{
	$time9sam=$time9sam;
	}
	else
	{
	$time9sam="";
	}
	if($time10sam>0)
	{
	$time10sam=$time10sam;
	}
	else
	{
	$time10sam="";
	}
	if($time11sam>0)
	{
	$time11sam=$time11sam;
	}
	else
	{
	$time11sam="";
	}
	if($time12sam>0)
	{
	$time12sam=$time12sam;
	}
	else
	{
	$time12sam="";
	}
	if($time1spm>0)
	{
	$time1spm=$time1spm;
	}
	else
	{
	$time1spm="";
	}
	if($time2spm>0)
	{
	$time2spm=$time2spm;
	}
	else
	{
	$time2spm="";
	}
	if($time3spm>0)
	{
	$time3spm=$time3spm;
	}
	else
	{
	$time3spm="";
	}
	if($time4spm>0)
	{
	$time4spm=$time4spm;
	}
	else
	{
	$time4spm="";
	}
	if($time5spm>0)
	{
	$time5spm=$time5spm;
	}
	else
	{
	$time5spm="";
	}
	if($time6spm>0)
	{
	$time6spm=$time6spm;
	}
	else
	{
	$time6spm="";
	}
	if($time7spm>0)
	{
	$time7spm=$time7spm;
	}
	else
	{
	$time7spm="";
	}
	if($time8spm>0)
	{
	$time8spm=$time8spm;
	}
	else
	{
	$time8spm="";
	}
	if($time9spm>0)
	{
	$time9spm=$time9spm;
	}
	else
	{
	$time9spm="";
	}
	$dir=$date.'//'.$image_uploadedby;
 if($totals >0)
 {
?>
<tr>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS"><?php echo strtoupper($image_uploadedbys);?></font></b></td>

<td align="center" height="20" bgcolor="<?php echo $bgs8 ; ?>"><font color="<?php echo $fs8 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time8sam;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs9 ; ?>"><font color="<?php echo $fs9 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time9sam;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs10 ; ?>"><font color="<?php echo $fs10 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time10sam;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs11 ; ?>"><font color="<?php echo $fs11 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time11sam;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs12 ; ?>"><font color="<?php echo $fs12 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time12sam;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs1 ; ?>"><font color="<?php echo $fs1 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time1spm;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs2 ; ?>"><font color="<?php echo $fs2 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time2spm;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs3 ; ?>"><font color="<?php echo $fs3 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time3spm;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs4 ; ?>"><font color="<?php echo $fs4 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time4spm;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs5 ; ?>"><font color="<?php echo $fs5 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time5spm;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs6 ; ?>"><font color="<?php echo $fs6 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time6spm;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs7 ; ?>"><font color="<?php echo $fs7 ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time7spm;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs8p ; ?>"><font color="<?php echo $fs8p ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time8spm;?></b></font></td>
<td align="center" height="20" bgcolor="<?php echo $bgs9p ; ?>"><font color="<?php echo $fs9p ; ?>" font-family="Trebuchet MS" font size="5"><b><?php echo $time9spm;?></b></font></td>
<td align="center" height="20"><a href="" onClick="window.open('imageuploadreport.php?id=<?php echo "$dir"; ?>','popup','width=950,height=500,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=center,menubar=no,status=no,left=100,top=100'); return false"><font color="#191970" font size="5"><b><?php echo $totals;?></b></font></a></td>
</tr>
<?php  }
endforeach;?>
<tr bgcolor="#F4A460">
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5">TOTAL</b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time8samt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time9samt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time10samt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time11samt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time12samt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time1spmt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time2spmt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time3spmt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time4spmt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time5spmt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time6spmt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time7spmt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time8spmt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $time9spmt;?></font></b></td>
<td align="center" height="20"><b><font color="#191970" font-family="Trebuchet MS" font size="5"><?php echo $totalst;?></font></b></td>
</tr>
</table>
<?php
}
else
{
}
?>
</table>
</div>
<div style="clear:both; float:none;" class="clear">
</div>
<table>
<tr height="50">
<td height="50">&nbsp;</td>
</tr>
</table>

</div>

	</div>	
	<div id="x"></div>	
</body>
</html>
