order admin
This commit is contained in:
@@ -300,6 +300,19 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderEvent $event
|
||||
*/
|
||||
public function updateDeliveryRef(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->setDeliveryRef($event->getDeliveryRef());
|
||||
$order->save();
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
@@ -330,6 +343,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
TheliaEvents::ORDER_PAY => array("create", 128),
|
||||
TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128),
|
||||
TheliaEvents::ORDER_UPDATE_STATUS => array("updateStatus", 128),
|
||||
TheliaEvents::ORDER_UPDATE_DELIVERY_REF => array("updateDeliveryRef", 128),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,10 +70,18 @@
|
||||
<requirement key="order_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.order.update.status" path="/admin/order/update/status">
|
||||
<route id="admin.order.list.update.status" path="/admin/order/update/status">
|
||||
<default key="_controller">Thelia\Controller\Admin\OrderController::updateStatus</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.order.update.status" path="/admin/order/update/{order_id}/status">
|
||||
<default key="_controller">Thelia\Controller\Admin\OrderController::updateStatus</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.order.update.deliveryRef" path="/admin/order/update/{order_id}/delivery-ref">
|
||||
<default key="_controller">Thelia\Controller\Admin\OrderController::updateDeliveryRef</default>
|
||||
</route>
|
||||
|
||||
<!-- end order management -->
|
||||
|
||||
<!-- Categories management -->
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class OrderController
|
||||
@@ -50,17 +51,22 @@ class OrderController extends BaseAdminController
|
||||
));
|
||||
}
|
||||
|
||||
public function updateStatus()
|
||||
public function updateStatus($order_id = null)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
|
||||
|
||||
$message = null;
|
||||
|
||||
try {
|
||||
$orderId = $this->getRequest()->get("order_id");
|
||||
$order = OrderQuery::create()->findPk($orderId);
|
||||
if($order_id !== null) {
|
||||
$order_id = $order_id;
|
||||
} else {
|
||||
$order_id = $this->getRequest()->get("order_id");
|
||||
}
|
||||
|
||||
$statusId = $this->getRequest()->get("status_id");
|
||||
$order = OrderQuery::create()->findPk($order_id);
|
||||
|
||||
$statusId = $this->getRequest()->request->get("status_id");
|
||||
$status = OrderStatusQuery::create()->findPk($statusId);
|
||||
|
||||
if(null === $order) {
|
||||
@@ -90,12 +96,42 @@ class OrderController extends BaseAdminController
|
||||
$params["order_page"] = $browsedPage;
|
||||
$this->redirectToRoute("admin.order.list", $params);
|
||||
} else {
|
||||
$params["order_id"] = $orderId;
|
||||
$this->redirectToRoute("admin.order.update.view", $params);
|
||||
$params["order_id"] = $order_id;
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params)));
|
||||
}
|
||||
}
|
||||
|
||||
public function updateDeliveryRef($order_id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
|
||||
|
||||
$message = null;
|
||||
|
||||
try {
|
||||
$order = OrderQuery::create()->findPk($order_id);
|
||||
|
||||
$deliveryRef = $this->getRequest()->get("delivery_ref");
|
||||
|
||||
if(null === $order) {
|
||||
throw new \InvalidArgumentException("The order you want to update status does not exist");
|
||||
}
|
||||
|
||||
$event = new OrderEvent($order);
|
||||
$event->setDeliveryRef($deliveryRef);
|
||||
|
||||
$this->dispatch(TheliaEvents::ORDER_UPDATE_DELIVERY_REF, $event);
|
||||
} catch(\Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
|
||||
if ($message) {
|
||||
$params["update_status_error_message"] = $message;
|
||||
}
|
||||
|
||||
$params["order_id"] = $order_id;
|
||||
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params)));
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ class OrderEvent extends ActionEvent
|
||||
protected $postage = null;
|
||||
protected $ref = null;
|
||||
protected $status = null;
|
||||
protected $deliveryRef = null;
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
@@ -117,6 +118,14 @@ class OrderEvent extends ActionEvent
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $deliveryRef
|
||||
*/
|
||||
public function setDeliveryRef($deliveryRef)
|
||||
{
|
||||
$this->deliveryRef = $deliveryRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
@@ -188,4 +197,12 @@ class OrderEvent extends ActionEvent
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getDeliveryRef()
|
||||
{
|
||||
return $this->deliveryRef;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +302,7 @@ final class TheliaEvents
|
||||
const ORDER_BEFORE_PAYMENT = "action.order.beforePayment";
|
||||
|
||||
const ORDER_UPDATE_STATUS = "action.order.updateStatus";
|
||||
const ORDER_UPDATE_DELIVERY_REF = "action.order.updateDeliveryRef";
|
||||
|
||||
const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate";
|
||||
const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate";
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="general-block-decorator">
|
||||
<div class="general-block-decorator">
|
||||
|
||||
{ifloop rel='the-order'}
|
||||
|
||||
@@ -29,18 +29,24 @@
|
||||
|
||||
{assign "orderStatusId" $STATUS}
|
||||
|
||||
<div class="lead clearfix">
|
||||
<span class='label label-default pull-left'>{$REF}</span>
|
||||
<div class="pull-right select-fixed-width">
|
||||
<form id="order-update-status-form" action="{url path="/admin/order/update/$ID/status"}" method="post">
|
||||
<select class="js-update-order-status" name="status_id" data-toggle="selectpicker">
|
||||
{loop type="order-status" name="all-status"}
|
||||
{assign "orderStatusLabel" "order_$CODE"}
|
||||
<option {if $ID == $orderStatusId}selected="selected" {/if} value="{$ID}" data-content="<span class='label label-{#$orderStatusLabel#}'>{$TITLE}</span>">{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="nav nav-tabs clearfix">
|
||||
<li class="active"><a href="#cart" data-toggle="tab"><span class="glyphicon glyphicon-shopping-cart"></span> {intl l="Ordered products"}</a></li>
|
||||
<li><a href="#bill" data-toggle="tab"><span class="glyphicon glyphicon-list-alt"></span> {intl l="Invoice and Delivery"}</a></li>
|
||||
<li><a href="#supplements" data-toggle="tab"><span class="glyphicon glyphicon-info-sign"></span> {intl l="Further information"}</a></li>
|
||||
<li class="pull-right select-fixed-width">
|
||||
<select name="order-status" data-toggle="selectpicker">
|
||||
{loop type="order-status" name="all-status"}
|
||||
{assign "orderStatusLabel" "order_$CODE"}
|
||||
<option {if $ID == $orderStatusId}selected="selected" {/if} value="{$ID}" data-content="<span class='label label-{#$orderStatusLabel#}'>{$TITLE}</span>">{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
@@ -149,9 +155,19 @@
|
||||
|
||||
<div class="tab-pane fade clearfix" id="bill">
|
||||
|
||||
<p class="title title-without-tabs">
|
||||
<div class="title title-without-tabs clearfix">
|
||||
{intl l='Delivery module'}
|
||||
</p>
|
||||
<div class="pull-right col-md-3">
|
||||
<form action="{url path="/admin/order/update/$ID/delivery-ref"}" method="post">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" name="delivery_ref" value="{$DELIVERY_REF}" placeholder="{intl l="tracking reference"}"/>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span></button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loop name="payment-module" type="module" id=$DELIVERY_MODULE}
|
||||
|
||||
@@ -173,7 +189,7 @@
|
||||
{intl l='Invoice informations'}
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-default btn-primary" title="{intl l='Download invoice as PDF'}" href="#">
|
||||
<span class="glyphicon glyphicon-cloud-download"></span> {intl l='PDF invoice'}
|
||||
<span class="glyphicon glyphicon-cloud-download"></span> {intl l='PDF | Invoice'}
|
||||
</a>
|
||||
<a class="btn btn-default btn-primary" title="{intl l='Edit invoice address'}" href="#edit_address_dialog" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-edit"></span>
|
||||
@@ -248,7 +264,7 @@
|
||||
{intl l='Delivery address'}
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-default btn-primary" title="{intl l='Download purchase order as PDF'}" href="#">
|
||||
<span class="glyphicon glyphicon-cloud-download"></span> {intl l='PDF purchase order'}
|
||||
<span class="glyphicon glyphicon-cloud-download"></span> {intl l='PDF | Purchase order'}
|
||||
</a>
|
||||
<a class="btn btn-default btn-primary" title="{intl l='Edit delivery address'}" href="#edit_address_dialog" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-edit"></span>
|
||||
@@ -311,56 +327,6 @@
|
||||
|
||||
</div> <!-- #bill -->
|
||||
|
||||
<div class="tab-pane fade clearfix" id="supplements">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed table-left-aligned">
|
||||
<caption>
|
||||
{intl l='Further information'}
|
||||
</caption>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><label for="">{intl l='Status'}</label></th>
|
||||
<td>
|
||||
<form action="" method="">
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
<select name="" id="" class="form-control">
|
||||
<option value="">Status 1</option>
|
||||
<option value="">Status 2</option>
|
||||
<option value="">Status 3</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="">{intl l='Order Tracking'}</label></th>
|
||||
<td>
|
||||
<form action="" method="">
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
<input type="text" id="" name="" class="form-control" value="" title="" placeholder="">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span></button>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{intl l='Bill'}</th>
|
||||
<td><a href="#" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-cloud-download"></span> {intl l='Download bill to pdf'}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{intl l='Delivery'}</th>
|
||||
<td><a href="#" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-cloud-download"></span> {intl l='Download delivery to pdf'}</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div> <!-- #supplements -->
|
||||
|
||||
</div>
|
||||
{/loop}
|
||||
|
||||
@@ -502,4 +468,11 @@
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(".js-update-order-status").change(function(e){
|
||||
e.preventDefault();
|
||||
$('#order-update-status-form').submit();
|
||||
});
|
||||
</script>
|
||||
|
||||
{/block}
|
||||
Reference in New Issue
Block a user