Current File : /home/inlingua/public_html/noida/icentex_noida/admin_fd/ingl_student.main.php |
<?php
// Copyright, Panalink Infotech Limited. Created on: 27-11-2010
session_start();
// Include the database connection details
require('../dbConnection.php');
// Include common functions
require('../commonFunc.php');
// Include common functions
require('../globalVars.php');
function randompassword()
{
$r=rand(111111,999999);
return $r;
}
// Setup table name, configuration and data entry form
$tableName = "ingl_student";
$tableConf = $tableName . ".conf.php";
$dataForm = $tableName . ".form.php";
$viewForm = $tableName . ".view.php";
// Include table configuration details
require($tableConf);
/*echo "<pre>";
print_r($_POST);
exit; */
// 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();
$currentMode = "";
$formPrompt = "";
$succFailMesg = "";
$showResult = "N";
$action = $_REQUEST['aC'];
if (($action == "") || ($action == "sA"))
{ // Set 'Add' mode in dataform
$currentMode = "Add"; $succFailMesg = "<b>Add details</b> [<a href='javascript:history.back()'>Back</a>]<br>";
}
else if ($action == "Add")
{ $currentMode = "Add";
$_REQUEST["login"]=trim($_REQUEST["login"]);
// 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 if($dbObject->Exists("login", $_REQUEST["login"]))
{ $succFailMesg = "<b>Could not add details, record with this login id exists.</b><br>";
$showResult = "N"; // Show dataentry form again
}*/
else
{ //$today = date("Y-m-d");
foreach($_POST['studentName'] as $key=>$val)
{
$login=$_POST['login'][$key]." ".$_POST['courseId'];
$password=$_POST['password'][$key];
$ref_No=$_POST['ref_No'][$key];
$email=$_POST['email'][$key];
if($val!="" && $login!="" && $password!="")
{
if($dbObject->Exists("login", $login))
{
//$showResult = "N";
$msgE.="".$login." , ";
}
else
{
$dbObject->setDbField("studentName",$val);
$dbObject->setDbField("login",$login);
$dbObject->setDbField("password",$password);
$dbObject->setDbField("ref_No",$ref_No);
$dbObject->setDbField("email",$email);
$dbObject->Save();
$student = str_replace(" ","%20",$val);
$cource=str_replace(" ","%20",$_POST['course']."/".$_POST['level']);
$stime = date("g:i a", strtotime($_POST['stime']));
$etime = date("g:i a", strtotime($_POST['etime']));
$sms = "Dear%20".$student."%20Your%20inlingua%20course%20has%20been%20confirmed%20as%20follows:%20Start%20Date%20".$_POST['startDate']."%20End%20Date%20".$_POST['endDate'].",%20Day:%20".$_POST['day'].".%20Timing%20".str_replace(" ","%20",$stime)."%20to%20".str_replace(" ","%20",$etime)."%20.You%20are%20requested%20to%20report%2015%20mins%20before%20the%20class%20time%20on%20the%20first%20day.%20Regards%20Inlingua%20".$_SESSION['branch'].".";//
//echo $sms;exit;
$dbObject->send_sms(trim($_POST['mobile'][$key]),$sms);
}
}
}
$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> [<a href='javascript:history.back()'>Back</a>]<br>";
$Query_join = "SELECT s.*, c.courseid as ccourseid FROM ingl_student s left join ingl_course c on c.recNo = s.courseId where s.recNo='".$_REQUEST["kV"]."' ";
// Retrieve record first
if ($dbObject->Retrieve_join($Query_join))
{ ; }
else { $succFailMesg = "<b>Could not retrieve details. Contact system administrator</b><br>"; }
}
else if ($action == "Update")
{ $currentMode = "Update";
$showResult = "Y"; // G9oto result part in dataform
$_REQUEST["login"]=trim($_REQUEST["login"]);
if($dbObject->ExistsUpdate("login", $_REQUEST["login"],"recNo", $_REQUEST["kV"]))
{ $succFailMesg = "<b>Could not add details, record with this login id exists.</b><br>";
$showResult = "N"; // Show dataentry form again
}
else
{
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> [<a href='javascript:history.back()'>Back</a>]<br>";
// Retrieve record first
if ($dbObject->Retrieve("recNo",$_REQUEST["kV"]))
{ ; }
else { $succFailMesg = "<b>Could not retrieve details. Contact system administrator</b><br>"; }
}
else if ($action == "Delete")
{ $showResult = "Y"; // Goto result part in dataform
if ($dbObject->Delete("recNo",$_REQUEST["kV"]))
{
$courseid=$_REQUEST[courseId];
$querySD="select * from ingl_course where recNo='".$courseid."'";
$resultSD=mysqli_query($conn,$querySD);
$numSD=mysqli_fetch_array($resultSD);
$level=$numSD[level];
$courseName=$numSD['courseid'];
$attendance_table=$numSD['attendance_table'];
if($level=="1A" || $level=="1B")
{
//$cert="certificate_1.php";
$tab="level_1";
}
elseif($level=="2A" || $level=="2B")
{
//$cert="certificate_2.php";
$tab="level_2";
}
elseif($level=="3A" || $level=="3B")
{
//$cert="certificate_3.php";
$tab="level_3";
}
elseif($level=="4")
{
//$cert="certificate_4.php";
$tab="level_4";
}
elseif($level=="5")
{
//$cert="certificate_5.php";
$tab="level_5";
}
$student=$_REQUEST["kV"];
$querySD="delete from ".$tab." where courseId='".$courseName."' && student_recNo='".$student."'";
$resultSD=mysqli_query($conn,$querySD);
$querySDA="delete from ".$attendance_table." where courseIdrecNo='".$courseid."' && studentrecNo='".$student."'";
$resultSDA=mysqli_query($conn,$querySDA);
$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> [<a href='javascript:history.back()'>Back</a>]<br>";
$dataForm = $viewForm;
$currentMode = "Update"; $succFailMesg = "<b>View details</b> [<a href='javascript:history.back()'>Back</a>]<br>";
$Query_join = "SELECT s.*, c.courseid as ccourseid FROM ingl_student s left join ingl_course c on c.recNo = s.courseId where s.recNo='".$_REQUEST["kV"]."' ";
// Retrieve record first
if ($dbObject->Retrieve_join($Query_join))
{ ; }
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;
?>