00001 <?php 00002 00009 class oxPriceList 00010 { 00016 protected $_aList = array(); 00017 00023 public function getBruttoSum() 00024 { 00025 $dSum = 0; 00026 foreach ( $this->_aList as $oPrice ) { 00027 $dSum += $oPrice->getBruttoPrice(); 00028 } 00029 00030 return $dSum; 00031 } 00032 00038 public function getNettoSum() 00039 { 00040 $dSum = 0; 00041 foreach ( $this->_aList as $oPrice ) { 00042 $dSum += $oPrice->getNettoPrice(); 00043 } 00044 00045 return $dSum; 00046 } 00047 00053 public function getVatInfo() 00054 { 00055 $oLang = oxLang::getInstance(); 00056 $aVatValues = array(); 00057 foreach ( $this->_aList as $oPrice ) { 00058 $sVatKey = $oLang->formatVat( $oPrice->getVat() ); 00059 if ( !isset( $aVatValues[$sVatKey] )) { 00060 $aVatValues[$sVatKey] = 0; 00061 } 00062 $aVatValues[$sVatKey] += $oPrice->getVATValue(); 00063 } 00064 00065 return $aVatValues; 00066 } 00067 00073 public function getPriceInfo() 00074 { 00075 $aPrices = array(); 00076 foreach ( $this->_aList as $oPrice ) { 00077 if ( !isset( $aPrices[$oPrice->getVat()] )) { 00078 $aPrices[$oPrice->getVat()] = 0; 00079 } 00080 $aPrices[$oPrice->getVat()] += $oPrice->getBruttoPrice(); 00081 } 00082 00083 return $aPrices; 00084 } 00085 00092 public function getMostUsedVatPercent() 00093 { 00094 $aPrices = $this->getPriceInfo(); 00095 if ( count( $aPrices ) == 0 ) { 00096 return; 00097 } 00098 00099 return array_search( max( $aPrices ), $aPrices ); 00100 } 00101 00109 public function addToPriceList( $oPrice ) 00110 { 00111 $this->_aList[] = $oPrice; 00112 } 00113 }