diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php
index 3bc33fc99..6b47d8881 100755
--- a/core/lib/Thelia/Action/Order.php
+++ b/core/lib/Thelia/Action/Order.php
@@ -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),
);
}
diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml
index a05ace847..378650057 100755
--- a/core/lib/Thelia/Config/Resources/config.xml
+++ b/core/lib/Thelia/Config/Resources/config.xml
@@ -198,6 +198,10 @@
+
+
+
+
diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml
index 838bd6da8..001938b8a 100755
--- a/core/lib/Thelia/Config/Resources/routing/admin.xml
+++ b/core/lib/Thelia/Config/Resources/routing/admin.xml
@@ -59,9 +59,9 @@
-
+
-
+
Thelia\Controller\Admin\OrderController::indexAction
@@ -70,7 +70,11 @@
\d+
-
+
+ Thelia\Controller\Admin\OrderController::updateStatus
+
+
+
diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php
index 9209cb361..bc94fd7be 100644
--- a/core/lib/Thelia/Controller/Admin/CustomerController.php
+++ b/core/lib/Thelia/Controller/Admin/CustomerController.php
@@ -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);
diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php
index b2047cc31..c74e056d8 100644
--- a/core/lib/Thelia/Controller/Admin/OrderController.php
+++ b/core/lib/Thelia/Controller/Admin/OrderController.php
@@ -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);
+ }
+
+
+
+
+ }
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Core/Event/OrderEvent.php b/core/lib/Thelia/Core/Event/OrderEvent.php
index 7089141bb..03abe7cb7 100755
--- a/core/lib/Thelia/Core/Event/OrderEvent.php
+++ b/core/lib/Thelia/Core/Event/OrderEvent.php
@@ -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;
+ }
}
diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php
index ee49d239b..d20535a3f 100755
--- a/core/lib/Thelia/Core/Event/TheliaEvents.php
+++ b/core/lib/Thelia/Core/Event/TheliaEvents.php
@@ -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
*/
diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php
index 25e12fec8..5b1e97cc1 100755
--- a/core/lib/Thelia/Core/Template/Loop/Order.php
+++ b/core/lib/Thelia/Core/Template/Loop/Order.php
@@ -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);
}
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php
new file mode 100755
index 000000000..333a522ec
--- /dev/null
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php
@@ -0,0 +1,63 @@
+. */
+/* */
+/*************************************************************************************/
+
+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'),
+ );
+ }
+}
diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php
index d76dd8dfa..dc537bf70 100755
--- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php
+++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php
@@ -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()
diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl
index a223bfdb4..4c115431f 100644
--- a/templates/admin/default/admin-layout.tpl
+++ b/templates/admin/default/admin-layout.tpl
@@ -5,11 +5,7 @@
{/block}
{* -- Define some stuff for Smarty ----------------------------------------- *}
-{assign 'order-not-paid' 'warning'}
-{assign 'order-paid' 'success'}
-{assign 'order-processing' 'primary'}
-{assign 'order-sent' 'info'}
-{assign 'order-canceled' 'danger'}
+{config_load file='variables.conf'}
@@ -118,21 +114,25 @@
{/loop}
{loop name="menu-auth-order" type="auth" roles="ADMIN" permissions="admin.orders.view"}
-