Newer
Older
<?php
/**
* This file contains QUI\ERP\Order\ProcessingStatus\Status
*/
namespace QUI\ERP\Order\ProcessingStatus;
use QUI;
use QUI\ERP\Order\AbstractOrder;
/**
* Class Exception
*
* @package QUI\ERP\Order\ProcessingStatus
*/
class Status
{
/**
* @var int
*/
/**
* @var bool
*/
public function __construct(int | string $id)
{
$list = Handler::getInstance()->getList();
if (!isset($list[$id])) {
'quiqqer/order',
'exception.processingStatus.not.found'
// notification
try {
$Package = QUI::getPackage('quiqqer/order');
$Config = $Package->getConfig();
$result = $Config->getSection('processing_status_notification');
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
if (!empty($result[$id])) {
}
//region Getter
/**
* Return the status id
*
* @return int
*/
{
return $this->id;
}
/**
* Return the title
*
* @param null|QUI\Locale $Locale (optional) $Locale
public function getTitle(null | QUI\Locale $Locale = null): string
{
if (!($Locale instanceof QUI\Locale)) {
$Locale = QUI::getLocale();
}
return $Locale->get('quiqqer/order', 'processing.status.' . $this->id);
/**
* Get status notification message
*
* @param AbstractOrder $Order - The order the status change applies to
* @param QUI\Locale|null $Locale (optional) - [default: QUI::getLocale()]
* @return string
*/
public function getStatusChangeNotificationText(AbstractOrder $Order, null | QUI\Locale $Locale = null): string
{
if (!($Locale instanceof QUI\Locale)) {
$Locale = QUI::getLocale();
}
$Customer = $Order->getCustomer();
$message = $Locale->get('quiqqer/order', 'processing.status.notification.' . $this->id, [
'customerName' => $Customer->getName(),
'orderNo' => $Order->getPrefixedNumber(),
'orderDate' => $Locale->formatDate($Order->getCreateDate()),
'orderStatus' => $this->getTitle($Locale)
if (QUI::getLocale()->isLocaleString($message)) {
$message = $Locale->get('quiqqer/order', 'processing.status.notification.template', [
'customerName' => $Customer->getName(),
'orderNo' => $Order->getPrefixedNumber(),
'orderDate' => $Locale->formatDate($Order->getCreateDate()),
'orderStatus' => $this->getTitle($Locale)
/**
* Return the status color
*
* @return string
*/
/**
* Check if the customer has to be notified if this status is set to an order
*
* @return bool
*/
{
return $this->notification;
}
//endregion
/**
* Status as array
*
* @param null|QUI\Locale $Locale - optional. if no locale, all translations would be returned
* @return array
*/
public function toArray(null | QUI\Locale $Locale = null): array
{
$title = $this->getTitle($Locale);
$languages = QUI::availableLanguages();
foreach ($languages as $language) {
$title[$language] = $Locale->getByLang(
$language,
'quiqqer/order',
);
$statusChangeText[$language] = $Locale->getByLang(
$language,
'quiqqer/order',
'id' => $this->getId(),
'title' => $title,
'color' => $this->getColor(),
'notification' => $this->isAutoNotification(),
'statusChangeText' => $statusChangeText