Current File : /home/inlingua/www/dwarka/icentex/admin_conveyance/ingl_conveyance_main.select.php
<?php

session_start();
/*
$loggedUserNo = $_SESSION['loggedUserNo'];
if ($loggedUserNo == "")
{	echo "Please <a href='index.php'>login</a> first.";
	exit(0);
}
*/

// Include header
include "header_conveyance.php";
?>
<script>
function delstatus(val) 
{	
if(confirm("Are you sure to cancel?"))
{
location.href="delet.conveyance.php?id="+val;
}
else
{
return false;
}
}
</script>
<?php
if($_REQUEST['action']=="cancel")
{
$ms="Cancelled";
}
$fmonth=$_REQUEST['fmonth'];
$fyear=$_REQUEST['fyear'];

$tmonth=$_REQUEST['tmonth'];
$tyear=$_REQUEST['tyear'];
?>
<h3><span class='pa-nor-navbar'><a href='index.php'>Home</a> >> <a href='ingl_conveyance_main.select.php'><?php echo $ms;  ?> Conveyance</a></span></h3>
<div id="contentnew">
<?php if ($_SESSION['dispMesg'][1] != "" && (date("U") - $_SESSION['dispMesg'][0] < 7)) 
{ 	?>
	<span id='mesgSpan'><font color='#da0000'><?php echo $_SESSION['dispMesg'][1];?></font></span>
	<script>
	setTimeout(function() {   $('#mesgSpan').fadeOut('slow'); }, 4000); // <-- time in milliseconds 
	</script>
	<br>
	<?php
}
unset($_SESSION['dispMesg']);
?>
<form  method="post" action="ingl_conveyance_main.select.php">
<input type="hidden" name="action" value="<?php echo $_REQUEST['action']; ?>" />
			<table cellpadding="3" cellspacing="3">
			<tr>
			<td>Name:</td><td><input type="text" name="search_name" value="<?php echo $_REQUEST[search_name]?>" /></td>
			
			<td>From:
			<select name='fmonth'>
<option value="All">All</option>
<option value="01" <?php if($fmonth=='01') echo"selected"; ?>>Jan</option>
<option value="02" <?php if($fmonth=='02') echo"selected"; ?>>Feb</option>
<option value="03" <?php if($fmonth=='03') echo"selected"; ?>>Mar</option>
<option value="04" <?php if($fmonth=='04') echo"selected"; ?>>Apr</option>
<option value="05" <?php if($fmonth=='05') echo"selected"; ?>>May</option>
<option value="06" <?php if($fmonth=='06') echo"selected"; ?>>Jun</option>
<option value="07" <?php if($fmonth=='07') echo"selected"; ?>>Jul</option>
<option value="08" <?php if($fmonth=='08') echo"selected"; ?>>Aug</option>
<option value="09" <?php if($fmonth=='09') echo"selected"; ?>>Sep</option>
<option value="10" <?php if($fmonth=='10') echo"selected"; ?>>Oct</option>
<option value="11" <?php if($fmonth=='11') echo"selected"; ?>>Nov</option>
<option value="12" <?php if($fmonth=='12') echo"selected"; ?>>Dec</option>
</select>&nbsp;<select name='fyear'>
<option value="All">All</option>
<?php

for($j=2010;$j<=2020;$j++)
{
echo"<option value='".$j."' ";
if($j==$fyear)
{
echo"selected";
}


echo">".$j."</option>";

}
?>
</select>

			</td>
			<td>To:
			<select name='tmonth'>
<option value="All">All</option>
<option value="01" <?php if($tmonth=='01') echo"selected"; ?>>Jan</option>
<option value="02" <?php if($tmonth=='02') echo"selected"; ?>>Feb</option>
<option value="03" <?php if($tmonth=='03') echo"selected"; ?>>Mar</option>
<option value="04" <?php if($tmonth=='04') echo"selected"; ?>>Apr</option>
<option value="05" <?php if($tmonth=='05') echo"selected"; ?>>May</option>
<option value="06" <?php if($tmonth=='06') echo"selected"; ?>>Jun</option>
<option value="07" <?php if($tmonth=='07') echo"selected"; ?>>Jul</option>
<option value="08" <?php if($tmonth=='08') echo"selected"; ?>>Aug</option>
<option value="09" <?php if($tmonth=='09') echo"selected"; ?>>Sep</option>
<option value="10" <?php if($fmonth=='10') echo"selected"; ?>>Oct</option>
<option value="11" <?php if($fmonth=='11') echo"selected"; ?>>Nov</option>
<option value="12" <?php if($fmonth=='12') echo"selected"; ?>>Dec</option>
</select>&nbsp;<select name='tyear'>
<option value="All">All</option>
<?php

for($j=2010;$j<=2020;$j++)
{
echo"<option value='".$j."' ";
if($j==$tyear)
{
echo"selected";
}


echo">".$j."</option>";

}
?>
</select>

			</td>
			<td  ><input type="submit" name="search_conveyance" value="Search" /></td>
			</tr>
			</table>
<?
// 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
$sqlQuery = "SELECT a.*,concat(year,RIGHT(concat(0,month),2)),b.name FROM ingl_conveyance_main a left join timesheet_user b on a.instructor=b.recNo where 1=1";


if($_REQUEST['action']=="cancel")
{
$sqlQuery .="&& a.status='cancel'";
}
else
{
$sqlQuery .="&& a.status='Send'";
}



if($_REQUEST[search_name]!="" && $_REQUEST['search_conveyance']=="Search") $sqlQuery .=" and b.name like '".$_REQUEST[search_name]."%'";

if($_REQUEST[fmonth]!="All" && $_REQUEST[fyear]!="All" && $_REQUEST['search_conveyance']=="Search")
{
	$year_month="".$_REQUEST[fyear]."".$_REQUEST[fmonth]."";
        $sqlQuery .=" and concat(year,RIGHT(concat(0,month),2))>=".$year_month."";
}

if($_REQUEST[tmonth]!="All" && $_REQUEST[tyear]!="All" && $_REQUEST['search_conveyance']=="Search")
{
	$year_month="".$_REQUEST[tyear]."".$_REQUEST[tmonth]."";
        $sqlQuery .=" and concat(year,RIGHT(concat(0,month),2))<=".$year_month."";
}
        $datepmk=mktime(0,0,0,date("m")-3,date("d"),date("Y"));
	$month=date("m",$datepmk);
	$year=date("Y",$datepmk);
	$year_month="".$year."".$month."";

if($_REQUEST['period']=="archive")
{
	
        $sqlQuery .="&& concat(year,RIGHT(concat(0,month),2)) <=".$year_month."";	
	
}
else{
	
	if($_REQUEST['search_conveyance']!="Search")
	{
	$sqlQuery .="&& concat(year,RIGHT(concat(0,month),2)) >".$year_month."";	
	}
}



$sqlQuery .= " order by a.year desc,a.month desc";

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

// Prepare add on URL
$addOnUrl = "&action=".$_REQUEST['action']."&search_name=".$_REQUEST[search_name]."&fmonth=".$_REQUEST[fmonth]."&fyear=".$_REQUEST[fyear]."
&tmonth=".$_REQUEST[tmonth]."&tyear=".$_REQUEST[tyear]."&search_conveyance=".$_REQUEST['search_conveyance']."";

$offset=$_REQUEST['offset'];

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 && count($prev_next_links) > 1)
{	echo "Page: ";
	array_walk($prev_next_links, 'printArray'); 
}

// Select records from table
$selectedRecords = $dbObject->Select($sqlQuery);
?>

<table border='0' class='pa-nor pa-table' width="100%">
<tr valign='top' class='rowH'>
<th>S.No</th>
<th>Instructor</th>
<th>Month</th>
<th>Year</th>

<th>Action</th>
</tr>
<?php
// If no records selected, print message
if (!$selectedRecords)
{	?>
	<tr><td colspan='5'>There are no entries</td></tr> 
	<?php
}
$i=1;	
while($objectData=$dbObject->SelectNext())
{

$queryU="select name from timesheet_user where recno='".$objectData['instructor']."'";
$resultU=mysqli_query($conn,$queryU);
$numU=mysqli_fetch_array($resultU);
	
if($i%2==0) $bgcolor='#F3F3F3';
else $bgcolor='#EBEBEB';
?>
	<tr valign='top' style='background:<?php echo $bgcolor ?>;height:25px;' onmouseover="this.className='pa-row-highlight'" onmouseout="this.className='pa-nor'">
	<td><?php echo $i;?></td>
	<td><?php echo $numU['name'];?></td>
	<td><?php echo $objectData['month'];?></td>
	<td><?php echo $objectData['year'];?></td>

	<td>
	
	<a href='ingl_conveyance_main.main.php?aC=sV&kV=<?php echo $objectData['recNo'] ;?>' title='View entry'><img src='images/view.png' border='0' hspace='2' style="border:none;"></a> 
	
	<?php
	if($objectData['status']!="cancel")
	{
	echo "| <a href='#' onclick='delstatus($objectData[recNo])'><img src='images/delete.png' title='cancel' border='0' hspace='2' style='border:none;'></a></td>";
	}
	?>
	</td>
	</tr>
	<?php
	$i++;
}
?>
</table>

<?php
// Print navigation bar
if ($resultsPerPage > 0 && $prev_next_links  && count($prev_next_links) > 1)
{	echo "Page: ";
	array_walk($prev_next_links, 'printArray'); 
	echo "<br>";
}
?>
<!--<br>
<a href="ingl_conveyance_main.main.php" title='Add entry'>Add new entry</a>
<br>-->
</div>
<script type="text/javascript">
function confDel()
{	var agree = confirm("Click OK to delete permanently or cancel");
	if (agree)
		return true;
	else
		return false;
}
</script>

<?php 
$dbObject->CloseConnection();

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