_doc->display404(); } protected function _doUserAutocompleteAjax() { $query = Qs_Request::getRequestValue('term'); $this->_displayJson($this->_getDataObj()->getUser4Autocomplete($query)); } protected function _sendGiftCardMail() { $send = Qs_Request::getPostValue('send'); $this->_getDataObj()->clearData(); $data = $this->_getDataObj()->getData(); if ($send == 'y' && !empty($data)) { $userObj = new App\User\Admin\Obj(); $userObj->setPrimaryKey($data['userId']); $mailData = [ 'cardCode' => $data['cardCode'], 'cardValue' => money_format('%i', $data['cardValue']), 'expirationDate' => date('m/d/Y', strtotime($data['expirationDate'])), 'created' => date('m/d/Y', strtotime($data['added'])), 'firstName' => $userObj->getData('firstName'), 'lastName' => $userObj->getData('lastName'), 'email' => $userObj->getData('email'), ]; $mailOptions = [ 'to' => $mailData['email'], 'body' => App_Settings_Obj::get($this->_settingsPrefix . 'Body'), 'subject' => App_Settings_Obj::get($this->_settingsPrefix . 'Subject'), 'from' => App_Settings_Obj::getEmailFrom($this->_settingsPrefix . 'From'), ]; if (empty($mailOptions['to']) || empty($mailOptions['body'])) { return false; } $placeholders = []; foreach ($mailData as $field => $value) { $placeholders['{' . $field . '}'] = htmlspecialchars($value); } $mailOptions['body'] = str_replace(array_keys($placeholders), $placeholders, $mailOptions['body']); $this->_sendMail($mailOptions); $message = $this->getConfig('itemName') . ' has been sent to ' . $mailData['email'] . ''; $this->_setBackMessage($message); $this->_getDataObj()->update(['statusId' => static::CARD_STATUS_SEND]); $this->_logGiftMail(); } return $this; } protected function _logGiftMail() { $this->_getLog()->setAction('sent', 'Sent "%itemTitle%" %itemName% to customer'); $this->_getLog()->write('sent', $this->_getDataObj()->getObjectInfo()); return $this; } protected function _postUpdate() { parent::_postUpdate(); $this->_sendGiftCardMail(); return $this; } protected function _postInsert() { parent::_postInsert(); $this->_sendGiftCardMail(); return $this; } protected function _doGenerateCode() { $this->_doc->display404(); } protected function _doGenerateCodeAjax() { $this->_displayJson(['code' => $this->_getDataObj()->generateCode()]); } }