I am having a Controller names SalesController, which have two Actions : addSalesAction (which performs the form submit and save data to database) and another is uploadFileAction (which perform a file upload for the newly added sale entry).
Now I want to use the id of the newly added sale entry to the uploadFileAction. How do I set the Id as Global variable and how do I use it?
I am getting Id by this method :
$this->db->begin();
$db_sales_order = new SaleOrder();
$cont = false;
$db_sales_order->loadFromJson($data);
if ($db_sales_order->save() === false) {
$this->db->rollback();
foreach ($db_sales_order->getMessages() as $message) {
$error_msg = $message . "\n";
}
} else {
$cont = TRUE;
$new_entry_id = $db_sales_order->id;
}
$new_entry_id
is the variable which store newly added sales entry id.
How to make it Gloabal so I can use it in another Action?