Current File : /home/inlingua/public_html/noida/icentex_noida/general_leave/leaves.select.php |
<?php
// Copyright, Panalink Infotech Limited. Created on: 17-03-2011
// Include header
include "header_leave.php";
?>
<script language="javascript">
$(function() {
$('#datepicker1').datepicker({
changeMonth: true,
changeYear: true
});
});
$(function() {
$('#datepicker2').datepicker({
changeMonth: true,
changeYear: true
});
});
</script>
<script>
$(document).ready(function(){
$(".lightbox").colorbox({width:"50%", height:"60%", iframe:true});
});
</script>
<?php
if($_REQUEST['st']=="waiting") $st="Pending Leaves";
if($_REQUEST['st']=="approved") $st="Approved Leaves";
if($_REQUEST['st']=="disapproved") $st="Denied Leaves";
if($_REQUEST['st']=="calSelf") $st="Cancel By Self Leaves";
echo"<div id='contentnew'><h4>".$st."</h4>";
echo"<div style='margin-left:10px;'>";
//echo"<div><a href='leaves.main.php'>Apply For Leave</a></div>";
// Include the database connection details
require('../dbConnection.php');
// Include common functions
require('../commonFunc.php');
// Include common functions
require('../globalVars.php');
// Include the table handler class
require('../dbHandler.class.php');
// Init and connect to database
$dbObject = new dbHandler();
$dbObject->connect();
$queryLWC="select count(id) as tot from leaves_non_teach where status='waiting' && timesheet_user_id='".$_SESSION['id']."'";
$resultLWC=mysql_query($queryLWC);
$numLWC=mysql_fetch_array($resultLWC);
$sqlQuery = "SELECT * FROM leaves_non_teach where 1=1";
if($_REQUEST['fromDate_search']!="" && $_REQUEST['toDate_search']=="") { $sqlQuery.=" && fromDate='".$_REQUEST['fromDate_search']."'"; }
else if($_REQUEST['fromDate_search']!="" && $_REQUEST['toDate_search']!="") { $sqlQuery.=" && fromDate>='".$_REQUEST['fromDate_search']."' && toDate<='".$_REQUEST['toDate_search']."'"; }
// Records selection sql
$sqlQuery .= " && status='".$_REQUEST['st']."' && timesheet_user_id='".$_SESSION['id']."'";
$sqlQuery .=" order by leaveAppliedDate desc";
// Prepare page navigation
$resultsPerPage = 20; // number of rows to return per page
$offset=$_REQUEST['offset'];
// Prepare add on URL
$addOnUrl = "&st=".$_REQUEST['st']."&fromDate_search=".$_REQUEST['fromDate_search']."&toDate_search=".$_REQUEST['toDate_search']."";
if ($resultsPerPage > 0)
{ $prev_next_links = $dbObject->prev123Next($sqlQuery, $resultsPerPage,$addOnUrl);
$sqlQuery .= " limit " . $offset . "," . $resultsPerPage ;
}
// Print navigation bar
function printArray($element) { echo "$element"; }
if ($resultsPerPage > 0 && $prev_next_links)
{ //echo "Page: ";
//array_walk($prev_next_links, 'printArray');
}
// Select records from table
$selectedRecords = $dbObject->Select($sqlQuery);
echo"<form action='leaves.select.php' method='POST'><input type='hidden' name='st' value='$_REQUEST[st]'>";
echo"From <input type='text' name='fromDate_search' size='10' id='datepicker1' value='$_REQUEST[fromDate_search]'></td><td> To <input type='text' name='toDate_search' size='10' id='datepicker2' value='$_REQUEST[toDate_search]'> <input type='submit' value='Search'><br><br></form>";
echo "<table border='0' class='pa-nor' cellspacing='0' width='100%'>";
echo "<tr valign='left' class='rowH' style='height:30px;'>";
//echo "<th><b>id</b></th>";
//echo "<th><b>timesheet_user_id</b></th>";
echo "<th><b>From Date</b></th>";
echo "<th><b>To Date</b></th>";
echo "<th><b>Days</b></th>";
echo "<th><b>Applied Date</b></th>";
echo "<th>Action</th>";
echo "</tr>";
// If no records selected, print message
if (!$selectedRecords)
{ echo "<tr><td colspan='5'>There are no selected records</td></tr>"; }
while($objectData=$dbObject->SelectNext())
{
if($i%2==0) $bgcolor='#F3F3F3';
else $bgcolor='#EBEBEB';
echo "<tr valign='top' style='background:$bgcolor;height:25px;' onmouseover=\"this.className='pa-row-highlight'\" onmouseout=\"this.className='pa-nor'\">";
//echo "<td>$objectData[id]</td>";
//echo "<td>$objectData[timesheet_user_id]</td>";
if($objectData['emergencyLeave']=="Yes" && $objectData['IsclassesSubstituted']=="No")
{
$com="<font size='1'>Compensated</font>";
}
else
{
$com="";
}
echo "<td>$objectData[fromDate]<br>".$com."</td>";
echo "<td>$objectData[toDate]</td>";
echo "<td>$objectData[noofdays]</td>";
echo "<td>$objectData[leaveAppliedDate]</td>";
echo "<td>";
echo "<a href='leaves_non_teach.main.php?aC=sV&kV=". $objectData['id'] ."'>View</a> ";
if($objectData['fromDate']> date("Y-m-d") && ($_REQUEST['st']=='waiting' || $_REQUEST['st']=="approved"))
{
echo "| <a href='javascript:cancelleaves(".$objectData['id'].");'>Cancel</a>";
}
echo"</td>";
echo "</tr>";
$i++;
}
print "</table>";
// Print navigation bar
if ($resultsPerPage > 0 && $prev_next_links)
{ echo "Page: ";
array_walk($prev_next_links, 'printArray');
}
?>
</div></div>
<script>
function cancelleaves(val)
{
if(confirm("Are you sure?"))
{
fromDate_search="<?php echo $_REQUEST['fromDate_search']?>";
toDate_search="<?php echo $_REQUEST['toDate_search']?>";
location.href="leaves.main.php?aC=Update&kV="+val+"&fromDate_search="+fromDate_search+"&toDate_search="+toDate_search+"";
}
else
{
return false;
}
}
</script>
<br>
<br>
<?php
$dbObject->CloseConnection();
// Include footer
include "footer_leave.php";
?>