Inital commit
This commit is contained in:
76
local/modules/RibClient/Loop/RibClient.php
Normal file
76
local/modules/RibClient/Loop/RibClient.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
/**
|
||||
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
|
||||
* Date: 16/04/2019 00:00
|
||||
*/
|
||||
namespace RibClient\Loop;
|
||||
|
||||
use RibClient\Model\RibClientQuery;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @method int getCustomerId()
|
||||
*/
|
||||
class RibClient extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('customer_id', null, true),
|
||||
Argument::createAnyTypeArgument('order_date', '')
|
||||
);
|
||||
}
|
||||
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
return RibClientQuery::create()->filterByCustomerId($this->getCustomerId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
* @return LoopResult
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$orderDate = \DateTime::createFromFormat('Y-m-d', $this->getOrderDate());
|
||||
|
||||
/** @var \RibClient\Model\RibClient $item */
|
||||
foreach ($loopResult->getResultDataCollection() as $item) {
|
||||
$loopResultRow = new LoopResultRow($item);
|
||||
|
||||
$loopResultRow
|
||||
->set('ID' , $item->getId())
|
||||
->set('ECHEANCE' , $item->getIban())
|
||||
;
|
||||
|
||||
// Calculer la date de paiement
|
||||
if (false !== $orderDate) {
|
||||
$datePaiement = $orderDate->add(new \DateInterval("P" . $item->getEcheance() . "D"));
|
||||
|
||||
$loopResultRow->set('DATE_PAIEMENT' , $datePaiement);
|
||||
}
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user