getAttribute('basket'))) { $this->setAttribute('basket', new Basket()); } return $this->getAttribute('basket'); } public function setActualIndentFormData($data) { $this->setAttribute('actualIndentFormData', $data); } public function getActualIndentFormData() { return $this->getAttribute('actualIndentFormData'); } public function getShipping() { return $this->getAttribute('shipping', false); } public function setShipping($shipping) { $this->setAttribute('shipping', $shipping); } public function getPayment() { return $this->getAttribute('payment', false); } public function setPayment($payment) { $this->setAttribute('payment', $payment); } public function getPack() { return $this->getAttribute('pack', false); } public function setPack($pack) { if(!is_null($pack)) { $this->setAttribute('pack', $pack); } } public function removePack() { $this->setAttribute('pack', false); } public function removePayment() { $this->setAttribute('payment', false); } public function removeShipping() { $this->setAttribute('shipping', false); } public function getBasketWeight() { $weight = 0; foreach($this->getBasket() as $count => $product) { if(isset($product['weight']) && !is_null($product['weight'])) { $weight += $product['weight'] * $count; } } return $weight; } public function getShippingPrice() { if($this->getShipping() != 'posta') { return 0; } else { $weight = $this->getBasketWeight(); foreach(sfConfig::get('app_doprava_cpCenik') as $w => $p) { if($weight <= $w) { return $p; } } return 0; } } public function getPaymentPrice() { if($this->getPayment() == 'dobirka') { if($this->getShipping() == 'posta') { $sumprice = $this->getBasket()->getSumPrice(); if($sumprice*sfConfig::get('app_doprava_dphCoeficient') <= 5000) { return sfConfig::get('app_doprava_dobirkaCPdo5000'); } else { return sfConfig::get('app_doprava_dobirkaCPnad5000'); } } elseif($this->getShipping() == 'toptrans') { return sfConfig::get('app_doprava_dobirkaToptrans'); } else { return 0; } } else { return 0; } } public function getPackPrice() { switch($this->getPack()) { case 'balik': return sfConfig::get('app_balne_balikCena'); case 'paleta': return sfConfig::get('app_balne_paletaCena'); case 'bedna': return sfConfig::get('app_balne_bednaCena'); default: return 0; } } public function getPackArra() { switch($this->getPack()) { case 'paleta': return sfConfig::get('app_balne_paletaZaloha'); case 'bedna': return sfConfig::get('app_balne_bednaZaloha'); default: return 0; } } public function getTotalPrice() { $totalPrice = $this->getBasket()->getSumPrice(); $totalPrice += $this->getShippingPrice(); $totalPrice += $this->getPaymentPrice(); $totalPrice += $this->getPackPrice(); $totalPrice += $this->getPackArra(); return $totalPrice; } public function getTotalShippingPrice() { $totalPrice = $this->getShippingPrice(); $totalPrice += $this->getPaymentPrice(); $totalPrice += $this->getPackPrice(); $totalPrice += $this->getPackArra(); return $totalPrice; } }