Current File : /home/inlingua/www/noida/icentex_noida/iNDEED/timesheet_user.select_30_10_2018.php
<?php include("header_indeed.php"); 
// Include header



// 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();
if($_REQUEST[loc]!="") $addq .=" and primarycenter='".$_REQUEST[loc]."'";
if($_REQUEST[search_name]!="") $addq .=" and name like '".$_REQUEST[search_name]."%'";
if($_REQUEST[usertype]!="") $addq .=" and usertype ='".$_REQUEST[usertype]."'";
if($_REQUEST[pay_type]!="") $addq .=" and pay_type ='".$_REQUEST[pay_type]."'";
if($_REQUEST[designation]!="") $addq .=" and designation ='".$_REQUEST[designation]."'";
if($_REQUEST[house]!="") $addq .=" and house ='".$_REQUEST[house]."'";

if($_REQUEST[status]!="" && isset($_REQUEST[status])) 
{
$addq .=" and status ='".$_REQUEST[status]."'";
}
else
{
$addq .=" and status ='Active'";
}

// Records selection sql
$sqlQuery = "SELECT * FROM timesheet_user where 1=1 && usertype!='timesheet_admin'";
 $sqlQuery .=$addq;
 $sqlQuery .=" order by name asc";
 
 $_SESSION['sqlQuery']=$sqlQuery;

// Prepare page navigation
$resultsPerPage = 60; // number of rows to return per page

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

if ($resultsPerPage > 0)
{	$prev_next_links = $dbObject->prev123Next($sqlQuery, $resultsPerPage,$addOnUrl);
	$sqlQuery .= " limit " . $offset . "," . $resultsPerPage ;
}

?>

			<h3>
User Manager

</h3>
	<div id="contentnew">		
		
			<form name="search_timesheet" method="post" action="timesheet_user.select.php">
			<table cellpadding="3" cellspacing="3" class="searchtable"  align="left" width="100%"><tr><td>Primary Center:</td><td><?php
$queryloc="select * from timesheet_location where status='1' order by location";
$resultloc=mysql_query($queryloc) or die(mysql_query());
?>
<select name='loc'>
<option value="">All Primary Center</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  ><input type="submit" name="search_timesheet" value="Search" /></td></tr>
</table>
</form>
											
<a href="timesheet_user.main.php">Add New User</a>&nbsp;&nbsp;
<?php
if(isset($_REQUEST['search_timesheet']))
{
?>
<a href="excel_report.php">Export in  Excel</a>
<?php
}
?>
<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  width='100%' border='1'  class='pa-nor' cellspacing='0'>";
echo "<tr valign='top' class='rowH'>";
echo "<th><b>Name</b></th>";

//echo "<th><b>Email</b></th>";
//echo "<th><b>Contact&nbsp;Number</b></th>";
//echo "<th><b>Pay Type</b></th>";
echo "<th><b>E-Mail</b></th>";
//echo "<th><b>S.Hours</b></th>";
//echo "<th><b>T.Hours</b></th>";
echo "<th><b>Status</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())
{	
$totalHours1=$objectData[startingHours];

 $query="select (sum(hours1) + sum(hours2) + sum(hours3) + sum(hours4) +  sum(hours5) +  sum(hours7) +  sum(hours8) + sum(hours9)) as totalhrs  from timesheet where instructorId='".$objectData[recNo]."' && status_send=1 &&  approve_status=1 && modify_status!='1' && modify_status!='3'";

$result=mysql_query($query) or die(mysql_error());

$num=mysql_fetch_array($result);

$totalHours1=$totalHours1+$num[totalhrs];



if($i%2==0) $bgcolor='#F3F3F3';
else $bgcolor='#EBEBEB';
echo "<tr valign='top' style='background:$bgcolor' onmouseover=\"this.className='pa-row-highlight'\" onmouseout=\"this.className='pa-nor'\">";

if($objectData[usertype]=="user")
{
$objectData[usertype]="Teaching services";
}
else if($objectData[usertype]=="FD")
{
$objectData[usertype]="Customer services";

}

	echo "<td>$objectData[name] &nbsp; <font size='1'>($objectData[usertype])</font></td>";

//echo "<td>$objectData[email]</td>";
//echo "<td>$objectData[contact_no]</td>";
//echo "<td>$objectData[pay_type]</td>";

if($objectData['status']=="Deactive")
{
$status="Deactivated";
}
else
{
$status=$objectData['status'];
}


echo "<td><font size='1'>$objectData[email]</font></td>";
//echo "<td>$objectData[startingHours]</td>";
//echo "<td>".$totalHours1."</td>";
echo "<td>$status</td>";

	echo "<td><a href='timesheet_user.main.php?aC=sM&kV=". $objectData['recNo'] ."&offset=".$_REQUEST[offset]."'>Modify</a> | ";
	echo " <a href='timesheet_user.main.php?aC=sV&kV=". $objectData['recNo'] ."'>View</a> | ";
	
	if($objectData['usertype']!='Teaching services')
	{
	echo " <a href='timesheet_user.main.php?aC=sD&kV=". $objectData['recNo'] ."&offset=".$_REQUEST[offset]."'>Delete</a>  | ";
	}
	
	echo " <a href='reset.php?kV=". $objectData['recNo'] ."'>Reset</a> 
	
	</td>";	
	echo "</tr>";
	$i++;
}
print "</table>";

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


<?php 
$dbObject->CloseConnection();

// Include footer

?>
</div>
<?php
include("footer_indeed.php");
?>