Current File : /home/inlingua/public_html/faridabad/icentex/admin_cert/advance_search_result.php
<?php
// Copyright, Panalink Infotech Limited. Created on: 27-11-2010

// Include header
include "header_cert.php";
?>
<h3>&nbsp;&nbsp;&nbsp;EOC Report Search Results</h3>
<div id="contentnew">



<?php
echo "<br>";

function Certificate_d($courseId,$level)
{
if($level=="1A" || $level=="1B" || $level=="1B+"|| $level=="E1S2" || $level=="E1S2+")
{
$cert="certificate_1_fd.php";
$tab="level_1";
}
elseif($level=="2A" || $level=="2B" || $level=="2A+" || $level=="2B+" || $level=="E2-S2" || $level=="E2-S2+"|| $level=="E2-S1"|| $level=="E2-S1+")
{
$cert="certificate_2_fd.php";
$tab="level_2";
}
elseif($level=="3A" || $level=="3B" || $level=="E3-S1" || $level=="E3-S2")
{
$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";
}
elseif($level=="Private")
{
$cert="certificate_Private_fd.php";
$tab="level_Private";
}
else
{
$cert="#";
}

 $queryC="select count(recNo) as tot from ".$tab." where courseId='".$courseId."'";
$resultC=mysqli_query($conn,$queryC);
$countT=mysqli_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=mysqli_query($conn,$queryS);
$countS=mysqli_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();
?>
<a href="javascript:history.back()">Back</a>
<br>

<?php

$where="";
// Records selection sql
if($_REQUEST[branch]!="" && $_REQUEST[branch]!="All") $where .=" and  branch ='".$_REQUEST[branch]."'";
if($_REQUEST[fd_admin]!="" && $_REQUEST[fd_admin]!="All") $where .=" and  fd_admin ='".$_REQUEST[fd_admin]."'";
if($_REQUEST[instructor]!="" ) $where .=" and  instructor ='".$_REQUEST[instructor]."'";
if($_REQUEST[language]!="" ) $where .=" and  language ='".$_REQUEST[language]."'";
if($_REQUEST[level]!="" ) $where .=" and  level ='".$_REQUEST[level]."'";
if($_REQUEST[courseid]!="" && $_REQUEST[courseidar]=="") $where .=" and  courseid ='".$_REQUEST[courseid]."'";
if($_REQUEST[courseidar]!="" &&  $_REQUEST[courseid]=="" ) $where .=" and  courseid ='".$_REQUEST[courseidar]."'";
if($_REQUEST[courseid]!="" && $_REQUEST[courseidar]!="") $where .=" and  (courseid ='".$_REQUEST[courseid]."' || courseid ='".$_REQUEST[courseidar]."')";
if($_REQUEST[startdate]!="" && $_REQUEST[enddate]!="" ) $where .=" and  startdate >='".$_REQUEST[startdate]."'";
if($_REQUEST[startdate]!="" && $_REQUEST[enddate]=="" ) $where .=" and  startdate ='".$_REQUEST[startdate]."'";
if($_REQUEST[enddate]!="" && $_REQUEST[startdate]!="") $where .=" and  enddate <='".$_REQUEST[enddate]."'";
if($_REQUEST[enddate]!="" && $_REQUEST[startdate]=="") $where .=" and  enddate ='".$_REQUEST[enddate]."'";
if($where!="")
{
$sqlQuery = "SELECT * FROM ingl_course where 1=1";
$sqlQuery .=$where;
  //$sqlQuery .=" order by enddate desc";
  $sqlQuery .=" order by courseid desc";
}
else
{
//$sqlQuery = "SELECT * FROM ingl_course order by enddate desc";
$sqlQuery = "SELECT * FROM ingl_course order by courseid desc";
}

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

// Prepare add on URL
$addOnUrl = "&branch=".$_REQUEST[branch]."&instructor=".$_REQUEST[instructor]."&language=".$_REQUEST[language]."&level=".$_REQUEST[level]."&courseid=".$_REQUEST[courseid]."&startdate=".$_REQUEST[startdate]."&enddate=".$_REQUEST[enddate]."&fd_admin=".$_REQUEST[fd_admin]."";


$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='6'>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=sV&kV=". $objectData['recNo'] ."' target='_blank'>View</a> <br><a href='search_cert.php?courseid=".$objectData['courseid']."&sumit_app=1' target='_blank'><font size='1'>Certificates in Html</font></a>";
	
	echo " <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";
?>