Current File : /home/inlingua/public_html/noida/icentex/attendance/ingl_reschedule.main.php |
<?php
// Copyright, Panalink Infotech Limited. Created on: 10-10-2011
session_start();
/*
$loggedUserNo = $_SESSION['loggedUserNo'];
if ($loggedUserNo == "")
{ echo "Please <a href='index.php'>login</a> first.";
exit(0);
}
*/
// 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 = "ingl_reschedule";
$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();
$currentMode = "";
$formPrompt = "";
$succFailMesg = "";
$showResult = "N";
$action = $_REQUEST['aC'];
if (($action == "") || ($action == "sA"))
{ // Set 'Add' mode in dataform
$currentMode = "Submit"; $succFailMesg = "<b>Add entry</b> [<a href='javascript:history.back()'>Back</a>]<br>";
}
else if ($action == "Submit")
{ $currentMode = "Submit";
// Perform check for duplicate entry
if($dbObject->Exists("recNo", $_REQUEST["recNo"]))
{ $succFailMesg = "<font color='#da0000'><b>Could not add. entry with this key already exists.</b></font><br>";
$showResult = "N"; // Show dataentry form again
}
else
{ //$today = date("Y-m-d");
$query="select * from ingl_reschedule where courserecNo='".$_REQUEST['courserecNo']."' && fromDate='".$_REQUEST['fromDate']."'";
$result=mysqli_query($conn,$query);
$count=mysqli_num_rows($result);
$num=mysqli_fetch_array($result);
if($count<=0)
{
$queryD="select * from ingl_reschedule where courserecNo='".$_REQUEST['courserecNo']."' && schedule_date='".$_REQUEST['fromDate']."' ";
$resultD=mysqli_query($conn,$queryD);
echo $countD=mysqli_num_rows($resultD);
$numD=mysqli_fetch_array($resultD);
if($countD>0)
{
$recNoD=$numD['recNo'];
$dbObject->setDbField("fromDate",$numD['fromDate']);
$dbObject->Delete("recNo",$recNoD);
}
if($numD['fromDate']!=$_REQUEST['schedule_date'])
{
$dbObject->Save();
}
}
else
{
$recNo=$num['recNo'];
$dbObject->setDbField("recNo",$recNo);
if ($dbObject->Update("recNo",$recNo))
{
$succFailMesg = "<b>Entry modified successfully</b><br>";
}
}
$succFailMesg = "<b>Entry added successfully</b><br>";
$showResult = "Y"; // Goto result part in dataform
//$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
//$goUrl = "ingl_reschedule.select.php";
?>
<script language="javascript">
parent.jQuery.fn.colorbox.close();
</script>
<?php
//header('Location: '.$goUrl);
}
}
else if ($action == "sM")
{ // Set 'Update' mode in dataform
$currentMode = "Update"; $succFailMesg = "<b>Modify entry</b> [<a href='javascript:history.back()'>Back</a>]<br>";
// Retrieve record first
if ($dbObject->Retrieve("recNo",$_REQUEST["kV"]))
{ ; }
else
{ $succFailMesg = "<font color='#da0000'><b>Could not retrieve entry. Contact system administrator</b></font> [<a href='javascript:history.back()'>Back</a>]<br>";
$showResult = "Y"; // Goto result part in dataform
}
}
else if ($action == "Update")
{ $currentMode = "Update";
$showResult = "Y"; // Goto result part in dataform
if ($dbObject->Update("recNo",$_REQUEST["kV"]))
{ $succFailMesg = "<b>Entry modified successfully</b><br>";
$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
$goUrl = "ingl_reschedule.select.php";
header('Location: '.$goUrl);
}
else
{ $succFailMesg = "<font color='#da0000'><b>Could not modify entry. Contact system administrator</b></font> [<a href='javascript:history.back()'>Back</a>]<br>" ;
}
}
else if ($action == "sD")
{ $currentMode = "Delete"; $succFailMesg = "<b>Delete entry</b> [<a href='javascript:history.back()'>Back</a>]<br>";
// Retrieve record first
if ($dbObject->Retrieve("recNo",$_REQUEST["kV"]))
{ ; }
else
{ $succFailMesg = "<font color='#da0000'><b>Could not retrieve entry. Contact system administrator</b></font> [<a href='javascript:history.back()'>Back</a>]<br>";
$showResult = "Y"; // Goto result part in dataform
}
}
else if ($action == "Delete")
{ $showResult = "Y"; // Goto result part in dataform
if ($dbObject->Delete("recNo",$_REQUEST["kV"]))
{ $succFailMesg = "<b>Entry deleted successfully</b><br>";
$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
$goUrl = "ingl_reschedule.select.php";
header('Location: '.$goUrl);
}
else
{ $succFailMesg = "<font color='#da0000'><b>Could not delete entry. Contact System administrator</b></font> [<a href='javascript:history.back()'>Back</a>]<br>" ; }
}
else
{ echo "Nothing to do !";
return;
}
// Load the data entry or view entry form
//require($dataForm);
$dbObject->CloseConnection();
return;
?>