<?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 back_users.user_id, back_users.email_address, back_users.caeated_date, profiles.profile_id, profiles.full_name, profiles.job_title, profiles.skill_set, profiles.profile_pic FROM back_users, profiles WHERE back_users.status = 'A' AND profiles.user_id = back_users.user_id";

$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_clients WHERE weby_clients.status in ('A','P')";

$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" />

<link rel="stylesheet" href="../css/style.css" type="text/css">

<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">

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

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

<![endif]-->

<title>SS WEB TECHNOLOGIES- Admin Dash board</title>

<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">

function setVisibility(id, visibility) {

document.getElementById(id).style.display = visibility;

}

</script>

<style>

.act_client {

	background: #373938 !important;

	color: #fff !important;

}

</style>

</head>



<body>

<div id="wrapper">



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

    

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

    <article class="project_list_inside_wrapper clear_fix">

    

    <section class="main_content">

    	<h1>Current Clients</h1>

        <?php 

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

		$msg1="Created Successfully";

		?>

         <div id="hide" class="msg_box">

      <font color="#3cda52"><?php echo $msg1; ?><img src="/RM/images/cross.png" width="12" height="12" alt="delete" style="padding-left:5px;" onclick="setVisibility('hide', 'none');"></font></div>

      <?php

		} 

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

		$msg2="Modified Successfully";

		?>

         <div id="hide" class="msg_box">

      <font color="#3cda52"><?php echo $msg2; ?><img src="/RM/images/cross.png" width="12" height="12" alt="delete" style="padding-left:5px;" onclick="setVisibility('hide', 'none');"></font></div>

      <?php

		} 

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

		$msg="Detleted Successfully";

		?>

         <div id="hide" class="msg_box">

      <font color="#f80f2a"><?php echo $msg; ?><img src="/RM/images/cross.png" width="12" height="12" alt="delete" style="padding-left:5px;" onclick="setVisibility('hide', 'none');"></font></div>

      <?php

		} ?>

        <!--<a class="create_btn" href="project-status.php">Project Report</a>-->

      <a class="create_btn" href="client-manage.php">Create Client</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['client_name']; ?> <a href="client-delete.php?cid=<?php echo $row_getProj['client_id']; ?>"><img src="/RM/images/cross.png" width="14" height="15" alt="delete"></a></h2>

                

                

                <div class="desc">

                  <p>Contact Manager: <?php echo $row_getProj['client_contact_name']; ?><br/>

                  Contact Mail: <?php echo $row_getProj['client_mail']; ?><br/>

                  

                  Contact Phone No: <?php echo $row_getProj['client_phone']; ?><br/>

                  Created on: <?php echo date('d/M/Y',strtotime($row_getProj['crated_date'])); ?><br/>

                  Status: <?php if($row_getProj['status']=="A") echo "Active"; if($row_getProj['status']=="P") echo "Pending"; ?></p>

                </div>

                

                <p><?php echo $row_getProj['client_address']; ?></p>

                <a href="client-edit.php?clientid=<?php echo $row_getProj['client_id']; ?>">More details &gt;</a>

                

                    </div>

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

               </article>

    </section>

    <aside class="side_bar">

  <h2>ACTIVE RESOURCES</h2>



         <form action="#" method="post" id="act_resource_search" class="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"></div>

    </article>

  	<!--<article class="arrow-bar">

    </article>-->

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

    

    </div>



</body>

</html>