Ejemplo n.º 1
0
 public function actionComment()
 {
     if (!isset($_GET['id'])) {
         throw new CHttpException(500, "Ломаешь?");
     }
     /**
      * @var $model SupportTickets
      */
     $model = SupportTickets::model()->findByAttributes(["userId" => Yii::app()->user->id, "id" => $_GET['id']]);
     if (!$model) {
         throw new CHttpException(404, "Не найдено");
     }
     if (Yii::app()->request->isPostRequest) {
         if (isset($_POST['content']) && isset($_POST['toClose'])) {
             if ($_POST['toClose'] == 1) {
                 $model->status = 2;
             } else {
                 $model->status = 0;
             }
             $model->save();
             $m2 = new SupportTicketsComments();
             $m2->ticketId = $model->id;
             $m2->userId = Yii::app()->user->id;
             $m2->datePosted = time();
             $m2->isAnswer = 0;
             $m2->content = $_POST['content'];
             $m2->save();
             $this->redirect($this->createUrl("list"));
         } else {
             $this->redirect($this->createUrl("view", ["id" => $model->id]));
         }
     }
 }
Ejemplo n.º 2
0
 public function actionComment()
 {
     if (!isset($_GET['id'])) {
         throw new CHttpException(500, "Ломаешь?");
     }
     /**
      * @var $model SupportTickets
      */
     $model = SupportTickets::model()->findByPk($_GET['id']);
     if (!$model) {
         throw new CHttpException(404, "Не найдено");
     }
     if (Yii::app()->request->isPostRequest) {
         if (isset($_POST['content']) && isset($_POST['toClose'])) {
             if ($_POST['toClose'] == 1) {
                 $model->status = 2;
             } else {
                 $model->status = 1;
             }
             $model->save();
             $m2 = new SupportTicketsComments();
             $m2->ticketId = $model->id;
             $m2->userId = Yii::app()->user->id;
             $m2->datePosted = time();
             $m2->isAnswer = 1;
             $m2->content = $_POST['content'];
             $m2->save();
             Yii::import('ext.yii-mail.*');
             $message = new YiiMailMessage();
             $message->view = 'supportNewReply';
             $message->setSubject('Тикет #' . $model->id . " - Новый ответ");
             $message->setBody(array('model' => $model), 'text/html');
             $message->setTo($model->user->email);
             $message->from = array(Yii::app()->params['adminEmail'] => 'Crystal Reality Games');
             Yii::app()->mail->send($message);
             $this->redirect($this->createUrl("index"));
         } else {
             $this->redirect($this->createUrl("view", ["id" => $model->id]));
         }
     }
 }