Current File : /home/inlingua/public_html/dwarka/icentex/conveyance/ingl_conveyance_kms.select.php
<?php
// Copyright, Panalink Infotech Limited. Created on: 09-06-2012
session_start();
/*
$loggedUserNo = $_SESSION['loggedUserNo'];
if ($loggedUserNo == "")
{	echo "Please <a href='index.php'>login</a> first.";
	exit(0);
}
*/

// Include header
include "header_conveyance.php";
?>

<h3><span class='pa-nor-navbar'><a href='admin_conveyance.php'>Home</a> >> <a href='ingl_conveyance_kms.select.php'>Kms Chart</a></span></h3>
<?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']);
?>

<?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
$sqlQuery = "SELECT * FROM ingl_conveyance_kms";

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

// Prepare add on URL
$addOnUrl = "";

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'>
<table border='0' class='pa-nor' width="100%">
<tr valign='top'><td align="center">CENTERS</td>
<?php
$queryS1="Select * from timesheet_location where show_conveyance=1 order by order_rates";
$resultS1=mysqli_query($conn,$queryS1);
while($numS1=mysqli_fetch_array($resultS1))
{

?>
<td style="background-color:#FFFF00;" align="center"><?php echo $numS1['location']; ?></td>
<?php
}
?>
</tr>

<?php
$queryS="Select * from timesheet_location where show_conveyance=1 order by order_rates";
$resultS=mysqli_query($conn,$queryS);



while($numS=mysqli_fetch_array($resultS))
{
?>
<tr valign='top'><td style="background-color:#FFFF00;"><?php echo $numS['location']; ?></td>
<?php
$queryS1="Select * from timesheet_location where show_conveyance=1 order by order_rates";
$resultS1=mysqli_query($conn,$queryS1);
while($numS1=mysqli_fetch_array($resultS1))
{
if($numS['recNo']!=$numS1['recNo'])
{
$queryKms="Select * from  ingl_conveyance_kms where center_from='".$numS['recNo']."' && center_to='".$numS1['recNo']."'";
$resultKms=mysqli_query($conn,$queryKms);
$numKms=mysqli_fetch_array($resultKms);
$countKms=mysqli_num_rows($resultKms);
if($countKms>0)
{
$kms=$numKms['kms'];
}
else
{
$kms=$dbObject->getDbField('kms');
}
?>
<td align="center"><b><?php echo $kms;?></b></td>
<?php
}
else
{
?>
<td style="background-color:#FFFF00;">&nbsp;</td>
<?php
}

}
?>

</tr>
<?php
}

?>

<tr valign='top'><td style="background-color:#FFFF00;">Home</td>
<?php
$queryS1="Select * from timesheet_location where show_conveyance=1 order by order_rates";
$resultS1=mysqli_query($conn,$queryS1);
while($numS1=mysqli_fetch_array($resultS1))
{
$queryKms="Select * from  ingl_conveyance_home_kms where  center_to='".$numS1['recNo']."' && user_recNo='".$_SESSION['id']."'";
$resultKms=mysqli_query($conn,$queryKms);
$numKms=mysqli_fetch_array($resultKms);
$countKms=mysqli_num_rows($resultKms);
if($countKms>0)
{
?>
<td align="center"><b><?php echo $numKms['kms'];?></b></td>
<?php

}
else
{
?>
<td align="center"><b>N.A.</b></td>
<?php
}

}
?>
</tr>

</table>
<br />
N.A. - Not Available

<?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>";
}
?>


<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";
?>