84 lines
3.8 KiB
PHP
Executable File
84 lines
3.8 KiB
PHP
Executable File
<?php
|
|
/*************************************************************************************/
|
|
/* */
|
|
/* Thelia */
|
|
/* */
|
|
/* Copyright (c) OpenStudio */
|
|
/* email : info@thelia.net */
|
|
/* web : http://www.thelia.net */
|
|
/* */
|
|
/* This program is free software; you can redistribute it and/or modify */
|
|
/* it under the terms of the GNU General Public License as published by */
|
|
/* the Free Software Foundation; either version 3 of the License */
|
|
/* */
|
|
/* This program is distributed in the hope that it will be useful, */
|
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
/* GNU General Public License for more details. */
|
|
/* */
|
|
/* You should have received a copy of the GNU General Public License */
|
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
/* */
|
|
/*************************************************************************************/
|
|
|
|
namespace ColissimoPickupPoint\Loop;
|
|
|
|
use ColissimoPickupPoint\Model\AddressColissimoPickupPoint;
|
|
use ColissimoPickupPoint\Model\AddressColissimoPickupPointQuery;
|
|
use Thelia\Core\Template\Loop\Address;
|
|
use Thelia\Core\Template\Element\LoopResult;
|
|
use Thelia\Core\Template\Element\LoopResultRow;
|
|
/**
|
|
* class ColissimoPickupPointDelivery
|
|
* @package ColissimoPickupPoint\Loop
|
|
* @author Thelia <info@thelia.net>
|
|
*/
|
|
class ColissimoPickupPointAddress extends Address
|
|
{
|
|
protected $exists = false;
|
|
protected $timestampable = false;
|
|
|
|
protected function setExists($id)
|
|
{
|
|
$this->exists = AddressColissimoPickupPointQuery::create()->findPK($id) !== null;
|
|
}
|
|
|
|
public function buildModelCriteria()
|
|
{
|
|
$id = $this->getId();
|
|
$this->setExists($id[0]);
|
|
|
|
return $this->exists ?
|
|
AddressColissimoPickupPointQuery::create()->filterById($id[0]) :
|
|
parent::buildModelCriteria();
|
|
}
|
|
|
|
public function parseResults(LoopResult $loopResult)
|
|
{
|
|
if (!$this->exists) {
|
|
return parent::parseResults($loopResult);
|
|
}
|
|
|
|
/** @var AddressColissimoPickupPoint $address */
|
|
foreach ($loopResult->getResultDataCollection() as $address) {
|
|
$loopResultRow = new LoopResultRow();
|
|
$loopResultRow
|
|
->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('CELLPHONE', $address->getCellphone())
|
|
;
|
|
$loopResult->addRow($loopResultRow);
|
|
}
|
|
|
|
return $loopResult;
|
|
}
|
|
}
|