oxtsproduct.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxTsProduct extends oxSuperCfg
00008 {
00014     protected $_sTsId = null;
00015 
00021     protected $_iAmount = null;
00022 
00028     protected $_fPrice = null;
00029 
00035     protected $_fNettoPrice = null;
00036 
00042     protected $_fVatValue = null;
00043 
00049     protected $_oPrice = null;
00050 
00051 
00057     protected $_dVat = null;
00058 
00064     protected $_sTsProtectProducts = array( "TS080501_500_30_EUR"   => array( "netto" => "0.82", "amount" => "500" ),
00065                                        "TS080501_1500_30_EUR"  => array( "netto" => "2.47", "amount" => "1500" ),
00066                                        "TS080501_2500_30_EUR"  => array( "netto" => "4.12", "amount" => "2500" ),
00067                                        "TS080501_5000_30_EUR"  => array( "netto" => "8.24", "amount" => "5000" ),
00068                                        "TS080501_10000_30_EUR" => array( "netto" => "16.47", "amount" => "10000" ),
00069                                        "TS080501_20000_30_EUR" => array( "netto" => "32.94", "amount" => "20000" )
00070                                 );
00071 
00077     public function getVat()
00078     {
00079         return $this->_dVat;
00080     }
00081 
00089     public function setVat( $dVat )
00090     {
00091         $this->_dVat = $dVat;
00092     }
00093 
00099     public function getTsId()
00100     {
00101         return $this->_sTsId;
00102     }
00103 
00111     public function setTsId( $sTsId )
00112     {
00113         $this->_sTsId = $sTsId;
00114     }
00115 
00121     public function getAmount()
00122     {
00123         if ( $this->_iAmount == null ) {
00124             if ( $sTsId = $this->getTsId() ) {
00125                 $aTsProducts = $this->getAllTsProducts();
00126                 if ( $aTsProducts[$sTsId] && is_array($aTsProducts[$sTsId]) ) {
00127                     $this->_iAmount = $aTsProducts[$sTsId]['amount'];
00128                 }
00129             }
00130         }
00131         return $this->_iAmount;
00132     }
00133 
00139     public function getFPrice()
00140     {
00141         if ( $this->_fPrice == null ) {
00142             if ( $oPrice = $this->getPrice() ) {
00143                 $this->_fPrice = oxRegistry::getLang()->formatCurrency( $oPrice->getBruttoPrice() );
00144             }
00145         }
00146         return $this->_fPrice;
00147     }
00148 
00154     public function getFNettoPrice()
00155     {
00156         if ( $this->_fNettoPrice == null ) {
00157             if ( $oPrice = $this->getPrice() ) {
00158                 $this->_fNettoPrice = oxRegistry::getLang()->formatCurrency( $oPrice->getNettoPrice() );
00159             }
00160         }
00161         return $this->_fNettoPrice;
00162     }
00163 
00169     public function getFVatValue()
00170     {
00171         if ( $this->_fVatValue == null ) {
00172             if ( $oPrice = $this->getPrice() ) {
00173                 $this->_fVatValue = oxRegistry::getLang()->formatCurrency( $oPrice->getVatValue() );
00174             }
00175         }
00176         return $this->_fVatValue;
00177     }
00178 
00184     public function getPrice()
00185     {
00186         if ( $this->_oPrice == null ) {
00187             if ( $sTsId = $this->getTsId() ) {
00188                 $aTsProducts = $this->getAllTsProducts();
00189                 if ( $aTsProducts[$sTsId] && is_array($aTsProducts[$sTsId]) ) {
00190                     $dPrice   = $aTsProducts[$sTsId]['netto'];
00191                     $oPrice = oxNew( 'oxPrice' );
00192                     $oPrice->setNettoPriceMode();
00193                     $oPrice->setPrice( $dPrice );
00194                     $oPrice->setVat( $this->getVat() );
00195                     $this->_oPrice = $oPrice;
00196                 }
00197             }
00198         }
00199         return $this->_oPrice;
00200     }
00201 
00207     public function getAllTsProducts()
00208     {
00209         return $this->_sTsProtectProducts;
00210     }
00211 }