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







<?php $msg = ""; if(isset($_REQUEST['msg'])) $msg = $_REQUEST['msg']; ?>







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







}







}















$leaveuid = $_GET['leaveid'];







$maxRows_getLeave = 2;







$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_getLeave = "SELECT distinct 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_profiles.user_id, weby_profiles.full_name, weby_profiles.profile_pic, weby_profiles.job_title, weby_profiles.skill_set, weby_projects.project_name, weby_users.user_id, weby_users.total_leaves, weby_users.email_address FROM weby_leave, weby_profiles, weby_projects, weby_users WHERE weby_leave.user_id = weby_profiles.user_id And weby_profiles.user_id = weby_users.user_id AND weby_leave.leave_id = $leaveuid order by weby_leave.updated_date";







$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_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;























?>























<!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 View</title>







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





  <script src="//code.jquery.com/jquery-1.10.2.js"></script>







  <script src="//code.jquery.com/ui/1.9.1/jquery-ui.js"></script>







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







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







	<![endif]-->







    <script>







function cancel() {







  location.href = "leave-list.php";







}







</script>







 <script>







$(function() {













  	$( "#start_date" ).datepicker({ dateFormat:'d-M-yy', changeDate: true,    changeMonth: true,  changeYear: true   });







	$( "#end_date" ).datepicker({ dateFormat:'d-M-yy', changeDate: true,    changeMonth: true,  changeYear: true   });







  







});















</script>







<script>







function calculateDate()







{







	try{







var startdate = document.getElementById('start_date').value;















var enddate = document.getElementById('end_date').value;















var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds







var firstDate = new Date(startdate);







var secondDate = new Date(enddate);















var totaldays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay))+1);

var n_days = 0;

var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var start = firstDate;
var end = secondDate;
while(start <= end){
  var d = start.getDay();
  if(d == 0 || d == 6){
    // do nothing
  }
  else{
    n_days = n_days + 1;
  }
    var newDate = start.setDate(start.getDate() + 1);
    start = new Date(newDate);
}

totaldays = n_days;













document.getElementById('leave_duration1').value = totaldays;















}







catch(e){















}















}















</script>







<script>







function validateForm() {







//alert(document.getElementById("leave").value);















	//return false;







   







	/*var startdate = document.getElementById('start_date').value;







	if (startdate == "") {







       alert("Start Date be filled out\n");







        return false;







    }*/







	







	/*var reason = document.getElementById('leave_reason').value;







	if (reason == "") {







        alert("Reason be filled out\n");







        return false;







    }*/







	var startdate = document.getElementById('start_date').value;







	var today = new Date();















	var mm = today.getMonth()+1; //January is 0!







	var dd = today.getDate();







	var yyyy = today.getFullYear();















	if(dd<10) {







    dd='0'+dd







	} 







	if(mm<10) {







    mm='0'+mm







	} 







	today = mm+'/'+dd+'/'+yyyy;







		







		







	//if (startdate < today) {



//



//       alert("Check From Date\n");



//



//        return false;



//



//    }







	







	







	var startdate = document.getElementById('start_date').value;







	var enddate = document.getElementById('end_date').value;






startdate = new Date(startdate);
enddate = new Date(enddate);
	if(startdate > enddate){







		alert("Check The Dates Entered\n");







        return false;







	}	







	if(enddate == "")







	{







		echo(document.getElementById('end_date').value = document.getElementById('start_date').value);







	}







	//var enddate = document.getElementById('end_date').value;



//



//	var today = new Date();



//



//



//



//	var mm = today.getMonth()+1; //January is 0!



//



//	var dd = today.getDate();



//



//	var yyyy = today.getFullYear();



//



//



//



//	if(dd<10) {



//



//    dd='0'+dd



//



//	} 



//



//	if(mm<10) {



//



//		mm='0'+mm



//



//	} 



//



//	today = mm+'/'+dd+'/'+yyyy;



//



//		



//



//		



//



//		if (enddate < today && startdate!='') {



//



//		



//



//        alert("Check End Date Date \n");



//



//        return false;



//



//    }







			else{







		alert("Leave status updated successfully")







	}







	







	















    }







	















</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 style="float: left;">Leave view</h1>

<p class="text_right" style="float: right;padding-right: 50px;">Total Leaves (<?php echo date("Y"); ?>): <strong><?php echo $row_getLeave['total_leaves']; ?></strong><br>

Used Leaves: <strong><?php $year = date('Y');

$query_getusedleaves = "SELECT SUM(`leave_duration`) AS usedleaves FROM weby_leave WHERE status = 'A' AND user_id = '$row_getLeave[user_id]' AND YEAR(start_date) = '$year'AND leave_type_id ='1'";

$getusedleaves = mysql_query($query_getusedleaves, $oprmConn) or die(mysql_error());

$row_getusedleaves = mysql_fetch_assoc($getusedleaves);

$usedleaves = $row_getusedleaves['usedleaves'];

if($usedleaves<=0){ $usedleaves = 0; } echo $usedleaves; ?></strong><br>

Balance Leaves: <strong><?php $Balance = $row_getLeave['total_leaves']-$usedleaves; echo $Balance; ?></strong><br>
Unpaid Leaves: <strong><?php $year = date('Y');

$query_getunpaidleave = "SELECT SUM(`leave_duration`) AS unpaidleave FROM weby_leave WHERE status = 'A' AND user_id = '$row_getLeave[user_id]' AND YEAR(start_date) = '$year'AND leave_type_id ='3'";

$getunpaidleave = mysql_query($query_getunpaidleave, $oprmConn) or die(mysql_error());

$row_getunpaidleave = mysql_fetch_assoc($getunpaidleave);

$unpaidleave = $row_getunpaidleave['unpaidleave'];

if($unpaidleave<=0){ $unpaidleave = 0; } echo $unpaidleave; ?></strong><br>
Absent : <strong><?php $year = date('Y');

$query_getabsentleave = "SELECT SUM(`leave_duration`) AS absentleave FROM weby_leave WHERE status = 'A' AND user_id = '$row_getLeave[user_id]' AND YEAR(start_date) = '$year'AND leave_type_id ='4'";

$getabsentleave = mysql_query($query_getabsentleave, $oprmConn) or die(mysql_error());

$row_getabsentleave = mysql_fetch_assoc($getabsentleave);

$absentleave = $row_getabsentleave['absentleave'];

if($absentleave<=0){ $absentleave = 0; } echo $absentleave; ?></strong><br>
</p>

<?php if(isset($_REQUEST['msg']) ){ ?>

<font color="#FF0000"><?php echo $msg; ?><a href="profile.php"><img src="/RM/images/cross.png" width="12" height="12" alt="delete"></a></font> <?php } ?>





<div class="admin_container clear_fix blue"> 

<div class="profile_img"><img src="/RM/images/<?php if(!empty($row_getProf['profile_pic']))echo $row_getProf['profile_pic']; else echo "black-img.jpg"; ?>" width="68" height="78" /></div>

<div class="resource_desc">

<h3><?php echo $row_getLeave['full_name']; ?><span class="desig"><br />







              <?php echo $row_getLeave['job_title']; ?> </span></h3>







                    <!--<input type="submit" value="Save" />--></span></h3>







				<span class="desig"><br />







Email Address: <?php echo $row_getLeave['email_address']; ?>  </span><br>            </div>







                







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







               <form action="update-leave.php" name="leave_view" method="POST" id="leave_view" onsubmit="return validateForm()"><br />







                <div class="left_side">



<div class="field_item">



               <label for="status"> Leave From:

                 </label>







                 <input type="hidden" name="hiddenField" id="hiddenField" />







               







                <input type="text" name="start_date" id="start_date" value="<?php echo date('d-M-Y',strtotime($row_getLeave['start_date'])); ?>"  readonly="readonly" />

</div>

<div class="field_item">



               <label for="status">Leave To:</label>







                 <input type="hidden" name="hiddenField" id="hiddenField" />







               







            <input type="text" name="end_date" id="end_date" value="<?php if($row_getLeave['end_date'] != NULL){ echo date('d-M-Y', strtotime($row_getLeave['end_date'])); } else{ echo date('d-M-Y', strtotime($row_getLeave['start_date'])); } ?>" onchange="calculateDate();" readonly="readonly" /></div>



<div class="field_item">



               <label for="status">  Leave Duration:</label>







                 <input type="hidden" name="hiddenField" id="hiddenField" />







               







              <input name="leave_duration1" type="text" id="leave_duration1" value=" <?php echo $row_getLeave['leave_duration']; ?>" readonly="readonly" />

</div>

<div class="field_item">



             <label for="status">Leave Reason :</label>







                 <input type="hidden" name="hiddenField" id="hiddenField" />







               







               <textarea rows="4" cols="50" name="text" id="text"  ><?php echo $row_getLeave['leave_reason']; ?></textarea>



</div>



             	

<div class="field_item">

<label>Leave Type:</label>

<select name="leave_type_id" id="leave_type_id">

<option value="ALL">ALL</option>

<?php mysql_select_db($database_oprmConn, $oprmConn);

$query_getleavetype = "SELECT * FROM weby_leave_types WHERE status = 'A' ORDER BY leave_type_id ASC";

$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){ do { ?>

<option value="<?php echo $row_getleavetype['leave_type_id']; ?>" <?php if($row_getleavetype['leave_type_id']==$row_getLeave['leave_type_id']){ ?> selected <?php } ?>><?php echo $row_getleavetype['leave_type_name']; ?></option>

<?php } while ($row_getleavetype = mysql_fetch_assoc($getleavetype)); } ?>

</select>

</div>





                  <div class="field_item">







					<label for="status">Status: </label>







                    <select name="status">







                      <option value="A"<?php if($row_getLeave['status']=="A") echo "selected"; ?>>Approve</option>







                      <option value="P" <?php if($row_getLeave['status']=="P") echo "selected"; ?>>Pending</option>







                      <option value="R" <?php if($row_getLeave['status']=="R") echo "selected"; ?>>Rejected</option>







                      <option value="C" <?php if($row_getLeave['status']=="C") echo "selected"; ?>>Canceled</option>





<option value="D" <?php if($row_getLeave['status']=="D") echo "selected"; ?>>Deleted</option>

                      







                    </select>







                    







                  </div>







                  <div class="field_item">







					<label for="status" style="width:200px; font-size:15px;">Currently Working Project(s): </label>







                                         







                   <label style="width: 235px; float: right; margin-bottom: 10px;"> <?php 



					mysql_select_db($database_oprmConn, $oprmConn);







			$query_getUprojects = "select * FROM weby_users_projects where user_id = '$row_getLeave[user_id]' AND status = 'A' AND weby_users_projects.project_id NOT IN ('10', '11')";



			



			$getUprojects = mysql_query($query_getUprojects, $oprmConn) or die(mysql_error());







$row_getUprojects = mysql_fetch_assoc($getUprojects);







$totalRows_getUprojects = mysql_num_rows($getUprojects);



			do{ 



			mysql_select_db($database_oprmConn, $oprmConn);







$query_getPid = "select * FROM weby_projects where projetc_id = '$row_getUprojects[project_id]' and status = 'A'";







$getPid = mysql_query($query_getPid, $oprmConn) or die(mysql_error());







$row_getPid = mysql_fetch_assoc($getPid);







$totalRows_getPid = mysql_num_rows($getPid);



					echo $row_getPid['project_name'].'<br>';



			



			  } while ($row_getUprojects = mysql_fetch_assoc($getUprojects)); ?></label>



			



			







</div>







                    <div class="action_items">







                    	<input type="submit" value="Save" name="submit" class="save_btn" onclick="MM_validateForm('start_date','','R','end_date','','R','status','','R');return document.MM_returnValue">







<input type="hidden" name="leave_id" id="leave_id" value="<?php echo "$leaveuid"; ?>" /> <input type="reset" value="Cancel" class="reset_btn" onclick="cancel()"  />







                        







                    </div>







                    







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







                    







             	







               </div></form>







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







             </div>







    </section>







    







    	<!-- Sidebar Goes here -->







           <aside class="sidebar"> 







       	  <?php /*?><div class="featured clear_fix">







            	<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" height="78" /></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-row'>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" 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" height="78" /></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>







