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 "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user