Rajout du module de gestion des avoirs
This commit is contained in:
270
local/modules/CreditNote/Loop/CreditNote.php
Normal file
270
local/modules/CreditNote/Loop/CreditNote.php
Normal file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the module CreditNote */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace CreditNote\Loop;
|
||||
|
||||
use CreditNote\Model\CreditNoteQuery;
|
||||
use CreditNote\Model\CreditNote as CreditNoteModel;
|
||||
use CreditNote\Model\Map\CreditNoteStatusI18nTableMap;
|
||||
use CreditNote\Model\Map\CreditNoteStatusTableMap;
|
||||
use CreditNote\Model\Map\CreditNoteTypeI18nTableMap;
|
||||
use CreditNote\Model\Map\CreditNoteTypeTableMap;
|
||||
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\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\Map\CustomerTableMap;
|
||||
use Thelia\Model\Map\OrderTableMap;
|
||||
|
||||
/**
|
||||
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
|
||||
*
|
||||
* @method string[] getRef()
|
||||
* @method string[] getInvoiceRef()
|
||||
* @method int[] getId()
|
||||
* @method int[] getStatusId()
|
||||
* @method int[] getOrderProductId()
|
||||
* @method int[] getTypeId()
|
||||
* @method int[] getOrderId()
|
||||
* @method int[] getCustomerId()
|
||||
* @method int[] getParentId()
|
||||
* @method string[] getOrder()
|
||||
* @method boolean|string getUsed()
|
||||
* @method boolean|string getInvoiced()
|
||||
*/
|
||||
class CreditNote extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
protected $timestampable = true;
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createAnyListTypeArgument('ref'),
|
||||
Argument::createAnyListTypeArgument('invoice_ref'),
|
||||
Argument::createIntListTypeArgument("id"),
|
||||
Argument::createAnyListTypeArgument("status_id"),
|
||||
Argument::createAnyListTypeArgument("order_product_id"),
|
||||
Argument::createAnyListTypeArgument("type_id"),
|
||||
Argument::createIntListTypeArgument("order_id"),
|
||||
Argument::createIntListTypeArgument("customer_id"),
|
||||
Argument::createIntListTypeArgument("parent_id"),
|
||||
Argument::createBooleanOrBothTypeArgument("used"),
|
||||
Argument::createBooleanOrBothTypeArgument("invoiced"),
|
||||
Argument::createEnumListTypeArgument(
|
||||
"order",
|
||||
[
|
||||
"id", "id-reverse",
|
||||
"create-date", "create-date-reverse",
|
||||
"status", "status-reverse",
|
||||
'update-date', 'update-date-reverse',
|
||||
],
|
||||
"id"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$query = new CreditNoteQuery();
|
||||
|
||||
if (null !== $id = $this->getId()) {
|
||||
$query->filterById($id);
|
||||
}
|
||||
|
||||
if (null !== $invoiceRef = $this->getInvoiceRef()) {
|
||||
$query->filterByInvoiceRef($invoiceRef);
|
||||
}
|
||||
|
||||
if (null !== $ref = $this->getRef()) {
|
||||
$query->filterByRef($ref);
|
||||
}
|
||||
|
||||
if (null !== $type = $this->getTypeId()) {
|
||||
$query->FilterByTypeId($type);
|
||||
}
|
||||
|
||||
if (null !== $status = $this->getStatusId()) {
|
||||
$query->filterByStatusId($status);
|
||||
}
|
||||
|
||||
if (null !== $orderProduct = $this->getOrderProductId()) {
|
||||
$query->useCreditNoteDetailQuery()
|
||||
->filterByOrderProductId($orderProduct)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
if (null !== $order = $this->getOrderId()) {
|
||||
$query->filterByOrderId($order);
|
||||
}
|
||||
|
||||
if (null !== $parent = $this->getParentId()) {
|
||||
$query->filterByParentId($parent);
|
||||
}
|
||||
|
||||
if (null !== $customer = $this->getCustomerId()) {
|
||||
$query->filterByCustomerId($customer);
|
||||
}
|
||||
|
||||
if (is_bool($this->getUsed())) {
|
||||
$query->useCreditNoteStatusQuery()
|
||||
->filterByUsed($this->getUsed())
|
||||
->endUse();
|
||||
}
|
||||
|
||||
if (is_bool($this->getInvoiced())) {
|
||||
$query->useCreditNoteStatusQuery()
|
||||
->filterByInvoiced($this->getInvoiced())
|
||||
->endUse();
|
||||
}
|
||||
|
||||
$this->addJoin($query);
|
||||
|
||||
$this->addVirtualColumn($query);
|
||||
|
||||
$this->buildModelCriteriaOrder($query);
|
||||
|
||||
$query->groupById();
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteQuery $query
|
||||
*/
|
||||
protected function buildModelCriteriaOrder($query)
|
||||
{
|
||||
foreach ($this->getOrder() as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$query->orderById();
|
||||
break;
|
||||
case "id-reverse":
|
||||
$query->orderById(Criteria::DESC);
|
||||
break;
|
||||
case 'create-date':
|
||||
$query->orderByCreatedAt(Criteria::ASC);
|
||||
break;
|
||||
case 'create-date-reverse':
|
||||
$query->orderByCreatedAt(Criteria::DESC);
|
||||
break;
|
||||
case 'status':
|
||||
$query->orderByStatusId(Criteria::ASC);
|
||||
break;
|
||||
case 'status-reverse':
|
||||
$query->orderByStatusId(Criteria::DESC);
|
||||
break;
|
||||
case 'update-date':
|
||||
$query->orderByUpdatedAt(Criteria::ASC);
|
||||
break;
|
||||
case 'update-date-reverse':
|
||||
$query->orderByUpdatedAt(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteQuery $query
|
||||
*/
|
||||
protected function addJoin($query)
|
||||
{
|
||||
$query->useCustomerQuery()
|
||||
->endUse();
|
||||
|
||||
$query->useOrderQuery()
|
||||
->endUse();
|
||||
|
||||
$query->useCreditNoteTypeQuery()
|
||||
->leftJoinCreditNoteTypeI18n(CreditNoteTypeI18nTableMap::TABLE_NAME)
|
||||
->endUse();
|
||||
|
||||
$query->addJoinCondition(CreditNoteTypeI18nTableMap::TABLE_NAME, CreditNoteTypeI18nTableMap::LOCALE . '=?', $this->getLocale());
|
||||
|
||||
$query->useCreditNoteStatusQuery()
|
||||
->leftJoinCreditNoteStatusI18n(CreditNoteStatusI18nTableMap::TABLE_NAME)
|
||||
->endUse();
|
||||
|
||||
$query->addJoinCondition(CreditNoteStatusI18nTableMap::TABLE_NAME, CreditNoteStatusI18nTableMap::LOCALE . '=?', $this->getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteQuery $query
|
||||
*/
|
||||
protected function addVirtualColumn($query)
|
||||
{
|
||||
$query
|
||||
->withColumn('CONCAT_WS(" ",' . CustomerTableMap::FIRSTNAME . ',' . CustomerTableMap::LASTNAME .')', 'CUSTOMER_NAME')
|
||||
->withColumn(OrderTableMap::REF, 'ORDER_REF')
|
||||
->withColumn(CreditNoteStatusI18nTableMap::TITLE, 'STATUS_TITLE')
|
||||
->withColumn(CreditNoteStatusTableMap::COLOR, 'STATUS_COLOR')
|
||||
->withColumn(CreditNoteTypeI18nTableMap::TITLE, 'TYPE_TITLE')
|
||||
->withColumn(CreditNoteTypeTableMap::COLOR, 'TYPE_COLOR');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var CreditNoteModel $entry */
|
||||
foreach ($loopResult->getResultDataCollection() as $entry) {
|
||||
$row = new LoopResultRow($entry);
|
||||
$row
|
||||
->set("ID", $entry->getId())
|
||||
->set("REF", $entry->getRef())
|
||||
->set("INVOICE_REF", $entry->getInvoiceRef())
|
||||
->set("INVOICE_DATE", $entry->getInvoiceDate())
|
||||
->set("TYPE_ID", $entry->getTypeId())
|
||||
->set("STATUS_ID", $entry->getStatusId())
|
||||
->set("ORDER_ID", $entry->getOrderId())
|
||||
->set("PARENT_ID", $entry->getParentId())
|
||||
->set("CUSTOMER_ID", $entry->getCustomerId())
|
||||
->set('CURRENCY_ID', $entry->getCurrencyId())
|
||||
->set("TOTAL_PRICE", $entry->getTotalPrice())
|
||||
->set("TOTAL_PRICE_WITH_TAX", $entry->getTotalPriceWithTax())
|
||||
|
||||
->set("DISCOUNT_WITHOUT_TAX", $entry->getDiscountWithoutTax())
|
||||
->set("DISCOUNT_WITH_TAX", $entry->getDiscountWithTax())
|
||||
|
||||
->set('CUSTOMER_NAME', $entry->getVirtualColumn('CUSTOMER_NAME'))
|
||||
->set('ORDER_REF', $entry->getVirtualColumn('ORDER_REF'))
|
||||
|
||||
->set('STATUS_TITLE', $entry->getVirtualColumn('STATUS_TITLE'))
|
||||
->set('STATUS_COLOR', $entry->getVirtualColumn('STATUS_COLOR'))
|
||||
->set('TYPE_TITLE', $entry->getVirtualColumn('TYPE_TITLE'))
|
||||
->set('TYPE_COLOR', $entry->getVirtualColumn('TYPE_COLOR'))
|
||||
;
|
||||
$this->addOutputFields($row, $entry);
|
||||
$loopResult->addRow($row);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getLocale()
|
||||
{
|
||||
if ($this->request->fromAdmin()) {
|
||||
return $this->request->getSession()->getAdminUser()->getLocale();
|
||||
} else {
|
||||
return $this->request->getSession()->getLang()->getLocale();
|
||||
}
|
||||
}
|
||||
}
|
||||
76
local/modules/CreditNote/Loop/CreditNoteAddress.php
Normal file
76
local/modules/CreditNote/Loop/CreditNoteAddress.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the module CreditNote */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace CreditNote\Loop;
|
||||
|
||||
use CreditNote\Model\CreditNoteAddressQuery;
|
||||
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\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
/**
|
||||
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
|
||||
*/
|
||||
class CreditNoteAddress extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('id', null, true)
|
||||
);
|
||||
}
|
||||
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = CreditNoteAddressQuery::create();
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
$search->filterById($id, Criteria::IN);
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \CreditNote\Model\CreditNoteAddress $creditNoteAddress */
|
||||
foreach ($loopResult->getResultDataCollection() as $creditNoteAddress) {
|
||||
$loopResultRow = new LoopResultRow($creditNoteAddress);
|
||||
$loopResultRow
|
||||
->set("ID", $creditNoteAddress->getId())
|
||||
->set("TITLE", $creditNoteAddress->getCustomerTitleId())
|
||||
->set("COMPANY", $creditNoteAddress->getCompany())
|
||||
->set("FIRSTNAME", $creditNoteAddress->getFirstname())
|
||||
->set("LASTNAME", $creditNoteAddress->getLastname())
|
||||
->set("ADDRESS1", $creditNoteAddress->getAddress1())
|
||||
->set("ADDRESS2", $creditNoteAddress->getAddress2())
|
||||
->set("ADDRESS3", $creditNoteAddress->getAddress3())
|
||||
->set("ZIPCODE", $creditNoteAddress->getZipcode())
|
||||
->set("CITY", $creditNoteAddress->getCity())
|
||||
->set("COUNTRY", $creditNoteAddress->getCountryId())
|
||||
->set("STATE", $creditNoteAddress->getStateId())
|
||||
->set("PHONE", $creditNoteAddress->getPhone())
|
||||
->set("CELLPHONE", $creditNoteAddress->getCellphone())
|
||||
;
|
||||
$this->addOutputFields($loopResultRow, $creditNoteAddress);
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
126
local/modules/CreditNote/Loop/CreditNoteComment.php
Normal file
126
local/modules/CreditNote/Loop/CreditNoteComment.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the module CreditNote */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace CreditNote\Loop;
|
||||
|
||||
use CreditNote\Model\CreditNoteCommentQuery;
|
||||
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\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\Map\AdminTableMap;
|
||||
|
||||
/**
|
||||
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
|
||||
*
|
||||
* @method string[] getCode()
|
||||
* @method int[] getId()
|
||||
* @method int[] getCreditNoteId()
|
||||
* @method string[] getOrder()
|
||||
*/
|
||||
class CreditNoteComment extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
protected $timestampable = true;
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument("id"),
|
||||
Argument::createIntListTypeArgument("credit_note_id"),
|
||||
Argument::createEnumListTypeArgument(
|
||||
"order",
|
||||
[
|
||||
"id", "id-reverse",
|
||||
"create-date", "create-date-reverse"
|
||||
],
|
||||
"create-date"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$query = new CreditNoteCommentQuery();
|
||||
|
||||
if (null !== $id = $this->getId()) {
|
||||
$query->filterById($id);
|
||||
}
|
||||
|
||||
if (null !== $creditNoteId = $this->getCreditNoteId()) {
|
||||
$query->filterByCreditNoteId($creditNoteId);
|
||||
}
|
||||
|
||||
$query->useAdminQuery()
|
||||
->endUse();
|
||||
|
||||
$query->withColumn(AdminTableMap::LOGIN, 'ADMIN_LOGIN');
|
||||
$query->withColumn(AdminTableMap::FIRSTNAME, 'ADMIN_FIRST_NAME');
|
||||
$query->withColumn(AdminTableMap::LASTNAME, 'ADMIN_LAST_NAME');
|
||||
|
||||
$this->buildModelCriteriaOrder($query);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteCommentQuery $query
|
||||
*/
|
||||
protected function buildModelCriteriaOrder($query)
|
||||
{
|
||||
foreach ($this->getOrder() as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$query->orderById();
|
||||
break;
|
||||
case "id-reverse":
|
||||
$query->orderById(Criteria::DESC);
|
||||
break;
|
||||
case 'create-date':
|
||||
$query->orderByCreatedAt(Criteria::ASC);
|
||||
break;
|
||||
case 'create-date-reverse':
|
||||
$query->orderByCreatedAt(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \CreditNote\Model\CreditNoteComment $entry */
|
||||
foreach ($loopResult->getResultDataCollection() as $entry) {
|
||||
$row = new LoopResultRow($entry);
|
||||
$row
|
||||
->set("ID", $entry->getId())
|
||||
->set("CREDIT_NOTE_ID", $entry->getCreditNoteId())
|
||||
->set("ADMIN_ID", $entry->getAdminId())
|
||||
->set("ADMIN_LOGIN", $entry->getVirtualColumn('ADMIN_LOGIN'))
|
||||
->set("ADMIN_FIRST_NAME", $entry->getVirtualColumn('ADMIN_FIRST_NAME'))
|
||||
->set("ADMIN_LAST_NAME", $entry->getVirtualColumn('ADMIN_LAST_NAME'))
|
||||
->set("COMMENT", $entry->getComment())
|
||||
;
|
||||
$this->addOutputFields($row, $entry);
|
||||
$loopResult->addRow($row);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
112
local/modules/CreditNote/Loop/CreditNoteDetail.php
Normal file
112
local/modules/CreditNote/Loop/CreditNoteDetail.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the module CreditNote */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace CreditNote\Loop;
|
||||
|
||||
use CreditNote\Model\CreditNoteDetailQuery;
|
||||
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\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
/**
|
||||
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
|
||||
*
|
||||
* @method int[] getId()
|
||||
* @method int[] getCreditNoteId()
|
||||
* @method string[] getOrder()
|
||||
*/
|
||||
class CreditNoteDetail extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
protected $timestampable = true;
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument("id"),
|
||||
Argument::createIntListTypeArgument("credit_note_id"),
|
||||
Argument::createEnumListTypeArgument(
|
||||
"order",
|
||||
[
|
||||
"id", "id-reverse"
|
||||
],
|
||||
"id"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$query = new CreditNoteDetailQuery();
|
||||
|
||||
if (null !== $id = $this->getId()) {
|
||||
$query->filterById($id);
|
||||
}
|
||||
|
||||
if (null !== $creditNoteId = $this->getCreditNoteId()) {
|
||||
$query->filterByCreditNoteId($creditNoteId);
|
||||
}
|
||||
|
||||
$this->buildModelCriteriaOrder($query);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteDetailQuery $query
|
||||
*/
|
||||
protected function buildModelCriteriaOrder($query)
|
||||
{
|
||||
foreach ($this->getOrder() as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$query->orderById();
|
||||
break;
|
||||
case "id-reverse":
|
||||
$query->orderById(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \CreditNote\Model\CreditNoteDetail $entry */
|
||||
foreach ($loopResult->getResultDataCollection() as $entry) {
|
||||
$row = new LoopResultRow($entry);
|
||||
$row
|
||||
->set("ID", $entry->getId())
|
||||
->set("CREDIT_NOTE_ID", $entry->getCreditNoteId())
|
||||
->set("PRICE", $entry->getPrice())
|
||||
->set("PRICE_WITH_TAX", $entry->getPriceWithTax())
|
||||
->set("TAX_RULE_ID", $entry->getTaxRuleId())
|
||||
->set("ORDER_PRODUCT_ID", $entry->getOrderProductId())
|
||||
->set("TYPE", $entry->getType())
|
||||
->set("QUANTITY", $entry->getQuantity())
|
||||
->set("TITLE", $entry->getTitle())
|
||||
;
|
||||
$this->addOutputFields($row, $entry);
|
||||
$loopResult->addRow($row);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
168
local/modules/CreditNote/Loop/CreditNoteStatus.php
Normal file
168
local/modules/CreditNote/Loop/CreditNoteStatus.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the module CreditNote */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace CreditNote\Loop;
|
||||
|
||||
use CreditNote\Model\CreditNoteStatusFlowQuery;
|
||||
use CreditNote\Model\CreditNoteStatusQuery;
|
||||
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\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
|
||||
*
|
||||
* @method string[] getCode()
|
||||
* @method int[] getId()
|
||||
* @method int[] getPosition()
|
||||
* @method int[] getCurrentStatusId()
|
||||
* @method string[] getOrder()
|
||||
* @method string|bool getInvoiced()
|
||||
* @method string|bool getUsed()
|
||||
*/
|
||||
class CreditNoteStatus extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
protected $timestampable = true;
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createAnyListTypeArgument('code'),
|
||||
Argument::createIntListTypeArgument("id"),
|
||||
Argument::createIntListTypeArgument("position"),
|
||||
Argument::createBooleanOrBothTypeArgument("invoiced", BooleanOrBothType::ANY),
|
||||
Argument::createBooleanOrBothTypeArgument("used", BooleanOrBothType::ANY),
|
||||
Argument::createIntListTypeArgument("current_status_id"),
|
||||
Argument::createEnumListTypeArgument(
|
||||
"order",
|
||||
[
|
||||
"id", "id-reverse",
|
||||
"create-date", "create-date-reverse",
|
||||
"code", "code-reverse",
|
||||
"position", "position-reverse"
|
||||
],
|
||||
"position"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$query = new CreditNoteStatusQuery();
|
||||
|
||||
if (null !== $id = $this->getId()) {
|
||||
$query->filterById($id);
|
||||
}
|
||||
|
||||
if (null !== $code = $this->getCode()) {
|
||||
$query->filterByCode($code);
|
||||
}
|
||||
|
||||
if (null !== $position = $this->getPosition()) {
|
||||
$query->filterByPosition($position);
|
||||
}
|
||||
|
||||
if (BooleanOrBothType::ANY !== $used = $this->getUsed()) {
|
||||
$query->filterByUsed($used);
|
||||
}
|
||||
|
||||
if (BooleanOrBothType::ANY !== $invoiced = $this->getInvoiced()) {
|
||||
$query->filterByInvoiced($invoiced);
|
||||
}
|
||||
|
||||
if (null !== $currentStatusId = $this->getCurrentStatusId()) {
|
||||
$flowIds = CreditNoteStatusFlowQuery::create()
|
||||
->filterByFromStatusId($currentStatusId)
|
||||
->find()->toArray('toStatusId');
|
||||
|
||||
$flowIds = array_keys($flowIds);
|
||||
|
||||
$query->filterById(array_merge($flowIds, $currentStatusId));
|
||||
}
|
||||
|
||||
$this->configureI18nProcessing($query, ['TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM']);
|
||||
|
||||
$this->buildModelCriteriaOrder($query);
|
||||
|
||||
$query->groupById();
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteStatusQuery $query
|
||||
*/
|
||||
protected function buildModelCriteriaOrder($query)
|
||||
{
|
||||
foreach ($this->getOrder() as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$query->orderById();
|
||||
break;
|
||||
case "id-reverse":
|
||||
$query->orderById(Criteria::DESC);
|
||||
break;
|
||||
case 'create-date':
|
||||
$query->orderByCreatedAt(Criteria::ASC);
|
||||
break;
|
||||
case 'create-date-reverse':
|
||||
$query->orderByCreatedAt(Criteria::DESC);
|
||||
break;
|
||||
case 'code':
|
||||
$query->orderByCode(Criteria::ASC);
|
||||
break;
|
||||
case 'code-reverse':
|
||||
$query->orderByCode(Criteria::DESC);
|
||||
break;
|
||||
case 'position':
|
||||
$query->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case 'position-reverse':
|
||||
$query->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \CreditNote\Model\CreditNoteStatus $entry */
|
||||
foreach ($loopResult->getResultDataCollection() as $entry) {
|
||||
$row = new LoopResultRow($entry);
|
||||
$row
|
||||
->set("ID", $entry->getId())
|
||||
->set("CODE", $entry->getCode())
|
||||
->set("COLOR", $entry->getColor())
|
||||
->set("POSITION", $entry->getPosition())
|
||||
->set("TITLE", $entry->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $entry->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $entry->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $entry->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
$this->addOutputFields($row, $entry);
|
||||
$loopResult->addRow($row);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
140
local/modules/CreditNote/Loop/CreditNoteType.php
Normal file
140
local/modules/CreditNote/Loop/CreditNoteType.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the module CreditNote */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace CreditNote\Loop;
|
||||
|
||||
use CreditNote\Model\CreditNoteTypeQuery;
|
||||
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\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
/**
|
||||
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
|
||||
*
|
||||
* @method string[] getCode()
|
||||
* @method int[] getId()
|
||||
* @method int[] getPosition()
|
||||
* @method string[] getOrder()
|
||||
*/
|
||||
class CreditNoteType extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
protected $timestampable = true;
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createAnyListTypeArgument('code'),
|
||||
Argument::createIntListTypeArgument("id"),
|
||||
Argument::createIntListTypeArgument("position"),
|
||||
Argument::createEnumListTypeArgument(
|
||||
"order",
|
||||
[
|
||||
"id", "id-reverse",
|
||||
"create-date", "create-date-reverse",
|
||||
"code", "code-reverse",
|
||||
"position", "position-reverse"
|
||||
],
|
||||
"position"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$query = new CreditNoteTypeQuery();
|
||||
|
||||
if (null !== $id = $this->getId()) {
|
||||
$query->filterById($id);
|
||||
}
|
||||
|
||||
if (null !== $code = $this->getCode()) {
|
||||
$query->filterByCode($code);
|
||||
}
|
||||
|
||||
if (null !== $position = $this->getPosition()) {
|
||||
$query->filterByPosition($position);
|
||||
}
|
||||
|
||||
$this->configureI18nProcessing($query, ['TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM']);
|
||||
|
||||
$this->buildModelCriteriaOrder($query);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteTypeQuery $query
|
||||
*/
|
||||
protected function buildModelCriteriaOrder($query)
|
||||
{
|
||||
foreach ($this->getOrder() as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$query->orderById();
|
||||
break;
|
||||
case "id-reverse":
|
||||
$query->orderById(Criteria::DESC);
|
||||
break;
|
||||
case 'create-date':
|
||||
$query->orderByCreatedAt(Criteria::ASC);
|
||||
break;
|
||||
case 'create-date-reverse':
|
||||
$query->orderByCreatedAt(Criteria::DESC);
|
||||
break;
|
||||
case 'code':
|
||||
$query->orderByCode(Criteria::ASC);
|
||||
break;
|
||||
case 'code-reverse':
|
||||
$query->orderByCode(Criteria::DESC);
|
||||
break;
|
||||
case 'position':
|
||||
$query->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case 'position-reverse':
|
||||
$query->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \CreditNote\Model\CreditNoteType $entry */
|
||||
foreach ($loopResult->getResultDataCollection() as $entry) {
|
||||
$row = new LoopResultRow($entry);
|
||||
$row
|
||||
->set("ID", $entry->getId())
|
||||
->set("CODE", $entry->getCode())
|
||||
->set("COLOR", $entry->getColor())
|
||||
->set("POSITION", $entry->getPosition())
|
||||
->set("TITLE", $entry->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $entry->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $entry->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $entry->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
$this->addOutputFields($row, $entry);
|
||||
$loopResult->addRow($row);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
148
local/modules/CreditNote/Loop/CreditNoteVersion.php
Normal file
148
local/modules/CreditNote/Loop/CreditNoteVersion.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the module CreditNote */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace CreditNote\Loop;
|
||||
|
||||
use CreditNote\Model\CreditNoteVersionQuery;
|
||||
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\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
/**
|
||||
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
|
||||
*
|
||||
* @method string[] getRef()
|
||||
* @method int[] getId()
|
||||
* @method string[] getOrder()
|
||||
*/
|
||||
class CreditNoteVersion extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
protected $timestampable = true;
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createAnyListTypeArgument('ref'),
|
||||
Argument::createIntListTypeArgument("id"),
|
||||
Argument::createEnumListTypeArgument(
|
||||
"order",
|
||||
[
|
||||
"id", "id-reverse",
|
||||
"create-date", "create-date-reverse"
|
||||
],
|
||||
"id"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$query = new CreditNoteVersionQuery();
|
||||
|
||||
if (null !== $id = $this->getId()) {
|
||||
$query->filterById($id);
|
||||
}
|
||||
|
||||
if (null !== $ref = $this->getRef()) {
|
||||
$query->filterByRef($ref);
|
||||
}
|
||||
|
||||
$this->addJoin($query);
|
||||
|
||||
$this->addVirtualColumn($query);
|
||||
|
||||
$this->buildModelCriteriaOrder($query);
|
||||
|
||||
$query->groupById();
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteVersionQuery $query
|
||||
*/
|
||||
protected function buildModelCriteriaOrder($query)
|
||||
{
|
||||
foreach ($this->getOrder() as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$query->orderById();
|
||||
break;
|
||||
case "id-reverse":
|
||||
$query->orderById(Criteria::DESC);
|
||||
break;
|
||||
case 'create-date':
|
||||
$query->orderByCreatedAt(Criteria::ASC);
|
||||
break;
|
||||
case 'create-date-reverse':
|
||||
$query->orderByCreatedAt(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteVersionQuery $query
|
||||
*/
|
||||
protected function addJoin($query)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreditNoteVersionQuery $query
|
||||
*/
|
||||
protected function addVirtualColumn($query)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \CreditNote\Model\CreditNoteVersion $entry */
|
||||
foreach ($loopResult->getResultDataCollection() as $entry) {
|
||||
$row = new LoopResultRow($entry);
|
||||
$row
|
||||
->set("ID", $entry->getId())
|
||||
->set("REF", $entry->getRef())
|
||||
->set("TYPE_ID", $entry->getTypeId())
|
||||
->set("STATUS_ID", $entry->getStatusId())
|
||||
->set("ORDER_ID", $entry->getOrderId())
|
||||
->set("PARENT_ID", $entry->getParentId())
|
||||
->set("CUSTOMER_ID", $entry->getCustomerId())
|
||||
->set("TOTAL_AMOUNT_PRICE", $entry->getTotalPriceWithTax())
|
||||
;
|
||||
$this->addOutputFields($row, $entry);
|
||||
$loopResult->addRow($row);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getLocale()
|
||||
{
|
||||
return $this->request->getSession()->getAdminEditionLang()->getLocale();
|
||||
}
|
||||
}
|
||||
78
local/modules/CreditNote/Loop/OrderCreditNote.php
Normal file
78
local/modules/CreditNote/Loop/OrderCreditNote.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the module CreditNote */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace CreditNote\Loop;
|
||||
|
||||
use CreditNote\Model\OrderCreditNoteQuery;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
/**
|
||||
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
|
||||
*
|
||||
* @method int[] getCreditNoteId()
|
||||
* @method int[] getOrderId()
|
||||
*/
|
||||
class OrderCreditNote extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
protected $timestampable = true;
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument("credit_note_id"),
|
||||
Argument::createIntListTypeArgument("order_id")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$query = new OrderCreditNoteQuery();
|
||||
|
||||
if (null !== $creditNoteId = $this->getCreditNoteId()) {
|
||||
$query->filterByCreditNoteId($creditNoteId);
|
||||
}
|
||||
|
||||
if (null !== $orderId = $this->getOrderId()) {
|
||||
$query->filterByOrderId($orderId);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \CreditNote\Model\OrderCreditNote $entry */
|
||||
foreach ($loopResult->getResultDataCollection() as $entry) {
|
||||
$row = new LoopResultRow($entry);
|
||||
$row
|
||||
->set("ORDER_ID", $entry->getOrderId())
|
||||
->set("CREDIT_NOTE_ID", $entry->getCreditNoteId())
|
||||
->set("AMOUNT", $entry->getAmountPrice())
|
||||
;
|
||||
$this->addOutputFields($row, $entry);
|
||||
$loopResult->addRow($row);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user