Current File : /home/inlingua/www/noida/icentex_noida/level_5.main.php
<?php
session_start();
ob_start();
// Copyright, Panalink Infotech Limited. Created on: 30-06-2010

// Include the database connection details
require('dbConnection.php');

// Include common functions
require('commonFunc.php');

// Include common functions
require('globalVars.php');


// Setup table name, configuration and data entry form
$tableName = "level_5";
$tableConf = $tableName . ".conf.php";
$dataForm = $tableName . ".form.php";
$viewForm = $tableName . ".view.php";

// Include table configuration details
require($tableConf);


// Include the table handler class
require('dbHandler.class.php');
$dbObject = new dbHandler();
$dbObject->setTableName($tableName);
$dbObject->setDbFieldList($dbFieldList);
$dbObject->setKeyFieldName("recNo");
$dbObject->connect();

// Retrieve parameters from request
$dbObject->getDbFieldsFromRequest();

function checkstudent($conn,$id)
{
$sqlQuery = "SELECT  recNo  FROM level_5 where 	student_recNo='".$id."'  ";
//echo $sqlQuery;
$result=mysqli_query($conn,$sqlQuery);
if(mysqli_num_rows($result)) $return =false;
else $return =true;
 
return $return;
}
$currentMode = "";
$formPrompt = "";
$succFailMesg = "";
$showResult = "N";

$action = $_REQUEST['aC'];
if (($action == "")  || ($action == "sA"))
{	// Set 'Add' mode in dataform
	$currentMode = "Save All"; $succFailMesg = "<b>Add details</b>&nbsp;&nbsp;&nbsp;&nbsp;<br>";
$level=$_REQUEST[level];
	
/*$cerification="This is to certify that {STUDENT_NAME} successfully completed the GPP".$level." course on the above dates and can communicate effectively in English at this level. General comments are shown below.";

$dbObject->setDbField("cerification_comment",$cerification);	
	
	$struct="{STUDENT_NAME} can use various grammatical structures at this level with a lot of ease. He can also transform sentences quite easily and accurately.";
	$dbObject->setDbField("useStructures",$struct);
	
	$fluency="He has very good pronunciation and fluency, but can only talk on a limited range of subjects because of which he tends to pause and lose focus while speaking.";
	$dbObject->setDbField("pronFluency",$fluency);
	
	$listening="He can understand questions quite well. He is also able to efficiently continue a topic started by someone else.";
	$dbObject->setDbField("listening_skill",$listening);
	
	$lexical="He has got quite a wide range of vocabulary. He can improve it more by reading books, magazine and newspaper, and watching programmes and movies in English.";
	$dbObject->setDbField("lexical_skill",$lexical);
	
	$generalcomment="He is quite comfortable with English as a language, and can improve quite a lot if he continues to speak and practice more often. It will really help him if he develops a circle of English speaking people around him.";
	$dbObject->setDbField("general_comment",$generalcomment);*/
}
else if ($action == "Save All")
{	$currentMode = "Save All"; 

	// Perform check for duplicate entry
	if($dbObject->Exists("recNo", $_REQUEST["recNo"]))
	{	$succFailMesg = "<b>Could not add details, record with this key exists.</b><br>";	
		$showResult = "N"; // Show dataentry form again
	}
	else
	{	
	//print_r($_REQUEST);
	//$today = date("Y-m-d");
	$i=0;
	$k=0;
	$t=gettype($_REQUEST[language]);
	if($t=="array")
	{
	foreach($_REQUEST[language] as $val)
	{
	$level=$_REQUEST[level];
	$recNo=$_REQUEST[recNo];
	$language=$val;
	$courseId=$_REQUEST[courseId][$i];
	$student_recNo=$_REQUEST[student_ids][$i];
	$level=$_REQUEST[level][$i];
	$startDate=$_REQUEST[startDate][$i];
	$endDate=$_REQUEST[endDate][$i];
	$name_student=$_REQUEST[name_student][$i];
	
	$cerification_comment="This is to certify that {STUDENT_NAME} completed the GPP".$level." course on the above dates and can communicate effectively in English at this level. General comments are shown below.";
	$cerification_comment=str_replace('{STUDENT_NAME}',"<strong>".ucfirst($name_student)."</strong>",$cerification_comment);
	
	$useStructures=$_REQUEST[useStructures][$i];
	$useStructures=str_replace('{STUDENT_NAME}',"<strong>".ucfirst($name_student)."</strong>",$useStructures);
	$pronFluency=$_REQUEST[pronFluency][$i];
	
	$listening_skill=$_REQUEST[listening_skill][$i];
	$lexical_skill=$_REQUEST[lexical_skill][$i];
	$general_comment=$_REQUEST[general_comment][$i];
	$overall_grade=$_REQUEST[overall_grade][$i];
	$eligibility=$_REQUEST[eligibility_.$i];
	$othereligibility=$_REQUEST[othereligibility][$i];
	$createdBy=$_REQUEST[createdBy];
	$createDate=$_REQUEST[createDate];
	$dbObject->setDbField("recNo",$recNo);
	$dbObject->setDbField("language",$language);
	$dbObject->setDbField("courseId",$courseId);
	$dbObject->setDbField("level",$level);
	$dbObject->setDbField("startDate",$startDate);
	$dbObject->setDbField("endDate",$endDate);
	$dbObject->setDbField("cerification_comment",$cerification_comment);
	$dbObject->setDbField("name_student",$name_student);
	$dbObject->setDbField("useStructures",$useStructures);
	$dbObject->setDbField("pronFluency",$pronFluency);
	$dbObject->setDbField("listening_skill",$listening_skill);
	$dbObject->setDbField("lexical_skill",$lexical_skill);
	$dbObject->setDbField("general_comment",$general_comment);
	$dbObject->setDbField("overall_grade",$overall_grade);
	$dbObject->setDbField("eligibility",$eligibility);
	$dbObject->setDbField("othereligibility",$othereligibility);
	$dbObject->setDbField("createdBy",$createdBy);
	$dbObject->setDbField("createDate",$createDate);
	$dbObject->setDbField("student_recNo",$student_recNo);
	$i++;
	if($name_student!="")
	{
	$dbObject->Save();
	$k++;
	}
	}
	$_SESSION[courseId]=$courseId;
		if($k==0)
	{
	$_REQUEST['student_no']=$i;
	
	$level=$_REQUEST[level][0];
	
/*$cerification="This is to certify that {STUDENT_NAME} successfully completed the GPP".$level." course on the above dates and can communicate effectively in English at this level. General comments are shown below.";

$dbObject->setDbField("cerification_comment",$cerification);	
	
	$struct="{STUDENT_NAME} can use various grammatical structures at this level with a lot of ease. He can also transform sentences quite easily and accurately.";
	$dbObject->setDbField("useStructures",$struct);
	
	$fluency="He has very good pronunciation and fluency, but can only talk on a limited range of subjects because of which he tends to pause and lose focus while speaking.";
	$dbObject->setDbField("pronFluency",$fluency);
	
	$listening="He can understand questions quite well. He is also able to efficiently continue a topic started by someone else.";
	$dbObject->setDbField("listening_skill",$listening);
	
	$lexical="He has got quite a wide range of vocabulary. He can improve it more by reading books, magazine and newspaper, and watching programmes and movies in English.";
	$dbObject->setDbField("lexical_skill",$lexical);
	
	$generalcomment="He is quite comfortable with English as a language, and can improve quite a lot if he continues to speak and practice more often. It will really help him if he develops a circle of English speaking people around him.";
	$dbObject->setDbField("general_comment",$generalcomment);*/
	
	$succFailMesg = "<b><font color='pink'><blink>Please Enter At Least One Record.</b></blink></font><br>";	
	$showResult = "N"; // Show dataentry form again
	}
	
	}
	else
	{
         $_SESSION[courseId]=$_REQUEST['cId'];	
		$succFailMesg = "<b>Details added successfully</b><br>";
		$showResult = "Y"; // Goto result part in dataform
		}
	}
}
else if ($action == "sM")
{	// Set 'Update' mode in dataform
	$currentMode = "Update"; $succFailMesg = "<b>Modify details</b>&nbsp;&nbsp;&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>";

	// Retrieve record first
	$Query = "SELECT a.*,s.studentName FROM ".$tableName." a left join  ingl_student
    s on s.recNo =a.student_recNo where a.recNo='".$_REQUEST[kV]."'";
	if ($dbObject->Retrieve_join($Query))

	{ ; }
	else { $succFailMesg = "<b>Could not retrieve details. Contact system administrator</b><br>"; }

}
else if ($action == "Update")
{	$currentMode = "Update"; 
	$showResult = "Y"; // Goto result part in dataform
	
	$name_student=$_REQUEST[name_student];
	$dbObject->setDbField("name_student",$name_student);
	
	$useStructures=$_REQUEST[useStructures];
	$dbObject->setDbField("useStructures",$useStructures);
	
	$pronFluency=$_REQUEST[pronFluency];
	$dbObject->setDbField("pronFluency",$pronFluency);
	
	$listening_skill=$_REQUEST[listening_skill];
	$dbObject->setDbField("listening_skill",$listening_skill);
	
	$lexical_skill=$_REQUEST[lexical_skill];
	$dbObject->setDbField("lexical_skill",$lexical_skill);
	
	$general_comment=$_REQUEST[general_comment];
	$dbObject->setDbField("general_comment",$general_comment);
	
	$overall_grade=$_REQUEST[overall_grade];
	$dbObject->setDbField("overall_grade",$overall_grade);
	
	$eligibility=$_REQUEST[eligibility_1];
	$dbObject->setDbField("eligibility",$eligibility);
	
	$othereligibility=$_REQUEST[othereligibility];
	$dbObject->setDbField("othereligibility",$othereligibility);
	
	$_SESSION[courseId]=$_REQUEST[courseId];
	
	if ($dbObject->Update("recNo",$_REQUEST["kV"]))
	{	$succFailMesg = "<b>Details modified successfully</b><br>"; }
	else
	{	$succFailMesg = "<b>Could not modify details. Contact system administrator</b><br>" ; }
}
else if ($action == "sD")
{	$currentMode = "Delete"; $succFailMesg = "<b>Delete details</b>&nbsp;&nbsp;&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>";
	// Retrieve record first
	
	 $Query = "SELECT a.*,s.studentName FROM ".$tableName." a left join  ingl_student
    s on s.recNo =a.student_recNo where a.recNo='".$_REQUEST[kV]."'";
	if ($dbObject->Retrieve_join($Query))
	{ ; }
	else { $succFailMesg = "<b>Could not retrieve details. Contact system administrator</b><br>"; }
}
else if ($action == "Delete")
{	$showResult = "D"; // Goto result part in dataform
	
	if ($dbObject->Delete("recNo",$_REQUEST["kV"]))
	{	$succFailMesg = "<b>Details deleted successfully</b><br>"; }
	else
	{	$succFailMesg = "<b>Could not delete details. Contact System administrator</b><br>" ; }
}
else if ($action == "sV")
{	// Set 'View' mode 
	$currentMode = "View"; $succFailMesg = "<b>View details</b>&nbsp;&nbsp;&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>";
	$dataForm = $viewForm;
	
	// Retrieve record first
			 $Query = "SELECT a.*,s.studentName FROM ".$tableName." a left join  ingl_student
    s on s.recNo =a.student_recNo where a.recNo='".$_REQUEST[kV]."'";
	if ($dbObject->Retrieve_join($Query))
	{ ; }
	else { $succFailMesg = "<b>Could not retrieve details. Contact system administrator</b><br>"; }

}
else
{	echo "Nothing to do !";
	return;
}

// Load the data entry or  view entry form
require($dataForm);

$dbObject->CloseConnection();
return;


?>