Current File : /home/inlingua/www/noida/icentex_noida/admin_cert/ingl_course.select.php
<?php
// Copyright, Panalink Infotech Limited. Created on: 27-11-2010

// Include header
include "header_cert.php";
?>
<h3>&nbsp;&nbsp;&nbsp;Courses</h3>
<div id="contentnew">



<?php
echo "<br>";

function Certificate_d($courseId,$level)
{
if($level=="1A" || $level=="1B")
{
$cert="certificate_1_fd.php";
$tab="level_1";
}
elseif($level=="2A" || $level=="2B"||$level=="E2-S1'"||$level=="E2-S1+")
{
$cert="certificate_2_fd.php";
$tab="level_2";
}
elseif($level=="3A" || $level=="3B")
{
$cert="certificate_3_fd.php";
$tab="level_3";
}
elseif($level=="4")
{
$cert="certificate_4_fd.php";
$tab="level_4";
}
elseif($level=="5")
{
$cert="certificate_5_fd.php";
$tab="level_4";
}
else
{
$cert="#";
}

 $queryC="select count(recNo) as tot from ".$tab." where courseId='".$courseId."'";
$resultC=mysql_query($queryC);
$countT=mysql_fetch_array($resultC);
if($countT[tot]>0)
{
$link="<a href='".$cert."?courseId=".$courseId."' target='_blank'><font size='1'>Download Certificate(".$countT[tot].")</font></a>";
}
else
{
$link="<font size='1'>Not Generated Yet</font>";
}
return $link;

}
///////////////////////////////////////////////////

function certificate_L($courseId)
{
$queryS="select count(recNo) as tot from ingl_student where courseId='".$courseId."'";
$resultS=mysql_query($queryS);
$countS=mysql_fetch_array($resultS);
if($countS[tot]>0)
{
$link="<a href='welcome_note_all.php?courseId=".$courseId."' target='_blank'><font size='1'>Download Letter(".$countS[tot].")</font></a>";
}
else
{
$link="<font size='1'>No Student Yet</font>";
}
return $link;
}

// 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();
?>
<form action="ingl_course.select.php">
<b>Search</b>&nbsp;&nbsp; <?php 
$query="select * from ingl_course  order by courseid";
$res=mysql_query($query);
if(mysql_num_rows($res)>0)
{
echo "<select name='courseId' onchange='displaystudent(this.value)'>";
echo"<option value=''>Select Course ID</option>";
while($rsult=mysql_fetch_array($res))
	{
	
	echo"<option value='".$rsult[courseid]."'" ;
	
	if($_REQUEST[courseId]==$rsult[courseid]) echo "selected";
	
	echo">".$rsult[courseid]."</option>";
	}
	echo"</select>";
}
else
{
echo "Please enter the Course ID ";
}
?>

<input type="hidden" name="search" value="1" />

<input class="submit1" type="Submit" value="Search" />
</form>
<br>

<?php

// Records selection sql
if($_REQUEST[courseId]!="")
{
//$sqlQuery = "SELECT * FROM ingl_course where  courseid='".$_REQUEST[courseId]."' order by enddate desc";
$sqlQuery = "SELECT * FROM ingl_course where  courseid='".$_REQUEST[courseId]."' order by courseid desc";
}
else
{
//$sqlQuery = "SELECT * FROM ingl_course order by enddate desc";
$sqlQuery = "SELECT * FROM ingl_course order by courseid desc";
}

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

// Prepare add on URL
$addOnUrl = "&courseId=".$_REQUEST[courseId];
$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)
{	//echo "Page: ";
	//array_walk($prev_next_links, 'printArray'); 
}

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

echo "<table border='1' class='pa-nor' cellspacing='0'>";
echo "<tr valign='top' class='rowH'>";

echo "<th><b>Course ID</b></th>";
echo "<th><b>Language</b></th>";
echo "<th><b>Level</b></th>";
echo "<th><b>Start date</b></th>";
echo "<th><b>End 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())
{	echo "<tr valign='top' onmouseover=\"this.className='pa-row-highlight'\" onmouseout=\"this.className='pa-nor'\">";
	
echo "<td>$objectData[courseid]<br>".certificate_L($objectData['recNo'])."</td>";
echo "<td>$objectData[language]</td>";
echo "<td>$objectData[level]</td>";
echo "<td>$objectData[startdate]</td>";
echo "<td>$objectData[enddate]</td>";

	echo "<td><a href='ingl_course.main.php?aC=sM&kV=". $objectData['recNo'] ."'>Modify</a> |";
	echo "<a href='ingl_course.main.php?aC=sV&kV=". $objectData['recNo'] ."'>View</a> |";
	echo " <a href='ingl_course.main.php?aC=sD&kV=". $objectData['recNo'] ."'>Delete</a><br>".Certificate_d($objectData[courseid],$objectData[level])."</td>";	
	echo "</tr>";
}
print "</table>";

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

</div>
<?php 
$dbObject->CloseConnection();

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