Current File : /home/inlingua/www/icentex/pg/ingl_invoice_main.main.php
<?php
//  Created on: 13-04-2013
session_start();
date_default_timezone_set('Asia/Calcutta');
/*
$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_main";
$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();

//Table2

// Setup table name, configuration and data entry form
$tableName1 = "ingl_invoice_detail";
$tableConf1 = $tableName1 . ".conf.php";


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


$dbObject1 = new dbHandler();
$dbObject1->setTableName($tableName1);
$dbObject1->setDbFieldList($dbFieldList1);
$dbObject1->setKeyFieldName("recNo");
$dbObject1->connect();

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

//////////////////////////////////////////

//Table3

// Setup table name, configuration and data entry form
$tableName3 = "ingl_invoice_payment";
$tableConf3 = $tableName3 . ".conf1.php";


// Include table configuration details
require($tableConf3);
$dbObject3 = new dbHandler();
$dbObject3->setTableName($tableName3);
$dbObject3->setDbFieldList($dbFieldList3);
$dbObject3->setKeyFieldName("recNo");
$dbObject3->connect();

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

//////////////////////////////////////////
$tableName4="ingl_invoice_reg";
$tableConf4=$tableName4.".conf.php";
// Include table configuration details
require($tableConf4);
$dbObject4 = new dbHandler();
$dbObject4->setTableName($tableName4);
$dbObject4->setDbFieldList($dbFieldList4);
$dbObject4->setKeyFieldName("recNo");
$dbObject4->connect();
// Retrieve parameters from request
$dbObject4->getDbFieldsFromRequest();
//////////////////////////////////////////
$currentMode = "";
$formPrompt = "";
$succFailMesg = "";
$showResult = "N";



$action = $_REQUEST['aC'];
if (($action == "")  || ($action == "sA"))
{	// Set 'Add' mode in dataform
       
	   
		$dbObject->setDbField("student_id",$_REQUEST['student_id']);	
		$queryS="select * from ingl_admission where ref_No='".$_REQUEST['student_id']."'";
		$resultS=mysqli_query($conn,$queryS);
		$numS=mysqli_fetch_array($resultS);
		$dbObject->setDbField("student_name","".$numS['firstName']." ".$numS['lastName']."");
		$dbObject->setDbField("student_address","".$numS['address']."");	
		$queryB="select * from timesheet_location where  location='".$_SESSION['branch']."' order by location";
		$resultB=mysqli_query($conn,$queryB);
		$numB=mysqli_fetch_array($resultB);
		$dbObject->setDbField("centre","".$numB['recNo']."");
		$dbObject->setDbField("createDate",date("Y-m-d"));
		
		$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 if($_REQUEST['category'][0]=="0" || $_REQUEST['product'][0]=="0")
	{
		$succFailMesg = "<font color='#da0000'><b>Could not add. Please select at least one item.</b></font><br>";	
		$showResult = "N"; // Show dataentry form again
	}
	else
	{	//$today = date("Y-m-d");
		
	$query_setId="ALTER TABLE ingl_invoice_main auto_increment = 1";
    $result=mysqli_query($conn,$query_setId);
       
                $queryB="select * from timesheet_location where recNo='".$_REQUEST['centre']."'";
                $resultB=mysqli_query($conn,$queryB);
                $numB=mysqli_fetch_array($resultB);
				
        $financial_year_to = (date('m') > 03) ? date('Y') +1 : date('Y');
        $year = $financial_year_to - 1;
		
	    $query="select count(recNo) as maxid from ingl_invoice_main where centre ='".$_REQUEST['centre']."' and type ='I' and financialyear='".$year."' ";
	   $result=mysqli_query($conn,$query);
	   $num=mysqli_fetch_array($result);
	   $roll=$num['maxid']+1;
	   
	   if(strlen($roll)=="1")
	   {
	   $rid=$year."000".$roll."";
	   }
	   else if(strlen($roll)=="2")
	   {
	   $rid=$year."00".$roll."";
	   }
	   else if(strlen($roll)=="3")
	   {
	   $rid=$year."0".$roll."";
	   }
	   else
	   {
	  $rid=$year."".$roll.""; 
	   }
	   	
			$rid="".$numB['code_prefix']."".$rid."";
			// echo $query;exit;
			$dbObject->setDbField("invoice_no","".$rid."");
			$dbObject->setDbField("createdBy","".$_SESSION['id']."");
		
		$dbObject->setDbField("createDate",date("Y-m-d H:i:s"));
		$dbObject->setDbField("financialyear",$year);
		$dbObject->setDbField("status_delete",0);
		$dbObject->setDbField("type","I");
		
		$insert_1=$dbObject->Save();
		
	if($insert_1>0)
	{
	
		//For Reg
		
		$product_Regid=$_REQUEST['product'][0];
		if($product_Regid==61||$product_Regid==62||$product_Regid==63)
		{
		//$Reg_Cate1=$_REQUEST['reg_category1'];
		$Reg_Cate2=$_REQUEST['reg_category2'];
		//$Reg_Cate3=$_REQUEST['reg_category3'];
		$Reg_product1=$_REQUEST['reg_product1'];
		$Reg_product2=$_REQUEST['reg_product2'];
		 $Reg_product3=$_REQUEST['reg_product3'];
		
		if( $Reg_product1!=0)
		{
		$dbObject4->setDbField("reg_category1",$Reg_Cate2);
		$dbObject4->setDbField("reg_product1",$Reg_product1);		
		}
		else
		{
		$dbObject4->setDbField("reg_category1","0");
		$dbObject4->setDbField("reg_product1","0");
		}
		if( $Reg_product2!=0)
		{
		$dbObject4->setDbField("reg_category2",$Reg_Cate2);
		$dbObject4->setDbField("reg_product2",$Reg_product2);
		}
		else
		{
		$dbObject4->setDbField("reg_category2","0");
		$dbObject4->setDbField("reg_product2","0");
		}
		if( $Reg_product3!=0)
		{
		$dbObject4->setDbField("reg_category3",$Reg_Cate2);
		$dbObject4->setDbField("reg_product3",$Reg_product3);
		}
		else
		{
		$dbObject4->setDbField("reg_category3","0");
		$dbObject4->setDbField("reg_product3","0");
		}
		
		$dbObject4->setDbField("recNo",$insert_1);
		$dbObject4->setDbField("invoice_no",$rid);
		$dbObject4->setDbField("level",$product_Regid);
				if($insert_1>0 && $rid>0)
				{
				$dbObject4->Save();
				}
		}
		//end Of Reg
		
		
		$des_array=$_REQUEST['category'];
	
		/*echo"<pre>";
		print_r($des_array);
		print_r($_REQUEST); 
		exit;
        */
		if(is_array($des_array))
		{
		foreach($des_array as  $key1=>$val1)
		{
			$category_id=$_REQUEST['category'][$key1];
			$product_id=$_REQUEST['product'][$key1];
			
			$queryD="select bill_details from ingl_billing_main where bill_category='".$product_id."'";
			$resultD=mysqli_query($conn,$queryD);
			$numD=mysqli_fetch_array($resultD);
			$product_desc=$numD['bill_details'];
			$rates=$_REQUEST['rates'][$key1];
			$tax_rates=$_REQUEST['tax_s'][$key1];
			$quantity=$_REQUEST['quan'][$key1];
			$amount=$_REQUEST['total'][$key1];
			$tax_amount=$_REQUEST['tax'][$key1];
			$remarks=$_REQUEST['description'][$key1];
			$CourseID=$_REQUEST['CourseID'][$key1];
			$Discount=$_REQUEST['Discount'][$key1];
			
			if($rates==''){
				$rates='0.00';
			}
			if($tax_rates==''){
				$tax_rates='0.00';
			}
			
			if($tax_amount==''){
				$tax_amount='0.00';
			}
			
			
			
		$dbObject1->setDbField("main_id",$insert_1);
		$dbObject1->setDbField("invoice_no",$rid);
		$dbObject1->setDbField("category_id",$category_id);
		$dbObject1->setDbField("product_id",$product_id);
		$dbObject1->setDbField("product_desc",$product_desc);
		$dbObject1->setDbField("rates",$rates);
		$dbObject1->setDbField("tax_rates",$tax_rates);
		$dbObject1->setDbField("quantity",$quantity);
		$dbObject1->setDbField("amount",$amount);
		$dbObject1->setDbField("tax_amount",$tax_amount);
		$dbObject1->setDbField("remarks",$remarks);
		$dbObject1->setDbField("Course_id",$CourseID);
		$dbObject1->setDbField("Discount",$Discount);
		
		if($category_id>0 && $product_id>0 && $insert_1>0)
		{
		$dbObject1->Save();
		}
			
		}
		}
		
		//$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");
		$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='".$_REQUEST['centre']."' and type ='I' and financialyear='".$year."' ";		
		$resultR=mysqli_query($conn,$queryR);
		$numR=mysqli_fetch_array($resultR);
	      $idR=$numR['maxid']+1;
		if(strlen($idR)=="1")
	   {
	   $idR=$year."000".$idR."";
	   }
	   else if(strlen($idR)=="2")
	   {
	   $idR=$year."00".$idR."";
	   }
	   else if(strlen($idR)=="3")
	   {
	   $idR=$year."0".$idR."";
	   }
	   else
	   {
	  $idR=$year."".$idR.""; 
	   }
		
		
		$idR1="".$numB['code_prefix']."".$idR."";
		
		$dbObject3->setDbField("invice_no",$insert_1);
		$dbObject3->setDbField("rcpt_id","".$idR1."");
		
		/*$dbObject3->setDbField("amount",$_REQUEST['rcpt_amount']);
		$dbObject3->setDbField("payment_mode",$_REQUEST['rcpt_payment_mode']);
		$dbObject3->setDbField("cheque_no",$_REQUEST['rcpt_cheque_no']);
		$dbObject3->setDbField("favour_of",$_REQUEST['rcpt_favour_of']);
		$dbObject3->setDbField("createDate",$_REQUEST['createDate']);
	    $dbObject3->setDbField("created_by","".$_SESSION['id']."");
		 $dbObject3->setDbField("product_id",$_REQUEST['product'][0]);*/
		 $dbObject3->setDbField("amount",$_POST['total'][0]);
		$dbObject3->setDbField("payment_mode",$_REQUEST['rcpt_payment_mode']);
		$dbObject3->setDbField("cheque_no",$_REQUEST['rcpt_cheque_no']);
		$dbObject3->setDbField("favour_of",$_REQUEST['rcpt_favour_of']);
		$dbObject3->setDbField("createDate",date("Y-m-d H:i:s"));
	    $dbObject3->setDbField("created_by","".$_SESSION['id']."");
		 $dbObject3->setDbField("product_id",$_REQUEST['product'][0]);
		if($insert_1>0)
		{
		$dbObject3->Save();
		}
		$insertpay=mysqli_insert_id($conn); 
		
		$sql="Select dt.*,main.bill_details,adm.mobile,adm.firstName from ingl_invoice_detail dt inner join ingl_billing_main main on dt.product_id=main.recNo 
inner join ingl_invoice_main invmain on invmain.invoice_no=dt.invoice_no inner join ingl_admission adm on adm.ref_No=invmain.student_id where dt.invoice_no='".$idR1."' order by recNo"; 
		 
		$selected = $dbObject->Select($sql); 
		//$selected = mysqli_query($conn,$sqlfetch); 
			if($selected)
			{
		 //
		
			 if($_POST['category'][0]==13)
		    {  
			$objectData=$dbObject->SelectNext(); 
			$mobile = trim($objectData['mobile']);
$product=str_replace(" ","%20",$objectData['bill_details']);	//$sms="Dear%20".$objectData['firstName']."%20Thank%20you%20for%20registering%20at%20inlingua%20".$_SESSION['branch']."%20for%20".$objectData['bill_details'].".%20Your%20registration%20ID%20is%20".$_POST['CourseID'][0].",receipt%20No%20is%20".$idR1.".%20The%20details%20of%20your%20course%20will%20be%20communicated%20soon.%20Regards,%20Inlingua%20".$_SESSION['branch']."."; 
			$sms="Dear%20".$objectData['firstName']."%20Thank%20you%20for%20registering%20at%20inlingua%20".$_SESSION['branch']."%20for%20".$product.".%20Your%20registration%20ID%20is%20".$_POST['CourseID'][0].",receipt%20No%20is%20".$idR1.".%20The%20details%20of%20your%20course%20will%20be%20communicated%20soon.%20Regards,%20Inlingua%20".$_SESSION['branch']."."; 
			}
			else
			{ 
				//$objectData=$dbObject->SelectNext(); 
				while($objectDatadt=$dbObject->SelectNext($selected))
                {
					$productdt.=$objectDatadt['bill_details'].",";
					$totalamt=$totalamt+$objectDatadt['amount'];
					$fname=$objectDatadt['firstName']; 
					$mobile = trim($objectDatadt['mobile']);
			    }  
				$rupeeSymbol = "%E2%82%B9";
				$product=str_replace(" ","%20",$productdt);
				$product=$product."%20Amount%20".$totalamt."%20INR";
				 
				$studentid=trim(str_replace(" ","%20",$_REQUEST['student_id']));
				//$sms="Dear%20".$fname."%20We%20have%20received%20your%20payment%20towards%20".$product.".%20Your%20receipts%20No.%20is%20".$idR1."%20and%20student%20ID%20is%20".$studentid.".%20Wishing%20you%20the%20best!%20Inlingua%20".$_SESSION['branch'].".";
				$sms= "Dear%20".$fname."%20We%20have%20received%20your%20payment%20towards%20".$product.".%20Your%20receipts%20No.%20is%20".$idR1."%20and%20student%20ID%20is%20".$studentid.".%20Wishing%20you%20the%20best!%20Inlingua%20".$_SESSION['branch'].".";
			}
			  
			$dbObject->send_sms($mobile,$sms);
			//exit;
		}
		
		
		$succFailMesg = "<b>Entry added successfully</b><br>";
	}
		$succFailMesg = "<b>Could not Add entry. Contact system administrator</b><br>";
		$showResult = "Y"; // Goto result part in dataform  
		$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
		$goUrl = "ingl_invoice_main.main.php?aC=sV&kV=".$insert_1."";
		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>Recipt Not Generate Try Again.</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
	$dbObject->setDbField("createdBy","".$_SESSION['id']."");
	$dbObject->setDbField("modifyDate",date("Y-m-d"));

	
	
	if ($dbObject->Update("recNo",$_REQUEST["kV"]))
	{
	
	
	//For Reg
		
		$product_Regid=$_REQUEST['product'][0];
		if($product_Regid==61||$product_Regid==62||$product_Regid==63)
		{
		//$Reg_Cate1=$_REQUEST['reg_category1'];
		$Reg_Cate2=$_REQUEST['reg_category2'];
		//$Reg_Cate3=$_REQUEST['reg_category3'];
		$Reg_product1=$_REQUEST['reg_product1'];
		$Reg_product2=$_REQUEST['reg_product2'];
		 $Reg_product3=$_REQUEST['reg_product3'];
		
		if( $Reg_product1!=0)
		{
		$dbObject4->setDbField("reg_category1",$Reg_Cate2);
		$dbObject4->setDbField("reg_product1",$Reg_product1);		
		}
		else
		{
		$dbObject4->setDbField("reg_category1","1");
		$dbObject4->setDbField("reg_product1","1");
		}
		if( $Reg_product2!=0)
		{
		$dbObject4->setDbField("reg_category2",$Reg_Cate2);
		$dbObject4->setDbField("reg_product2",$Reg_product2);
		}
		else
		{
		$dbObject4->setDbField("reg_category2","1");
		$dbObject4->setDbField("reg_product2","1");
		}
		if( $Reg_product3!=0)
		{
		$dbObject4->setDbField("reg_category3",$Reg_Cate2);
		$dbObject4->setDbField("reg_product3",$Reg_product3);
		}
		else
		{
		$dbObject4->setDbField("reg_category3","1");
		$dbObject4->setDbField("reg_product3","1");
		}
		
		$dbObject4->setDbField("recNo",$_REQUEST["kV"]);
		$dbObject4->setDbField("invoice_no",$_REQUEST['Invoice']);
		$dbObject4->setDbField("level",$product_Regid);
		$dbObject4->Update("recNo",$_REQUEST["kV"]);
		}
		//end Of Reg
	    $amount="select amount from ingl_invoice_detail where invoice_no='".$_REQUEST['Invoice']."'";
		$resultAM=mysqli_query($conn,$amount);
		$tamount=mysqli_fetch_array($resultAM);
		$dbObject1->Delete("main_id",$_REQUEST["kV"]);
		$query_setId="ALTER TABLE ingl_invoice_detail auto_increment = 1";
        $result=mysqli_query($conn,$query_setId);
		
		$invoice=$_REQUEST['Invoice'];
	
	   $des_array=$_REQUEST['category'];
		
		if(is_array($des_array))
		{
			$j=0;
		foreach($des_array as  $key1=>$val1)
		{
			
		    if($tamount[$j]>0){	
			$category_id=$_REQUEST['category'][$key1];
			$product_id=$_REQUEST['product'][$key1];
			
			$queryD="select bill_details from ingl_billing_main where bill_category='".$product_id."'";
			$resultD=mysqli_query($conn,$queryD);
			$numD=mysqli_fetch_array($resultD);
			$product_desc=$numD['bill_details'];
			$rates='0.00';
			$tax_rates='0.00';
			$quantity=$_REQUEST['quan'][$key1];
			$amount=$tamount[$j];
			$tax_amount=$_REQUEST['tax'][$key1];
			$remarks=$_REQUEST['description'][$key1];
			$CourseID=$_REQUEST['CourseID'][$key1];
			$Discount=$_REQUEST['Discount'][$key1];
			
			
			
			$dbObject1->setDbField("recNo",0);
			$dbObject1->setDbField("main_id",$_REQUEST["kV"]);
			$dbObject1->setDbField("invoice_no",$invoice);
			$dbObject1->setDbField("category_id",$category_id);
			$dbObject1->setDbField("product_id",$product_id);
			$dbObject1->setDbField("product_desc",$product_desc);
			$dbObject1->setDbField("rates",$rates);
			$dbObject1->setDbField("tax_rates",$tax_rates);
			$dbObject1->setDbField("quantity",$quantity);
			$dbObject1->setDbField("amount",$amount);
			$dbObject1->setDbField("tax_amount",$tax_amount);
			$dbObject1->setDbField("remarks",$remarks);
			$dbObject1->setDbField("Course_id",$CourseID);
			$dbObject1->setDbField("Discount",$Discount);
			
		if($category_id>0 && $product_id>0)
		{
		$dbObject1->Save();
		}
		$j++;
			}		
		}
		}
		
		
		$succFailMesg = "<b>Entry modified successfully</b><br>";
	
		$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
		$goUrl = "ingl_invoice_main.main.php?aC=sV&kV=".$_REQUEST['kV']."";
		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>Recipt Not Generate Try Again. </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
	
	$dbObject->setDbField("status_delete",1);
	
	if ($dbObject->Update("recNo",$_REQUEST["kV"]))
	{
		$succFailMesg = "<b>Entry Cancelled successfully</b><br>";
	
		$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
		$goUrl = "ingl_invoice_main.select.php";
		header('Location: '.$goUrl);
	}
	else{
	$succFailMesg = "<font color='#da0000'><b>Could not Cancel entry. Contact System administrator</b></font>&nbsp;&nbsp;&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>" ; 	
	}
	
	/*if ($dbObject->Delete("recNo",$_REQUEST["kV"]))
	{
		$dbObject1->Delete("main_id",$_REQUEST["kV"]);
		$succFailMesg = "<b>Entry deleted successfully</b><br>";
	
		$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
		$goUrl = "ingl_invoice_main.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 == "sDel")
{
 
        if ($dbObject->Delete("recNo",$_REQUEST["kV"]))
	{
		$dbObject4->Delete("recNo",$_REQUEST["kV"]);
		$dbObject1->Delete("main_id",$_REQUEST["kV"]);
		$query_del="delete from ingl_invoice_payment where invice_no='".$_REQUEST["kV"]."'";
		$resul_del=mysqli_query($conn,$query_del) or die(mysql_error($conn));
		
		$succFailMesg = "<b>Entry deleted successfully</b><br>";
	
		$_SESSION['dispMesg'] = array(date("U"), $succFailMesg);
		$goUrl = "ingl_invoice_main.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"; 	
		  
	/*$goUrl = "rcpt_pdf.php?kV=".$_REQUEST["kV"]."";
		header('Location: '.$goUrl);*/
	//$succFailMesg = "<b>Invoice (<a href='invoice_pdf.php?kV=".$_REQUEST["kV"]."' target='_blank'>Print</a>)</b>&nbsp;&nbsp;<b>(<a href='ingl_invoice_payment.select.php?kV=".$_REQUEST["kV"]."' target='_blank'>Receipts</a>)</b>&nbsp;&nbsp;[<a href='javascript:history.back()'>Back</a>]<br>";
	
	
	
	 $succFailMesg = "<aside class='contentbox-head'> <span class='title'>Entry (<span class='status-row'><a style='color:white;' href='rcpt_pdf.php?recNo=".$_REQUEST["kV"]."' target='_blank' title='Add entry'>Receipts</a></span>
)</span>


</aside>";
            
         $dataForm = $viewForm; 
	
	// Retrieve record first
	if ($dbObject->Retrieve("recNo",$_REQUEST["kV"]))
	{ ; }
	else 
	{	$succFailMesg = "<font color='#da0000'><b>Recipt Not Generate Try Again.</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;

?>