<?php require_once('../Connections/oprmConn.php'); include('check-admin-session.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;



}



}







$maxRows_getLeave = 10;



$pageNum_getLeave = 0;



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



  $pageNum_getLeave = $_GET['pageNum_getLeave'];



}



$startRow_getLeave = $pageNum_getLeave * $maxRows_getLeave;



mysql_select_db($database_oprmConn, $oprmConn);



$query_getSelect = "SELECT weby_users.user_id,  weby_users.caeated_date, weby_profiles.full_name, weby_users.status FROM weby_users, weby_profiles WHERE weby_profiles.user_id = weby_users.user_id AND weby_users.status = 'A' AND weby_profiles.status = 'A' AND weby_users.user_role != '1' ";



$getSelect = mysql_query($query_getSelect, $oprmConn) or die(mysql_error());



$row_getSelect = mysql_fetch_assoc($getSelect);



$totalRows_getSelect = mysql_num_rows($getSelect);















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



mysql_select_db($database_oprmConn, $oprmConn);



$query_getLeave = "SELECT weby_profiles.user_id, weby_profiles.full_name, weby_leave.leave_id, weby_leave.user_id, weby_leave.start_date, weby_leave.end_date, weby_leave.leave_duration, weby_leave.leave_reason, weby_leave.leave_type_id, weby_leave.status, weby_leave.created_date, weby_users.user_id FROM weby_profiles, weby_leave, weby_users WHERE weby_leave.user_id = weby_users.user_id AND weby_leave.user_id = weby_profiles.user_id AND weby_profiles.status = 'A' AND weby_leave.status!='D'  ORDER BY weby_leave.start_date DESC";



$query_limit_getLeave = sprintf("%s LIMIT %d, %d", $query_getLeave, $startRow_getLeave, $maxRows_getLeave);



$getLeave = mysql_query($query_limit_getLeave, $oprmConn) or die(mysql_error());



$row_getLeave = mysql_fetch_assoc($getLeave);



}











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



$uidd = $_GET['uid'];







mysql_select_db($database_oprmConn, $oprmConn);



$query_getLeave = "SELECT weby_profiles.user_id, weby_profiles.full_name, weby_leave.leave_id, weby_leave.user_id, weby_leave.start_date, weby_leave.end_date, weby_leave.leave_duration, weby_leave.leave_reason, weby_leave.status, weby_leave.created_date, weby_users.user_id FROM weby_profiles, weby_leave, weby_users WHERE weby_leave.user_id = weby_users.user_id AND weby_leave.user_id = weby_profiles.user_id and weby_leave.user_id = '$uidd' AND weby_profiles.status = 'A' AND weby_leave.status!='D' ORDER BY weby_leave.start_date DESC";



$query_limit_getLeave = sprintf("%s LIMIT %d, %d", $query_getLeave, $startRow_getLeave, $maxRows_getLeave);



$getLeave = mysql_query($query_limit_getLeave, $oprmConn) or die(mysql_error());



$row_getLeave = mysql_fetch_assoc($getLeave);



if($uidd == 'ALL'){



$url="leave-list.php";



	header("Location:$url");



    }



}



















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



  $totalRows_getLeave = $_GET['totalRows_getLeave'];



} else {



  $all_getLeave = mysql_query($query_getLeave);



  $totalRows_getLeave = mysql_num_rows($all_getLeave);



}



$totalPages_getLeave = ceil($totalRows_getLeave/$maxRows_getLeave)-1;







$queryString_getLeave = "";



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



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



  $newParams = array();



  foreach ($params as $param) {



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



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



      array_push($newParams, $param);



    }



  }



}















/*



mysql_select_db($database_oprmConn, $oprmConn);



$query_getLeave = "SELECT weby_profiles.user_id, weby_profiles.full_name, weby_leave.leave_id, weby_leave.user_id, weby_leave.start_date, weby_leave.end_date, weby_leave.leave_duration, weby_leave.leave_reason, weby_leave.status, weby_leave.created_date, weby_users.user_id FROM weby_profiles, weby_leave, weby_users WHERE weby_leave.user_id = weby_users.user_id AND weby_leave.user_id = weby_profiles.user_id order by weby_leave.updated_date desc";



$query_limit_getLeave = sprintf("%s LIMIT %d, %d", $query_getLeave, $startRow_getLeave, $maxRows_getLeave);



$getLeave = mysql_query($query_limit_getLeave, $oprmConn) or die(mysql_error());



$row_getLeave = mysql_fetch_assoc($getLeave);







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



  $totalRows_getLeave = $_GET['totalRows_getLeave'];



} else {



  $all_getLeave = mysql_query($query_getLeave);



  $totalRows_getLeave = mysql_num_rows($all_getLeave);



}



$totalPages_getLeave = ceil($totalRows_getLeave/$maxRows_getLeave)-1;



*/







$maxRows_getRes = 2;



$pageNum_getRes = 0;



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



  $pageNum_getRes = $_GET['pageNum_getRes'];



}



$startRow_getRes = $pageNum_getRes * $maxRows_getRes;







mysql_select_db($database_oprmConn, $oprmConn);



$query_getRes = "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_users.status = 'P' AND weby_profiles.user_id = weby_users.user_id";



$query_limit_getRes = sprintf("%s LIMIT %d, %d", $query_getRes, $startRow_getRes, $maxRows_getRes);



$getRes = mysql_query($query_limit_getRes, $oprmConn) or die(mysql_error());



$row_getRes = mysql_fetch_assoc($getRes);







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



  $totalRows_getRes = $_GET['totalRows_getRes'];



} else {



  $all_getRes = mysql_query($query_getRes);



  $totalRows_getRes = mysql_num_rows($all_getRes);



}



$totalPages_getRes = ceil($totalRows_getRes/$maxRows_getRes)-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_users.status = 'A' AND weby_users.user_role <> 1 AND weby_profiles.user_id = weby_users.user_id AND weby_profiles.status = 'A'";



$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_getPassEx = "select p.*, passport_edate - current_date as days_left FROM weby_profiles p,weby_users a where p.user_id = a.user_id and a.status = 'A' having days_left <= 180";



$getPassEx = mysql_query($query_getPassEx, $oprmConn) or die(mysql_error());



$row_getPassEx = mysql_fetch_assoc($getPassEx);



$totalRows_getPassEx = mysql_num_rows($getPassEx);



?>
<!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-Leave 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]-->

<script type='text/javascript'>



function redirect(){







var uid = document.getElementById('uid').options[document.getElementById('uid').selectedIndex].value;







window.location = "leave-list.php?uid="+uid+"";







}







</script>
<style>
.act_leave  { 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 --> 
  
  <!-- Content Goes here -->
  
  <article class="inside_wrapper clear_fix"> 
    
    <!-- Main Content Goes here -->
    
    <section class="main_content">
      <h1>Current Leaves</h1>
      <?php if(isset($_REQUEST['msg']) ){ ?>
      <div class="msg_cancel"><font color="#FF0000"><?php echo $msg; ?><a href="leave-list.php"><img src="/RM/images/cross.png" width="12" height="12" alt="delete"></a></font></div>
      <?php } ?>
      <div class="welcome_box">
        <div class="timesheet_type">
          <div class="welcome_box1" style="top:0px; padding:0px;">
            <div class="welcome_txt"><strong>Select Resource: </strong>
              <select name="uid" id="uid" onChange="redirect();">
                <option value="ALL">ALL</option>
                <?php do { ?>
                <option value="<?php echo $row_getSelect['user_id']; ?>"  <?php if($row_getSelect['user_id'] == $_GET['uid']){ ?> selected="selected" <?php } ?> > <?php echo $row_getSelect['full_name']; ?> </option>
                <?php } while ($row_getSelect = mysql_fetch_assoc($getSelect)); ?>
              </select>
              <a href="leave-print.php<?php if(isset($_GET['uid'])){?>?uid=<?php echo $row_getLeave['user_id'];}?>"><img src="/RM/images/csv.jpg" style="height:20px; width:25px;" /></a></div>
          </div>
        </div>
      </div>
      
      <!--<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> --> 
      
      <!-- Timesheets Goes here -->
      
      <div class="timesheet_table clear_fix">
        <div class="column_title"> <span class="item_small">Resource Name </span><span class="item_small">From Date</span><span class="item_small">To Date</span><span class="item_small">Duration</span><span class="item_small">Leave Type</span><span class="item_small">Reason</span><span class="item_small">Status</span><!--<span class="item_small">Rate(£)</span><span class="item_small">Total</span>--> 
          
        </div>
        <?php if($totalRows_getLeave) { do { ?>
          <div class="row <?php if($n==0) { echo "yellow"; $n=1; } else $n=0; ?>"> <span class="item_small"><?php echo $rest = substr($row_getLeave['full_name'], 0,10); ?></span><span class="item_small"><?php echo date('d/M/Y',strtotime($row_getLeave['start_date'])); ?></span><span class="item_small">
            <?php if($row_getLeave['leave_duration'] > 1){ echo date('d/M/Y',strtotime($row_getLeave['end_date']));} ?>
            </span><span class="item_small"><?php echo $row_getLeave['leave_duration']; ?></span>
<span class="item_small"><?php $query_getleavetype = "SELECT * FROM weby_leave_types WHERE status = 'A' AND leave_type_id = '$row_getLeave[leave_type_id]'";
$getleavetype = mysql_query($query_getleavetype, $oprmConn) or die(mysql_error());
$row_getleavetype = mysql_fetch_assoc($getleavetype);
$totalRows_getleavetype = mysql_num_rows($getleavetype);
if($totalRows_getleavetype>0){ echo $row_getleavetype['leave_type_name']; } else { echo '-'; } ?></span>
<span class="item_small" title="<?php echo $row_getLeave['leave_reason']; ?>"><?php echo $rest = substr($row_getLeave['leave_reason'], 0, 10); ?>...</span><span class="item_small"><a href="leave-view.php?leaveid=<?php echo $row_getLeave['leave_id']; ?>"><strong>
            <input type="submit" name="submit" class="save_btn" value="<?php  if($row_getLeave['status']=="P"){



	   $s = "Pending";} if($row_getLeave['status']=="R"){



	   $s = "Rejected";} if($row_getLeave['status']=="C"){



	   $s = "Cancled";} if($row_getLeave['status']=="A"){

	   $s = "Approved";}

	 if($row_getLeave['status']=="D"){

	   $s = "Deleted";}

	    echo $s; ?>">
            </strong></a></span> </div>
          <?php } while ($row_getLeave = mysql_fetch_assoc($getLeave)); ?>
        <div class="nav-right">
          <table width="600" border="0" align="center" cellpadding="2" style="clear:both">
            <tr>
              <td colspan="4" align="center"><?php echo ($startRow_getLeave + 1) ?> to <?php echo min($startRow_getLeave + $maxRows_getLeave, $totalRows_getLeave) ?> of <?php echo $totalRows_getLeave ?></td>
            </tr>
            <tr>
              <td align="center"><?php if ($pageNum_getLeave > 0) { // Show if not first page ?>
                  <a href="<?php printf("%s?pageNum_getLeave=%d%s", $currentPage, 0, $queryString_getLeave); ?>">&lt;&lt; First</a>
                  <?php } // Show if not first page ?></td>
              <td align="center"><?php if ($pageNum_getLeave > 0) { // Show if not first page ?>
                  <a href="<?php printf("%s?pageNum_getLeave=%d%s", $currentPage, max(0, $pageNum_getLeave - 1), $queryString_getLeave); ?>">&lt; Previous</a>
                  <?php } // Show if not first page ?></td>
              <td align="center"><?php if ($pageNum_getLeave < $totalPages_getLeave) { // Show if not last page ?>
                  <a href="<?php printf("%s?pageNum_getLeave=%d%s", $currentPage, min($totalPages_getLeave, $pageNum_getLeave + 1), $queryString_getLeave); ?>">Next &gt;</a>
                  <?php } // Show if not last page ?></td>
              <td align="center"><?php if ($pageNum_getLeave < $totalPages_getLeave) { // Show if not last page ?>
                  <a href="<?php printf("%s?pageNum_getLeave=%d%s", $currentPage, $totalPages_getLeave, $queryString_getLeave); ?>">Last &gt;&gt;</a>
                  <?php } // Show if not last page ?></td>
            </tr>
          </table>
        </div>
        <?php } else echo "<div class='no-rows'>No records found</div>";?>
      </div>
      
      <!-- dislpay the expiring passport details --> 
      
      <!--<div class="timesheet_table">



       	  <div class="column_title">



                	<span class="item_wide">Resource Name</span><span class="item_wide">Visa Ex.Date </span><span class="item_wide">Visa Number</span><span class="item_wide">Days to Expire</span>



          </div>



                



                 <?php $n1 = 0; if($totalRows_getPassEx>0) { do { ?>



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



                     <span class="item_wide"><?php echo $row_getPassEx['full_name']; ?></span><span class="item_wide"><?php echo $row_getPassEx['passport_edate']; ?></span><span class="item_wide"><?php echo $row_getPassEx['passport_number']; ?></span> <span class="item_wide" <?php if($row_getPassEx['days_left']<=0) echo "style='color:#FF0000;'"; ?>><strong><?php echo $row_getPassEx['days_left']; ?></strong></span>                    </div>



                   <?php } while ($row_getPassEx = mysql_fetch_assoc($getPassEx)); } else echo "No Expiring Visa."; ?></div>--> 
      
      <!-- /end / --> 
      
    </section>
    
    <!-- Sidebar Goes here -->
    
    <aside class="sidebar">
      <?php /*?><div class="featured">
        <h2 class="white_txt">PENDING RESOURCES</h2>
        <?php if($totalRows_getRes>0) { do { ?>
        <div class="profile_box"> <a href="resources-view.php?user_id=<?php echo $row_getRes['user_id']; ?>"><img src="/RM/images/<?php if(!empty($row_getRes['profile_pic'])) echo $row_getRes['profile_pic']; else echo "black-img.jpg";?>" width="68" /></a>
          <p class="profile_title"><a href="resources-view.php?user_id=<?php echo $row_getRes['user_id']; ?>"><?php echo $row_getRes['full_name']; ?></a><span class="desig"><br />
            <?php echo $row_getRes['job_title']; ?></span></p>
          <p class="profile_desc"><?php echo $row_getRes['skill_set']; ?></p>
          <div class="clear-fix">&nbsp;</div>
        </div>
        <?php } while ($row_getRes = mysql_fetch_assoc($getRes)); } else { echo "<div class='no-rows'>No Pending Resources</div>";}?>
      </div><?php */?>
      <h2>ACTIVE RESOURCES</h2>
      <form action="resources-list.php" method="post" id="act_resource_search">
        <input name="search" class="search" type="text" size="30" />
        <input name="submit" type="submit" class="search-sub" 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 Active Resources</div>";} ?>
      
      <!-- <div class="profile_box"> <a href="resources-view.php?user_id=1234"><img src="/RM/images/black-img.jpg" /></a>



                    <p class="profile_title"><a href="resources-view.php?user_id=1234">David Masciana</a><span class="desig"><br />



				  IT Business Analyst</span></p>



                    <p class="profile_desc">Cisco IP knowledge is preferred to Cisco CCNA/Juniper JNCIA and similar level 		



                    ....</p>



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



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







mysql_free_result($getRes);







mysql_free_result($getRes1);







mysql_free_result($getPassEx);



?>