THE ORIGINAL POST
I have a form [Record] with three "submit" type buttons each with the "update" operation.
Why?
One to update the form and redirect to one page
One to update the form and redirect to another page
One to update the form, execute a custom insert and redirect to another page.
All depending on which button you press.
The problem is that for some reason either programmatically or using CCS normal redirect functions, I am not able to filter which button has been pressed and direct code execution accordingly.
I am using this code to determine which button was pressed. It is used in the form's AfterExecuteUpdate event:
global $DBConnection1;
global $Redirect;
global $LastinvID;
if ($Component->PressedButton == "Button_Update") {
$Redirect = "estimate_list.php";
} elseif ($Component->PressedButton == "Button_Update1"){
$Redirect = "invoice_list.php";
} elseif ($Component->PressedButton == "Button_Invoice"){
$db = new clsDBConnection1();
$estimateid = CCGetFromGet("EstID", 0);
$result = $db->query("INSERT INTO invoice (TimeCreated, CustomerRef, ClassRef)
SELECT now(), CustomerRef, ClassRef
FROM estimate WHERE EstID = $estimateid");
$LastinvID = CCDLookUp("last_insert_id()","invoice","",$DBConnection1);
$Redirect ="invoice_edit.php?INVID=" . $LastinvID;
}
I have deliberately not defined Return pages for the button components or for the form.
The problem is, whichever of the 3 buttons you press, it always executes the code after
($Component->PressedButton == "Button_Invoice") {
...
Is it because my "Button_Invoice" button happens to be the first submit button on the form and CCS can only handle one submit button of each kind (insert, delete, update, search, cancel)?