public function actionFeedback() { $content = zmf::val('content', 1); if (!$content) { $this->jsonOutPut(0, '内容不能为空哦~'); } //一个小时内最多只能反馈5条 if (zmf::actionLimit('feedback', '', 5, 3600)) { $this->jsonOutPut(0, '操作太频繁,请稍后再试'); } $attr['uid'] = $this->uid; $attr['type'] = 'web'; $attr['contact'] = zmf::val('email', 1); $attr['appinfo'] = zmf::val('url', 1); $attr['sysinfo'] = Yii::app()->request->userAgent; $attr['content'] = $content; $model = new Feedback(); $model->attributes = $attr; if ($model->validate()) { if ($model->save()) { $this->jsonOutPut(1, '感谢您的反馈'); } else { $this->jsonOutPut(1, '感谢您的反馈'); } } else { $this->jsonOutPut(0, '反馈失败,请重试'); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Feedback(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $panel_ident = $_REQUEST['panel_ident']; if (isset($_POST['Feedback'])) { $model->attributes = $_POST['Feedback']; $model->q_time = Time::now(); if ($model->save()) { $model->addTags('tag1, tag2, tag3')->save(); if (isset($_GET['ajax'])) { $str = Yii::t('cp', 'Create Success On ') . Time::now(); Yii::app()->user->setFlash('success', $str); $this->renderPartial('create_next', array('model' => $model, 'panel_ident' => $panel_ident), false, true); exit; } else { $this->redirect(array('view', 'id' => $model->id)); } } } if (isset($_GET['ajax'])) { $this->renderPartial('create', array('model' => $model, 'panel_ident' => $panel_ident), false, true); } else { $this->render('create', array('model' => $model)); } }
public function submitAction() { // Get our context (this takes care of starting the session, too) $context = $this->getDI()->getShared('ltiContext'); $this->view->disable(); $this->view->ltiContext = $context; $this->view->userAuthorized = $context->valid; // Check for valid LTI context if ($context->valid) { // Store user feedback in the Feedback Phalcon model $feedback = new Feedback(); $feedback->type = $_POST["feedbackType"]; $feedback->feedback = $_POST["feedback"]; $feedback->student_email = $context->getUserEmail(); $feedback->student_name = $context->getUserName(); // The Phalcon model code takes care of creating a new row in the PostgreSQL database if ($feedback->save()) { echo "Thank you for your feedback!"; } else { echo "There was an error saving your feedback"; } // Send an email with this feedback to the developer $to = $this->getDI()->getShared('config')->feedback_email; $subject = 'Dashboard Feedback: ' . $feedback->type . " " . date(DATE_RFC2822); $message = $feedback->feedback . "\n Sent by " . $feedback->student_name . ", " . $feedback->student_email; $headers = 'From: admin@byuopenanalytics-dashboard.com' . "\r\n" . 'Reply-To: admin@byuopenanalytics-dashboard.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); } else { echo "You must be signed in to submit feedback"; } }
public function actionFeedback() { $form = new FeedbackForm('insert'); $formName = get_class($form); $this->performAjaxValidation($form); // проверить не передан ли тип и присвоить его аттрибуту модели $module = Yii::app()->getModule('feedback'); if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST[$formName])) { $form->setAttributes(Yii::app()->getRequest()->getPost($formName)); if ($form->validate()) { // обработка запроса $feedback = new Feedback(); $feedback->setAttributes($form->getAttributes()); if ($feedback->save()) { Yii::app()->eventManager->fire(FeedbackEvents::SUCCESS_SEND_MESSAGE, new SendFeedbackMessageEvent($feedback)); if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->ajax->success(Yii::t('FeedbackModule.feedback', 'Your message sent! Thanks!')); } Yii::app()->getUser()->setFlash(YFlashMessages::SUCCESS_MESSAGE, Yii::t('FeedbackModule.feedback', 'Your message sent! Thanks!')); $this->redirect($module->successPage ? [$module->successPage] : ['/feedback/contact/index/']); } else { if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->ajax->failure(Yii::t('FeedbackModule.feedback', 'It is not possible to send message!')); } Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, Yii::t('FeedbackModule.feedback', 'It is not possible to send message!')); } } else { if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->ajax->rawText(CActiveForm::validate($form)); } } } $this->render('index', ['model' => $form, 'module' => $module]); }
public function add_feedback() { $type = Input::get('type'); $title = Input::get('title'); $content = Input::get('content'); if (!isset($type)) { return Response::json(array('errCode' => 1, 'message' => '请选者反馈类型')); } if (!isset($title)) { return Response::json(array('errCode' => 2, 'message' => '请输入标题')); } if (!isset($content)) { return Response::json(array('errCode' => 3, 'message' => '请输入内容')); } $feedback = new Feedback(); $feedback->user_id = Sentry::getUser()->user_id; $feedback->type = $type; $feedback->title = $title; $feedback->content = $content; $feedback->status = 0; if (!$feedback->save()) { return Response::json(array('errCode' => 4, 'message' => '保存失败')); } return Response::json(array('errCode' => 0, 'message' => '保存成功')); }
public static function addFeedback($userId, $data) { $feedback = new Feedback(); $feedback->user_id = $userId; $feedback->attributes = $data; return $feedback->save(); die; }
* If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Feedback(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Feedback'])) { $model->attributes = $_POST['Feedback']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } }
public function accessRules() { return array(array('allow', 'actions' => array('index', 'view'), 'users' => array('*')), array('allow', 'actions' => array('create', 'update'), 'users' => array('@')), array('allow', 'actions' => array('admin', 'delete'), 'users' => array('admin')), array('deny', 'users' => array('*'))); } /** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $this->render('view', array('model' => $this->loadModel($id))); } /** * Creates a new model.
public function addFeedback($attr) { if (is_array($attr)) { $model = new Feedback(); $model->created_at = time(); $model->updated_at = time(); $model->setAttributes($attr); if ($model->save(FALSE)) { return $model; } } return FALSE; }
public function actionAjaxSave() { if (Yii::app()->request->isAjaxRequest) { $model = new Feedback(); $model->attributes = $_POST['Feedback']; if ($model->save()) { echo true; } Yii::app()->end(); } else { throw new CHttpException(400); } }
public function postCreate() { $validator = Validator::make(Input::all(), Feedback::$rules); if ($validator->passes()) { $feedback = new Feedback(); $feedback->title = Input::get('title'); $feedback->body = Input::get('body'); $user = Auth::user(); $feedback->user_id = $user->id; $feedback->save(); return Redirect::to('feedbacks/index')->with('message', 'Feedback Created'); } return Redirect::to('feedbacks/formcreate')->with('message', 'Something went wrong')->withErrors($validator)->withInput(); }
public function submit() { if ($this->validate()) { $feedback = new Feedback(); $feedback->name = $this->name; $feedback->content = $this->content; $feedback->email = $this->email; $feedback->phone = $this->phone; $feedback->create_time = date('Y-m-d'); $feedback->is_reply = 0; return $feedback->save(); } return false; }
public function actionCustomer() { $this->layout = false; if (isset($_POST['feedback'])) { $model = new Feedback(); $errorMessage = null; $createFeedback = json_decode($_POST['feedback'], true); $sql_existFeedback = "SELECT * FROM `st_feedback` WHERE order_id = '" . $createFeedback['order_id'] . "'"; if (!Order::model()->existOrderByOrderId($createFeedback['order_id'])) { $errorMessage = "订单号有错,请核实后重新输入"; } elseif (is_dir("images/feedback/" . $createFeedback['order_id'])) { $errorMessage = "已经提交过问题,请等候处理,或直接与客服人员联系"; } else { $model->order_id = $createFeedback['order_id']; $model->text = $createFeedback['content_text']; $model->contact_method = isset($createFeedback['contact_method']) ? $createFeedback['contact_method'] : null; $model->create_time = date("Y-m-d H:i:s"); $model->dealed = 2; if (!$model->save()) { $errorMessage = "提交的信息可能有误,请重新提交或者与客服联系。"; } if (isset($_POST['image'])) { $images = CUploadedFile::getInstancesByName('image'); if (isset($images) && count($images) > 0) { foreach ($images as $image => $pic) { $pic->saveAs(Yii::getPathOfAlias('webroot') . '/images/feedback/' . $order_id . $pic->name); } } $model->photo_name = "feedback.png"; } if (!$model->save()) { $errorMessage = "提交的信息可能有误,请重新提交或者与客服联系。"; } } $this->render('customer', array('errorMessage' => $errorMessage)); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Feedback(); if (Yii::app()->user->id) { $model->email = Yii::app()->user->getModel()->email; $model->name = Yii::app()->user->getModel()->getName(); } if (isset($_POST['Feedback'])) { $model->attributes = $_POST['Feedback']; if ($model->save()) { $this->redirect('/feedback/index'); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Feedback(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Feedback'])) { $model->attributes = $_POST['Feedback']; if ($model->save()) { if (Yii::app()->user->getLevel() == 3) { $this->redirect(array('view', 'id' => $model->id_feedback)); } Yii::app()->user->setFlash('notifFeedback', 'Feedback telah dikirim.'); $this->redirect(array('create')); } } $this->render('create', array('model' => $model)); }
public function add_feedback() { if (!Input::has('title')) { return Response::json(array('error_code' => 2, 'message' => '请输入标题')); } if (!Input::has('content')) { return Response::json(array('error_code' => 3, 'message' => '请输入反馈内容')); } $feedback = new Feedback(); $feedback->title = Input::get('title'); $feedback->content = Input::get('content'); $feedback->user_id = Session::get('user.id'); if (!$feedback->save()) { return Response::json(array('error_code' => 1, 'message' => '反馈失败')); } return Response::json(array('error_code' => 0, 'message' => '反馈成功')); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Feedback(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $panel_ident = $_REQUEST['panel_ident']; if (isset($_POST['Feedback'])) { $model->attributes = $_POST['Feedback']; $model->q_time = Time::now(); if ($model->save()) { // $model->addTags('tag1, tag2, tag3')->save(); $str = '反馈 ' . $model->id . ' 已新建 ' . Time::now(); Yii::app()->user->setFlash('success', $str); $this->redirect(array('update', 'id' => $model->id)); } } $this->render('create', array('model' => $model), false, true); }
public function actionCustomer() { $this->layout = false; if (isset($_POST['feedback'])) { $model = new Feedback(); $errorMessage = null; $createFeedback = json_decode($_POST['feedback'], true); if (!isset($createFeedback['order_id']) || !Order::model()->existOrderByOrderId($createFeedback['order_id'])) { $errorMessage = Yii::t('feedback', 'Error orderid, please try again!'); $this->render('customer', array('errorMessage' => $errorMessage)); return 0; } elseif (is_dir("images/feedback/" . $createFeedback['order_id'])) { $errorMessage = Yii::t('feedback', 'Feedback has already submited please wait!'); $this->render('customer', array('errorMessage' => $errorMessage)); return 0; } elseif (!isset($createFeedback['content_text']) || $createFeedback['content_text'] === null) { $errorMessage = Yii::t('feedback', 'Text can not be blank!'); $this->render('customer', array('errorMessage' => $errorMessage)); return 0; } else { $model->order_id = $createFeedback['order_id']; $model->text = $createFeedback['content_text']; $model->contact_method = isset($createFeedback['contact_method']) ? $createFeedback['contact_method'] : null; $model->create_time = date("Y-m-d H:i:s"); $model->dealed = 2; $images = CUploadedFile::getInstancesByName('image'); if (isset($images)) { mkdir(Yii::getPathOfAlias('webroot') . '/images/feedback/' . $model->order_id . '/'); chmod(Yii::getPathOfAlias('webroot') . '/images/feedback/' . $model->order_id . '/', 0755); if (isset($images) && count($images) > 0) { foreach ($images as $image => $pic) { $pic->saveAs(Yii::getPathOfAlias('webroot') . '/images/feedback/' . $model->order_id . '/' . $pic->name); } } $model->photo_name = "feedback.png"; } if (!$model->save()) { $errorMessage = Yii::t('feedback', 'Feedback message has error, please try again!'); } } $this->render('customer', array('errorMessage' => $errorMessage)); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'update' page. */ public function actionCreate() { $this->breadcrumbs = array('Список обращений' => array('/feedback'), 'Новая запись'); $model = new Feedback(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); // set attributes from get if (isset($_GET['Feedback'])) { $model->attributes = $_GET['Feedback']; } if (isset($_POST['Feedback'])) { $model->attributes = $_POST['Feedback']; if ($model->save()) { $url = isset($_POST['go_to_list']) ? $this->listUrl('index') : $this->itemUrl('update', $model->id); $this->redirect($url); } } $this->render('create', array('model' => $model)); }
/** * Сохраняем данные в СУБД, при наявности POST-запросаЖ * * @param AnswerForm $form - форма ответа * @param Feedback $model - модель * * @return mixed */ public function saveAnswer(AnswerForm $form, Feedback $model) { if (Yii::app()->getRequest()->getIsPostRequest() && ($data = Yii::app()->getRequest()->getPost('AnswerForm')) !== null) { $form->setAttributes($data); if ($form->validate()) { $model->setAttributes(array('answer' => $form->answer, 'status' => Feedback::STATUS_FINISHED)); if ($model->save(true, array('answer', 'status'))) { //отправка ответа $mail = Yii::createComponent('yupe\\components\\Mail'); $body = $this->renderPartial('answerEmail', array('model' => $model), true); $mail->send(Yii::app()->getModule('feedback')->notifyEmailFrom, $model->email, 'RE: ' . $model->theme, $body, Yii::app()->getModule('yupe')->siteName); Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('FeedbackModule.feedback', 'Reply on message was sent!')); $this->redirect($this->createUrl('view', array('id' => $model->id))); } else { return array($form, $model); } } } return array($form, $model); }
/** * Обратный звонок */ public function actionFeedback() { $form = new FeedbackForm('insert'); $formName = get_class($form); $this->performAjaxValidation($form); if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST[$formName])) { $form->setAttributes($_POST[$formName]); // Проверка if ($form->validate()) { $feedback = new Feedback(); $feedback->setAttributes($form->getAttributes()); //var_dump($feedback->getAttributes()); //exit(); // Сохранение if ($feedback->save()) { // Отправка уведомления $this->_feedbackConfirmationEmail($feedback); if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->ajax->success(Yii::t('FeedbackModule.feedback', 'Ваше сообщение отправлено. Спасибо!')); } else { Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('FeedbackModule.feedback', 'Ваше сообщение отправлено. Спасибо!')); } // Обновляем страницу $this->refresh(); } else { // Ошибка сохранения if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->ajax->failure(Yii::t('FeedbackModule.feedback', 'There is an error when trying to send message! Please try later!')); } else { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('FeedbackModule.feedback', 'There is an error when trying to send message! Please try later!')); } } } else { if (Yii::app()->getRequest()->getIsAjaxRequest()) { echo CActiveForm::validate($form); Yii::app()->end(); } } } $this->render('feedback', array('model' => $form)); }
/** * Store a newly created resource in storage. * * @return Response */ public function storeFeedback() { // Validate the inputs $validator = Validator::make(Input::all(), Feedback::$rules); // Check if the form validates with success if ($validator->passes()) { // Get the inputs, with some exceptions $data = Input::except('csrf_token'); $feedback = new Feedback(); $feedback->feed_back = $data['feed_back']; $feedback->consumer_id = Auth::id(); $feedback->deal_id = $data['deal_id']; if ($feedback->save()) { $feedbacks = Feedback::ByDealId($data['deal_id']); // Redirect to the new country page return View::make('site.feedbacks.index', 'feedbacks'); } } // Form validation failed return Redirect::to('feedback/create')->withInput()->withErrors($validator); }
public function actionCreate() { $allflag = Yii::app()->request->getParam('allflag', 0); $model = new Feedback(); $model->dpid = $this->companyId; if (Yii::app()->request->isPostRequest) { $model->attributes = Yii::app()->request->getPost('Feedback'); $se = new Sequence("feedback"); $model->lid = $se->nextval(); $model->allflag = $allflag; $model->create_at = date('Y-m-d H:i:s', time()); $model->update_at = date('Y-m-d H:i:s', time()); $model->delete_flag = '0'; //var_dump($model);exit; if ($model->save()) { Yii::app()->user->setFlash('success', yii::t('app', '添加成功')); $this->redirect(array('feedback/index', 'companyId' => $this->companyId, 'allflag' => $allflag)); } } $this->render('create', array('model' => $model, 'allflag' => $allflag)); }
/** * 用户反馈 */ public function actionFeedback() { $this->checkUser(); $uid = $this->uid; $attr['uid'] = $uid; $attr['type'] = $this->appPlatform; $attr['contact'] = $this->getValue('contact', 0); $attr['appinfo'] = $this->getValue('appinfo', 0); $attr['sysinfo'] = $this->getValue('sysinfo', 0); $attr['content'] = $this->getValue('content', 1); $model = new Feedback(); $model->attributes = $attr; if ($model->validate()) { if ($model->save()) { $this->output('感谢您的反馈', $this->succCode); } else { $this->output('感谢您的反馈', $this->succCode); } } else { $this->output('反馈失败,请重试', $this->errorCode); } }
/** * Сохраняем данные в СУБД, при наявности POST-запроса * * @param AnswerForm $form - форма ответа * @param Feedback $model - модель * * @return mixed */ public function saveAnswer(AnswerForm $form, Feedback $model) { if (Yii::app()->getRequest()->getIsPostRequest() && ($data = Yii::app()->getRequest()->getPost('AnswerForm')) !== null) { $form->setAttributes($data); if ($form->validate()) { $model->setAttributes(['answer' => $form->answer, 'answer_user' => Yii::app()->user->getId(), 'answer_time' => new CDbExpression('NOW()'), 'status' => Feedback::STATUS_ANSWER_SENDED]); if ($model->save()) { //отправка ответа $body = $this->renderPartial('answerEmail', ['model' => $model], true); Yii::app()->mail->send(Yii::app()->getModule('feedback')->notifyEmailFrom, $model->email, 'RE: ' . $model->theme, $body); if (Yii::app()->getRequest()->getIsAjaxRequest() == false) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('FeedbackModule.feedback', 'Reply on message was sent!')); $this->redirect(['/feedback/feedbackBackend/view/', 'id' => $model->id]); } else { Yii::app()->ajax->success(['message' => Yii::t('FeedbackModule.feedback', 'Reply on message was sent!')]); return true; } } else { return [$form, $model]; } } } return [$form, $model]; }
/** * * Show/handle feedback form */ public function showFeedback() { $form = new Form(); $inputName = new InputText('name'); $inputName->addValidator(new Validator()); $form->addElement($inputName, 'Naam (verplicht)'); $inputEmail = new InputText('email'); $inputEmail->addValidator(new EmailValidator(false)); $form->addElement($inputEmail, 'E-mailadres (niet verplicht)'); $inputMessage = new TextArea('comment'); $inputMessage->addValidator(new LengthValidator(true, 20, 1000)); $form->addElement($inputMessage, 'Feedback (verplicht)'); $this->assign('form', $form); $this->template = '/feedback/feedback.form.tpl'; // Validate if this form has just been posted if ($form->isPosted()) { $form->validate(); if ($form->getErrors()) { $this->assign('hasErrors', true); $this->assign('errors', $form->getErrors()); } else { // Save feedback $oFeedback = new Feedback(); $oFeedback->name = htmlentities($inputName->getValue()); $oFeedback->email = htmlentities($inputEmail->getValue()); $oFeedback->message = htmlentities($inputMessage->getValue()); $oFeedback->ip = $_SERVER['REMOTE_ADDR']; $oFeedback->save(); $this->assign('feedback', $oFeedback); $this->template = '/feedback/feedback.confirm.tpl'; } } $this->assignSettings(); $this->smarty->display('templates' . $this->template); }
/** * Test #17. * The findByHash function returns an object populated with previous * values if a hash for a previous instance is given. * @depends testUpdate * @depends testHashGetInstance */ public function testHashOldInstance() { global $testTripId1, $testReferenceId1, $testUserId1; // create the object and save it $object = new Feedback($testTripId1, $testReferenceId1, $testUserId1); $object->setType("like"); $object->setDeleted('N'); $this->assertTrue($object->save()); $this->assertEquals(1, $this->countTestRows()); $old_hash = $object->getHash(); // change values and update the object $object->setType("off"); $object->setDeleted('Y'); $this->assertTrue($object->save()); $this->assertEquals(2, $this->countTestRows()); $new_hash = $object->getHash(); // read the object from the database and confirm that the old // values are returned $object = Feedback::findByHash($old_hash); $this->assertNotNull($object); $this->assertEquals($testTripId1, $object->getTripId()); $this->assertEquals($testReferenceId1, $object->getReferenceId()); $this->assertEquals($testUserId1, $object->getUserId()); $this->assertEquals("like", $object->getType()); $this->assertEquals('N', $object->getDeleted()); $this->assertEquals($old_hash, $object->getHash()); // read the new object from the database and confirm that the new // values are returned $object = Feedback::findByHash($new_hash); $this->assertNotNull($object); $this->assertEquals($testTripId1, $object->getTripId()); $this->assertEquals($testReferenceId1, $object->getReferenceId()); $this->assertEquals($testUserId1, $object->getUserId()); $this->assertEquals("off", $object->getType()); $this->assertEquals('Y', $object->getDeleted()); $this->assertEquals($new_hash, $object->getHash()); }
<?php require_once "inc/init.php"; if (!Session::getUser()) { CommonUtil::redirect("index"); exit(0); } if (!isset($_POST["feedback"])) { CommonUtil::redirect("index"); exit(0); } $fb = new Feedback(); $fb->user = Session::getUser()->id; $fb->feedback = $_POST["feedback"]; $fb->timestamp = Database::now(); $fb->save(); require "views/head.php"; ?> <div style="width: 20em; padding: 2em; background-color: #555; margin: 3em auto; color: #f5f5f5"> <h2>Kiitos palautteestasi!</h2> <p>Sivu uudelleenohjaa <a href="index">etusivulle</a> automaattisesti kolmen sekunnin kuluessa.</p> </div> <script> setTimeout(function(){ document.location = "index"; },3000); </script> <?php require "views/foot.php";
/** * Отправление подтверждения пользователю и уведомления админу * @param DictionaryData $type * @return FeedbackForm $feedbackForm */ protected function _processForm($type) { if ($type->id == Feedback::TYPE_CALLBACK) { $feedbackForm = new CallbackForm('insert'); } elseif ($type->id == Feedback::TYPE_ORDER) { $feedbackForm = new OrderForm('insert'); } elseif ($type->id == Feedback::TYPE_REVIEW) { $feedbackForm = new ReviewForm('insert'); } else { $feedbackForm = new FeedbackForm('insert'); } $formName = get_class($feedbackForm); $this->performAjaxValidation($feedbackForm); if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST[$formName])) { $feedbackForm->setAttributes($_POST[$formName]); // Проверка if ($feedbackForm->validate()) { $feedback = new Feedback(); $feedback->type_id = $type->id; $feedback->type = $type; $feedback->setAttributes($feedbackForm->getAttributes()); if ($type->id == Feedback::TYPE_ORDER && isset($_POST['productId']) && !empty($_POST['productId'])) { Yii::import("application.modules.catalog.models.Product"); $product = Product::model()->findByPk((int) $_POST['productId']); if (is_null($product)) { throw new CHttpException('404'); } $feedback->theme = 'Заявка на товар "' . $product->title . '"'; $feedback->text = '<p>Ссылка на товар: ' . CHtml::link($product->title, $product->getPermaLink()) . '</p>'; } // Сохранение if ($feedback->save()) { // Отправка уведомлений if (Yii::app()->getModule('feedback')->sendConfirmation) { $this->_feedbackConfirmationEmail($feedback); } $successMessage = $type->id == Feedback::TYPE_ORDER ? 'Ваше сообщение отправлено! Спасибо! В ближайшее время наши менеджеры свяжутся с Вами!' : 'Ваше сообщение отправлено! Спасибо!'; if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->ajax->success($successMessage); } else { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, $successMessage); } } else { // Ошибка сохранения if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->ajax->failure(Yii::t('FeedbackModule.feedback', 'There is an error when trying to send message! Please try later!')); } else { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('FeedbackModule.feedback', 'There is an error when trying to send message! Please try later!')); } } // Обновляем страницу $this->refresh(); } else { // Ошибка валидации if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->ajax->failure('Пожалуйста, проверьте правильность заполнения формы'); } } } return $feedbackForm; }
public function feedback() { $writer = Student::where('auth', '=', Input::get('auth'))->first(); $feedClass = Input::get('class'); $commit = Input::get('commit'); $system = Input::get('system'); $feedback = new Feedback(); $feedback->feedClass = $feedClass; $feedback->commit = $commit; $feedback->stu_id = $writer->id; $feedback->system = $system; $feedback->checked = 0; $feedback->save(); return "suc"; }