src/bekanntmacher/boxmaker-bundle/src/Module/Cart.php line 59

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright Bekanntmacher
  4.  *
  5.  * @author Simon Wohler <s.wohler@bekanntmacher.ch>
  6.  * @license    commercial
  7.  */
  8. namespace Bekanntmacher\BoxmakerBundle\Module;
  9. use Bekanntmacher\BoxmakerBundle\Classes\Config;
  10. use Bekanntmacher\BoxmakerBundle\Model\FarbeModel;
  11. use Bekanntmacher\BoxmakerBundle\Model\TypeModel;
  12. use Bekanntmacher\BoxmakerBundle\Model\ConfigModel;
  13. use Bekanntmacher\BoxmakerBundle\Model\WelleModel;
  14. use Bekanntmacher\BoxmakerBundle\Model\TypeOptionModel;
  15. use Bekanntmacher\BoxmakerBundle\Module\CartUtil;
  16. /**
  17.  * Boxmaker Typelist
  18.  */
  19. class Cart extends TypeUtil
  20. {
  21.     /**
  22.      * @var string Template
  23.      */
  24.     protected $strTemplate 'mod_boxmaker_cart';
  25.     /**
  26.      * The Configuration object
  27.      * @var object
  28.      */
  29.     protected $objConfig;
  30.     /**
  31.      * Display a wildcard in the back end
  32.      * @return string
  33.      */
  34.     public function generate()
  35.     {
  36.         // Display a wildcard in the back end
  37.         if (TL_MODE === 'BE')
  38.         {
  39.             $template =new \BackendTemplate('be_wildcard');
  40.             $template->wildcard '### BOXMAKER TYPE DETAIL ###';
  41.             $template->title $this->name;
  42.             $template->id $this->id;
  43.             $template->link $this->name;
  44.             $template->href 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' $this->id;
  45.         }
  46.         return parent::generate();
  47.     }
  48.     /**
  49.      * Generate the module
  50.      */
  51.     public function compile()
  52.     {
  53.         // Instantiate session
  54.         $objSession = \System::getContainer()->get('session');
  55.         // check if a cart exists
  56.         if($objSession->has('mybox_cart') && $objSession->get('mybox_cart') !== null)
  57.         {
  58.             $arrCart $objSession->get('mybox_cart');
  59.         } else {
  60.             $arrCart = array();
  61.             $this->Template->empty true;
  62.         }
  63.         // Instantiate config
  64.         $this->objConfig = new Config(ConfigModel::findByPk($this->boxmaker_config)->row());
  65.         $this->Template->boxmaker_config $this->boxmaker_config;
  66.         // Instantiate cart util
  67.         $objCartUtil = new CartUtil($this->objConfig);
  68.         // Generate cart items
  69.         $cart_items = array();
  70.         foreach ($arrCart as $pos => $arrType)
  71.         {
  72.             $cart_items[] = $objCartUtil->renderType($pos$arrType'cart_item');
  73.         }
  74.         $this->Template->cart_items $cart_items;
  75.         
  76.         // Cart Footer
  77.         $this->Template->show_total = (count($arrCart) == 1) ? true false;
  78.         $this->Template->boxmaker_currency $this->objConfig->boxmaker_currency;
  79.         $this->Template->zwischensumme $objCartUtil->getAmount($objCartUtil->zwischensummefalse);
  80.         // VEK
  81.         $vek $objCartUtil->zwischensumme * ($this->objConfig->boxmaker_vek/100);
  82.         $this->Template->vek $objCartUtil->getAmount($vekfalse);
  83.         $this->Template->vek_prozent $this->objConfig->boxmaker_vek ' % ' $GLOBALS['TL_LANG']['MSC']['boxmaker_vek_label'];
  84.         $mwst = ($objCartUtil->zwischensumme $vek) * ($this->objConfig->boxmaker_mwst/100);
  85.         $this->Template->mwst $objCartUtil->getAmount($mwstfalse);
  86.         $this->Template->mwst_satz $this->objConfig->boxmaker_mwst '%';
  87.         $this->Template->total $objCartUtil->getAmount($objCartUtil->zwischensumme $vek $mwstfalse);
  88.         $this->Template->message_plus $objCartUtil->getMessagePlus();
  89.     }
  90. }