I would like to execute two functions of a class, during the same instantiation. I need two tasks to run at the same time. See here :
First file : manage_stock_service.php
<?php
require_once __DIR__ . "/../../includes/php/initialize.php";
include './../../config/config.inc.php';
include './../../init.php';
include './../ps_emailalerts/MailAlert.php';
class Manage_stock_service extends Initialize {
public $resultat;
public function __construct() {
parent::__construct();
$this->resultat= [];
}
public function __destruct() {
parent::__destruct();
}
//Update the stock in database
public function manage_stock_supply_order_detail_update()
{
$spathSQL_update_stock= $this->GLOBALS_INI["PATH_HOME"] . "files/manage_stock/sql/supply_list/manage_stock_UPDATE_supply_order_update_stock.sql";
$this->oBdd->getSelectDatas($spathSQL_update_stock, array(
'id_product' => $old_received['id_product'],
'id_attribute' => $old_received['id_product_attribute'],
'quantity' => $diff_received
));
}
//Notifies the customer that the product is back in stock.
public function sendMailToClient()
{
$customer_qty = (int) Configuration::get('MA_CUSTOMER_QTY');
$quantity = $diff_received;
if ($customer_qty && $quantity > 0) {
MailAlert::sendCustomerAlert((int) $old_received['id_product'], (int) $old_received['id_product_attribute']);
}
}
}
?>
And the second : manage_stock_supply_order_detail_update.php
<?php
require_once "manage_stock_service.php";
class Manage_stock_supply_order_detail_update {
public $resultat;
public function __construct() {
$this->resultat = [];
$this->main();
}
function main() {
$obj_manage_stock_list = new Manage_stock_service();
$obj_manage_stock_list->manage_stock_supply_order_detail_update();
$obj_manage_stock_list->sendMailToCustomer();
$this->resultat = $obj_manage_stock_list->resultat;
$this->VARS_HTML = $obj_manage_stock_list->VARS_HTML;
unset($obj_manage_stock_list);
}
}
?>
I was wondering if it was possible to do $obj_manage_stock_list->sendMailToCustomer();, and if not what would be the way to execute the function in the manage_stock_supply_order_detail_update.php file.
I wanted to execute the sendMailToCustomer() function in the manage_stock_supply_order_detail_update() function but according to my tests this is impossible.
Does anyone have an idea?
Thanks in advance !