Current File : /home/inlingua/public_html/dwarka/icentex/admin_conveyance/ingl_conveyance_bands.main.php
<?php
// Copyright, Panalink Infotech Limited. Created on: 10-06-2012
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_conveyance_bands";
$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 = "Add"; $succFailMesg = "<b>Add entry</b>&nbsp;&nbsp;&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>";
}
else if ($action == "Add")
{	$currentMode = "Add"; 

	// 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");
		$dbObject->Save();
		$succFailMesg = "<b>Entry added successfully</b><br>";
		$showResult = "Y"; // Goto result part in dataform
		
		$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
		$goUrl = "ingl_conveyance_bands.select.php";
		header('Location: '.$goUrl);		
	}
}
else if ($action == "sM")
{	// Set 'Update' mode in dataform
	$currentMode = "Update"; $succFailMesg = "<b>Modify entry</b>&nbsp;&nbsp;&nbsp;&nbsp;[<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>&nbsp;&nbsp;&nbsp;&nbsp;[<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_conveyance_bands.select.php";
		header('Location: '.$goUrl);	
	}
	else
	{	$succFailMesg = "<font color='#da0000'><b>Could not modify entry. Contact system administrator</b></font>&nbsp;&nbsp;&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>" ; 
	}
}
else if ($action == "sD")
{	$currentMode = "Delete"; $succFailMesg = "<b>Delete entry</b>&nbsp;&nbsp;&nbsp;&nbsp;[<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>&nbsp;&nbsp;&nbsp;&nbsp;[<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_conveyance_bands.select.php";
		header('Location: '.$goUrl);
	}
	else
	{	$succFailMesg = "<font color='#da0000'><b>Could not delete entry. Contact System administrator</b></font>&nbsp;&nbsp;&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>" ; }
}
else if ($action == "sV")
{	// Set 'View' mode 
	$currentMode = "View"; $succFailMesg = "<b>View entry</b>&nbsp;&nbsp;&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>";
	$dataForm = $viewForm;
	
	// Retrieve record first
	if ($dbObject->Retrieve("recNo",$_REQUEST["kV"]))
	{ ; }
	else 
	{	$succFailMesg = "<font color='#da0000'><b>Could not retrieve entry. Contact system administrator</b></font>&nbsp;&nbsp;&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>"; 
		$showResult = "Y"; // Goto result part in dataform
	}

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

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

$dbObject->CloseConnection();
return;

?>