Current File : /var/www/vinorea/modules/ipexportimport/classes/import/order/EIAOrderHistory.php |
<?php
/**
*
* NOTICE OF LICENSE
*
* @author SmartPresta <tehran.alishov@gmail.com>
* @copyright 2024 SmartPresta
* @license Commercial License
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class EIAOrderHistory
{
public $id_order;
public $id_process;
public $user_notification;
public $id_state;
public $date_add;
public $row;
public $validateOnly;
public function __construct($id_order, $id_process, $user_notification, $id_state, $date_add, $row, $validateOnly = false)
{
$this->id_order = $id_order;
$this->id_process = $id_process;
$this->user_notification = $user_notification;
$this->id_state = $id_state;
$this->date_add = $date_add;
$this->row = $row;
$this->validateOnly = $validateOnly;
}
public function run()
{
$history = new OrderHistoryCore();
$history->id_order = (int) $this->id_order;
$history->id_employee = (int) Context::getContext()->employee->id;
$history->id_order_state = (int) $this->id_state;
$history->date_add = $this->date_add;
if (($error = $history->validateFields(false, true)) !== true) {
throw new PrestaShopException("Error: $error. ID: $this->id_order. Row in file: $this->row.");
}
if ($this->user_notification == 'yes') {
$this->validateOnly || $history->addWithemail(false);
} else {
$this->validateOnly || $history->add(false);
}
}
}