public function actionReply() { try { $model = new ProEnquiryPropertyReply(); if (isset($_POST['ProEnquiryPropertyReply'])) { $model->attributes = $_POST['ProEnquiryPropertyReply']; if ($model->save()) { //set replied status $enquiryProperty = ProEnquiryProperty::getItemById($model->enquiry_property_id); $enquiryProperty->status = ENQUIRY_PROPERTY_REPLIED; $enquiryProperty->scenario = null; $enquiryProperty->update(array('status')); //send email SendEmail::sendEmailReplyEnquiryAgent($model); Yii::app()->user->setFlash('success', 'Your email has been sent.'); $this->redirect(array('index')); } else { Yii::app()->user->setFlash('error', 'Your email could not send. Please try again.'); $this->redirect(array('index')); } } else { Yii::log("Invalid request. Please do not repeat this request again."); throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } } catch (Exception $e) { Yii::log("Exception " . print_r($e, true), 'error'); throw new CHttpException(400, $e->getMessage()); } }