Jump to content

Recommended Posts

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 !

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.