oxtsproduct.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxTsProduct extends oxSuperCfg
00007 {
00013     protected $_sTsId = null;
00014 
00020     protected $_iAmount = null;
00021 
00027     protected $_fPrice = null;
00028 
00034     protected $_oPrice = null;
00035 
00041     protected $_sTsProtectProducts = array( "TS080501_500_30_EUR"   => array( "netto" => "0.82", "amount" => "500" ),
00042                                        "TS080501_1500_30_EUR"  => array( "netto" => "2.47", "amount" => "1500" ),
00043                                        "TS080501_2500_30_EUR"  => array( "netto" => "4.12", "amount" => "2500" ),
00044                                        "TS080501_5000_30_EUR"  => array( "netto" => "8.24", "amount" => "5000" ),
00045                                        "TS080501_10000_30_EUR" => array( "netto" => "16.47", "amount" => "10000" ),
00046                                        "TS080501_20000_30_EUR" => array( "netto" => "32.94", "amount" => "20000" )
00047                                 );
00048 
00054     public function getTsId()
00055     {
00056         return $this->_sTsId;
00057     }
00058 
00066     public function setTsId( $sTsId )
00067     {
00068         $this->_sTsId = $sTsId;
00069         $this->_setDeprecatedValues();
00070     }
00071 
00077     public function getAmount()
00078     {
00079         if ( $this->_iAmount == null ) {
00080             if ( $sTsId = $this->getTsId() ) {
00081                 $aTsProducts = $this->getAllTsProducts();
00082                 if ( $aTsProducts[$sTsId] && is_array($aTsProducts[$sTsId]) ) {
00083                     $this->_iAmount = $aTsProducts[$sTsId]['amount'];
00084                 }
00085             }
00086         }
00087         return $this->_iAmount;
00088     }
00089 
00095     public function getFPrice()
00096     {
00097         if ( $this->_fPrice == null ) {
00098             if ( $oPrice = $this->getPrice() ) {
00099                 $this->_fPrice = oxLang::getInstance()->formatCurrency( $oPrice->getBruttoPrice() );
00100             }
00101         }
00102         return $this->_fPrice;
00103     }
00104 
00110     public function getPrice()
00111     {
00112         if ( $this->_oPrice == null ) {
00113             if ( $sTsId = $this->getTsId() ) {
00114                 $aTsProducts = $this->getAllTsProducts();
00115                 if ( $aTsProducts[$sTsId] && is_array($aTsProducts[$sTsId]) ) {
00116                     $oConfig  = $this->getConfig();
00117                     $dVat     = $oConfig->getConfigParam( 'dDefaultVAT' );
00118                     $dPrice   = oxPrice::netto2Brutto($aTsProducts[$sTsId]['netto'], $dVat);
00119 
00120                     $oPrice = oxNew( 'oxPrice' );
00121                     $oPrice->setPrice( $dPrice );
00122                     if ( $oConfig->getConfigParam( 'blCalcVATForPayCharge' ) ) {
00123                         $oPrice->setVat( $dVat );
00124                     }
00125                     $this->_oPrice = $oPrice;
00126                 }
00127             }
00128         }
00129         return $this->_oPrice;
00130     }
00131 
00137     public function getAllTsProducts()
00138     {
00139         return $this->_sTsProtectProducts;
00140     }
00141 
00147     public function _setDeprecatedValues()
00148     {
00149         $this->sTsId = $this->getTsId();
00150         $this->iAmount = $this->getAmount();
00151         $this->fPrice = $this->getFPrice();
00152     }
00153 
00154 }