public function actionReply()
 {
     $model = new TicketMessage();
     if (isset($_POST['TicketMessage'])) {
         $model->attributes = $_POST['TicketMessage'];
         if ($model->save()) {
             //更新T状态is_answered:1
             $t = Ticket::model()->findByPk($model->ticket_id);
             $t->is_answered = 1;
             $t->status = 'Staff-Reply';
             $t->lastreply_time = date('Y-m-d H:i:s');
             $t->save();
             Yii::app()->user->setFlash('view-ticket', 'Your notes has been posted successfully.');
             $this->redirect(array('ticket/view', 'id' => $model->ticket_id));
         }
     }
 }
 public function actionCreate()
 {
     $model = new OpenTicketForm();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['OpenTicketForm'])) {
         $model->attributes = $_POST['OpenTicketForm'];
         if ($model->validate()) {
             //开票操作一
             $ticket = new Ticket();
             $ticket->user_email = $model->user_email;
             $ticket->user_name = $model->user_name;
             $ticket->subject = $model->subject;
             $ticket->create_time = date('Y-m-d H:i:s');
             $ticket->update_time = date('Y-m-d H:i:s');
             $ticket->dept_id = 0;
             $ticket->topic_id = $model->help_topic;
             $ticket->user_id = Yii::app()->user->getState('user_id');
             $ticket->status = 'open';
             $ticket->is_answered = 0;
             if (!$ticket->save()) {
                 var_dump($ticket->errors);
                 die;
             }
             //print_r($ticket->errors);exit;
             //开票操作二
             $message = new TicketMessage();
             $message->ticket_id = $ticket->ticket_id;
             $message->staff_id = 0;
             $message->msg_content = $model->msg_content;
             $message->create_time = date('Y-m-d H:i:s');
             $message->update_time = date('Y-m-d H:i:s');
             $message->ip_address = '127.0.0.1';
             $message->save();
             //页面跳转
             Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
             $this->refresh();
         }
     }
     //$this->redirect(array('view','id'=>1));
     $this->render('create', array('model' => $model));
 }
예제 #3
0
 public function actionView($id)
 {
     $ticket = Ticket::model()->with('messages')->findByPk($id);
     if (!$ticket) {
         throw new CHttpException(404);
     }
     if ($ticket->client_id != Yii::app()->params['client_id']) {
         throw new CHttpException(401);
     }
     $this->pageName = Yii::t('SupportModule.default', 'MODULE_NAME');
     $modelForm = new TicketMessage();
     if (Yii::app()->request->isPostRequest && $ticket->status != 0) {
         $modelForm->attributes = $_POST['TicketMessage'];
         $modelForm->ticket_id = $ticket->id;
         $modelForm->user_id = Yii::app()->params['client_id'];
         if ($modelForm->validate()) {
             $modelForm->save(false);
             Yii::app()->user->setFlash('success', Yii::t('app', 'SUCCESS_MSG_SAND'));
             $this->refresh();
         }
     }
     $this->render('view', array('model' => $ticket, 'modelForm' => $modelForm));
 }