Go to the documentation of this file.00001 <?php
00002
00008 class oxPriceList
00009 {
00015 protected $_aList = array();
00016
00022 public function __construct()
00023 {
00024 }
00025
00031 public function getBruttoSum()
00032 {
00033 $dSum = 0;
00034 foreach ( $this->_aList as $oPrice ) {
00035 $dSum += $oPrice->getBruttoPrice();
00036 }
00037
00038 return $dSum;
00039 }
00040
00046 public function getNettoSum()
00047 {
00048 $dSum = 0;
00049 foreach ( $this->_aList as $oPrice ) {
00050 $dSum += $oPrice->getNettoPrice();
00051 }
00052
00053 return $dSum;
00054 }
00055
00061 public function getVatInfo()
00062 {
00063 $oLang = oxLang::getInstance();
00064 $aVatValues = array();
00065 foreach ( $this->_aList as $oPrice ) {
00066 $sVatKey = ( string ) $oLang->formatVat( $oPrice->getVat() );
00067 if ( !isset( $aVatValues[$sVatKey] )) {
00068 $aVatValues[$sVatKey] = 0;
00069 }
00070 $aVatValues[$sVatKey] += $oPrice->getVATValue();
00071 }
00072
00073 return $aVatValues;
00074 }
00075
00081 public function getPriceInfo()
00082 {
00083 $aPrices = array();
00084 foreach ( $this->_aList as $oPrice ) {
00085 $sVat = ( string ) $oPrice->getVat();
00086 if ( !isset( $aPrices[$sVat] )) {
00087 $aPrices[$sVat] = 0;
00088 }
00089 $aPrices[$sVat] += $oPrice->getBruttoPrice();
00090 }
00091
00092 return $aPrices;
00093 }
00094
00101 public function getMostUsedVatPercent()
00102 {
00103 $aPrices = $this->getPriceInfo();
00104 if ( count( $aPrices ) == 0 ) {
00105 return;
00106 }
00107
00108 return array_search( max( $aPrices ), $aPrices );
00109 }
00110
00118 public function addToPriceList( $oPrice )
00119 {
00120 $this->_aList[] = $oPrice;
00121 }
00122 }