Improved order management in back-office
This commit is contained in:
@@ -46,7 +46,11 @@ class OrderController extends BaseAdminController
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::ORDER, array(), AccessManager::VIEW)) return $response;
|
||||
return $this->render("orders", array("display_order" => 20));
|
||||
|
||||
return $this->render("orders", array(
|
||||
"display_order" => 20,
|
||||
"orders_order" => $this->getListOrderFromSession("orders", "orders_order", "create-date-reverse")
|
||||
));
|
||||
}
|
||||
|
||||
public function viewAction($order_id)
|
||||
|
||||
@@ -26,17 +26,20 @@ namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\SearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\Base\Customer;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
use Thelia\Model\Map\CustomerTableMap;
|
||||
use Thelia\Model\Map\OrderAddressTableMap;
|
||||
use Thelia\Model\OrderAddressQuery;
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\TypeCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Thelia\Core\Template\Loop
|
||||
@@ -72,7 +75,14 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('create-date', 'create-date-reverse'))
|
||||
new Type\EnumListType(array(
|
||||
'id', 'id-reverse',
|
||||
'reference', 'reference-reverse',
|
||||
'create-date', 'create-date-reverse',
|
||||
'company', 'company-reverse',
|
||||
'customer-name', 'customer-name-reverse',
|
||||
'status', 'status-reverse'
|
||||
))
|
||||
),
|
||||
'create-date-reverse'
|
||||
)
|
||||
@@ -165,12 +175,67 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt
|
||||
|
||||
foreach ($orderers as $orderer) {
|
||||
switch ($orderer) {
|
||||
case 'id':
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case 'id_reverse':
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
|
||||
case 'reference':
|
||||
$search->orderByRef(Criteria::ASC);
|
||||
break;
|
||||
case 'reference_reverse':
|
||||
$search->orderByRef(Criteria::DESC);
|
||||
break;
|
||||
|
||||
case "create-date":
|
||||
$search->orderByCreatedAt(Criteria::ASC);
|
||||
break;
|
||||
case "create-date-reverse":
|
||||
$search->orderByCreatedAt(Criteria::DESC);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
$search->orderByStatusId(Criteria::ASC);
|
||||
break;
|
||||
case "status":
|
||||
$search->orderByStatusId(Criteria::DESC);
|
||||
break;
|
||||
|
||||
case 'company' :
|
||||
$search
|
||||
->joinOrderAddressRelatedByDeliveryOrderAddressId()
|
||||
->withColumn(OrderAddressTableMap::COMPANY, 'company')
|
||||
->orderBy('company', Criteria::ASC)
|
||||
;
|
||||
break;
|
||||
case 'companyreverse' :
|
||||
$search
|
||||
->joinOrderAddressRelatedByDeliveryOrderAddressId()
|
||||
->withColumn(OrderAddressTableMap::COMPANY, 'company')
|
||||
->orderBy('company', Criteria::DESC)
|
||||
;
|
||||
break;
|
||||
|
||||
case 'customer-name' :
|
||||
$search
|
||||
->joinCustomer()
|
||||
->withColumn(CustomerTableMap::FIRSTNAME, 'firstname')
|
||||
->withColumn(CustomerTableMap::LASTNAME, 'lastname')
|
||||
->orderBy('lastname', Criteria::ASC)
|
||||
->orderBy('firstname', Criteria::ASC)
|
||||
;
|
||||
break;
|
||||
case 'customer-name-reverse' :
|
||||
$search
|
||||
->joinCustomer()
|
||||
->withColumn(CustomerTableMap::FIRSTNAME, 'firstname')
|
||||
->withColumn(CustomerTableMap::LASTNAME, 'lastname')
|
||||
->orderBy('lastname', Criteria::DESC)
|
||||
->orderBy('firstname', Criteria::DESC)
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\Smarty\Exception\SmartyPluginException;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Tools\DateTimeFormat;
|
||||
use Thelia\Tools\MoneyFormat;
|
||||
use Thelia\Tools\NumberFormat;
|
||||
|
||||
/**
|
||||
@@ -135,6 +136,40 @@ class Format extends AbstractSmartyPlugin
|
||||
$this->getParam($params, "thousands_sep", null)
|
||||
);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* display a amount in expected format
|
||||
*
|
||||
* available parameters :
|
||||
* number => int or float number
|
||||
* decimals => how many decimals format expected
|
||||
* dec_point => separator for the decimal point
|
||||
* thousands_sep => thousands separator
|
||||
* symbol => Currency symbol
|
||||
*
|
||||
* ex : {format_money number="1246.12" decimals="1" dec_point="," thousands_sep=" " symbol="€"} will output "1 246,1 €"
|
||||
*
|
||||
* @param $params
|
||||
* @param null $template
|
||||
* @throws \Thelia\Core\Template\Smarty\Exception\SmartyPluginException
|
||||
* @return string the expected number formatted
|
||||
*/
|
||||
public function formatMoney($params, $template = null)
|
||||
{
|
||||
$number = $this->getParam($params, "number", false);
|
||||
|
||||
if ($number === false || $number == '') {
|
||||
return "";
|
||||
}
|
||||
|
||||
return MoneyFormat::getInstance($this->request)->format(
|
||||
$number,
|
||||
$this->getParam($params, "decimals", null),
|
||||
$this->getParam($params, "dec_point", null),
|
||||
$this->getParam($params, "thousands_sep", null),
|
||||
$this->getParam($params, "symbol", null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an array of SmartyPluginDescriptor
|
||||
@@ -143,7 +178,8 @@ class Format extends AbstractSmartyPlugin
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor("function", "format_date", $this, "formatDate"),
|
||||
new SmartyPluginDescriptor("function", "format_number", $this, "formatNumber")
|
||||
);
|
||||
new SmartyPluginDescriptor("function", "format_number", $this, "formatNumber"),
|
||||
new SmartyPluginDescriptor("function", "format_money", $this, "formatMoney")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,9 @@ class Module extends AbstractSmartyPlugin
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($content))
|
||||
if (! empty($content)) {
|
||||
return $template->fetch(sprintf("string:%s", $content));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
</span>
|
||||
</p>
|
||||
|
||||
{ifloop rel="address"}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
@@ -212,6 +213,13 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{/ifloop}
|
||||
|
||||
{elseloop rel="address"}
|
||||
<div class="alert alert-info">
|
||||
{intl l="This customer has not defined any delivery address"}
|
||||
</div>
|
||||
{/elseloop}
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
@@ -28,22 +28,30 @@
|
||||
{loop type="order" name="the-order" id=$order_id customer="*"}
|
||||
|
||||
{loop type="currency" name="order-currency" id=$CURRENCY}
|
||||
{assign "orderCurrency" $SYMBOL}
|
||||
{$orderCurrency=$SYMBOL}
|
||||
{/loop}
|
||||
|
||||
{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">
|
||||
<div class="row">
|
||||
<div class="col-md-7 title">
|
||||
{intl l='Order %ref' ref=$REF}
|
||||
</div>
|
||||
|
||||
<div class="col-md-5 actions">
|
||||
<form class="form-horizontal" role="form" id="order-update-status-form" action="{url path="/admin/order/update/$ID/status"}" method="post">
|
||||
<input class="js-current-tab" type="hidden" name="tab" value="{$oder_tab}">
|
||||
<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>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-6 control-label">{intl l="Order status:"}</label>
|
||||
<div class="col-sm-6">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -59,16 +67,16 @@
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed table-left-aligned">
|
||||
<caption class="clearfix">
|
||||
{intl l='Cart'}
|
||||
{intl l='Cart - Prices in %currency' currency=$orderCurrency}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-md-7">{intl l="Product"}</th>
|
||||
<th class="col-md-1">{intl l="Unit. price"}</th>
|
||||
<th class="col-md-1">{intl l="Tax"}</th>
|
||||
<th class="col-md-1">{intl l="Unit taxed price"}</th>
|
||||
<th class="col-md-1">{intl l="Quantity"}</th>
|
||||
<th class="col-md-1">{intl l="Taxed total"}</th>
|
||||
<th class="col-md-1 text-right">{intl l="Unit. price"}</th>
|
||||
<th class="col-md-1 text-right">{intl l="Tax"}</th>
|
||||
<th class="col-md-1 text-right">{intl l="Unit taxed price"}</th>
|
||||
<th class="col-md-1 text-right">{intl l="Quantity"}</th>
|
||||
<th class="col-md-1 text-right">{intl l="Taxed total"}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -95,11 +103,11 @@
|
||||
</dl>
|
||||
{/ifloop}
|
||||
</td>
|
||||
<td>{$orderCurrency} {$realPrice}</td>
|
||||
<td>{$orderCurrency} {$realTax}</td>
|
||||
<td>{$orderCurrency} {$realTaxedPrice}</td>
|
||||
<td>{$QUANTITY}</td>
|
||||
<td>{$orderCurrency} {$realTaxedPrice * $QUANTITY}</td>
|
||||
<td class="text-right">{format_money number=$realPrice symbol=$orderCurrency}</td>
|
||||
<td class="text-right">{format_money number=$realTax symbol=$orderCurrency}</td>
|
||||
<td class="text-right">{format_money number=$realTaxedPrice symbol=$orderCurrency}</td>
|
||||
<td class="text-right">{$QUANTITY}</td>
|
||||
<td class="text-right">{format_money number=$realTaxedPrice * $QUANTITY symbol=$orderCurrency}</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
@@ -107,17 +115,17 @@
|
||||
<tr class="active">
|
||||
<td colspan="2" class="td-unstyled"></td>
|
||||
<td colspan="3"><strong>{intl l="Total without discount"}</strong></td>
|
||||
<td><strong>{$orderCurrency} {$TOTAL_TAXED_AMOUNT-$POSTAGE}</strong></td>
|
||||
<td class="text-right"><strong>{format_money number=$TOTAL_TAXED_AMOUNT-$POSTAGE symbol=$orderCurrency}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="td-unstyled"></td>
|
||||
<td colspan="3"><strong>{intl l="Discount"}</strong></td>
|
||||
<td><strong>{$orderCurrency} {$DISCOUNT}</strong></td>
|
||||
<td class="text-right"><strong>{format_money number=$DISCOUNT symbol=$orderCurrency}</strong></td>
|
||||
</tr>
|
||||
<tr class="active">
|
||||
<td colspan="2" class="td-unstyled"></td>
|
||||
<td colspan="3"><strong>{intl l="Coupon code"}</strong></td>
|
||||
<td>
|
||||
<td class="text-right">
|
||||
{loop type="order_coupon" name="couponcode" order=$ID}
|
||||
{$CODE}{if $LOOP_COUNT != $LOOP_TOTAL}, {/if}
|
||||
{/loop}
|
||||
@@ -129,17 +137,17 @@
|
||||
<tr>
|
||||
<td colspan="2" class="td-unstyled"></td>
|
||||
<td colspan="3"><strong>{intl l="Total including discount"}</strong></td>
|
||||
<td><strong>{$orderCurrency} {$TOTAL_TAXED_AMOUNT-$POSTAGE}</strong></td>
|
||||
<td class="text-right"><strong>{format_money number=$TOTAL_TAXED_AMOUNT-$POSTAGE symbol=$orderCurrency}</strong></td>
|
||||
</tr>
|
||||
<tr class="active">
|
||||
<td colspan="2" class="td-unstyled"></td>
|
||||
<td colspan="3"><strong>{intl l="Postage"}</strong></td>
|
||||
<td><strong>{$orderCurrency} {$POSTAGE}</strong></td>
|
||||
<td class="text-right"><strong>{format_money number=$POSTAGE symbol=$orderCurrency}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="td-unstyled"></td>
|
||||
<td colspan="3" class="last"><strong>{intl l="Total"}</strong></td>
|
||||
<td class="last"><strong>{$orderCurrency} {$TOTAL_TAXED_AMOUNT}</strong></td>
|
||||
<td class="last text-right"><strong>{format_money number=$TOTAL_TAXED_AMOUNT symbol=$orderCurrency}</strong></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -32,12 +32,57 @@
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{intl l="Order n°"}</th>
|
||||
<th>{intl l="Date & Hour"}</th>
|
||||
<th>{intl l="Company"}</th>
|
||||
<th>{intl l="Name"}</th>
|
||||
<th>{intl l="Amount"}</th>
|
||||
<th>{intl l="Status"}</th>
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$orders_order
|
||||
order='reference'
|
||||
reverse_order='reference-reverse'
|
||||
path={url path='/admin/orders'}
|
||||
request_parameter_name='orders_order'
|
||||
label="{intl l='Order #'}"
|
||||
} </th>
|
||||
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$orders_order
|
||||
order='create-date'
|
||||
reverse_order='create-date-reverse'
|
||||
path={url path='/admin/orders'}
|
||||
request_parameter_name='orders_order'
|
||||
label="{intl l='Date & Hour'}"
|
||||
} </th>
|
||||
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$orders_order
|
||||
order='company'
|
||||
reverse_order='company-reverse'
|
||||
path={url path='/admin/orders'}
|
||||
request_parameter_name='orders_order'
|
||||
label="{intl l='Company'}"
|
||||
} </th>
|
||||
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$orders_order
|
||||
order='customer-name'
|
||||
reverse_order='customer-name-reverse'
|
||||
path={url path='/admin/orders'}
|
||||
request_parameter_name='orders_order'
|
||||
label="{intl l='Cutomer Name'}"
|
||||
} </th>
|
||||
|
||||
<th class="object-title text-right">{intl l='Amount'}</th>
|
||||
|
||||
<th class="object-title text-center">
|
||||
{admin_sortable_header
|
||||
current_order=$orders_order
|
||||
order='status'
|
||||
reverse_order='status-reverse'
|
||||
path={url path='/admin/orders'}
|
||||
request_parameter_name='orders_order'
|
||||
label="{intl l='Status'}"
|
||||
} </th>
|
||||
|
||||
{module_include location='orders_table_header'}
|
||||
|
||||
@@ -47,7 +92,11 @@
|
||||
|
||||
<tbody>
|
||||
|
||||
{loop type="order" name="order-list" customer="*" backend_context="1" page={$order_page} limit={#max_displayed_orders#} status=$status_filter|default:'*'}
|
||||
{loop type="order" name="order-list" customer="*" order=$orders_order backend_context="1" page={$order_page} limit={#max_displayed_orders#} status=$status_filter|default:'*'}
|
||||
|
||||
{loop type="currency" name="order-currency" id=$CURRENCY}
|
||||
{$orderCurrency=$SYMBOL}
|
||||
{/loop}
|
||||
|
||||
{loop type="order_address" name="order-invoice-address" id=$INVOICE_ADDRESS}
|
||||
{assign "orderInvoiceFirstName" $FIRSTNAME}
|
||||
@@ -66,8 +115,8 @@
|
||||
<td>{format_date date=$CREATE_DATE}</td>
|
||||
<td>{$orderInvoiceCompany}</td>
|
||||
<td><a href="{url path='/admin/customer/update' customer_id=$CUSTOMER}">{$orderInvoiceFirstName|ucwords} {$orderInvoiceLastName|upper}</a></td>
|
||||
<td>{$TOTAL_TAXED_AMOUNT}</td>
|
||||
<td><span class="label label-{#$orderStatusLabel#}">{$orderStatus}</span></td>
|
||||
<td class="text-right">{format_money number=$TOTAL_TAXED_AMOUNT symbol=$orderCurrency}</td>
|
||||
<td class="text-center"><span class="label label-{#$orderStatusLabel#}">{$orderStatus}</span></td>
|
||||
|
||||
{module_include location='orders_table_row'}
|
||||
|
||||
@@ -94,14 +143,14 @@
|
||||
<div class="text-center">
|
||||
<ul class="pagination pagination-centered">
|
||||
{if $order_page != 1}
|
||||
<li><a href="{url path="/admin/orders" page="1"}">«</a></li>
|
||||
<li><a href="{url path="/admin/orders" page=1 orders_order=$orders_order}">«</a></li>
|
||||
{else}
|
||||
<li class="disabled"><a href="#">«</a></li>
|
||||
{/if}
|
||||
|
||||
{pageloop rel="order-list"}
|
||||
{if $PAGE != $CURRENT}
|
||||
<li><a href="{url path="/admin/orders" page=$PAGE}">{$PAGE}</a></li>
|
||||
<li><a href="{url path="/admin/orders" page=$PAGE orders_order=$orders_order}">{$PAGE}</a></li>
|
||||
|
||||
{else}
|
||||
<li class="active"><a href="#">{$PAGE}</a></li>
|
||||
@@ -110,7 +159,7 @@
|
||||
|
||||
{/pageloop}
|
||||
{if $PAGE == $LAST && $LAST != $CURRENT}
|
||||
<li><a href="{url path="/admin/orders" page="$PAGE"}">»</a></li>
|
||||
<li><a href="{url path="/admin/orders" page=$PAGE orders_order=$orders_order}">»</a></li>
|
||||
{else}
|
||||
<li class="disabled"><a href="#">»</a></li>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user