bool value, ...] */ public static function getCartItemCapabilities() { return []; } /** * Method should set primary key and init item object * @param array $data ['id' =>, 'cartId' =>, 'productId' =>, ...] * * @return mixed */ public function setCartItemData(array $data) { $this->_cartItemData = $data; $this->setPrimaryKey($this->_cartItemData['productCategoryId']); return $this; } protected function _getSingleAttendeeData($columns = '*') { $select = $this->_db->select(); $select->from($this->_getPair('TradeShowAttendee', 'a'), $columns) ->where('`registrationId` = ?', $this->_cartItemData['productId']) ->limit(1); return $this->_db->fetchRow($select); } protected function _getVendorData() { $select = $this->_db->select(); $select->from($this->_getPair('TradeShowVendor', 'tsv')) ->where('`tsv`.`registrationId` = ?', $this->_cartItemData['productId']) ->limit(1); $registration = $this->_db->fetchRow($select); if (!$registration) { return null; } $select->reset(); $select->from($this->_getPair('TradeShowAttendee', 'tsa'), ['name' => AttendeeModel::getNameWithNicknameExpr()]) ->where('`registrationId` = ?', $this->_cartItemData['productId'], Qs_Db::INT_TYPE); $registration['boothRepresentatives'] = $this->_db->fetchCol($select); $registration['boothCount'] = count($registration['boothRepresentatives']); $select->reset(); $select->from($this->_getPair('TradeShowAttendee', 'a'), ['userId', '_userId' => AttendeeModel::getFullNameExpr('a')]) ->where('`registrationId` = ?', $this->_cartItemData['productId'], Qs_Db::INT_TYPE); $registration['userId'] = $this->_db->fetchAll($select); return $registration; } public function getCartItemData() { return $this->_cartItemData; } /** * Prepare item data (from db) * @return array */ public function prepareCartItemData() { if ($this->_cartItemData) { $this->_cartItemData['typeTitle'] = $this->getConfig('itemName'); $this->_cartItemData['applyTax'] = 'n'; $this->_cartItemData['applyShipping'] = 'n'; $this->_cartItemData['allowChangeQuantity'] = in_array( Factory::CAPABILITY_CHANGE_QTY, $this->getCartItemCapabilities() ) ? 'y' : 'n'; $this->_cartItemData['showDescription'] = 'y'; //assign registration data $vendorData = $this->_getVendorData(); if ($vendorData) { /** vendor item */ $this->_cartItemData['vendor'] = $vendorData; } else { /** single attendee item*/ $this->_cartItemData['userId'] = $this->_getSingleAttendeeData( ['userId', '_userId' => AttendeeModel::getFullNameExpr('a')] ); } $obj = new Obj(); $obj->setPrimaryKey($this->_cartItemData['productCategoryId']); $data = $obj->getData(); if ($data) { $this->_cartItemData['url'] = View::getViewUrl($data['alias']); } } return $this->_cartItemData; } public function getDescriptions() { if (Entity::TYPE_SINGLE_ATTENDEE == $this->_cartItemData['recordType']) { return $this->_getSingleAttendeeDescriptions(); } return $this->_getVendorDescriptions(); } protected function _getSingleAttendeeDescriptions() { $attendee = $this->_getSingleAttendeeData(['*', 'fullName' => AttendeeModel::getNameWithNicknameExpr('a')]); if (!$attendee) { return [ 'description' => '', 'shortDescription' => '', ]; } /** @var Qs_Doc $doc */ $doc = Zend_Registry::get('doc'); $doc->getSmarty()->assign('attendee', $attendee); return [ 'description' => $doc->getSmarty()->fetch('TradeShow/cart-singleAttendee-description.tpl'), 'shortDescription' => $doc->getSmarty()->fetch('TradeShow/cart-singleAttendee-shortDescription.tpl'), ]; } protected function _getVendorDescriptions() { $registration = $this->_getVendorData(); if (!$registration) { return [ 'description' => '', 'shortDescription' => '', ]; } /** @var Qs_Doc $doc */ $doc = Zend_Registry::get('doc'); $doc->getSmarty()->assign('registration', $registration); return [ 'description' => $doc->getSmarty()->fetch('TradeShow/cart-vendor-description.tpl'), 'shortDescription' => $doc->getSmarty()->fetch('TradeShow/cart-vendor-shortDescription.tpl'), ]; } public function beforeValidateCart() { return $this; } /** * @return bool */ public function validateCartItem() { $error = null; $data = $this->getCartItemData(); if (isset($data['vendor']) && $data['vendor']['exhibitorCompanyName'] && $data['productCategoryId']) { $tradeShowId = $data['productCategoryId']; /** vendor item*/ $validatorOptions = ['tradeShowId' => $tradeShowId]; $validatorObj = new VendorNotRegisteredValidator($validatorOptions); if (true !== $validatorObj->isValid($data['vendor']['exhibitorCompanyName'])) { $this->addErrors($validatorObj->getMessages()); } $attendeeValidatorOptions = array_merge($validatorOptions, ['elementId' => 'userId']); $attendeeValidatorObj = new AttendeeNotRegisteredValidator($attendeeValidatorOptions); if (true !== $attendeeValidatorObj->isValid(null, $data['vendor'])) { $this->addErrors($attendeeValidatorObj->getMessages()); } $isBoothSpaceValidator = new IsBoothSpace(['cartId' => $this->_cartItemData['cartId']]); if (!$isBoothSpaceValidator->isCartValid($tradeShowId)) { $this->addErrors($isBoothSpaceValidator->getMessages()); } if ($this->getErrors()) { return false; } } else { /** single attendee item*/ $validatorOptions = ['tradeShowId' => $data['productCategoryId'], 'elementId' => 'userId']; $validatorObj = new AttendeeNotRegisteredValidator($validatorOptions); if (true !== $validatorObj->isValid(null, $data['userId'])) { $this->addErrors($validatorObj->getMessages()); return false; } } return true; } public function addErrors(array $errors) { $this->_errors = $this->_errors + $errors; return $this; } public function completeItemList(array $itemList) { return $this; } public function afterCartItemRemove() { return $this; } public function getErrors() { return $this->_errors; } }