Current File : /home/inlingua/public_html/noida/icentex_noida/admin/backup/timesheet.select.php
<?php
// Copyright, Panalink Infotech Limited. Created on: 22-05-2010

// Include header
include "header.php";



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

// Records selection sql
if($_REQUEST[loc]!="") $addq .=" and location='".$_REQUEST[loc]."'";
if($_REQUEST[search_name]!="") $addq .=" and Instname like '".$_REQUEST[search_name]."%'";
if($_REQUEST[timesheet_from]!="") $addq .=" and fromDate >='".$_REQUEST[timesheet_from]."'";
if($_REQUEST[timesheet_to]!="") $addq .=" and toDate <='".$_REQUEST[timesheet_to]."'";

if($_REQUEST[user]=="")
{

$sqlQuery = "SELECT * FROM timesheet where status_send='1' && approve_status='1' && modify_status!='1' &&  modify_status!='3'  ";
$sqlQuery .=$addq;
 $sqlQuery .=" order by count_send  desc,recNo desc";
}
else
{
$sqlQuery = "SELECT * FROM timesheet where status_send='1' && approve_status='1' && modify_status!='1' &&  modify_status!='3' && instructorId='".$_REQUEST[user]."'  ";
$sqlQuery .=$addq;
$sqlQuery .="order by count_send  desc,recNo desc";
}
$offset=$_REQUEST['offset'];
// Prepare page navigation
$resultsPerPage = 20; // number of rows to return per page

// Prepare add on URL
$addOnUrl = "&loc=".$_REQUEST[loc]."&search_name=".$_REQUEST[search_name]."&timesheet_from=".$_REQUEST[timesheet_from]."&timesheet_to=".$_REQUEST[timesheet_to]."&user=".$_REQUEST[user];

if ($resultsPerPage > 0)
{	$prev_next_links = $dbObject->prev123Next($sqlQuery, $resultsPerPage,$addOnUrl);
	$sqlQuery .= " limit " . $offset . "," . $resultsPerPage ;
}
?>
<div class="clear"></div>
<?php include("left.php"); ?>
<div id="content-wrap" style="padding-top:20px;" >
  <div id="content-box" >
		<div id="toolbar-title" >
			<h3>
Timesheet

</h3>
			
			<div class="clear"></div>
		</div>
		<div id="toolbar-box">
		  <div class="toolbar" id="toolbar"></div>
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
		
		<div id="element-box">
			<div class="m">
			<script language="javascript">
$(function() {
		$('#timesheet_from').datepicker({
			changeMonth: true,
			changeYear: true
		});
	});
	
</script>
<script language="javascript">
$(function() {
		$('#timesheet_to').datepicker({
			changeMonth: true,
			changeYear: true
		});
	});
	
</script>
<form name="search_timesheet" method="post" action="timesheet.select.php">
			<table cellpadding="3" cellspacing="3" class="searchtable"  align="left"><tr><td>Location:</td><td><?php
$queryloc="select * from timesheet_location order by location";
$resultloc=mysql_query($queryloc) or die(mysql_query());
?>
<select name='loc'>
<option value="">All Location</option>
<?php
while($num=mysql_fetch_array($resultloc))
{
if($num['location']=="S.Extn")
{

echo"<option value='".$num[location]."' ";
if($_REQUEST['loc']==$num[location])
{
echo"selected";
}
echo">South Extension</option>";


}
else
{

echo"<option value='".$num[location]."' ";
if($_REQUEST['loc']==$num[location])
{
echo"selected";
}
echo">".$num[location]."</option>";
}
}
?>
</select>
</td><td>Name:</td><td><input type="text" name="search_name" value="<?php echo $_REQUEST[search_name]?>" /></td><td>From:</td><td class="searchtd"><input type='text' name='timesheet_from' value="<?php echo $_REQUEST[timesheet_from]?>" size='20' maxlength='200' id="timesheet_from" readonly></td><td>To:</td><td class="searchtd"><input type='text' name='timesheet_to' value="<?php echo $_REQUEST[timesheet_to]?>" size='20' maxlength='200' id="timesheet_to" readonly></td>
<td  ><input type="submit" name="search_timesheet" value="Search" /></td>
</table>
<input type="hidden" name="user" value="<?php echo $_REQUEST[user]?>" />
</form>
			<?php
			$queryM="select * from timesheet where modify_status=1";
$resultM=mysql_query($queryM) or die(mysql_error());
$countM=mysql_fetch_array($resultM);
if($countM >0)
{
echo"<font color='red'>*To Modify any timesheet please first clear the waited </font><a href='list_modify.php'><font color='red'>modify timesheets</font></a>.  ";
}
			?>
				<table class="adminform">
					<tbody>
					
					<tr>
												<td valign="top" width="100%">
											
<!--<a href="taxes.main.php">Add new tax</a>-->
<script language="javascript">
<!--
function delstatus(val) 
{	
if(confirm("Are you sure to delete?"))
{
location.href="delet.timesheet.php?id="+val;
}
else
{
return false;
}
}
function modifystatus(val) 
{	
	if(confirm("Are you sure to modify?."))
	{
	location.href="modify.timesheet.php?id="+val;
	}
	else
	{
	return false;
	}

}
-->
</script>
<br>
												<?php

// 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 "<table border='0' class='pa-nor' cellspacing='0' width='100%'>";
echo "<tr valign='center' class='pa-sel-header' style='height:30px;'>";
//echo "<th><b>recNo</b></th>";
echo "<th><b>From Date</b></th>";
echo "<th><b>To Date</b></th>";
echo "<th><b>Name</b></th>";
echo "<th><b>Location</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>"; }
$i=1;	


while($objectData=$dbObject->SelectNext())
{	
if($i%2==0) $bgcolor='#F3F3F3';
else $bgcolor='#EBEBEB';
if($objectData[first_id])
{
$bgcolor='#C9C9C9';
$first_id=$objectData[first_id];
}
if($first_id==$objectData[recNo]) $bgcolor='#C9C9C9';
echo "<tr valign='top'  style='background:$bgcolor;height:25px;' onmouseover=\"this.className='pa-row-highlight'\" onmouseout=\"this.className='pa-nor'\" >";


	//echo "<td>$objectData[recNo]</td>";
echo "<td>$objectData[fromDate]</td>";
echo "<td>$objectData[toDate]</td>";
echo "<td>$objectData[Instname]</td>";

if($objectData['location']=="S.Extn")
{
$location="South Extension";
}
else
{
$location=$objectData[location];
}
echo "<td>$location</td>";

	echo "<td>";
	if($countM==0)
	{
	echo"<a href='#' onclick='modifystatus($objectData[recNo])'>Modify</a> | ";
	}
	echo "<a href='timesheet.main.php?aC=sV&kV=". $objectData['recNo'] ."'>View</a> | ";
	echo " <a href='#' onclick='delstatus($objectData[recNo])'>Delete</a></td>";	
	echo "</tr>";
	
	$i++;
}
print "</table>";



// Print navigation bar
if ($resultsPerPage > 0 && $prev_next_links)
{	echo "Page: ";
	array_walk($prev_next_links, 'printArray'); 
}
?>
</div>

<br>
<div id="cpanel">
				<div style="float: left;">
			<div class="icon"></div>
		</div>
				<div style="float: left;">
			<div class="icon"></div>
		</div>
				
				<div style="float: left;"></div>
			</div>
	</td>
												<td valign="top" width="45%">&nbsp;</td>
					</tr>
				</tbody></table>
			</div>
			
		</div>
		<div class="clear"></div>
		<p class="copyright">&nbsp;</p>
  </div>
</div>
</body></html>


<?php 
$dbObject->CloseConnection();

// Include footer
//include "footer.php";
?>