_filterFields) && array_key_exists('query', $this->_filter)) { Qs_Db_Filter::where($select, $this->_filterFields, $this->_filter['query']); if (!empty($this->_filter['query'])) { $select->orWhere( 'IF (`Cart`.`userId` = 0, CONCAT_WS(\' \', `Transaction`.`billingFirstName`, `Transaction`.`billingLastName`) LIKE(?), CONCAT_WS(\' \', `User`.`firstName`, `User`.`lastName`) LIKE (?))', '%' . $this->_filter['query'] . '%'); } } return parent::_filter($select); } public function getListSelect() { if (null === $this->_select) { parent::getListSelect(); $columns = array( 'customerName' => new Zend_Db_Expr(' IF(`Cart`.`userId` = 0 || `User`.`id` IS NULL, CONCAT( CONCAT_WS( " ", `' . $this->_tableAlias . '`.`billingFirstName`, `' . $this->_tableAlias . '`.`billingLastName` ), " (Guest)" ), CONCAT_WS(" ", `User`.`firstName`, `User`.`lastName`) )' ) ); $this->_select->joinLeft($this->_getPair('User'), '`User`.`id` = `Cart`.`userId`', $columns); } return $this->_select; } protected function _prepareList(&$list) { foreach (array_keys($list) as $key) { $this->_prepareRowFormElements($list[$key]); $this->_prepareRow($list[$key]); } return $this; } protected function _prepareRowFormElements(array &$row) { $toolForm = new App_ECommerce_Order_Admin_Form_Tool(array( 'defaults' => array('paid' => $row['paid'], 'status' => $row['status']), 'appendAllRow' => false )); $toolForm->setDefaults(); $paidFormElement = $toolForm->getElement('paid') ->setName('paid' . $row['id']) ->setAttrib('class', 'cell_paid'); $statusFormElement = $toolForm->getElement('status') ->setName('status' . $row['id']) ->setAttrib('class', 'cell_status'); if ($row['status'] == App_ECommerce_Order_Admin_Obj::STATUS_ORDER_CLOSED) { $paidFormElement->setAttrib('disabled', 'disabled'); $statusFormElement->setAttrib('disabled', 'disabled'); } $row['paidFormElement'] = $paidFormElement->render(); $row['statusFormElement'] = $statusFormElement->render(); return parent::_prepareRow($row); } public function getOrderStatuses($appendAllRow = false) { $list = parent::getOrderStatuses(); if (true === $appendAllRow && is_array($list)) { $list = array('' => '-------') + $list; } return $list; } public function getPaidStatuses($appendAllRow = false) { $list = parent::getPaidStatuses(); if (true === $appendAllRow && is_array($list)) { $list = array('' => '-------') + $list; } return $list; } public function changeStatuses(array $selectedPrimary, $field, $status) { if (!in_array($field, $this->_allowedChangeStatusFields) || !array_key_exists($status, $this->{'_' . ($field == 'status' ? 'order' : 'paid') . 'Statuses'}) ) { return false; } $table = $this->_getTable(); $updatedPrimary = array(); foreach ($selectedPrimary as $primaryKey) { $id = $primaryKey['id']; if (($data = $this->_getFromDb($id)) && $data[$field] != self::STATUS_ORDER_CLOSED) { $table->update(array($field => $status), array('id = ?' => $id)); $updatedPrimary[] = $id; } } return $updatedPrimary; } public function delete() { $this->_getTable()->updateByKey(array('enabled' => 'n'), $this->getPrimaryKey()); } public function createEmptyOrder() { $data = array( 'enabled' => 'n' ); if (false !== ($id = $this->insert($data))) { $this->_getTable('Cart')->insert(array('transactionId' => $id)); return $id; } return false; } public function cancelOrder() { parent::delete(); $cartId = $this->_getTable('Cart')->searchBy(array('transactionId' => $this->getPrimaryKey()), 'id'); if ($cartId) { $this->_getTable('Cart')->deleteByKey($cartId); } return $this; } }