49 lines
1.7 KiB
PHP
49 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace OrderStatusNotify\Controller\Back;
|
|
|
|
use Thelia\Controller\Admin\BaseAdminController;
|
|
use OrderStatusNotify\Model\OrderStatusNotificationQuery;
|
|
use OrderStatusNotify\Model\OrderStatusNotification;
|
|
|
|
/**
|
|
* Class OrderStatusController
|
|
* @package OrderStatusNotify\Controller\Back
|
|
* @author Laurent LE CORRE <laurent@thecoredev.fr>
|
|
*/
|
|
class OrderStatusController extends BaseAdminController
|
|
{
|
|
public function showStatus()
|
|
{
|
|
$vars = '';
|
|
if (null !== $result = OrderStatusNotificationQuery::create()->findByToNotify(true)) {
|
|
foreach ($result->getData() as $order_status) {
|
|
// Il faut serialiser le tableau afin de pouvoir l'exploiter dans la page HTML.
|
|
$vars .= $order_status->getOrderStatusId() . ',';
|
|
}
|
|
}
|
|
return $this->render('display-order-status', ['status' => $vars]);
|
|
}
|
|
|
|
public function setToggleVisibilityAction()
|
|
{
|
|
try {
|
|
$order_status_to_modify = $_GET['order_status_id'];
|
|
$current_order_status = OrderStatusNotificationQuery::create()->findOneByOrderStatusId($order_status_to_modify);
|
|
if (null === $current_order_status) {
|
|
$new_order_status = new OrderStatusNotification();
|
|
$new_order_status->setOrderStatusId($order_status_to_modify);
|
|
$new_order_status->setToNotify(true);
|
|
$new_order_status->save();
|
|
}
|
|
else {
|
|
$current_order_status->delete();
|
|
}
|
|
} catch (\Exception $ex) {
|
|
// Any error
|
|
return $this->errorPage($ex);
|
|
}
|
|
|
|
return $this->nullResponse();
|
|
}
|
|
} |