Current File : /home/inlingua/public_html/faridabad/icentex/admin_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:"70%", height:"60%", iframe:true});
});
</script>
<?php
function getInstructor($conn,$inst)
{
$query='select recNo, name from timesheet_user where usertype="user" and status="Active" order by name';
$res=mysqli_query($conn,$query);
$option .="<select name='name_instructor'><option value=''>Select</option>";
while($result=mysqli_fetch_array($res))
{
if($inst==$result[recNo]){
$option .="<option selected value='".$result[recNo]."'>".$result[name]."</option>";
}
else{$option .="<option value='".$result[recNo]."'>".$result[name]."</option>";}
}
$option .="</select>";
return $option;
}
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 where status='waiting'";
$resultLWC=mysqli_query($conn,$queryLWC);
$numLWC=mysqli_fetch_array($resultLWC);
// Records selection sql
$sqlQuery = "SELECT a.*,b.name,b.recNo FROM leaves a left join timesheet_user b on a.timesheet_user_id=b.recNo where 1=1 ";
if($_REQUEST['fromDate_search']!="" && $_REQUEST['toDate_search']=="") { $sqlQuery.=" && a.fromDate='".$_REQUEST['fromDate_search']."'"; }
else if($_REQUEST['fromDate_search']!="" && $_REQUEST['toDate_search']!="") { $sqlQuery.=" && a.fromDate>='".$_REQUEST['fromDate_search']."' && a.toDate<='".$_REQUEST['toDate_search']."'"; }
if($_REQUEST['name_instructor']!="") $sqlQuery.=" && b.recNo ='".$_REQUEST['name_instructor']."'";
$sqlQuery.= " && a.status='".$_REQUEST['st']."'";
$sqlQuery .=" order by a.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']."&name_instructor=".$_REQUEST['name_instructor']."";
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]'> Instructor ".getInstructor($conn,$_REQUEST['name_instructor'])." <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>Instructor</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><a href='leavebalance.php?id=".$objectData[recNo]."&name=".$objectData[name]."' class='lightbox'>$objectData[name]</a><br>".$com."</td>";
echo "<td>$objectData[fromDate]</td>";
echo "<td>$objectData[toDate]</td>";
echo "<td>$objectData[noofdays]</td>";
echo "<td>$objectData[leaveAppliedDate]</td>";
echo "<td>";
echo "<a href='leaves.main.php?aC=sV&kV=". $objectData['id'] ."'><font size='1'>View</font></a> <br>";
if($_REQUEST['st']=="waiting" || $_REQUEST['st']=="approved")
{
//echo" <a href='leaves.main.php?aC=sM&kV=". $objectData['id'] ."&st=".$_REQUEST['st']."&fromDate_search=".$_REQUEST['fromDate_search']."&toDate_search=".$_REQUEST['toDate_search']."&name_instructor=".$_REQUEST['name_instructor']."'><font size='1'>Modify</font></a> <br>";
}
if($_REQUEST['st']=="waiting")
{
echo " <a onclick='Approveleaves($objectData[id])' href='javascript:void(0)' href='#'><font size='1'>Approve</font></a> <br>";
}
if($_REQUEST['st']=="waiting" || $_REQUEST['st']=="approved")
{
echo " <a onclick='DisApproveleaves($objectData[id])' href='javascript:void(0)' href='#'><font size='1'>Denied</font></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 Approveleaves(val)
{
if(confirm("Are you sure?"))
{
fromDate_search="<?php echo $_REQUEST['fromDate_search']?>";
toDate_search="<?php echo $_REQUEST['toDate_search']?>";
name_instructor="<?php echo $_REQUEST['name_instructor']?>";
location.href="leaves.main.php?aC=approved&kV="+val+"&fromDate_search="+fromDate_search+"&toDate_search="+toDate_search+"&name_instructor="+name_instructor+"";
}
else
{
return false;
}
}
function DisApproveleaves(val)
{
if(confirm("Are you sure?"))
{
fromDate_search="<?php echo $_REQUEST['fromDate_search']?>";
toDate_search="<?php echo $_REQUEST['toDate_search']?>";
name_instructor="<?php echo $_REQUEST['name_instructor']?>";
location.href="leaves.main.php?aC=sM&kV="+val+"&fromDate_search="+fromDate_search+"&toDate_search="+toDate_search+"&name_instructor="+name_instructor+"";
}
else
{
return false;
}
}
</script>
<br>
<br>
<?php
$dbObject->CloseConnection();
// Include footer
include "footer_leave.php";
?>