order admin
This commit is contained in:
@@ -63,7 +63,6 @@ class Customer extends BaseLoop
|
||||
)
|
||||
),
|
||||
Argument::createBooleanTypeArgument('reseller'),
|
||||
Argument::createBooleanTypeArgument('last_order'),
|
||||
Argument::createIntTypeArgument('sponsor')
|
||||
);
|
||||
}
|
||||
@@ -130,20 +129,6 @@ class Customer extends BaseLoop
|
||||
$loopResultRow->set("SPONSOR", $customer->getSponsor());
|
||||
$loopResultRow->set("DISCOUNT", $customer->getDiscount());
|
||||
|
||||
$lastOrderDate = "";
|
||||
$lastOrderAmount = "";
|
||||
|
||||
if ($this->getLastOrder()) {
|
||||
$order = $customer->getOrders()->getFirst();
|
||||
if ($order) {
|
||||
$lastOrderDate = $order->getCreatedAt();
|
||||
$lastOrderAmount = $order->getTotalAmount();
|
||||
}
|
||||
}
|
||||
|
||||
$loopResultRow->set("LASTORDER_DATE", $lastOrderDate);
|
||||
$loopResultRow->set("LASTORDER_AMOUNT", $lastOrderAmount);
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\OrderAddressQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -54,29 +55,7 @@ class OrderAddress extends BaseLoop
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
new Argument(
|
||||
'id',
|
||||
new TypeCollection(
|
||||
new Type\IntListType(),
|
||||
new Type\EnumType(array('*', 'any'))
|
||||
)
|
||||
),
|
||||
new Argument(
|
||||
'customer',
|
||||
new TypeCollection(
|
||||
new Type\IntType(),
|
||||
new Type\EnumType(array('current'))
|
||||
),
|
||||
'current'
|
||||
),
|
||||
Argument::createBooleanOrBothTypeArgument('default'),
|
||||
new Argument(
|
||||
'exclude',
|
||||
new TypeCollection(
|
||||
new Type\IntListType(),
|
||||
new Type\EnumType(array('none'))
|
||||
)
|
||||
)
|
||||
Argument::createIntTypeArgument('id', null, true)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -91,60 +70,27 @@ class OrderAddress extends BaseLoop
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id && !in_array($id, array('*', 'any'))) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
$search->filterById($id, Criteria::IN);
|
||||
|
||||
$customer = $this->getCustomer();
|
||||
$orderAddresses = $this->search($search, $pagination);
|
||||
|
||||
if ($customer === 'current') {
|
||||
$currentCustomer = $this->securityContext->getCustomerUser();
|
||||
if ($currentCustomer === null) {
|
||||
return new LoopResult();
|
||||
} else {
|
||||
$search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL);
|
||||
}
|
||||
} else {
|
||||
$search->filterByCustomerId($customer, Criteria::EQUAL);
|
||||
}
|
||||
$loopResult = new LoopResult($orderAddresses);
|
||||
|
||||
$default = $this->getDefault();
|
||||
|
||||
if ($default === true) {
|
||||
$search->filterByIsDefault(1, Criteria::EQUAL);
|
||||
} else if($default === false) {
|
||||
$search->filterByIsDefault(0, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (null !== $exclude && 'none' !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$addresses = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($addresses);
|
||||
|
||||
foreach ($addresses as $address) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $address, $this->versionable, $this->timestampable, $this->countable);
|
||||
foreach ($orderAddresses as $orderAddress) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $orderAddress, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow
|
||||
->set("ID", $address->getId())
|
||||
->set("LABEL", $address->getLabel())
|
||||
->set("CUSTOMER", $address->getCustomerId())
|
||||
->set("TITLE", $address->getTitleId())
|
||||
->set("COMPANY", $address->getCompany())
|
||||
->set("FIRSTNAME", $address->getFirstname())
|
||||
->set("LASTNAME", $address->getLastname())
|
||||
->set("ADDRESS1", $address->getAddress1())
|
||||
->set("ADDRESS2", $address->getAddress2())
|
||||
->set("ADDRESS3", $address->getAddress3())
|
||||
->set("ZIPCODE", $address->getZipcode())
|
||||
->set("CITY", $address->getCity())
|
||||
->set("COUNTRY", $address->getCountryId())
|
||||
->set("PHONE", $address->getPhone())
|
||||
->set("CELLPHONE", $address->getCellphone())
|
||||
->set("DEFAULT", $address->getIsDefault())
|
||||
->set("ID", $orderAddress->getId())
|
||||
->set("TITLE", $orderAddress->getCustomerTitleId())
|
||||
->set("COMPANY", $orderAddress->getCompany())
|
||||
->set("FIRSTNAME", $orderAddress->getFirstname())
|
||||
->set("LASTNAME", $orderAddress->getLastname())
|
||||
->set("ADDRESS1", $orderAddress->getAddress1())
|
||||
->set("ADDRESS2", $orderAddress->getAddress2())
|
||||
->set("ADDRESS3", $orderAddress->getAddress3())
|
||||
->set("ZIPCODE", $orderAddress->getZipcode())
|
||||
->set("CITY", $orderAddress->getCity())
|
||||
->set("COUNTRY", $orderAddress->getCountryId())
|
||||
->set("PHONE", $orderAddress->getPhone())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
@@ -23,33 +23,77 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* OrderStatus loop
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*
|
||||
* Class OrderStatus
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderStatus extends BaseLoop
|
||||
class OrderStatus extends BaseI18nLoop
|
||||
{
|
||||
public function getArgDefinitions()
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
// TODO : a coder !
|
||||
return new LoopResult();
|
||||
$search = OrderStatusQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$orderStatusList = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($orderStatusList);
|
||||
|
||||
foreach ($orderStatusList as $orderStatus) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $orderStatus, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $orderStatus->getId())
|
||||
->set("IS_TRANSLATED",$orderStatus->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("CODE", $orderStatus->getCode())
|
||||
->set("TITLE", $orderStatus->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $orderStatus->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $orderStatus->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $orderStatus->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user