<?php require_once('../Connections/oprmConn.php'); include('check-admin-session.php'); 

if(isset($_GET['week'])){
//get ipaddress
mysql_select_db($database_oprmConn, $oprmConn);
$query_getipaddr = "SELECT  * FROM weby_timesheets WHERE task_week = '$_GET[week]' and task_year = '$_GET[year]' and user_id = '$_GET[uid]' and status in ('A', 'Q', 'I') ORDER BY created_date ASC";
$getipaddr = mysql_query($query_getipaddr, $oprmConn) or die(mysql_error());
$row_getipaddr = mysql_fetch_assoc($getipaddr);
$totalRows_getipaddr = mysql_num_rows($getipaddr);

mysql_select_db($database_oprmConn, $oprmConn);
$query_getWeek = "SELECT  DISTINCT (project_id) FROM weby_timesheets WHERE task_week = '$_GET[week]' and task_year = '$_GET[year]' and user_id = '$_GET[uid]' and status in ('A', 'Q', 'I') ORDER BY project_id ASC";

$getWeek = mysql_query($query_getWeek, $oprmConn) or die(mysql_error());

$row_getWeek = mysql_fetch_assoc($getWeek);

$totalRows_getWeek = mysql_num_rows($getWeek);

}



if(isset($_POST['submit'])){



$count = $_POST['cnt'];



$i=0;



$week_number = $_POST['week'];



$year = $_POST['year'];

$puid = $_POST['uid'];

$status = $_POST['status'];



for($m = 0; $m <= $count; $m++){



if($m > 0){



	$varprj = "project".$m;



	



	}



	else if($m == 0){



	 $varprj = "project";



	}



	$project = $_POST[$varprj];



	for($w=1; $w<=7; $w++){



		 $dtt = date('Y-m-d', strtotime($year."W".$week_number.$w));



	if($m > 0){



	

		$vart1 = "total_hrs".$w.$m;		



	}



	else if($m == 0){



		$vart1 = "total_hrs".$w;

	}

$total_hrs= $_POST[$vart1];

$pt = $project;

$user_id = $_SESSION['user_id'];

$token = rand(15420,999898);

//echo $total_hrs.'<br>'.$status.'<br>'.$week_number.'<br>'.$year.'<br>'.$pt.'<br>'.$puid.'<br>'.$count.'<br>'.$dtt.'<br>';

mysql_select_db($database_oprmConn, $oprmConn);					

$query_Recordset1 = "UPDATE weby_timesheets SET total_hrs = '$total_hrs', status = '$status', updated_by = '$user_id', token = '$token' WHERE task_week = '$week_number' AND task_year = '$year' AND created_date = '$dtt' AND status in ('A', 'Q', 'I') AND project_id = '$pt' AND user_id = '$puid'"; 



$Recordset1 = mysql_query($query_Recordset1, $oprmConn) or die(mysql_error());

	mysql_select_db($database_oprmConn, $oprmConn);

$q = "select max(timesheet_id) as tid FROM weby_timesheets where user_id = '$puid' and task_week = '$week_number' and task_year = '$year' and status = '$status'";

$query_getProj12 = $q;

$getProj12 = mysql_query($query_getProj12, $oprmConn) or die(mysql_error());

$row_getTime12 = mysql_fetch_assoc($getProj12);

$totalRows_getProj12 = mysql_num_rows($getProj12);

/**************************************************************************************************/
mysql_select_db($database_oprmConn, $oprmConn);
$query_gettotalhrs = "SELECT SUM(`total_hrs`) FROM weby_timesheets,weby_projects WHERE weby_timesheets.status IN ('A','Q', 'I') AND weby_timesheets.task_year = '$year' AND weby_timesheets.task_week = '$week_number' AND weby_timesheets.user_id = '$puid' AND weby_timesheets.project_id=weby_projects.projetc_id GROUP BY weby_timesheets.user_id,weby_timesheets.task_week";
$gettotalhrs = mysql_query($query_gettotalhrs, $oprmConn) or die(mysql_error());
$row_gettotalhrs = mysql_fetch_assoc($gettotalhrs);
$totalRows_gettotalhrs = mysql_num_rows($gettotalhrs);
$totalprojhrs = $row_gettotalhrs['SUM(`total_hrs`)'].' hrs';
mysql_select_db($database_oprmConn, $oprmConn);
$query_getProjects = "SELECT weby_projects.project_name,SUM(`total_hrs`) FROM weby_timesheets,weby_projects WHERE weby_timesheets.status IN ('A','Q', 'I') AND weby_timesheets.task_year = '$year' AND weby_timesheets.task_week = '$week_number' AND weby_timesheets.user_id = '$puid' AND weby_timesheets.project_id=weby_projects.projetc_id GROUP BY weby_timesheets.user_id,weby_timesheets.task_week,weby_timesheets.project_id ORDER BY weby_projects.project_name ASC";
$getProjects = mysql_query($query_getProjects, $oprmConn) or die(mysql_error());
$row_getProjects = mysql_fetch_assoc($getProjects);
$totalRows_getProjects = mysql_num_rows($getProjects); $i=1;
do{ $projnames = $projnames.$i.'. '.$row_getProjects['project_name'].' ('.$row_getProjects['SUM(`total_hrs`)'].' hrs), '; $i++;
}while($row_getProjects = mysql_fetch_assoc($getProjects));
/**************************************************************************************************/

$tid = $row_getTime12['tid'];
mysql_select_db($database_oprmConn, $oprmConn);



$q = "SELECT weby_profiles.full_name,weby_timesheets.created_date, weby_timesheets.timesheet_id, weby_timesheets.project_id, weby_timesheets.total_hrs, weby_timesheets.hr_rate, weby_timesheets.total_amount, weby_timesheets.status, weby_timesheetstatus.status_label, weby_projects.project_name, weby_users.email_address FROM weby_timesheets, weby_profiles, weby_projects , weby_users, weby_timesheetstatus WHERE weby_timesheets.timesheet_id = '$tid' and weby_timesheets.user_id = weby_profiles.user_id and weby_users.user_id = weby_profiles.user_id AND weby_profiles.user_id =weby_timesheets.user_id AND weby_projects.projetc_id = weby_timesheets.project_id and weby_timesheetstatus.status_key = weby_timesheets.status";



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProj = $q;



$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());



$row_getTime = mysql_fetch_assoc($getProj);



$totalRows_getProj = mysql_num_rows($getProj);



 $s = $row_getTime['status_label'];



 $d = date('d/m/Y', strtotime($row_getTime['created_date']));


require_once('timesheet-view-mail.php');

	


	

$l = "timesheet-all.php?msg1";

header("Location: $l");

			

}

//}

}

}

if (!function_exists("GetSQLValueString")) {



function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 



{



  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;



  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);



  switch ($theType) {



    case "text":



      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";



      break;    



    case "long":



    case "int":



      $theValue = ($theValue != "") ? intval($theValue) : "NULL";



      break;



    case "double":



      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";



      break;



    case "date":



      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";



      break;



    case "defined":



      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;



      break;



  }



  return $theValue;



}



}



$maxRows_getRes = 2;



$pageNum_getRes = 0;



if (isset($_GET['pageNum_getRes'])) {



  $pageNum_getRes = $_GET['pageNum_getRes'];



}



$startRow_getRes = $pageNum_getRes * $maxRows_getRes;



mysql_select_db($database_oprmConn, $oprmConn);



$query_getRes = "SELECT weby_users.user_id, weby_users.email_address, weby_users.caeated_date, weby_profiles.profile_id, weby_profiles.full_name, weby_profiles.job_title, weby_profiles.skill_set, weby_profiles.profile_pic FROM weby_users, weby_profiles WHERE weby_users.status = 'P' AND weby_profiles.user_id = weby_users.user_id";



$query_limit_getRes = sprintf("%s LIMIT %d, %d", $query_getRes, $startRow_getRes, $maxRows_getRes);



$getRes = mysql_query($query_limit_getRes, $oprmConn) or die(mysql_error());



$row_getRes = mysql_fetch_assoc($getRes);



if (isset($_GET['totalRows_getRes'])) {



  $totalRows_getRes = $_GET['totalRows_getRes'];



} else {



  $all_getRes = mysql_query($query_getRes);



  $totalRows_getRes = mysql_num_rows($all_getRes);



}



$totalPages_getRes = ceil($totalRows_getRes/$maxRows_getRes)-1;



$maxRows_getRes1 = 2;



$pageNum_getRes1 = 0;



if (isset($_GET['pageNum_getRes1'])) {



  $pageNum_getRes1 = $_GET['pageNum_getRes1'];



}



$startRow_getRes1 = $pageNum_getRes1 * $maxRows_getRes1;



mysql_select_db($database_oprmConn, $oprmConn);



//$query_getRes1 = "SELECT weby_users.user_id, weby_users.email_address, weby_users.caeated_date, weby_profiles.profile_id, weby_profiles.full_name, weby_profiles.job_title, weby_profiles.skill_set, weby_profiles.profile_pic, weby_profiles.cv_file FROM weby_users, weby_profiles, weby_timesheets WHERE weby_users.status = 'A' AND weby_profiles.user_id = weby_users.user_id and  weby_users.user_id = weby_timesheets.user_id and weby_timesheets.timesheet_id = '$_REQUEST[timesheetid]'";

$query_getRes1 = "SELECT weby_users.user_id, weby_users.email_address, weby_users.caeated_date, weby_profiles.profile_id, weby_profiles.full_name, weby_profiles.job_title, weby_profiles.skill_set, weby_profiles.profile_pic FROM weby_users, weby_profiles WHERE weby_profiles.status = 'A' AND weby_users.status = 'A' AND weby_users.user_role <> 1 AND weby_profiles.user_id = weby_users.user_id order by weby_profiles.profile_id desc";

$query_limit_getRes1 = sprintf("%s LIMIT %d, %d", $query_getRes1, $startRow_getRes1, $maxRows_getRes1);



$getRes1 = mysql_query($query_limit_getRes1, $oprmConn) or die(mysql_error());



$row_getRes1 = mysql_fetch_assoc($getRes1);



if (isset($_GET['totalRows_getRes1'])) {



  $totalRows_getRes1 = $_GET['totalRows_getRes1'];



} else {



  $all_getRes1 = mysql_query($query_getRes1);



  $totalRows_getRes1 = mysql_num_rows($all_getRes1);



}



$totalPages_getRes1 = ceil($totalRows_getRes1/$maxRows_getRes1)-1;



mysql_select_db($database_oprmConn, $oprmConn);



$query_timesheetVie = "SELECT weby_timesheets.total_hrs, weby_timesheets.hr_rate, weby_timesheets.total_amount, weby_timesheets.taks_details, weby_timesheets.status, weby_projects.projetc_id, weby_projects.project_name, weby_projects.project_description, weby_timesheets.created_by, weby_timesheets.updated_date, weby_timesheets.timesheet_id, weby_timesheetstatus.status_label FROM weby_timesheets, weby_projects, weby_timesheetstatus WHERE weby_timesheets.timesheet_id = '$_REQUEST[timesheetid]' AND weby_projects.projetc_id = weby_timesheets.project_id AND weby_timesheetstatus.status_key = weby_timesheets.status";



$timesheetVie = mysql_query($query_timesheetVie, $oprmConn) or die(mysql_error());



$row_timesheetVie = mysql_fetch_assoc($timesheetVie);



$totalRows_timesheetVie = mysql_num_rows($timesheetVie);



mysql_select_db($database_oprmConn, $oprmConn);



$query_getUserDet = "SELECT weby_profiles.full_name, weby_profiles.job_title, weby_profiles.skill_set, weby_profiles.profile_id, weby_profiles.cv_file, weby_profiles.profile_pic FROM weby_profiles, weby_timesheets WHERE weby_profiles.user_id =  weby_timesheets.user_id AND weby_timesheets.timesheet_id = '$_REQUEST[timesheetid]'";



$getUserDet = mysql_query($query_getUserDet, $oprmConn) or die(mysql_error());



$row_getUserDet = mysql_fetch_assoc($getUserDet);



$totalRows_getUserDet = mysql_num_rows($getUserDet);



mysql_select_db($database_oprmConn, $oprmConn);



$query_getTmSt = "SELECT * FROM weby_timesheetstatus where status='A'";



$getTmSt = mysql_query($query_getTmSt, $oprmConn) or die(mysql_error());



$row_getTmSt = mysql_fetch_assoc($getTmSt);



$totalRows_getTmSt = mysql_num_rows($getTmSt);



?><!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>



<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />



<title>SS WEB TECHNOLOGIES - Tool-Admin Timesheet View</title>



<link rel="stylesheet" href="../css/style.css" type="text/css">



    <!-- IE Fix for HTML5 Tags -->



    <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> 



	<![endif]-->

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>



<script src="//code.jquery.com/jquery-1.10.2.js"></script>



<script src="//code.jquery.com/ui/1.9.1/jquery-ui.js"></script>



<script src="../js/jquery.flexslider.js"></script>



<script language="JavaScript">



function setVisibility(id, visibility) {



document.getElementById(id).style.display = visibility;



}



</script>



<script language="JavaScript">



//function addItem(div)



//{



//for(var i = 0; i < 3; i++) {



//var ediv=document.getElementById(div);



//var temp=ediv.innerHTML;



//var newdiv = document.createElement('div');



//var divIdName=div+i;//i hav taken 1 for sample for adding id to the div



//newdiv.setAttribute('id',divIdName);



//newdiv.innerHTML =temp;



//ediv.appendChild(newdiv);



//}



//cnt}



window.gcount = 0;



jQuery(function($){



	var $repeater0 = $('#repeater0');



	var $project = $('#project');



	var $selectproj = $('#selectproj');



	var $field_item = $('#field_item');



	//var $cproject = $('#cproject');



	var total_hrs1 = $('#total_hrs1');



	var total_hrs2 = $('#total_hrs2');



	var total_hrs3 = $('#total_hrs3');



	var total_hrs4 = $('#total_hrs4');



	var total_hrs5 = $('#total_hrs5');



	var total_hrs6 = $('#total_hrs6');



	var total_hrs7 = $('#total_hrs7');



	$('#addemail').click(function(e){



		e.preventDefault();



		if(gcount != 0){



		//var cprojecto = 'cproject' + gcount;



		var field_itemido = 'field_item' + gcount;



		var projectido = 'project' + gcount;



		var total_hrs1o = 'total_hrs1' + gcount;



		var total_hrs2o = 'total_hrs2' + gcount;



		var total_hrs3o = 'total_hrs3' + gcount;



		var total_hrs4o = 'total_hrs4' + gcount;



		var total_hrs5o = 'total_hrs5' + gcount;



		var total_hrs6o = 'total_hrs6' + gcount;



		var total_hrs7o = 'total_hrs7' + gcount;



		var ro = 'repeater0' + gcount;



		var $repeatero = $('#'+ro);



	}



		else{



		var field_itemido = 'field_item';



		//var cprojecto = 'cproject';



		var projectido = 'project';



		var total_hrs1o = 'total_hrs1';



		var total_hrs2o = 'total_hrs2';



		var total_hrs3o = 'total_hrs3';



		var total_hrs4o = 'total_hrs4';



		var total_hrs5o = 'total_hrs5';



		var total_hrs6o = 'total_hrs6';



		var total_hrs7o = 'total_hrs7';



		var ro = 'repeater0';



		var $repeatero = $('#'+ro);



	



		}



		



		var count = gcount + 1;



		



		gcount = count;



		if(count > <?php echo ($totalRows_getTotalproj-1);?>){



			alert("That's enough already!");



			return;



		}



		var idname = 'repeater0' + count;



		//var pidname = 'project' + (++count);



		var field_itemid = 'field_item' + count;



		//var cprojectid = 'cproject' + count;



		var projectid = 'project' + count;



		var selectprojid = 'selectproj' + count;



		var total_hrs1id = 'total_hrs1' + count;



		var total_hrs2id = 'total_hrs2' + count;



		var total_hrs3id = 'total_hrs3' + count;



		var total_hrs4id = 'total_hrs4' + count;



		var total_hrs5id = 'total_hrs5' + count;



		var total_hrs6id = 'total_hrs6' + count;



		var total_hrs7id = 'total_hrs7' + count;

		

		//alert(count);



		//$repeater0.html( parseInt($repeater0.html()) + 1 )



		//$repeater0.parent().append($repeater0.clone().attr({id: idname}));



		



		try{



		$repeater0.append($repeatero.clone().attr({id: idname}));



		



		$repeater = $("body").find('#'+idname);



		$repeater.find('#'+field_itemido).attr('name', field_itemid);



		$repeater.find('#'+field_itemido).attr('id', field_itemid);



		



		//$repeater.find('#'+cprojecto).attr('checked', 'checked');



		//$repeater.find('#'+cprojecto).attr('name', cprojectid);



		//$repeater.find('#'+cprojecto).attr('id', cprojectid);



		$repeater.find('#'+projectido).attr('name', projectid);



		$repeater.find('#'+projectido).attr('id', projectid);



		$repeater.find('#'+total_hrs1o).attr('name', total_hrs1id);



		$repeater.find('#'+total_hrs1o).attr('id', total_hrs1id);

		

		$repeater.find('#'+total_hrs2o).attr('name', total_hrs2id);



		$repeater.find('#'+total_hrs2o).attr('id', total_hrs2id);

		

		$repeater.find('#'+total_hrs3o).attr('name', total_hrs3id);



		$repeater.find('#'+total_hrs3o).attr('id', total_hrs3id);



		$repeater.find('#'+total_hrs4o).attr('name', total_hrs4id);



		$repeater.find('#'+total_hrs4o).attr('id', total_hrs4id);



		$repeater.find('#'+total_hrs5o).attr('name', total_hrs5id);



		$repeater.find('#'+total_hrs5o).attr('id', total_hrs5id);



		$repeater.find('#'+total_hrs6o).attr('name', total_hrs6id);



		$repeater.find('#'+total_hrs6o).attr('id', total_hrs6id);



		$repeater.find('#'+total_hrs7o).attr('name', total_hrs7id);



		$repeater.find('#'+total_hrs7o).attr('id', total_hrs7id);



		



		



		}catch(err){alert(err);}



		



		



		//$('#repeater0').html(function(count, id) { return +id+1 });



	});



	



});



	jQuery(function($){



	$('#removeButton').click(function(e){



		e.preventDefault();



		var count = gcount;



		



		if(count == 0){



			alert("Can not remove all projects!");



			return;



		}



		else



		{



			



		



		gcount = count - 1;



	



		var idname = 'repeater0' + count;



		//var pidname = 'project' + (++count);



		



		//alert(count);



		//$repeater0.html( parseInt($repeater0.html()) + 1 )



		//$repeater0.parent().append($repeater0.clone().attr({id: idname}));



		



		try{



		



		$('#'+idname).remove();



		}catch(err){alert(err);}



		



		



		



		}



		//$('#repeater0').html(function(count, id) { return +id+1 });



	});



	



});



	



</script>



<script language="JavaScript">



function setVisibility(id, visibility) {



document.getElementById(id).style.display = visibility;



}



</script>

<script type='text/javascript'>



function redirect(){



var week = document.getElementById('week').options[document.getElementById('week').selectedIndex].value;



var year = document.getElementById('year').options[document.getElementById('year').selectedIndex].value;



window.location = "timesheet-view.php?week="+week+"&year="+year;



}



</script>



<script>



function validateForm() {



  



	var totalhr1 = document.getElementById('total_hrs1').value;



	if (totalhr1 == "") {



        alert ("Total Hours out");



        return false;



    }



	var totalhr2 = document.getElementById('total_hrs2').value;



	if (totalhr2 == "") {



        alert ("Total Hours out");



        return false;



    }



	var totalhr3 = document.getElementById('total_hrs3').value;



	if (totalhr3 == "") {



        alert ("Total Hours out");



        return false;



    }



	var totalhr4 = document.getElementById('total_hrs4').value;



	if (totalhr4 == "") {



        alert ("Total Hours out");



        return false;



    }



	var totalhr5 = document.getElementById('total_hrs5').value;



	if (totalhr5 == "") {



        alert ("Total Hours out");



        return false;



    }



	var totalhr6 = document.getElementById('total_hrs6').value;



	if (totalhr6 == "") {



        alert ("Total Hours out");



        return false;



    }



	var totalhr7 = document.getElementById('total_hrs7').value;



	if (totalhr7 == "") {



        alert ("Total Hours out");



        return false;



    }



		document.getElementById('submit_timesheet').action='timesheet-view.php?'+"count="+gcount;



	}



</script>
<style>
.act_tsheet { background: #373938;
  color: #fff;}
</style>
</head>



<body>



<!-- Wrapper Starts -->

<div class="wrapper">

    <?php  require_once('../includes/header.php'); ?>
    
<?php  require_once('../includes/tools-menu.php'); ?>
  <!-- Content Goes here -->


    <article class="inside_wrapper clear_fix">



    



    	<!-- Main Content Goes here -->



      <section class="main_content timesheet_view">



    		  <h1>Timesheet view</h1>



               <div class="admin_container clear_fix yellow"> 



               



               <div class="left_side" style="margin: 0 auto;width: 98%; float:none">



             	<form method="post" action="" id="submit_timesheet" name="submit_timesheet" onsubmit="return validateForm()">



         

<?php if(isset($_GET['week'])){?>
<div class="field_item">
<?php mysql_select_db($database_oprmConn, $oprmConn);
$query_getUname = "SELECT * FROM weby_profiles WHERE user_id = '$_GET[uid]' and status = 'A'";
$getUname = mysql_query($query_getUname, $oprmConn) or die(mysql_error());
$row_getUname = mysql_fetch_assoc($getUname);
$totalRows_getUname = mysql_num_rows($getUname); ?>
<label style="padding-bottom:15px;">Submitted By:</label><label style="padding-bottom:15px;"><?php echo $row_getUname['full_name'];?></label></div>
                    <!--
<div class="ip_add" style="float: right;margin-top:-10px;">
<label id="weekproth" style="width:100px;">IP Address:</label>
<label id="weekproth" style="width:100px;"><b><//?php echo $row_getipaddr['ip_address']; ?></b></label></div>-->
<div class="field_item">
<label>Week submitted:</label>
<?php	echo '<select name="week" id="week" onChange="redirect();">';
//echo '<option value="0">Select Week</option> ';
$i = 1;



						$pweek = $_GET['week'];



						//$year = $_GET['year'];



						while($i<=52)



						{



							if($i<10)



						{



							$year = $_GET['year'];



								//$padi = '0'.$i;



								$value = "value='0".$i."'";



								



									



							}



							else



							{



								$year = $_GET['year'];



								//$padi = $i;



								$value = "value='".$i."'";



								



							}



							if(isset($_GET['week']))



							{



								if($i<10)



								{



									$gwk = $i;



									$gwk = sprintf("%02s", $i);



								



								}



								if($i>=10)



								{



									$gwk = $i;



																	



								}



								if($i == $_GET['week'])



								{

									$year = $_GET['year'];



									//$year = $_GET['year'];



									$dwk = date('d M, Y', strtotime($year."W".$gwk.'7'));



									



									echo '<option '.$value.' selected="selected">'.'W/e '.$dwk.'</option>';



									



								}



								



							}



							



							$i++;



						}







					



                   echo '</select>



                    '; ?>



               <input type="hidden" name="year" id="year" value="<?php echo $_GET['year'];?>" />

               <input type="hidden" name="uid" id="uid" value="<?php echo $_GET['uid'];?>" />



				<input type="hidden" name="cnt" id="cnt" value="<?php echo $totalRows_getWeek - 1; ?>" />

                

              <label id="weekth" style="width:140px;">Week Total Hours:</label>

			 <label id="weekth" style="width:200px;"><b><?php

				 mysql_select_db($database_oprmConn, $oprmConn);

$query_getHrs = "SELECT  SUM(`total_hrs`) FROM weby_timesheets WHERE task_year = '$_GET[year]' and task_week = '$_GET[week]' and user_id = '$_GET[uid]' and status in ('A', 'Q', 'I')";

$getHrs = mysql_query($query_getHrs, $oprmConn) or die(mysql_error());

$row_getHrs = mysql_fetch_assoc($getHrs);

$totalRows_getHrs = mysql_num_rows($getHrs);


$query_MAXHrs = "SELECT  weekly_hrs FROM weby_users WHERE  user_id = '$_GET[uid]'";

$MAXHrs = mysql_query($query_MAXHrs, $oprmConn) or die(mysql_error());

$row_MAXHrs = mysql_fetch_assoc($MAXHrs);

$totalRows_MAXHrs = mysql_num_rows($MAXHrs);



     echo $row_getHrs['SUM(`total_hrs`)']; ?></b>/ (Max. Hours Allowed: <?php echo $row_MAXHrs['weekly_hrs']; ?>)</label></div>   

                

                

                

                



	<?php 



		$n = 0;



		 do { 



				mysql_select_db($database_oprmConn, $oprmConn);



$query_getPdtls = "SELECT  * FROM weby_timesheets WHERE project_id = '$row_getWeek[project_id]' and user_id = '$_GET[uid]'";



$getPdtls = mysql_query($query_getPdtls, $oprmConn) or die(mysql_error());



$row_getPdtls = mysql_fetch_assoc($getPdtls);



$totalRows_getPdtls = mysql_num_rows($getPdtls);



 if($n != 0){$n = $n;} 



 else if($n == 0){$n = '';} 	



		?>

                 <div>



<div id="repeater0<?php echo $n; ?>">
<div class="field_item" id="field_item"><input type="hidden" name="asgprj" id="asgprj" value="<?php echo $totalRows_getTotalproj;?>" />
<label id="selectproj">Project Name:</label>
<select name="project<?php echo $n; ?>" id="project<?php echo $n; ?>"><?php mysql_select_db($database_oprmConn, $oprmConn);
$query_getprjname = "SELECT  * FROM weby_projects WHERE projetc_id = '$row_getWeek[project_id]'";
$getprjname = mysql_query($query_getprjname, $oprmConn) or die(mysql_error());
$row_getprjname = mysql_fetch_assoc($getprjname);
$totalRows_getprjname = mysql_num_rows($getprjname);
mysql_select_db($database_oprmConn, $oprmConn);
$query_getProj = "SELECT * FROM weby_projects WHERE weby_projects.status = 'A' AND weby_projects.projetc_id = '$row_getprjname[projetc_id]'";
$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());
$row_getProj = mysql_fetch_assoc($getProj);
$totalRows_getProj = mysql_num_rows($getProj);
do{ ?>
<option value="<?php echo $row_getProj['projetc_id']; ?>" <?php if($row_getProj['projetc_id'] == $row_getprjname['projetc_id']){ ?> selected="selected" <?php } ?> > <?php echo $row_getProj['project_name']; ?></option>
<?php } while ($row_getProj = mysql_fetch_assoc($getProj));
$rows = mysql_num_rows($getProj);
if($rows > 0) {
mysql_data_seek($getProj, 0);
$row_getProj = mysql_fetch_assoc($getProj);
} ?></select>				
<label id="weekproth" style="width:140px;"> Total Hours:</label>
<label id="weekproth" style="width:40px;"><b><?php
mysql_select_db($database_oprmConn, $oprmConn);
$query_getHrs = "SELECT  SUM(`total_hrs`) FROM weby_timesheets WHERE task_year = '$_GET[year]' and task_week = '$_GET[week]' and user_id = '$_GET[uid]' and project_id = '$row_getWeek[project_id]' and status in ('A', 'Q', 'I')";
$getHrs = mysql_query($query_getHrs, $oprmConn) or die(mysql_error());
$row_getHrs = mysql_fetch_assoc($getHrs);
$totalRows_getHrs = mysql_num_rows($getHrs);
echo $row_getHrs['SUM(`total_hrs`)']; ?></b></label> </div>	

 <!--       
<div class="field_item" id="field_item" >
<label id="selectproj">Client Name:</label>
<label id="cli_name"><//?php //get client id
mysql_select_db($database_oprmConn, $oprmConn);
$query_getcid = "SELECT  * FROM weby_timesheets WHERE project_id = '$row_getWeek[project_id]' and task_week = '$_GET[week]' and task_year = '$_GET[year]' and user_id = '$_GET[uid]' and status in ('A', 'Q', 'I') ORDER BY created_date ASC";
$getcid = mysql_query($query_getcid, $oprmConn) or die(mysql_error());
$row_getcid = mysql_fetch_assoc($getcid);
$totalRows_getcid = mysql_num_rows($getcid);
mysql_select_db($database_oprmConn, $oprmConn);
$query_getclients = "SELECT * FROM weby_clients WHERE status = 'A' AND client_id = '$row_getcid[client_id]'";
$getclients = mysql_query($query_getclients, $oprmConn) or die(mysql_error());
$row_getclients = mysql_fetch_assoc($getclients);
$totalRows_getclients = mysql_num_rows($getclients);
echo $row_getclients['client_name']; ?></label>
 </div>	-->
        



					<div class="field_item">

						<div class="timesheet_tablet">               

					<div class="column_titlet">



					<?php $week_number = $_GET['week'];



						$year = $_GET['year'];



						for($day=1; $day<=7; $day++)



						{



							$dwk = date('d-m-Y', strtotime($year."W".$week_number.$day));



							$dayn = date('D',strtotime($year."W".$week_number.$day)); ?>



							<span class="item_smalltt" style="width:68px; font-size:10px;"><?php echo $dayn; ?></span> 



							<?php } ?>



                        



                    </div>



                                   <?php $week_number = $_GET['week'];



						$year = $_GET['year'];



						for($day=1; $day<=7; $day++)



						{



							$dwk = date('d-m-Y', strtotime($year."W".$week_number.$day));



							$dayn = date('D',strtotime($year."W".$week_number.$day));



?>



                                   <span class="item_smallt" style="width:68px; font-size:10px;" name="datewk<?php echo $day;?>" id="datewk<?php echo $day;?>"><?php echo $dwk; ?><br />09:00 AM- 05:00 PM</span>



                                  



                                   <?php } ?>



                                   </div>



                                   <div class="timesheet_tablet">



                                    <?php 



	mysql_select_db($database_oprmConn, $oprmConn);



$query_getHors = "SELECT  * FROM weby_timesheets WHERE project_id = '$row_getWeek[project_id]' and task_week = '$_GET[week]' and task_year = '$_GET[year]' and user_id = '$_GET[uid]' and status in ('A', 'Q', 'I') ORDER BY created_date ASC";



$getHors = mysql_query($query_getHors, $oprmConn) or die(mysql_error());



$row_getHors = mysql_fetch_assoc($getHors);



$totalRows_getHors = mysql_num_rows($getHors);



$day = 1;



						do{



							



?>



                                   



                                    <span class="item_smallt" style="width:68px;" ><input type="text" name="total_hrs<?php echo $day.$n; ?>" id="total_hrs<?php echo $day.$n; ?>" maxlength="4" size="4" value="<?php echo $row_getHors['total_hrs'];?>" /><input type="hidden" name="id<?php echo $day.$n; ?>" id="id<?php echo $day.$n; ?>" value="<?php echo $row_getHors['timesheet_id'];?>" /></span>



		 <?php $day = $day + 1;



		  } while ($row_getHors = mysql_fetch_assoc($getHors)); ?>



									 



					  </div>



					</div>



                      <div class="clear-fix">&nbsp;</div>



					



                  



					



                   <!-- <input type="reset" value="Add" class="reset_btn" onclick="javascript:addItem('repeater0');" >-->



                   </div>



                   <div class="clear-fix">&nbsp;</div></div>



                     <?php $n = $n + 1; } while ($row_getWeek = mysql_fetch_assoc($getWeek)); ?> 



				



                



       

                    <div class="field_item">

				<label for="status">Status: </label>



                    <select name="status">



                      <?php 



do {  

 $query_getStatus = "SELECT * FROM weby_timesheets WHERE task_week = '$_GET[week]' and user_id = '$_GET[uid]' and task_year = '$_GET[year]' and status in ('A', 'Q', 'I')";

$getStatus = mysql_query($query_getStatus, $oprmConn) or die(mysql_error());

$row_getStatus = mysql_fetch_assoc($getStatus);

$totalRows_getStatus = mysql_num_rows($getStatus);



?>



                      <option value="<?php echo $row_getTmSt['status_key']?>"<?php if (($row_getStatus['status'] == $row_getTmSt['status_key'])) {?> selected="selected"<?php } ?>><?php echo $row_getTmSt['status_label']?></option>



                      <?php



} while ($row_getTmSt = mysql_fetch_assoc($getTmSt));



  $rows = mysql_num_rows($getTmSt);



  if($rows > 0) {



      mysql_data_seek($getTmSt, 0);



	  $row_getTmSt = mysql_fetch_assoc($getTmSt);



  }



?>



                    </select>



            		</div>



                  <div class="field_item">



					<label for="add_resource"></label>



                    



            		</div>



                    <div class="action_items">



                    <input type="hidden" name="from" id="from" value="4" />



                    <input type="hidden" name="tid" id="tid" value="<?php echo $row_timesheetVie['timesheet_id']; ?>" />



                    	<input type="submit" value="Save" name="submit" class="save_btn">



                        <input type="reset" value="Cancel" class="reset_btn"  onClick="window.location='timesheet-all.php';">



                    </div>

                    <?php } ?>



                    <div class="clear-fix">&nbsp;</div>

</form></section>

    	<!-- Sidebar Goes here --><aside class="sidebar"> 



       	  <?php /*?><div class="featured">



            	<h2 class="white_txt">PENDING RESOURCES</h2>



                <?php if($totalRows_getRes>0) { do { ?>



                <div class="profile_box">



                    <a href="resources-view.php?user_id=<?php echo $row_getRes['user_id']; ?>"><img src="/RM/images/<?php if(!empty($row_getRes['profile_pic'])) echo $row_getRes['profile_pic']; else echo "black-img.jpg";?>" width="68" /></a>



                    <p class="profile_title"><a href="resources-view.php?user_id=<?php echo $row_getRes['user_id']; ?>"><?php echo $row_getRes['full_name']; ?></a><span class="desig"><br />



                    <?php echo $row_getRes['job_title']; ?></span></p>



                <p class="profile_desc"><?php echo $row_getRes['skill_set']; ?></p>



                  <div class="clear-fix">&nbsp;</div>



            </div>



          <?php } while ($row_getRes = mysql_fetch_assoc($getRes)); } else { echo "<div class='no-row'>No Pending Resources</div>";}?></div>
<?php */?>


       	  <h2>ACTIVE RESOURCES</h2>



         <form action="resources-list.php" method="post" id="act_resource_search">



         <input name="search" class="search" type="text" size="30" />



         <input name="submit" class="search-sub" type="submit" value="Search" />



         </form>



         



         



                <?php if($totalRows_getRes1>0) { do { ?>



                  <div class="profile_box">



                    <a href="resources-view.php?user_id=<?php echo $row_getRes1['user_id']; ?><?php ?>"><img src="/RM/images/<?php if(!empty($row_getRes1['profile_pic'])) echo $row_getRes1['profile_pic']; else echo "black-img.jpg";?>" width="68" /></a>



                    <p class="profile_title"><a href="resources-view.php?user_id=<?php echo $row_getRes1['user_id']; ?>"><?php echo $row_getRes1['full_name']; ?></a><span class="desig"><br />



                    <?php echo $row_getRes1['job_title']; ?></span></p>



                  <p class="profile_desc"><?php echo $row_getRes1['skill_set']; ?></p>



                    <div class="clear-fix">&nbsp;</div>



                        </div>



                  <?php } while ($row_getRes1 = mysql_fetch_assoc($getRes1)); } else { echo "<div>No Active Resources</div>";} ?>



                  



                  <!-- <div class="profile_box"> <a href="resources-view.php?user_id=1234"><img src="/RM/images/black-img.jpg" /></a>



                    <p class="profile_title"><a href="resources-view.php?user_id=1234">David Masciana</a><span class="desig"><br />



				  IT Business Analyst</span></p>



                    <p class="profile_desc">Cisco IP knowledge is preferred to Cisco CCNA/Juniper JNCIA and similar level 		



                    ....</p>



                <div class="clear-fix">&nbsp;</div>



          </div> -->



          



          <p><a href="resources-list.php">View all >></a></p>



   	  </aside> </article>

    





        



    



    	 



    



     	<div class="clear-fix">&nbsp;</div> 



        



    </article>



    



     	<div class="clear-fix">&nbsp;</div>


   <!-- Footer Goes here -->

     <?php  require_once('../includes/footer.php'); ?>
    





	 



    



</div>



</body>



</html>



<?php



mysql_free_result($timesheetVie);



mysql_free_result($getUserDet);



mysql_free_result($getTmSt);



mysql_free_result($getRes);



mysql_free_result($getRes1);



?>