<?php require_once('../Connections/oprmConn.php'); ?>
<?php $msg = ""; if(isset($_REQUEST['msg'])) $msg = $_REQUEST['msg']; ?>
<?php include('check-admin-session.php'); 
if(isset($_POST['search'])) {
$l = "resources-search.php?key=".$_REQUEST['search'];
header("Location: $l");
}
?>
<?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_getTimeSheet = 2;
$pageNum_getTimeSheet = 0;
if (isset($_GET['pageNum_getTimeSheet'])) {
  $pageNum_getTimeSheet = $_GET['pageNum_getTimeSheet'];
}
$startRow_getTimeSheet = $pageNum_getTimeSheet * $maxRows_getTimeSheet;

mysql_select_db($database_oprmConn, $oprmConn);
$query_getTimeSheet = "SELECT distinct weby_timesheets.timesheet_id, weby_timesheets.user_id, weby_timesheets.total_hrs, weby_timesheets.hr_rate, weby_timesheets.total_amount, weby_profiles.full_name, weby_projects.project_name, weby_profiles.profile_pic, weby_profiles.job_title, weby_profiles.skill_set FROM weby_timesheets, weby_profiles, weby_projects, weby_users_projects WHERE weby_timesheets.user_id = weby_profiles.user_id  AND weby_projects.projetc_id = weby_timesheets.project_id and weby_profiles.user_id = weby_users_projects.user_id and weby_users_projects.project_id = weby_projects.projetc_id order by weby_timesheets.updated_date desc";
$query_limit_getTimeSheet = sprintf("%s LIMIT %d, %d", $query_getTimeSheet, $startRow_getTimeSheet, $maxRows_getTimeSheet);
$getTimeSheet = mysql_query($query_limit_getTimeSheet, $oprmConn) or die(mysql_error());
$row_getTimeSheet = mysql_fetch_assoc($getTimeSheet);

if (isset($_GET['totalRows_getTimeSheet'])) {
  $totalRows_getTimeSheet = $_GET['totalRows_getTimeSheet'];
} else {
  $all_getTimeSheet = mysql_query($query_getTimeSheet);
  $totalRows_getTimeSheet = mysql_num_rows($all_getTimeSheet);
}
$totalPages_getTimeSheet = ceil($totalRows_getTimeSheet/$maxRows_getTimeSheet)-1;

mysql_select_db($database_oprmConn, $oprmConn);
$query_getRes1 = "SELECT weby_users.user_id, weby_users.employee_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_users.status, weby_profiles.hr_rate FROM weby_users, weby_profiles WHERE weby_profiles.user_id = weby_users.user_id AND weby_profiles.status = 'A' AND weby_users.user_role != '1' AND weby_users.status in ('A','P','R')";
$getRes1 = mysql_query($query_getRes1, $oprmConn) or die(mysql_error());
$row_getRes1 = mysql_fetch_assoc($getRes1);
$totalRows_getRes1 = mysql_num_rows($getRes1);

mysql_select_db($database_oprmConn, $oprmConn);
$query_getProj = "SELECT * FROM weby_projects WHERE weby_projects.status = 'A'";
$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());
$row_getProj = mysql_fetch_assoc($getProj);
$totalRows_getProj = mysql_num_rows($getProj);
?><!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 Resource List</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]-->
    <style>
.act_resource { background: #373938;
  color: #fff;}
.pendinglink a {
	  background: #004183;
    color: white;
    padding: 5px 15px;
    float: left;
  }
</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" style="width:100%;">
    <h1>All Resources </h1>
    <?php if(isset($_REQUEST['msg']) ){ ?>
<font color="#FF0000"><?php echo $msg; ?><a href="resources-list.php"><img src="/RM/images/cross.png" width="12" height="12" alt="delete"></a></font>
<div class="clear-fix">&nbsp;</div><?php } ?>
<?php  $getParms = $_GET["type"]; ?>
<form method="get">
       <div class="filter-wrapper">
           <select id="employe-filter" name="type" onchange="javascript:this.form.submit()">
          <option  value="">All Employe</option>
          <option <?php if($getParms == 'A'){ ?> selected <?php } ?> value="A">Active Employe</option>
          <option <?php if($getParms == 'R'){ ?> selected <?php } ?> value="R">Resigned Employe</option>
        </select>
       </div>
       </form>
<div class="pendinglink"><a href="/RM/admin/pending-resources-list">Pending Resources List</a></div>
	   
	   
    <div class="search_box">
      <form action="#" method="post" id="search">
        <input name="search" type="text" size="30" />
        <input name="submit" type="submit" value="Search" />
      </form>
    </div>
    <div class="clear-fix">&nbsp;</div>
    <article class="resource_list clear_fix"><?php  $odd=1; ?>
    <?php if($totalRows_getRes1>0) { do { ?>
    <?php

    if($row_getRes1['status'] === $getParms){ ?>
   
    <div class="resource_item odd <?php if($row_getRes1['status']=="A") echo "active"; ?>">
      <div class="img_wrap"><img src="/RM/images/<?php if(!empty($row_getRes1['profile_pic'])) echo $row_getRes1['profile_pic']; else echo "black-img.jpg";?>" width="68"></div>
      <p class="resource_title"><?php echo $row_getRes1['full_name']; ?><span class="desig"><br>
          <?php echo $row_getRes1['job_title']; ?> <!-- <br/>		  Emp id: KL0<?php //echo $row_getRes1['employee_id']; ?>		-->  </span></p>
      <p class="resource_desc"><?php echo substr($row_getRes1['skill_set'],0,100); ?></p>
      <div class="resource_details"> <span class="reource_label lineheight"><strong>Current Project: </strong></span>
          
            <?php 
					  mysql_select_db($database_oprmConn, $oprmConn);
$query_getProf = "SELECT b.project_name FROM weby_users_projects a, weby_projects b WHERE a.user_id = '$row_getRes1[user_id]' AND a.project_id = b.projetc_id and a.status = 'A' and projetc_id NOT IN ('10', '11')";
$getProf = mysql_query($query_getProf, $oprmConn) or die(mysql_error());
$row_getProf = mysql_fetch_assoc($getProf);
$totalRows_getProf = mysql_num_rows($getProf);
if($totalRows_getProf>0) {
 ?>


            <?php do { ?>
              <li class="projecttitle"><?php echo $row_getProf['project_name']; ?></li>

              <?php } while ($row_getProf = mysql_fetch_assoc($getProf)); ?>
            <?php } else { echo "<br> No Project Assigned"; } ?>
          
      </div>
     <!-- <div class="resource_details"> <span class="reource_label">Rate: </span>
          <h4>&pound; <?php //echo $row_getRes1['hr_rate']; ?></h4>
      </div>-->
     <div class="edit_links"> <a href="resources-view.php?user_id=<?php echo $row_getRes1['user_id']; ?>" class="view"></a> <a href="resources-view.php?user_id=<?php echo $row_getRes1['user_id']; ?>" class="edit"></a> </div></div>
     <?php } 
     if($getParms == ''){
     ?>
     
     <div class="resource_item odd <?php if($row_getRes1['status']=="A") echo "active"; ?>">
      <div class="img_wrap"><img src="/RM/images/<?php if(!empty($row_getRes1['profile_pic'])) echo $row_getRes1['profile_pic']; else echo "black-img.jpg";?>" width="68"></div>
      <p class="resource_title"><?php echo $row_getRes1['full_name']; ?><span class="desig"><br>
          <?php echo $row_getRes1['job_title']; ?> <!-- <br/>		  Emp id: KL0<?php //echo $row_getRes1['employee_id']; ?>		-->  </span></p>
      <p class="resource_desc"><?php echo substr($row_getRes1['skill_set'],0,100); ?></p>
      <div class="resource_details"> <span class="reource_label lineheight"><strong>Current Project: </strong></span>
          
            <?php 
					  mysql_select_db($database_oprmConn, $oprmConn);
$query_getProf = "SELECT b.project_name FROM weby_users_projects a, weby_projects b WHERE a.user_id = '$row_getRes1[user_id]' AND a.project_id = b.projetc_id and a.status = 'A' and projetc_id NOT IN ('10', '11')";
$getProf = mysql_query($query_getProf, $oprmConn) or die(mysql_error());
$row_getProf = mysql_fetch_assoc($getProf);
$totalRows_getProf = mysql_num_rows($getProf);
if($totalRows_getProf>0) {
 ?>


            <?php do { ?>
              <li class="projecttitle"><?php echo $row_getProf['project_name']; ?></li>

              <?php } while ($row_getProf = mysql_fetch_assoc($getProf)); ?>
            <?php } else { echo "<br> No Project Assigned"; } ?>
          
      </div>
     <!-- <div class="resource_details"> <span class="reource_label">Rate: </span>
          <h4>&pound; <?php //echo $row_getRes1['hr_rate']; ?></h4>
      </div>-->
     <div class="edit_links"> <a href="resources-view.php?user_id=<?php echo $row_getRes1['user_id']; ?>" class="view"></a> <a href="resources-view.php?user_id=<?php echo $row_getRes1['user_id']; ?>" class="edit"></a> </div></div>
     <?php } ?>
     
    <?php } while ($row_getRes1 = mysql_fetch_assoc($getRes1)); } else echo "No records found"; ?>
    </article>
    </section>
    <!-- Sidebar Goes here -->
    <aside class="sidebar">
      <?php #include("timesheet.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($getRes1);
//mysql_free_result($getProf);
?>
<style>
    .filter-wrapper {
    width: 100%;
    text-align: right;
    margin-left: -10px;
}
select#employe-filter {
    width: 350px;
}
</style>