vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Module/OrderDetails.php line 83

Open in your IDE?
  1. <?php
  2. /*
  3.  * Isotope eCommerce for Contao Open Source CMS
  4.  *
  5.  * Copyright (C) 2009 - 2019 terminal42 gmbh & Isotope eCommerce Workgroup
  6.  *
  7.  * @link       https://isotopeecommerce.org
  8.  * @license    https://opensource.org/licenses/lgpl-3.0.html
  9.  */
  10. namespace Isotope\Module;
  11. use Contao\CoreBundle\Exception\AccessDeniedException;
  12. use Contao\FrontendUser;
  13. use Contao\Input;
  14. use Contao\PageError403;
  15. use Contao\PageModel;
  16. use Contao\StringUtil;
  17. use Haste\Util\Format;
  18. use Isotope\Frontend\ProductCollectionAction\ReorderAction;
  19. use Isotope\Model\ProductCollection\Order;
  20. use Isotope\Template;
  21. /**
  22.  * @property int    $iso_cart_jumpTo
  23.  * @property int    $iso_gallery
  24.  * @property string $iso_collectionTpl
  25.  * @property string $iso_orderCollectionBy
  26.  */
  27. class OrderDetails extends AbstractProductCollection
  28. {
  29.     /**
  30.      * Template
  31.      * @var string
  32.      */
  33.     protected $strTemplate 'mod_iso_orderdetails';
  34.     /**
  35.      * Display a wildcard in the back end
  36.      *
  37.      * @param bool $blnBackend
  38.      *
  39.      * @return string
  40.      */
  41.     public function generate($blnBackend false)
  42.     {
  43.         if ($blnBackend) {
  44.             $this->backend true;
  45.             $this->jumpTo  0;
  46.             $this->setWildcard(false);
  47.         }
  48.         return parent::generate();
  49.     }
  50.     /**
  51.      * Generate the module
  52.      */
  53.     protected function compile()
  54.     {
  55.         $order $this->getCollection();
  56.         if (null === $order) {
  57.             return;
  58.         }
  59.         parent::compile();
  60.         $this->Template->info                 StringUtil::deserialize($order->checkout_infotrue);
  61.         $this->Template->date                 Format::date($order->locked);
  62.         $this->Template->time                 Format::time($order->locked);
  63.         $this->Template->datim                Format::datim($order->locked);
  64.         $this->Template->orderDetailsHeadline sprintf($GLOBALS['TL_LANG']['MSC']['orderDetailsHeadline'], $order->getDocumentNumber(), $this->Template->datim);
  65.         $this->Template->orderStatus          sprintf($GLOBALS['TL_LANG']['MSC']['orderStatusHeadline'], $order->getStatusLabel());
  66.         $this->Template->orderStatusKey       $order->getStatusAlias();
  67.     }
  68.     /**
  69.      * @inheritdoc
  70.      */
  71.     protected function getCollection()
  72.     {
  73.         static $order false;
  74.         if (false !== $order) {
  75.             return $order;
  76.         }
  77.         $order Order::findOneBy('uniqid', (string) Input::get('uid'));
  78.         // Also check owner (see #126)
  79.         if (null === $order
  80.             || (FE_USER_LOGGED_IN === true
  81.                 && $order->member 0
  82.                 && FrontendUser::getInstance()->id != $order->member
  83.             )
  84.         ) {
  85.             $this->Template          = new Template('mod_message');
  86.             $this->Template->type    'error';
  87.             $this->Template->message $GLOBALS['TL_LANG']['ERR']['orderNotFound'];
  88.             return null;
  89.         }
  90.         // Order belongs to a member but not logged in
  91.         if ('FE' === TL_MODE && $this->iso_loginRequired && $order->member && FE_USER_LOGGED_IN !== true) {
  92.             throw new AccessDeniedException();
  93.         }
  94.         if ('FE' === TL_MODE) {
  95.             /** @var PageModel $objPage */
  96.             global $objPage;
  97.             $order->preventSaving(false);
  98.             $order->orderdetails_page $objPage->id;
  99.         }
  100.         return $order;
  101.     }
  102.     /**
  103.      * @inheritdoc
  104.      */
  105.     protected function getEmptyMessage()
  106.     {
  107.         // An order can never be empty
  108.         return '';
  109.     }
  110.     /**
  111.      * @inheritdoc
  112.      */
  113.     protected function canEditQuantity()
  114.     {
  115.         return false;
  116.     }
  117.     /**
  118.      * @inheritdoc
  119.      */
  120.     protected function canRemoveProducts()
  121.     {
  122.         return false;
  123.     }
  124.     /**
  125.      * {@inheritdoc}
  126.      */
  127.     protected function getActions()
  128.     {
  129.         if ('BE' === TL_MODE) {
  130.             return [];
  131.         }
  132.         return [
  133.             new ReorderAction($this),
  134.         ];
  135.     }
  136. }