예제 #1
0
 public function getFeedbackForm()
 {
     require_once APPLICATION_PATH . '/forms/FeedbackForm.php';
     $form = new FeedbackForm();
     $form->setAction($this->_helper->url('feedback'));
     return $form;
 }
예제 #2
0
 /**
  * Display feedback form
  */
 public function actionIndex()
 {
     Yii::import('feedback.models.FeedbackForm');
     $model = new FeedbackForm();
     if (isset($_POST['FeedbackForm'])) {
         $model->attributes = $_POST['FeedbackForm'];
     }
     if (Yii::app()->request->isPostRequest && $model->validate()) {
         $model->sendMessage();
         Yii::app()->request->redirect($this->createUrl('index'));
     }
     $this->render('index', array('model' => $model));
 }
예제 #3
0
 public function actionIndex()
 {
     $this->pageTitle = Yii::t('common', '反馈中心') . SEPARATOR . Setting::getValueByCode('inside_title', true);
     $criteria = new CDbCriteria();
     $criteria->compare('is_reply', 1);
     $criteria->order = 'id DESC';
     $criteria->limit = 5;
     $feedbacks = Feedback::model()->findAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->compare('t.banner_position_id', 4);
     $banner = Banner::model()->localized()->find($criteria);
     $this->layout = 'main';
     $feedbackForm = new FeedbackForm();
     if (isset($_POST['FeedbackForm'])) {
         $feedbackForm->setAttributes($_POST['FeedbackForm']);
         if ($feedbackForm->submit()) {
             $this->redirect(array('success'));
         }
     }
     $this->render('index', array('feedbacks' => $feedbacks, 'feedbackForm' => $feedbackForm, 'banner' => $banner));
 }
예제 #4
0
 public function actionIndex()
 {
     $form = new FeedbackForm();
     if (Yii::app()->request->isPostRequest) {
         $params = Yii::app()->request->getParam('FeedbackForm');
         $form->setAttributes($params);
         if ($form->validate()) {
             $mail = new YiiMailer();
             $mail->setView('feedback');
             $mail->setData(['form' => $form]);
             $mail->setFrom($form->email, $form->name);
             $mail->setReplyTo($form->email);
             $mail->setTo(Yii::app()->params->adminEmail);
             $mail->setSubject('Система расписания: ' . $form->subject);
             if ($mail->send()) {
                 Yii::app()->user->setFlash('success', 'Ваше сообщение отправлено, спасибо!');
                 $form->unsetAttributes();
             } else {
                 Yii::app()->user->setFlash('error', 'Ошибка при отправке');
             }
         }
     }
     $this->render('index', ['model' => $form]);
 }
 public function configure()
 {
     self::$subjects = sfConfig::get('app_feedback_subjects', array('Subject A', 'Subject B', 'Subject C'));
     $this->widgetSchema->setNameFormat('feedback[%s]');
     $this->setWidgets(array('name' => new sfWidgetFormInput(array(), array('placeholder' => 'First and last name')), 'email' => new sfWidgetFormInputEmail(array(), array('placeholder' => '*****@*****.**')), 'subject' => new sfWidgetFormSelect(array('choices' => self::$subjects)), 'message' => new sfWidgetFormTextarea(array(), array('placeholder' => 'Tell us what you want to say...'))));
     $this->widgetSchema->setNameFormat('feedback[%s]');
     $this->setValidators(array('name' => new sfValidatorString(array('required' => false)), 'email' => new sfValidatorEmail(), 'subject' => new sfValidatorChoice(array('choices' => array_keys(self::$subjects))), 'message' => new sfValidatorString(array('min_length' => 4))));
     $this->widgetSchema->setLabels(array('name' => 'Your Name', 'email' => 'Your Email Address', 'subject' => 'Subject', 'message' => 'Your Message'));
     if (sfConfig::get('app_recaptcha_active', false)) {
         $this->setWidget('response', new sfWidgetFormInputHidden());
         $this->validatorSchema->setPostValidator(new sfValidatorSchemaReCaptcha('challenge', 'response'));
         $this->validatorSchema->setOption('allow_extra_fields', true);
         $this->validatorSchema->setOption('filter_extra_fields', false);
     }
     parent::configure();
 }
 public function doSendFeedback()
 {
     if (Input::get('type') == 'private') {
         $validator = Validator::make(array('last_name' => trim(Input::get('last_name')), 'first_name' => trim(Input::get('first_name')), 'patronymic_name' => trim(Input::get('patronymic_name')), 'phone_number' => trim(Input::get('phone_number')), 'email' => trim(Input::get('email')), 'question' => trim(Input::get('question'))), array('last_name' => 'required|min:2|max:32', 'first_name' => 'required|min:2|max:32', 'patronymic_name' => 'required|min:2|max:32', 'phone_number' => 'required|min:7|max:7', 'email' => 'required|email|min:6|max:32', 'question' => 'required'));
         if ($validator->fails()) {
             return Response::json(array('status' => false));
         }
         FeedbackForm::create(array('id_theme' => Input::get('subject'), 'full_name' => trim(Input::get('last_name')) . ' ' . trim(Input::get('first_name')) . ' ' . trim(Input::get('patronymic_name')), 'phone_number' => trim(Input::get('phone_code')) . trim(Input::get('phone_number')), 'email' => trim(Input::get('email')), 'question' => trim(Input::get('question')), 'is_bank_client' => 0, 'is_active' => 0));
     } else {
         $validator = Validator::make(array('name' => trim(Input::get('name')), 'phone_number' => trim(Input::get('phone_number')), 'email' => trim(Input::get('email')), 'question' => trim(Input::get('question'))), array('name' => 'required|min:2|max:255', 'phone_number' => 'required|min:7|max:7', 'email' => 'required|email|min:6|max:32', 'question' => 'required'));
         if ($validator->fails()) {
             return Response::json(array('status' => false));
         }
         FeedbackForm::create(array('id_theme' => Input::get('subject'), 'full_name' => trim(Input::get('name')), 'phone_number' => trim(Input::get('phone_code')) . trim(Input::get('phone_number')), 'email' => trim(Input::get('email')), 'question' => trim(Input::get('question')), 'is_bank_client' => 1, 'is_active' => 0));
     }
     return Response::json(array('status' => true));
 }
예제 #7
0
 public function actionFeedback()
 {
     $model = new FeedbackForm();
     if ($_POST['FeedbackForm']) {
         $model->setAttributes($_POST['FeedbackForm']);
         if (!Yii::app()->user->isGuest) {
             $model->email = Yii::app()->user->getModel()->email;
             $model->name = Yii::app()->user->getModel()->getName();
         }
         if ($model->send()) {
             $this->render('page', array('page' => 'Ваше уведомление отправлено!'));
             Yii::app()->end();
         }
     }
     $this->render('feedback', array('model' => $model));
 }
예제 #8
0
 /**
  * Отправка письма администратору
  */
 public function actionFeedback()
 {
     $model = new FeedbackForm();
     if (isset($_POST['FeedbackForm'])) {
         $model->attributes = $_POST['FeedbackForm'];
         if ($model->validate()) {
             $headers = "From: {$model->email}\r\nReply-To: {$model->email}";
             if (mail(Yii::app()->params['adminEmail'], $model->name, $model->message, $headers)) {
                 echo CJSON::encode(array('success' => 'ok'));
                 exit;
             }
         } else {
             echo CJSON::encode(array('error' => 'ok'));
             exit;
         }
     } else {
         $popup = $this->renderPartial('_feedbackform', array('model' => $model), true);
         echo CJSON::encode(array('popup' => $popup));
         exit;
     }
 }