order admin
This commit is contained in:
@@ -287,6 +287,19 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
/* @todo */
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderEvent $event
|
||||
*/
|
||||
public function updateStatus(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->setStatusId($event->getStatus());
|
||||
$order->save();
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
@@ -316,6 +329,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128),
|
||||
TheliaEvents::ORDER_PAY => array("create", 128),
|
||||
TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128),
|
||||
TheliaEvents::ORDER_UPDATE_STATUS => array("updateStatus", 128),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +198,10 @@
|
||||
</call>
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.type" class="Thelia\Core\Template\Smarty\Plugins\Type" scope="request">
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
</service>
|
||||
|
||||
<service id="smart.plugin.form" class="Thelia\Core\Template\Smarty\Plugins\Form" scope="request">
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@
|
||||
|
||||
<!-- end Customer rule management -->
|
||||
|
||||
<!-- Order rule management -->
|
||||
<!-- order management -->
|
||||
|
||||
<route id="admin.order" path="/admin/order">
|
||||
<route id="admin.order.list" path="/admin/orders">
|
||||
<default key="_controller">Thelia\Controller\Admin\OrderController::indexAction</default>
|
||||
</route>
|
||||
|
||||
@@ -70,7 +70,11 @@
|
||||
<requirement key="order_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end Customer rule management -->
|
||||
<route id="admin.order.update.status" path="/admin/order/update/status">
|
||||
<default key="_controller">Thelia\Controller\Admin\OrderController::updateStatus</default>
|
||||
</route>
|
||||
|
||||
<!-- end order management -->
|
||||
|
||||
<!-- Categories management -->
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ class CustomerController extends BaseAdminController
|
||||
$customer = CustomerQuery::create()->findPk($customer_id);
|
||||
|
||||
if(null === $customer) {
|
||||
throw new \InvalidArgumentException(sprintf("%d customer id does not exists", $customer_id));
|
||||
throw new \InvalidArgumentException(sprintf("%d customer id does not exist", $customer_id));
|
||||
}
|
||||
|
||||
$form = $this->validateForm($customerModification);
|
||||
@@ -127,7 +127,7 @@ class CustomerController extends BaseAdminController
|
||||
$customer = CustomerQuery::create()->findPk($customer_id);
|
||||
|
||||
if(null === $customer) {
|
||||
throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exists"));
|
||||
throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exist"));
|
||||
}
|
||||
|
||||
$event = new CustomerEvent($customer);
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
|
||||
/**
|
||||
* Class OrderController
|
||||
* @package Thelia\Controller\Admin
|
||||
@@ -44,4 +50,52 @@ class OrderController extends BaseAdminController
|
||||
));
|
||||
}
|
||||
|
||||
public function updateStatus()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
|
||||
|
||||
$message = null;
|
||||
|
||||
try {
|
||||
$orderId = $this->getRequest()->get("order_id");
|
||||
$order = OrderQuery::create()->findPk($orderId);
|
||||
|
||||
$statusId = $this->getRequest()->get("status_id");
|
||||
$status = OrderStatusQuery::create()->findPk($statusId);
|
||||
|
||||
if(null === $order) {
|
||||
throw new \InvalidArgumentException("The order you want to update status does not exist");
|
||||
}
|
||||
if(null === $status) {
|
||||
throw new \InvalidArgumentException("The status you want to set to the order does not exist");
|
||||
}
|
||||
|
||||
$event = new OrderEvent($order);
|
||||
$event->setStatus($statusId);
|
||||
|
||||
$this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);
|
||||
} catch(\Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
|
||||
if ($message) {
|
||||
$params["update_status_error_message"] = $message;
|
||||
}
|
||||
|
||||
$browsedPage = $this->getRequest()->get("order_page");
|
||||
|
||||
if($browsedPage) {
|
||||
$params["order_page"] = $browsedPage;
|
||||
$this->redirectToRoute("admin.order.list", $params);
|
||||
} else {
|
||||
$params["order_id"] = $orderId;
|
||||
$this->redirectToRoute("admin.order.update.view", $params);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ class OrderEvent extends ActionEvent
|
||||
protected $paymentModule = null;
|
||||
protected $postage = null;
|
||||
protected $ref = null;
|
||||
protected $status = null;
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
@@ -108,6 +109,14 @@ class OrderEvent extends ActionEvent
|
||||
$this->ref = $ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $status
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
@@ -171,4 +180,12 @@ class OrderEvent extends ActionEvent
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,9 +301,12 @@ final class TheliaEvents
|
||||
const ORDER_AFTER_CREATE = "action.order.afterCreate";
|
||||
const ORDER_BEFORE_PAYMENT = "action.order.beforePayment";
|
||||
|
||||
const ORDER_UPDATE_STATUS = "action.order.updateStatus";
|
||||
|
||||
const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate";
|
||||
const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate";
|
||||
|
||||
|
||||
/**
|
||||
* Sent on image processing
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,13 @@ class Order extends BaseLoop
|
||||
),
|
||||
'current'
|
||||
),
|
||||
Argument::createIntListTypeArgument('status'),
|
||||
new Argument(
|
||||
'status',
|
||||
new TypeCollection(
|
||||
new Type\IntListType(),
|
||||
new Type\EnumType(array('*'))
|
||||
)
|
||||
),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
@@ -98,7 +104,7 @@ class Order extends BaseLoop
|
||||
|
||||
$status = $this->getStatus();
|
||||
|
||||
if (null !== $status) {
|
||||
if (null !== $status && $status != '*') {
|
||||
$search->filterByStatusId($status, Criteria::IN);
|
||||
}
|
||||
|
||||
|
||||
63
core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php
Executable file
63
core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
class Type extends AbstractSmartyPlugin
|
||||
{
|
||||
public function assertTypeModifier($value, $option)
|
||||
{
|
||||
$typeClass = "\\Thelia\\Type\\$option";
|
||||
if(!class_exists($typeClass)) {
|
||||
throw new \InvalidArgumentException(sprintf("Invalid type name `%s` in `assertType` modifier", $option));
|
||||
}
|
||||
|
||||
$typeInstance = new $typeClass();
|
||||
if(!$typeInstance->isValid($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the various smarty plugins handled by this class
|
||||
*
|
||||
* @return an array of smarty plugin descriptors
|
||||
*/
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor('modifier', 'assertType', $this, 'assertTypeModifier'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,10 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
$this->template = $template_path_from_template_base;
|
||||
|
||||
$this->setTemplateDir(THELIA_TEMPLATE_DIR.$this->template);
|
||||
|
||||
$config_dir = THELIA_TEMPLATE_DIR.$this->template.'/configs';
|
||||
|
||||
$this->setConfigDir($config_dir);
|
||||
}
|
||||
|
||||
public function getTemplate()
|
||||
|
||||
Reference in New Issue
Block a user