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

<?php include('check-admin-session.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_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;



$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 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_getProj = "SELECT * FROM weby_projects WHERE weby_projects.status = 'A' AND projetc_id NOT IN ('10', '11')";

$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  Project 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_prjt { 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">

    		 <h1>Current Project</h1>

             

                <!--<div class="welcome_box">

                <div class="timesheet_type"><div class="welcome_txt arrow">Welcome Admin

            	<ul> <li><a href="index.php">Dashboard</a></li>

                <li><a href="timesheet-all.php">Time sheet</a></li>

                <li><a href="project-list.php">Projects</a></li>

            	<li><a href="resources-list.php">Resources</a></li>

            	<li><a href="profile.php">Profile</a></li>

                <li><a href="leave-list.php">Leave Manager</a></li>

                 <li><a href="reports.php">Records</a></li>

            	<li><a href="logout.php">Logout</a></li>

            	</ul>	

                </div>

                </div>	

             </div> -->

             

    		<!-- Projects list Goes here --> 

            	<a class="create_btn" href="project-manage.php">Create Project</a>

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



            <article class="project_list clear_fix"><?php  $odd=1; ?>

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

              <div class="project_item <?php  if($odd==1){ echo "odd"; $odd=0; } else{ $odd=1; } ?>">

                <h2><?php echo $row_getProj['project_name']; ?> <a href="project-delete.php?pid=<?php echo $row_getProj['projetc_id']; ?>"><img src="/RM/images/cross.jpg" width="14" height="15" alt="delete"></a></h2>

                <p><?php echo substr($row_getProj['project_description'],0,200); ?></p>

                <a href="project-edit.php?projectid=<?php echo $row_getProj['projetc_id']; ?>">More details &gt;</a>

                <div class="desc">

                  <?php /*?><p>Created on: <?php echo date('d/M/Y',strtotime($row_getProj['crated_date'])); ?><br/>
<?php */?>
                    Status: <?php if($row_getProj['status']=="A") echo "Active"; ?></p>

                </div>

                    </div>

                <?php } while ($row_getProj = mysql_fetch_assoc($getProj)); } else echo "<div class='no-rows'>No Projets available</div>";?>

               </article>

        </section>

    

    	<!-- Sidebar Goes here -->

      <aside class="sidebar"> 

        	<?php #include("timesheet.php"); ?>

        	<h2>ACTIVE RESOURCES</h2>

         <form action="#" 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']; ?>"><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 Pending Resources</div>";} ?>

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

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



mysql_free_result($getTimeSheet);

?>