_filter['customerName'])) { Qs_Db_Filter::where($select, ['billingFirstName', 'billingLastName'], $this->_filter['customerName']); } if (!empty($this->_filterFields) && array_key_exists('query', $this->_filter)) { Qs_Db_Filter::where($select, $this->_filterFields, $this->_filter['query']); } return $this; } 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([ 'defaults' => ['paid' => $row['paid'], 'status' => $row['status']], 'appendAllRow' => false, ]); $toolForm->setDefaults(); $paidFormElement = $toolForm->getElement('paid') ->setName('paid' . $row['id']) ->setAttrib('class', 'cell_paid'); /** @var Zend_Form_Element_Select $statusFormElement */ $statusFormElement = $toolForm->getElement('status') ->setName('status' . $row['id']) ->setAttrib('class', 'cell_status'); $statuses = $statusFormElement->getMultiOptions(); if (!$row['shippingName']) { unset($statuses[App_ECommerce_Order_Abstract_Obj::STATUS_ORDER_PACKED]); unset($statuses[App_ECommerce_Order_Abstract_Obj::STATUS_ORDER_SENT]); } $statusFormElement->setMultiOptions($statuses); 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 = ['' => '-------'] + $list; } return $list; } public function getPaidStatuses($appendAllRow = false) { $list = parent::getPaidStatuses(); if (true === $appendAllRow && is_array($list)) { $list = ['' => '-------'] + $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 = []; foreach ($selectedPrimary as $primaryKey) { $id = $primaryKey['id']; if (($data = $this->_getFromDb($id)) && $data[$field] != self::STATUS_ORDER_CLOSED) { $table->update([$field => $status], ['id = ?' => $id]); $updatedPrimary[] = $id; } } return $updatedPrimary; } public function delete() { $this->_getTable()->updateByKey(['enabled' => 'n'], $this->getPrimaryKey()); } public function createEmptyOrder() { $data = [ 'enabled' => 'n', ]; if (false !== ($id = $this->insert($data))) { $this->_getTable('Cart')->insert(['transactionId' => $id]); return $id; } return false; } public function cancelOrder() { parent::delete(); $cartId = $this->_getTable('Cart')->searchBy(['transactionId' => $this->getPrimaryKey()], 'id'); if ($cartId) { $this->_getTable('Cart')->deleteByKey($cartId); } return $this; } }