Current File : /home/inlingua/public_html/noida/icentex/pg/ingl_invoice_payment.main.php |
<?php
// Created on: 10-05-2013
session_start();
//print_r($_SESSION);
/*
$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_invoice_payment";
$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
$dbObject->setDbField("invice_no",$_REQUEST['invice_no']);
$dbObject->setDbField("createDate",date("Y-m-d"));
$currentMode = "Add";
$succFailMesg = "<b>Add entry</b> [<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");
//$arrayAlpha=array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
$queryB="select * from timesheet_location where location='".$_SESSION['branch']."'";
$resultB=mysqli_query($conn,$queryB);
$numB=mysqli_fetch_array($resultB);
$queryR="select count(a.recNo) as maxid from ingl_invoice_payment a left join ingl_invoice_main b on b.recNo=a.invice_no
where b.centre='".$numB['recNo']."'";
$resultR=mysqli_query($conn,$queryR);
$numR=mysqli_fetch_array($resultR);
$idR=$numR['maxid']+1;
if(strlen($idR)=="1")
{
$idR="000".$idR."";
}
else if(strlen($idR)=="2")
{
$idR="00".$idR."";
}
else if(strlen($idR)=="3")
{
$idR="0".$idR."";
}
else
{
$idR="".$idR."";
}
$idR1="".$numB['code_prefix']."".$idR."";
/*echo"<pre>";
print_r($des_array);
print_r($_REQUEST);
exit;*/
$queryA="select recNo from ingl_invoice_payment where invice_no='".$_REQUEST['invice_no']."'";
$resultA=mysqli_query($conn,$queryA);
$numA=mysqli_fetch_array($resultA);
$countA=mysqli_num_rows($resultA);
$arrayAlpha_jid=$arrayAlpha[$countA];
$queryB="select invoice_no from ingl_invoice_main where recNo='".$_REQUEST['invice_no']."'";
$resultB=mysqli_query($conn,$queryB);
$numB=mysqli_fetch_array($resultB);
$rid1="".$numB['invoice_no']."".$arrayAlpha_jid."";
$dbObject->setDbField("rcpt_id",$idR1);
//$dbObject->setDbField("createDate",date("Y-m-d H:i:s"));
$dbObject->setDbField("created_by",$_SESSION['id']);
$dbObject->Save();
$insert_id=mysqli_insert_id();
$succFailMesg = "<b>Entry added successfully</b><br>";
$showResult = "Y"; // Goto result part in dataform
$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
$goUrl = "ingl_invoice_payment.select.php?kV=".$_REQUEST['invice_no']."";
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
$dbObject->setDbField("modifyDate",date("Y-m-d H:i:s"));
//$dbObject->setDbField("createdby",$_SESSION['id']);
if ($dbObject->Update("recNo",$_REQUEST["kV"]))
{ $succFailMesg = "<b>Entry modified successfully</b><br>";
$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
//$goUrl = "ingl_invoice_payment.select.php";
$goUrl = "ingl_invoice_payment.select.php?kV=".$_REQUEST['invice_no']."";
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_invoice_payment.select.php";
$goUrl = "ingl_invoice_payment.select.php?kV=".$_REQUEST['invice_no']."";
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 if ($action == "sV")
{ // Set 'View' mode
$currentMode = "View"; $succFailMesg = "<b>View entry</b> [<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> [<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;
?>