_data = $this->prepareSignupFormData($this->getTradeShowData(), $this->_data); return $this; } public function prepareSignupFormData(array $tradeShow, array $data) { $result = $data; $result['tradeShowId'] = $this->getTradeShowId(); $result['recordType'] = Entity::TYPE_VENDOR; $result['paymentType'] = null; $result['paymentDate'] = null; $result['bought'] = "n"; TradeShowObj::preparePricingData($tradeShow); /** attendees total price **/ $memberPrice = (float) $tradeShow['boothRepresentativePrice']; $attendeeCount = count($data['userId']); $total = bcmul($attendeeCount, $memberPrice, 2); /**if boothSpace == withTable, add to total price**/ $total = bcadd($total, $tradeShow['boothSpacePrice'], 2); /**if electricityHookUp checked, add to total price**/ if ($tradeShow['electricityPrice'] && $data['electricityHookUp'] == 'y') { $total = bcadd($total, $tradeShow['electricityPrice'], 2); } $result['amount'] = $total; return $result; } protected function _insertDependency() { $this->_insertVendorData($this->_data); $this->_insertAttendeeData($this->_data); $this->_data['registrationId'] = $this->_primaryKey; return $this; } public function update(array $data = null) { throw new Exception('Not supported'); } protected function _getCart() { if (null === $this->_cart) { $this->_cart = new App_ECommerce_Cart_Obj(); $this->_cart->setPrimaryKey($this->_cart->getCartId()); } return $this->_cart; } /** * Filter bought and in cart vendors of current user * @param string $alias TradeShowRegistration table alias * @return array */ public function getWhere($alias = null) { $aliasPrefix = (null === $alias) ? '' : "`{$alias}`."; $inCartExpr = $this->_getInCartExpr($alias); $where[] = new Zend_Db_Expr( "{$aliasPrefix}`bought` = 'y' OR ({$aliasPrefix}`bought` IS NULL AND EXISTS({$inCartExpr}))" ); return $where; } /** * @param string $alias TradeShowRegistration table alias * @return \Zend_Db_Expr */ protected function _getInCartExpr($alias = null) { $aliasPrefix = (null === $alias) ? '' : "`{$alias}`."; $_cartId = (int) $this->_getCart()->getCartId(); $_cartItemTable = Qs_Db::getTableName('CartItem'); $sql = "SELECT 1 FROM `{$_cartItemTable}` `ci` " . "WHERE `ci`.`cartId` = {$_cartId} " . " AND `ci`.`productId` = {$aliasPrefix}`id` " . "LIMIT 1"; return new Zend_Db_Expr($sql); } }