<?php require_once('../Connections/oprmConn.php'); 

if(!isset($_SESSION['user_id'])){
	header("location: ../index.php");
}

if($_SESSION['role_id']!=2) {
header("Location: ../index.php"); }

if(isset($_REQUEST['timesheetid'])) {
$l = "timesheet-edit.php?timesheet_id=".$_REQUEST['timesheetid']."&token=".$_REQUEST['token'];
header("location: $l");
}

if(!isset($_GET['year'])){
	$week = date('W');
	$year = date('Y');
	header("Location: timesheet-view.php?week=$week&year=$year&project=0");
}
$ipaddress = $_SERVER['REMOTE_ADDR'];

if(isset($_POST['save'])){ 
$count = $_GET['count'];
$i=0;
$week_number = $_POST['week'];
$year = $_POST['year'];
for($m = 0; $m <= $count; $m++){
if($m > 0){	$varprj = "project".$m; $varclient = "client".$m; } else if($m == 0){ $varprj = "project"; $varclient = "client"; }
$project = $_POST[$varprj]; $client = $_POST[$varclient];
if(($project != 0) && ($client != '')){
$user = "$_SESSION[user_id]";
mysql_select_db($database_oprmConn, $oprmConn);
$query_PendingGalleries = "SELECT * FROM weby_timesheets WHERE project_id = '$project' AND task_week = '$week_number' AND task_year = '$year' AND user_id = '$user' AND status != 'D'";
$PendingGalleries = mysql_query($query_PendingGalleries, $oprmConn) or die(mysql_error());
$row_PendingGalleries = mysql_fetch_assoc($PendingGalleries);
$totalRows_PendingGalleries = mysql_num_rows($PendingGalleries);
if($totalRows_PendingGalleries == 0){
	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];
//echo $total_hrs.','.$project.','.$dtt.'<br>';
$proid = $row_PendingGalleries['project_id'];

mysql_select_db($database_oprmConn, $oprmConn);
$query_getProjuser = "SELECT * FROM weby_projects WHERE weby_projects.status = 'A' AND weby_projects.projetc_id = '$project'";
$getProjuser = mysql_query($query_getProjuser, $oprmConn) or die(mysql_error());
$row_getProjuser = mysql_fetch_assoc($getProjuser);
$totalRows_getProjuser = mysql_num_rows($getProjuser);
$pt = $project;
$d = date("Y-m-d",strtotime($_POST['date'])); 
$user_id = $_SESSION['user_id'];
$token = rand(15420,999898);
$status = "I";

mysql_select_db($database_oprmConn, $oprmConn);
$qu = "INSERT INTO weby_timesheets (user_id,project_id,client_id,total_hrs,hr_rate,total_amount,taks_details,task_week,task_year,ip_address,status,created_by,created_date,updated_by,token) VALUES ('$user_id','$pt','$client','$total_hrs','$hr_rate','$total_amount','$dt','$week_number','$year','$ipaddress','$status','$user_id','$dtt','$user_id','$token')";				
$query_getProj = $qu;
$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());
$msg = "Timesheet save to draft Successfully";
header("location: timesheet.php?&msg=".$msg."");
}
}
else  if($totalRows_PendingGalleries > 0){
	$msg = "Already Submited For this Week";
	header("location: timesheet-view.php?week=$week_number&year=$year&msgdg=".$msg."");
}
} else  if($project == 0){
	$msg = "No Project Selected";
	header("location: timesheet-view.php?week=$week_number&year=$year&msgdg=".$msg."");
} else  if($client == ''){
	$msg = "No Client Selected";
	header("location: timesheet-view.php?week=$week_number&year=$year&msgdg=".$msg."");
}
}
}



if(isset($_POST['submit'])){
$count = $_GET['count'];
$i=0;
$week_number = $_POST['week'];
$year = $_POST['year'];
for($m = 0; $m <= $count; $m++){
if($m > 0){	$varprj = "project".$m; $varclient = "client".$m; } else if($m == 0){ $varprj = "project"; $varclient = "client"; }
$project = $_POST[$varprj]; $client = $_POST[$varclient];
if(($project != 0) && ($client != '')){
$user = "$_SESSION[user_id]";
mysql_select_db($database_oprmConn, $oprmConn);
$query_PendingGalleries = "SELECT * FROM weby_timesheets WHERE project_id = '$project' AND task_week = '$week_number' AND task_year = '$year' AND user_id = '$user' AND status != 'D'";
$PendingGalleries = mysql_query($query_PendingGalleries, $oprmConn) or die(mysql_error());
$row_PendingGalleries = mysql_fetch_assoc($PendingGalleries);
$totalRows_PendingGalleries = mysql_num_rows($PendingGalleries);

if($totalRows_PendingGalleries == 0){
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];
$proid = $row_PendingGalleries['project_id'];

mysql_select_db($database_oprmConn, $oprmConn);
$query_getProjuser = "SELECT * FROM weby_projects WHERE weby_projects.status = 'A' AND weby_projects.projetc_id = '$project'";
$getProjuser = mysql_query($query_getProjuser, $oprmConn) or die(mysql_error());
$row_getProjuser = mysql_fetch_assoc($getProjuser);
$totalRows_getProjuser = mysql_num_rows($getProjuser);
$pt = $project;
$d = date("Y-m-d",strtotime($_POST['date'])); 
$user_id = $_SESSION['user_id'];
$token = rand(15420,999898);
$status = "A";
mysql_select_db($database_oprmConn, $oprmConn);
$qu = "INSERT INTO weby_timesheets (user_id,project_id,client_id,total_hrs,hr_rate,total_amount,taks_details,task_week,task_year,ip_address,status,created_by,created_date,updated_by,token) VALUES ('$user_id','$pt','$client','$total_hrs','$hr_rate','$total_amount','$dt','$week_number','$year','$ipaddress','$status','$user_id','$dtt','$user_id','$token')";				
$query_getProj = $qu;
$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());


/*********************************************************/
mysql_select_db($database_oprmConn, $oprmConn);
$q = "select max(timesheet_id) as tid FROM weby_timesheets where user_id = '$_SESSION[user_id]'";

mysql_select_db($database_oprmConn, $oprmConn);
$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);
$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.task_week, weby_timesheets.status, weby_projects.project_name, weby_users.email_address FROM weby_timesheets, weby_profiles, weby_projects , weby_users 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";
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);

mysql_select_db($database_oprmConn, $oprmConn);
$query_getProj22 = "select email_address FROM weby_users where user_role = 1";
$getProj22 = mysql_query($query_getProj22, $oprmConn) or die(mysql_error());
$row_getProj22 = mysql_fetch_assoc($getProj22);
$totalRows_getProj22 = mysql_num_rows($getProj22);
$s = "InActive";
if($row_getTime['status']=="A")
$s = "Approved";
if($row_getTime['status']=="P")
$s = "Pending";
if($row_getTime['status']=="D")
$s = "Deleted";

require_once('timesheet-view-mail.php');
$msg = "Timesheet Submited Successfully";
header("location: timesheet.php?&msg=".$msg."");
}
} else  if($totalRows_PendingGalleries > 0){
$msg = "Already Submited For this Week";
header("location: timesheet-view.php?week=$week_number&year=$year&msgdg=".$msg."");
}
} else  if($project == 0){
	$msg = "No Project Selected";
	header("location: timesheet-view.php?week=$week_number&year=$year&msgdg=".$msg."");
} else  if($client == ''){
	$msg = "No Client Selected";
	header("location: timesheet-view.php?week=$week_number&year=$year&msgdg=".$msg."");
}




}
}







?>

<?php



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;



}



}







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, weby_profiles.hr_rate FROM weby_users, weby_profiles WHERE weby_profiles.user_id = weby_users.user_id and weby_users.user_id = '$_SESSION[user_id]'";



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



$row_getRes = mysql_fetch_assoc($getRes);



$totalRows_getRes = mysql_num_rows($getRes);







mysql_select_db($database_oprmConn, $oprmConn);



$query_getProj = "SELECT * FROM weby_projects WHERE weby_projects.status = 'A' AND weby_projects.projetc_id in (select distinct project_id FROM weby_users_projects where status = 'A' and user_id = '$_SESSION[user_id]')";



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



$row_getProj = mysql_fetch_assoc($getProj);



$totalRows_getProj = mysql_num_rows($getProj);





mysql_select_db($database_oprmConn, $oprmConn);



$query_getTotalproj = "SELECT * FROM weby_users_projects WHERE user_id = '$_SESSION[user_id]' AND status = 'A'";



$getTotalproj = mysql_query($query_getTotalproj, $oprmConn) or die(mysql_error());



$row_getTotalproj = mysql_fetch_assoc($getTotalproj);



$totalRows_getTotalproj = mysql_num_rows($getTotalproj);

?><!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-Resource Dashboard</title>

<link rel="stylesheet" href="../css/style.css" type="text/css">
<style>
.act_timesheet { background: #373938;
  color: #fff;}
</style>
    <!-- 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">
window.gcount = 0;
jQuery(function($){
	var $repeater0 = $('#repeater0');
	var $project = $('#project');
	var $selectproj = $('#selectproj');
	var $selectclient = $('#selectclient');
	var $field_item = $('#field_item');
	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 clientido = 'client' + 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 clientido = 'client';
		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 clientid = 'client' + 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;
		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('#'+projectido).attr('name', projectid);
	$repeater.find('#'+projectido).attr('id', projectid);
	$repeater.find('#'+clientido).attr('name', clientid);
	$repeater.find('#'+clientido).attr('id', clientid);
	
		$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);}
});
});
	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;
	try{
	$('#'+idname).remove();
	}catch(err){alert(err);}
	}
	});
	});
</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;
//var project = document.getElementById('project').options[document.getElementById('project').selectedIndex].value;
//alert(si);
//window.location = "http://e2eips.co.uk/eter-tools/resource/timesheet-view.php?week="+week+"&year="+year+"&project="+project;
window.location = "timesheet-view.php?week="+week+"&year="+year;
}
</script>
<script>
function validateForm() {
document.getElementById('submit_timesheet').action='timesheet-view.php?'+"count="+gcount;	
	var total1 = 0;
	var total2 = 0;
	var total3 = 0;
	var total4 = 0;
	var total5 = 0;
	var total6 = 0;
	var total7 = 0;
<?php for($i=0;$i<=$totalRows_getTotalproj;$i++) { ?>
<?php if($i==0){ echo $i=''; } ?>
var totalhr1 = parseFloat(document.getElementById('total_hrs1<?php echo $i; ?>').value);
	total1 = total1 + totalhr1;
	var totalhr2 = parseFloat(document.getElementById('total_hrs2<?php echo $i; ?>').value);
	total2 = total2 + totalhr2;
	var totalhr3 = parseFloat(document.getElementById('total_hrs3<?php echo $i; ?>').value);
	total3 = total3 + totalhr3;
	var totalhr4 = parseFloat(document.getElementById('total_hrs4<?php echo $i; ?>').value);
	total4 = total4 + totalhr4;
	var totalhr5 = parseFloat(document.getElementById('total_hrs5<?php echo $i; ?>').value);
	total5 = total5 + totalhr5;
	var totalhr6 = parseFloat(document.getElementById('total_hrs6<?php echo $i; ?>').value);

	total6 = total6 + totalhr6;

	var totalhr7 = parseFloat(document.getElementById('total_hrs7<?php echo $i; ?>').value);
	
	total7 = total7 + totalhr7;
	
	if (total1 > 24) {
        alert ("Effort totals per day should be less than 24hrs");
        return false;
    }

	if (total2 > 24) {
        alert ("Effort totals per day should be less than 24hrs");
        return false;
    }

	if (total3 > 24) {
        alert ("Effort totals per day should be less than 24hrs");
        return false;
    }

	if (total4 > 24) {
        alert ("Effort totals per day should be less than 24hrs");
        return false;
    }

	if (total5 > 24) {
        alert ("Effort totals per day should be less than 24hrs");
        return false;
    }
	
	if (total6 > 24) {
        alert ("Effort totals per day should be less than 24hrs");
        return false;
    }
	
	if (total7 > 24) {
        alert ("Effort totals per day should be less than 24hrs");
        return false;
    }	
	
<?php } ?>

	}

</script>


</head>



<body>

<!-- Wrapper Starts -->
<div class="wrapper">

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

    

    <article  class="inside_wrapper clear_fix">
  <section class="main_content">

    	 <h1>Submit Timesheet</h1>
 <?php if($_GET['msgdg']){

			$msgdg =  $_GET['msgdg'];

		?>

        <script type="text/javascript">

		alert("<?php echo $msgdg; ?>");

		</script>

		<?php } ?>
         

      <article class="resource_timesheet">
      <?php 
	  if($totalRows_getProj == 0){ ?>

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

         <p class="notimesheet"> No projects assigned to you. You can't submit Timesheet </p>

         <?php }if($totalRows_getProj > 0){ ?>

      <?php $pweek = date('W');



		  $pyear = date('Y'); ?>

     

      <?php if($_GET['msgalr']){ ?>

       <div id="hide" class="msg_box"><font color='red'> You Have already submited timesheet for week

      <?php $_GET['week'] ?>

      . To view Submited Timeshhet go to <a href="index.php"> Timesheet list</a> </font></div>

      <?php } ?>

      

     


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

         

          

          

          <div class="field_item">

            <label>Select Year:</label>

            <?php 

						echo '<select name="year" id="year" onChange="redirect();">'; 

						$pyear = date('Y');

						$pryear = $pyear-1;

						

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

						{

							if($_GET['year'] == $pyear)

							{

								echo '<option value="'.$pryear.'">'.$pryear.'</option>';

								echo '<option value="'.$pyear.'" selected="selected">'.$pyear.'</option>';

							}

							if($_GET['year'] == $pryear)

						{

								echo '<option value="'.$pryear.'" selected="selected">'.$pryear.'</option>';

								echo '<option value="'.$pyear.'">'.$pyear.'</option>';

							}

							

						}

						else

						{

							echo '<option value="'.$pryear.'">'.$pryear.'</option>';

							echo '<option value="'.$pyear.'" selected="selected">'.$pyear.'</option>';

						}

						echo '</select>';

					?>

          </div>

          <div class="field_item">

          <label>Select Week:</label>
             <?php

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

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

$row_MAXHrs = mysql_fetch_assoc($MAXHrs);

$totalRows_MAXHrs = mysql_num_rows($MAXHrs);
                    
                    ?>

          <?php

						

						echo '<select name="week" id="week" onChange="redirect();">';

						//echo '<option value="select">Select</option>';

						$i = 1;

						$pweek = date('W');

						//$year = date('Y');

						while($i<=52)

						{

							if($i<10)

						{

							$year = date('Y');

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

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

								

									

							}

							else

							{

								$year = $_GET['year'];

								//$padi = $i;

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

								

							}

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

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

								if($i<10)

								{

									$gwk = $i;

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

								

								}

								if($i>=10)

								{

									$gwk = $i;

																	

								}

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

								{

									$year = $_GET['year'];

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

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

								}

								else

								{

									//echo "<option ".$value.">".$i."</option>";

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


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


								}

							}

							

							$i++;

						}



					

                   echo '</select>

                    Max. Hours Allowed:' .$row_MAXHrs['weekly_hrs'].
                 

                '</div>';

				

				 

                

               

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

				{
?>

<input type="hidden" name="cnt" id="cnt" value="0" />

<div id="repeater0">

<div class="field_item" id="field_item"><input type="hidden" name="asgprj" id="asgprj" value="<?php echo $totalRows_getTotalproj;?>" />
<label id="selectproj">Select project:</label>
<select name="project" id="project">
<option value="0">Select project</option>  
<?php do{ ?> 
<option value="<?php echo $row_getProj['projetc_id']; ?>" <?php if($row_getProj['projetc_id'] == $_GET['project']){ ?> 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></div>
<!--<div class="field_item" id="field_item">
<label id="selectclient">Select Client:</label>
<select name="client" id="client">
<option value="0">Select Client</option>  
<//?php mysql_select_db($database_oprmConn, $oprmConn);
$query_getclients = "SELECT * FROM weby_clients WHERE status = 'A'";
$getclients = mysql_query($query_getclients, $oprmConn) or die(mysql_error());
$row_getclients = mysql_fetch_assoc($getclients);
$totalRows_getclients = mysql_num_rows($getclients);
if($totalRows_getclients>0){ do{ ?> 
<option value="<//?php echo $row_getclients['client_id']; ?>"> <//?php echo $row_getclients['client_name']; ?></option>
<//?php } while ($row_getclients = mysql_fetch_assoc($getclients)); } ?></select>
</div>-->
    <select name="client" id="client" style="display:none;">
<option value="0"> </option>
</select>
<?php if(isset($_GET['week'])){
if(($totalRows_PendingGalleries == 0)){ ?>
<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:79px; font-size:12px;"><?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:79px; font-size:12px;" 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 $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:79px;" ><input type="text" name="total_hrs<?php echo $day;?>" id="total_hrs<?php echo $day;?>" maxlength="4" size="4" value="0" /></span>
<?php } ?>



									 



					  </div>



					</div>

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



					</div>

                   <input type="button" id="addemail" value="Add" />

                   

                   <input type="button" class="remove" value="Remove" name="removeButton" id="removeButton"  />



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

                     <div class="submt">



					<div class="action_items" style="margin:0">



					  <input name="save" id="save" type="submit" class="save_btn" onclick="MM_validateForm('datewk','','R','total_hrs','','R','task_details','','R');return document.MM_returnValue" value="Save as Draft">
                      
                       <?php // echo $no = date('W').' & '.$_GET['week'];
  if(($_GET['year'] < date('Y'))){ ?>

					  <input type="submit" name="submit" id="submit"  onclick="MM_validateForm('datewk','','R','total_hrs','','R','task_details','','R');return document.MM_returnValue" value="Submit to Admin" class="reset_btn">

<?php } ?>

                      
  <?php // echo $no = date('W').' & '.$_GET['week'];
  if(($_GET['year'] == date('Y')) && ($_GET['week'] < date('W'))){ ?>

					  <input type="submit" name="submit" id="submit"  onclick="MM_validateForm('datewk','','R','total_hrs','','R','task_details','','R');return document.MM_returnValue" value="Submit to Admin" class="reset_btn">

<?php } ?>

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



									</div></div>

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


				

				

				



				<?php } ?>

                

        </form>

            </article>

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

         <?php } if($totalRows_getProj == 0){ ?>

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

         <p class="notimesheet"> No projects assigned to you. You can't submit Timesheet </p>

         <?php } } }?>

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

		

    </section>

    <div class="clear-fix"></div>

    </article>

    

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

    <!-- Footer Goes here -->

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

    

</div>

</body>

</html>

<?php

//mysql_free_result($getTime);



//mysql_free_result($getProfile);

?>