Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Ysa\Core\Block;
- use Magento\Framework\View\Element\Template as Template;
- use Ysa\Core\Model\Api as RequestApi;
- use Magento\Framework\View\Element\Template\Context;
- use Ysa\Core\Model\RentacarRules;
- use Ysa\Core\Helper\Data as Helper;
- use Ysa\Core\Model\RentacarLocationContentFactory;
- class BookingRules extends Template
- {
- protected $requestApi;
- protected $modelRentacar;
- protected $_helper;
- protected $_locationContent;
- protected $_rentacarLocationContentFactory;
- public function __construct(
- RequestApi $requestApi,
- Context $context,
- RentacarRules $modelRentacar,
- Helper $helper,
- RentacarLocationContentFactory $locationContent,
- \Ysa\Core\Model\ResourceModel\RentacarLocationContent\CollectionFactory $rentacarLocationContentFactory,
- array $data = []
- )
- {
- $this->_helper = $helper;
- $this->requestApi = $requestApi;
- $this->modelRentacar = $modelRentacar;
- $this->_locationContent = $locationContent;
- $this->_rentacarLocationContentFactory = $rentacarLocationContentFactory;
- parent::__construct($context,$data);
- }
- public function getBookingRules()
- {
- $plateCode = $this->getRequest()->getParam('plancode');
- $responseXml = simplexml_load_string($this->modelRentacar->getRentaCarRules($plateCode));
- $response = $responseXml->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children();
- if($response->count())
- {
- return $response;
- } else {
- return false;
- }
- }
- //Helper Acriss Code Completo
- public function getAcriss($acriss)
- {
- return $this->_helper->getAcrrisCode($acriss);
- }
- //Helper Descrição dos planos
- public function getCarContractDescription($carContract)
- {
- return $this->_helper->getCarContractDescription($carContract);
- }
- public function getFinalPrice($value)
- {
- return $this->_helper->getFinalPrice($value);
- }
- public function getPriceCost($value)
- {
- return $this->_helper->getCostPrice($value);
- }
- public function getDaysQty(){
- $start = strtotime($this->getRequest()->getParam('arrival_date'));
- $end = strtotime($this->getRequest()->getParam('devolution_date'));
- $days = ($end - $start) / 86400;
- return $days;
- }
- public function setPricePerPeriod($price){
- $pricePerPeriod = (float) $price * $this->getDaysQty();
- return number_format($pricePerPeriod, '2',',','.');
- }
- public function setPricePerDay($nett){
- $pricePerDay = (float) $nett / $this->getDaysQty();
- return $this->getFinalPrice($pricePerDay);
- }
- public function getLocationContent($code)
- {
- $carContent = $this->_locationContent->create();
- return $carContent->load($code, 'zone_code')->getData();
- }
- public function getZoneCodeParam()
- {
- return $this->getRequest()->getParam('zone_code');
- }
- public function getRentacarLocationByZoneCode($zoneCode){
- $rentacarLocationContentCollection = $this->_rentacarLocationContentFactory->create();
- $rentacarLocationContentCollection->addFieldToFilter('zone_code', ['eq' => $zoneCode]);
- $rentacarLocationContentCollection->setPageSize(10);
- $rentacarLocationContentCollection->getSelect()->__toString();
- return $rentacarLocationContentCollection->toArray();
- }
- public function getRentacarLocationByCode($rentacarLocationCode){
- $rentacarLocationContentCollection = $this->_rentacarLocationContentFactory->create();
- $rentacarLocationContentCollection->addFieldToFilter('code', ['eq' => $rentacarLocationCode]);
- $rentacarLocationContentCollection->setPageSize(10);
- $rentacarLocationContentCollection->getSelect()->__toString();
- return $rentacarLocationContentCollection->toArray();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement