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

if(!isset($_SESSION['user_id']))



{



	header("location: ../index.php");



}

if($_SESSION['role_id']!=2) {

header("Location: ../index.php");

}

 $msg = ""; if(isset($_REQUEST['msg'])) $msg = $_REQUEST['msg']; 

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;



}



}



if (!isset($_GET['timesheets'])) {



$maxRows_getTime = 10;



$pageNum_getTime = 0;



}



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



  $pageNum_getTime = $_GET['pageNum_getTime'];



}















$maxRows_getTime = 10;



$pageNum_getTime = 0;



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



  $pageNum_getTime = $_GET['pageNum_getTime'];



}



$startRow_getTime = $pageNum_getTime * $maxRows_getTime;



$uid = $_SESSION['user_id'];

//echo date('Y');



mysql_select_db($database_oprmConn, $oprmConn);

$query_getTime = "SELECT DISTINCT (task_week), task_year FROM weby_timesheets WHERE user_id = '$uid' AND status in ('A', 'I', 'B', 'Q') ORDER BY task_year DESC , task_week DESC";

$query_limit_getTime = sprintf("%s LIMIT %d, %d", $query_getTime, $startRow_getTime, $maxRows_getTime);

			

			$getTime = mysql_query($query_limit_getTime, $oprmConn) or die(mysql_error());

			

			$row_getTime = mysql_fetch_assoc($getTime);











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



  $totalRows_getTime = $_GET['totalRows_getTime'];



} else {



  $all_getTime = mysql_query($query_getTime);



  $totalRows_getTime = mysql_num_rows($all_getTime);



}



$totalPages_getTime = ceil($totalRows_getTime/$maxRows_getTime)-1;







$queryString_getTime = "";



if (!empty($_SERVER['QUERY_STRING'])) {



  $params = explode("&", $_SERVER['QUERY_STRING']);



  $newParams = array();



  foreach ($params as $param) {



    if (stristr($param, "pageNum_getTime") == false && 



        stristr($param, "totalRows_getTime") == false) {



      array_push($newParams, $param);



    }



  }



}





$uid = $_SESSION['user_id'];



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProfile = "SELECT weby_profiles.*, weby_users.caeated_date as jdate FROM weby_profiles, weby_users WHERE weby_profiles.user_id = '$uid' AND weby_users.user_id =  weby_profiles.user_id AND weby_profiles.status='A'";



$getProfile = mysql_query($query_getProfile, $oprmConn) or die(mysql_error());



$row_getProfile = mysql_fetch_assoc($getProfile);



$totalRows_getProfile = mysql_num_rows($getProfile);

?><!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="//code.jquery.com/jquery-1.10.2.js"></script>

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



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



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



	<![endif]-->



<script type="text/javascript">



<!--



function MM_validateForm() { //v4.0



  if (document.getElementById){



    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;



    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);



      if (val) { nm=val.name; if ((val=val.value)!="") {



        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');



          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';



        } else if (test!='R') { num = parseFloat(val);



          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';



          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');



            min=test.substring(8,p); max=test.substring(p+1);



            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';



      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }



    } if (errors) alert('The following error(s) occurred:\n'+errors);



    document.MM_returnValue = (errors == '');



} }



//-->








function checkP(){



if(document.getElementById("new_password").value != document.getElementById("confirm_password").value) {



alert("New password and Confirm password should be same");



document.getElementById("new_password").focus();



return false;



}



}



function MM_openBrWindow(theURL,winName,features) { //v2.0



  window.open(theURL,winName,features);



}















		







</script>

<script>



$(function() {



	



   $( "#passport_edate" ).datepicker();



	$( "#visa_edate" ).datepicker();



	



  



});







</script>
</head>



<body>

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

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

    

    <!-- Content Goes here -->

    <article class="inside_wrapper clear_fix">

    

    	<!-- Main Content Goes here -->

     <section class="main_content">

    

    	  <h2>Current Timesheets</h2>



             <?php if(isset($_REQUEST['msg']) ){ 

			 $msg="Timesheet Updated Successfully"?>



             <div id="hide" class="msg_cancel"><font color="#3cda52"><?php echo $msg; ?><a href="timesheet.php"><img src="/RM/images/cross.png" width="12" height="12" alt="delete" onclick="setVisibility('hide', 'none');"></a></font></div>

              <?php } ?>
<a class="create_btn"  href="timesheet-view.php">
<p align="right">Add Time sheet</p></a><div class="clear-fix">&nbsp;</div>
               <?php if(isset($_REQUEST['msgm']) ){ 

			 $msg="Timesheet Modified & Submited Successfully"?>



             <div id="hide" class="msg_cancel"><font color="#3cda52"><?php echo $msg; ?><a href="timesheet.php"><img src="/RM/images/cross.png" width="12" height="12" alt="delete" onclick="setVisibility('hide', 'none');"></a></font></div>

              <?php } ?>



             <?php if(isset($_REQUEST['msgdr']) ){ 

			 $msg="Timesheet Saved to Drafts Successfully"?>



             <div id="hide" class="msg_cancel"><font color="#3cda52"><?php echo $msg; ?><a href="timesheet.php"><img src="/RM/images/cross.png" width="12" height="12" alt="delete" onclick="setVisibility('hide', 'none');"></a></font></div>

              <?php } ?>



             

 <article class="resource_timesheet clear_fix">

<?php  if(isset($_GET['week'])){ 

if($totalRows_getTime > 7){?>



 <div class="welcome_box1">

					<div class="welcome_txt"><strong>Select Project: </strong>

                   <select name="project" id="project" onChange="redirect1();">



                    <option value="ALL">ALL</option>

                    <?php do { ?>

                    

                      <option value="<?php echo $row_getId['project_id']; ?>"  <?php if($row_getId['project_id'] == $_GET['project']){ ?> selected="selected" <?php } ?> > 

						  <?php $poid = $row_getId['project_id'];			

		mysql_select_db($database_oprmConn, $oprmConn);

		$query_getSelectwkprjss = "SELECT * FROM projects WHERE projects.projetc_id = '$poid' AND status = 'A'";

		$getSelectwkprjss = mysql_query($query_getSelectwkprjss, $oprmConn) or die(mysql_error());

		$row_getSelectwkprjss = mysql_fetch_assoc($getSelectwkprjss);

		$totalRows_getSelectwkprjss = mysql_num_rows($getSelectwkprjss); echo $row_getSelectwkprjss['project_name']; ?>

                          </option>

                      <?php } while ($row_getId = mysql_fetch_assoc($getId)); ?>

                      

                      </select>

</div>

</div>

<?php } } ?>

<div class="welcome_box1">

					<?php /*?><div class="welcome_txt"><strong>Select Week: </strong>

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

                    <option value="ALL">ALL</option>

                    <?php do { ?>

                    

                      <option value="<?php echo $row_getSelect['task_week']; ?>"  <?php if($row_getSelect['task_week'] == $_GET['week']){ ?> selected="selected" <?php } ?> > 

						  <?php echo $row_getSelect['task_week']; ?>

                          </option>

                      <?php } while ($row_getSelect = mysql_fetch_assoc($getSelect)); ?>

                      

                      </select>

</div><?php */?>

</div>

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





             



    		<!-- Timesheets Goes here -->



      	   	 <div class="timesheet_table no-border">



             	<div class="column_title">



                	<span class="item_wide">Week Number</span>

                    <span class="item_wide">Week end Date</span>

                    <span class="item_wide">Resource</span>

                    <!--<span class="item_wide">Project</span>-->

                    <span class="item_small">Status</span>

                    <span class="item_small">Total Hours</span>

                    <span class="item_small">Action</span>

                    <!--<span class="item_small">Rate(£)</span><span class="item_small">Total</span>-->                </div>



                <?php $n =0; if($totalRows_getTime>0) { do { 

				 mysql_select_db($database_oprmConn, $oprmConn);

$query_getWeka = "SELECT * FROM weby_timesheets WHERE task_week = '$row_getTime[task_week]' and task_year = '$row_getTime[task_year]' and user_id = '$_SESSION[user_id]' and status <> 'D' ORDER BY created_date DESC";

$getWeka = mysql_query($query_getWeka, $oprmConn) or die(mysql_error());

$row_getWeka = mysql_fetch_assoc($getWeka);

$totalRows_getWeka = mysql_num_rows($getWeka);

				?>

                 <div class="row <?php if($n==0) { echo "yellow"; $n=1; } else $n=0; ?>">

                 <span class="item_wide"><?php echo $row_getTime['task_week']; ?></span>

                 <span class="item_wide"><?php
				 $year = $row_getWeka['task_year'];
				 $gwk =  $row_getTime['task_week'];
				//echo $dwk = date('d/M/Y', strtotime($year."W".$gwk.'7'));
				//echo $dwk = date('d-m-Y', strtotime($year."W".$gwk.'7'));
				  echo date('d/M/Y',strtotime($row_getWeka['created_date'])); ?></span>

                 <span class="item_wide"><?php 

				 mysql_select_db($database_oprmConn, $oprmConn);



			$query_getDraft = "SELECT * FROM weby_profiles WHERE user_id = '$row_getWeka[user_id]'";

			

			$getDraft = mysql_query($query_getDraft, $oprmConn) or die(mysql_error());

			

			$row_getDraft = mysql_fetch_assoc($getDraft);

			

			$totalRows_getDraft = mysql_num_rows($getDraft);

				 echo $row_getDraft['full_name']; ?></span>

               

                 <span class="item_small"><?php if($row_getWeka['status'] == 'I'){echo 'In Draft';} if($row_getWeka['status'] == 'B'){echo 'Rejected';} if($row_getWeka['status'] == 'A'){echo 'Pending';}if($row_getWeka['status'] == 'Q'){echo 'Approved';} ?></span>

                 <span class="item_small"><?php 

				 mysql_select_db($database_oprmConn, $oprmConn);

$query_getHrs = "SELECT  SUM(`total_hrs`) FROM weby_timesheets WHERE task_week = '$row_getTime[task_week]' and task_year = '$row_getTime[task_year]' and user_id = '$_SESSION[user_id]' and status in ('A', 'I', 'B', 'Q')";



$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`)']; ?></span>

                 <span class="item_small">

                 <?php if(($row_getWeka['status'] == 'I') || ($row_getWeka['status'] == 'B')){ ?><a href="timesheet-edit.php?week=<?php if($row_getWeka['task_week'] < 10){ echo '0'.$row_getWeka['task_week'];} else {echo $row_getWeka['task_week'];} ?>&year=<?php echo $row_getWeka['task_year']; ?>">Edit</a><?php } if(($row_getWeka['status'] == 'A') || ($row_getWeka['status'] == 'Q')){?><a href="timesheet-view-week.php?week=<?php if($row_getWeka['task_week'] < 10){ echo '0'.$row_getWeka['task_week'];} else {echo $row_getWeka['task_week'];} ?>&year=<?php echo $row_getWeka['task_year']; ?>">View</a><?php } ?>

                 </span>

                       </div>



                  <?php } while ($row_getTime = mysql_fetch_assoc($getTime)); ?>

<div class="h-line"></div>

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

<table width="300" border="0" align="center" cellpadding="2" style="clear:both">

<tr>

<td>


<?php echo ($startRow_getTime + 1) ?> to <?php echo min($startRow_getTime + $maxRows_getTime, $totalRows_getTime) ?> of <?php echo $totalRows_getTime ?>
</td>
</tr>

          

          <tr>



            <td align="center"><?php if ($pageNum_getTime > 0) { // Show if not first page ?>



                <a href="<?php printf("%s?pageNum_getTime=%d%s", $currentPage, 0, $queryString_getTime); ?>">&lt;&lt; First</a>



                <?php } // Show if not first page ?></td>



            <td align="center"><?php if ($pageNum_getTime > 0) { // Show if not first page ?>



                <a href="<?php printf("%s?pageNum_getTime=%d%s", $currentPage, max(0, $pageNum_getTime - 1), $queryString_getTime); ?>">&lt; Previous</a>



                <?php } // Show if not first page ?></td>



            <td align="center"><?php if ($pageNum_getTime < $totalPages_getTime) { // Show if not last page ?>



                <a href="<?php printf("%s?pageNum_getTime=%d%s", $currentPage, min($totalPages_getTime, $pageNum_getTime + 1), $queryString_getTime); ?>">Next &gt;</a>



                <?php } // Show if not last page ?></td>



            <td align="center"><?php if ($pageNum_getTime < $totalPages_getTime) { // Show if not last page ?>



                <a href="<?php printf("%s?pageNum_getTime=%d%s", $currentPage, $totalPages_getTime, $queryString_getTime); ?>">Last &gt;&gt;</a>



                <?php } // Show if not last page ?></td>



          </tr>



        </table>

</div>

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

        </div>
<div class="buttons">

<a class="a_btn" href="timesheet-archive.php">Archive</a>



</div>

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

           



                  <?php } else echo '<div  class="no-rows">No Pending timesheet entries.</div>';?>



             </div>


</article>
		

    </section>

    

    	<!-- Sidebar Goes here -->

      <aside class="sidebar"> 

        	<div class="featured clear_fix">

            	<h2 class="white_txt">My Profile</h2>

                <div class="profile_box"> <a href="index.php?resourceid=<?php echo $row_getProfile['profile_id']; ?>"><img src="/RM/images/<?php if(!empty($row_getProfile['profile_pic'])) echo $row_getProfile['profile_pic']; else echo "black-img.jpg"; ?>" width="68" /></a>

                  <p class="profile_title"><a href="index.php?resourceid=<?php echo $_SESSION[user_id]; ?>"><?php echo $row_getProfile['full_name']; ?></a><span class="desig"><br />

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

                    <p class="profile_desc"><?php echo $row_getProfile['skill_set']; ?><br /><!--<br />Rate: £<?php/* echo $row_getProfile['hr_rate'];*/ ?> per hour--></p>

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

                    <!--<p class="text_right">Joined on: <?php echo date('d/M/Y',strtotime($row_getProfile['jdate'])); ?><br />-->

					<!--Last updated: <?php /*echo date('d/M/Y',strtotime($row_getProfile['updated_date']));*/ ?>--></p> 

                   <!-- <p><a href="index.php?resourceid=<?php echo $row_getProfile['profile_id']; ?>"><font color="#fbd937">Edit Profile</font></a></p>-->

                </div> 

        </div>

     	 <!--<h3>Recent Activity</h3> -->

        

         <?php #include("recent-ac.php"); ?>

                </aside>



    

    	 

    

     	<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($getTime);



mysql_free_result($getProfile);

?>