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

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

{

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

}

?>

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

}

}



$maxRows_getRec = 2;

$pageNum_getRec = 0;

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

  $pageNum_getRec = $_GET['pageNum_getRec'];

}

$startRow_getRec = $pageNum_getRec * $maxRows_getRec;



mysql_select_db($database_oprmConn, $oprmConn);

$query_getRec = "SELECT weby_timesheets.timesheet_id, weby_timesheets.total_hrs, weby_timesheets.project_id, weby_timesheets.hr_rate, weby_timesheets.total_amount, weby_timesheets.taks_details, weby_timesheets.created_by, weby_timesheets.created_date, weby_timesheets.updated_date, weby_timesheetstatus.status_label, weby_projects.project_name, weby_timesheets.token FROM weby_timesheets, weby_timesheetstatus, weby_projects WHERE weby_timesheets.status = weby_timesheetstatus.status_key AND weby_projects.projetc_id = weby_timesheets.project_id AND weby_timesheets.user_id = '$_SESSION[user_id]' ORDER BY weby_timesheets.updated_date desc";

$query_limit_getRec = sprintf("%s LIMIT %d, %d", $query_getRec, $startRow_getRec, $maxRows_getRec);

$getRec = mysql_query($query_limit_getRec, $oprmConn) or die(mysql_error());

$row_getRec = mysql_fetch_assoc($getRec);



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

  $totalRows_getRec = $_GET['totalRows_getRec'];

} else {

  $all_getRec = mysql_query($query_getRec);

  $totalRows_getRec = mysql_num_rows($all_getRec);

}

$totalPages_getRec = ceil($totalRows_getRec/$maxRows_getRec)-1;

?>

<?php //do {

	if ($row_getRec['timesheet_id']=="") { echo "There are no activities found"; }

	

	if ($row_getRec['timesheet_id']!="") { ?>

<div class="activity">

  <h3><a href="timesheet-view.php?timesheetid=<?php echo $row_getRec['timesheet_id']; ?>&token=<?php echo $row_getRec['token']; ?>"><?php echo $row_getRec['project_name']; ?></a></h3>

  <p><b>Total Effort:</b> <?php echo $row_getRec['total_hrs']; ?>hrs &nbsp; &nbsp; &nbsp; <b>Status:</b> <?php echo $row_getRec['status_label']; ?><br />

    <b>Submitted on: </b><?php echo date("d/m/Y",strtotime($row_getRec['created_date'])); ?><br />

  <!--<b>Last Update: </b><?php /*echo date("d/m/Y",strtotime($row_getRec['updated_date']));*/ ?>--></p>

  </div>

      <?php } while ($row_getRec = mysql_fetch_assoc($getRec)); ?>

	  

 

  <?php

mysql_free_result($getRec);

?>

     