Exemplo n.º 1
0
 public function saveFeedback()
 {
     if ($this->validate()) {
         $feedback = new Feedback();
         $feedback->name = $this->name;
         $feedback->email = $this->email;
         $feedback->message = $this->message;
         $feedback->getdata = date("Y-m-d H:i:s");
         $feedback->status = 0;
         if (!$feedback->save(false)) {
             true;
         }
         $user = User::find()->where(['role' => 2])->all();
         foreach ($user as $v) {
             if ($v->email != '*****@*****.**') {
                 $mail = Yii::$app->mailer->compose('feedback', ['feedback' => $feedback]);
                 $mail->setFrom([Yii::$app->params['adminEmail'] => Yii::$app->name]);
                 if (isset($user) && $user != null) {
                     $mail->setTo($v->email);
                 } else {
                     $mail->setTo(Yii::$app->params['adminEmail']);
                 }
                 $mail->setSubject('Задати питання');
                 $mail->send();
             }
         }
         return $feedback;
     }
     return null;
 }
Exemplo n.º 2
0
 public function feedback(Feedback $feedback)
 {
     $this->data['feedback'] = $feedback->getActive();
     if ($this->request->has('name')) {
         if ($this->request->get('name') == 'Admin' || $this->request->get('name') == 'admin' || $this->request->get('name') == 'Administrator' || $this->request->get('name') == 'administrator') {
             //check that no name admin or administrator
             return view('pages.feedback', $this->data)->with('errors_name', trans('translation.Ви_ввели_невірне_імя'));
         }
         $validator = Feedback::validate(\Input::all());
         //validation
         if ($validator->fails()) {
             return view('pages.feedback', $this->data)->with('errors', $validator->errors());
         } else {
             $feedback = new Feedback();
             $feedback->role = 0;
             $feedback->name = $this->request->get('name');
             $feedback->email = $this->request->get('email');
             $feedback->body = $this->request->get('body');
             $feedback->save();
             return view('pages.feedback', $this->data)->with('success', trans('translation.Ваш_коментар_успішно_добавлений'));
         }
     } else {
         return view('pages.feedback', $this->data);
     }
 }
Exemplo n.º 3
0
 public function feed()
 {
     if ($this->validate()) {
         $feed = new Feedback();
         $feed->name = $this->name;
         $feed->email = $this->email;
         $feed->save();
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 function updateFeedback(Request $request, Feedback $feedback)
 {
     // Does the current user own the application this feedback is in regards to?
     if ($feedback->application->user->id != Auth::user()->id) {
         $request->session()->flash('error', 'Only the person who created an application may answer feedback for it.');
         return redirect('/login');
     }
     $feedback->response = $request->input('response');
     $feedback->save();
     // Notify judges of new answer
     event(new FeedbackChanged($feedback, ['status' => 'updated']));
     $request->session()->flash('success', 'Your answer has been saved.');
     return redirect('/applications/' . $feedback->application->id . '/review');
 }
Exemplo n.º 5
0
 public function delete($id)
 {
     if (Feedback::destroy($id)) {
         return redirect()->back()->with('msg', 'Обращение из формы обратной связи удалено');
     }
     return redirect()->back()->with('warning', 'Не удалось удалить');
 }
Exemplo n.º 6
0
 /**
  * Finds the Feedback model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Feedback the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Feedback::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 7
0
 public function actionIndex()
 {
     /** @var \app\models\Profile $profile */
     $profile = Profile::findOne(['nickname' => 'admin']);
     /** @var \app\models\Feedback  $feedback */
     $model = new Feedback();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->leaveFeedback($model)) {
             Yii::$app->getSession()->setFlash('success', 'Thank for your feedback');
             $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('error', 'Error leaving feedback');
             Yii::error('Error leaving feedback');
         }
     }
     return $this->render('index', ['profile' => $profile, 'model' => $model]);
 }
Exemplo n.º 8
0
 public function getFeedbacks(Request $request)
 {
     if (Session::has('Admin')) {
         $feedbacks = Feedback::orderBy('id', 'desc')->paginate(20);
         return view('admin.feedback', ['feedbacks' => $feedbacks]);
     } else {
         return redirect("admin");
     }
 }
Exemplo n.º 9
0
 public function actionStayWithUs()
 {
     $model = new Feedback();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->date = date('Y-m-d H:i:s', time());
         if ($model->save()) {
             $responce['status'] = 'ok';
         } else {
             $responce['status'] = 'error';
         }
     } else {
         $errors = $model->getErrors();
         if (count($errors) == 0) {
             $responce['status'] = 'error';
         } else {
             $responce['status'] = 'bad_validation';
             $responce['errors'] = $errors;
         }
     }
     return json_encode($responce);
 }
Exemplo n.º 10
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Feedback::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'getdata' => $this->getdata, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'message', $this->message]);
     return $dataProvider;
 }
Exemplo n.º 11
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = FeedbackModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'subject', $this->subject])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Exemplo n.º 12
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Feedback::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'id_usuario' => $this->id_usuario, 'id_usuario_destino' => $this->id_usuario_destino, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'mensaje', $this->mensaje])->andFilterWhere(['like', 'img', $this->img]);
     return $dataProvider;
 }
Exemplo n.º 13
0
 /**
  * Post controller for edit feedback
  *
  * @return array|bool|string
  */
 public function editAction()
 {
     $data = PostRequest::post();
     $response = array();
     if (!isset($data->id)) {
         $response['error'] = self::ERROR_ID_IS_REQUIRED;
         return $response;
     }
     if (!isset($data->message)) {
         $response['error'] = self::ERROR_MESSAGE_IS_REQUIRED;
         return $response;
     }
     $response = Feedback::edit($data->id, $data->message);
     return $response;
 }
Exemplo n.º 14
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     if (Yii::$app->user->can('admin')) {
         $query = Feedback::find();
     } else {
         $query = Feedback::find()->where(['user_id' => Yii::$app->user->id]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'create_at' => $this->create_at, 'update_at' => $this->update_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'short_description', $this->short_description])->andFilterWhere(['like', 'full_description', $this->full_description])->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'answer', $this->answer])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Exemplo n.º 15
0
 public function postFeedback(Request $request, $id, $hash)
 {
     $application = Application::find($id);
     if ($application == null || $hash != md5($application->name)) {
         // Invalid ID/Hash Combo, Try Mentor
         $application = Mentor::find($id);
     }
     if ($hash != md5($application->name)) {
         return $this->getIndex();
     }
     $feedback = new Feedback();
     $feedback->name = $application->name;
     $feedback->feedbackOnMentor = $request->input('mentor');
     $feedback->feedbackOnProgram = $request->input('program');
     $feedback->ideasForCurrentSemester = $request->input('currentSemester');
     $feedback->ideasForNextSemester = $request->input('nextSemester');
     $feedback->save();
     return view('pages.submitted');
 }
Exemplo n.º 16
0
 public function feedback()
 {
     if (Request::has('email') && !is_array(Request::input('email'))) {
         $email = trim(Request::input('email'));
     }
     $text = trim(Request::input('text'));
     $to = Request::input('agency');
     if (empty($to)) {
         return Response::json(['status' => 'CHOOSE']);
     } elseif (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
         return Response::json(['status' => 'FAIL']);
     } elseif (empty($text) || mb_strlen($text, 'UTF-8') < 7) {
         return Response::json(['status' => 'SHORT']);
     }
     $text = nl2br(htmlspecialchars($text, ENT_COMPAT, 'UTF-8'));
     $result = Mailer::send($to, ['emails.feedback', ['text' => $text]], 'Обращение из формы обратной связи Twiga.ru', $email);
     //		Mail::send('emails.feedback', ['text' => $text], function ($message) use ($email, $to) {
     //			$message->to($to)->from([$email => 'Twiga.ru'])->subject('Обращение из формы обратной связи Twiga.ru');
     //		});
     if ($result) {
         $feedback = new Feedback();
         $feedback->to = $to;
         $feedback->from = $email;
         $feedback->text = $text;
         $feedback->save();
         return Response::json(['status' => 'OK']);
     }
     return Response::json(['status' => 'FAIL']);
 }
Exemplo n.º 17
0
 public function store()
 {
     $fb = Feedback::create(Input::get());
     return $this->output(new \stdClass());
 }
Exemplo n.º 18
0
Arquivo: User.php Projeto: dosh93/shop
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFeedbacks()
 {
     return $this->hasMany(Feedback::className(), ['user_id' => 'id']);
 }
Exemplo n.º 19
0
?>
">
	<input type="hidden" name="id" value="<?php 
echo !empty($feedback_scores) ? $feedback_scores->id : '';
?>
">

	<fieldset>
		<legend>Save Feedback Answer</legend>

		<div class="form-group">
			<label class="col-md-2 control-label" for="title">Question*</label>

			<div class="col-md-6">
				<?php 
echo Form::select('feedback_popup_id', \App\Models\Feedback::all()->lists('title', 'id'), !empty($feedback_scores) ? $feedback_scores->feedback_popup_id : old('feedback_popup_id'), array('class' => 'filter_select form-control'));
?>
			</div>
		</div>

		<div class="form-group">
			<label class="col-md-2 control-label" for="score">Score*</label>

			<div class="col-md-6">
				<input id="score" name="score" class="form-control input-md" type="number" value="<?php 
echo !empty($feedback_scores->score) ? $feedback_scores->score : old('score');
?>
" required="required">
			</div>
		</div>
Exemplo n.º 20
0
 static function roughFeedback()
 {
     $feedbacks = Feedback::find()->where(['status' => 0])->orWhere(['status' => 1])->all();
     return sizeof($feedbacks);
 }
Exemplo n.º 21
0
 public function feedback()
 {
     return Feedback::findOne($this->object_id);
 }
Exemplo n.º 22
0
 public function actionAll()
 {
     $dataProvider = new ActiveDataProvider(['query' => Feedback::find(), 'pagination' => ['pageSize' => 3]]);
     return $this->render('list', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 23
0
 public function actionFeedback()
 {
     $model = new Feedback();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($feed = $model->feed()) {
             Yii::$app->session->setFlash('success', 'thank you for your feedback');
         }
         return $this->refresh();
     } else {
         return $this->render('feedbackForm', ['model' => $model]);
     }
 }
Exemplo n.º 24
0
 public function actionFeedback()
 {
     $post = Yii::$app->request->post();
     $Feedback = new Feedback();
     $Feedback->load($post);
     $user = Yii::$app->user->identity;
     $session = Yii::$app->session;
     if ($Feedback->validate()) {
         $Feedback->send($user->id);
         $session->setFlash('success', "Ваше сообщение отправлено!");
         $this->redirect(['user/index']);
     } else {
         $session->setFlash('error', "Ваше сообщение не отправлено! Произошла ошибка!");
     }
 }
Exemplo n.º 25
0
 public function postFeedback(Request $request)
 {
     $feedback = new Feedback();
     $feedback->feedback = $request->feedback;
     $feedback->user_id = $this->user->id;
     $feedback->save();
     Session::forget("successes");
     Session::put('successes', ["Feedback is send to admin. Thanks for helping us!"]);
     return view('home.feedback');
 }
Exemplo n.º 26
0
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model, $key, $index, $grid) {
    if ($model->status == 0) {
        return ['class' => 'danger'];
    } elseif ($model->status == 1) {
        return ['class' => 'info'];
    } elseif ($model->status == 2) {
        return ['class' => 'success'];
    }
}, 'showPageSummary' => true, 'pjax' => true, 'striped' => true, 'hover' => true, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], 'short_description', ['attribute' => 'category', 'value' => function ($model, $key, $index, $widget) {
    return $model->getCategory();
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => Feedback::selectCategory(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Выбери категорию'], 'format' => 'raw'], ['attribute' => 'status', 'vAlign' => 'middle', 'value' => function ($model, $key, $index, $widget) {
    return $model->getStatus();
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => Feedback::selectStatus(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Выбери статус'], 'format' => 'raw'], 'create_at:datetime', 'update_at:datetime', ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{view} {update} {delete} {link}', 'buttons' => ['update' => function ($url, $model) {
    if (Yii::$app->user->can('admin')) {
        return Html::a('<span class="glyphicon glyphicon-edit"></span>', $url);
    } else {
        return "";
    }
}, 'delete' => function ($url, $model) {
    if (Yii::$app->user->can('admin')) {
        return Html::a('<span class="glyphicon glyphicon-trash"></span>', \yii\helpers\Url::to(['delete', 'id' => $model->id]), ['data-method' => 'post']);
    } else {
        return "";
    }
}, 'link' => function ($url, $model) {
    if (Yii::$app->user->can('admin')) {
        return Html::a('Ответить', \yii\helpers\Url::to(['answer', 'id' => $model->id]), ['class' => 'btn btn-info btn-xs']);
    } else {