public function actionIndex()
 {
     $model = new CreateTicketForm();
     $request = Yii::app()->request;
     $formData = $request->getPost(get_class($model), false);
     if ($formData) {
         $model->attributes = $formData;
         if (!$model->hasErrors()) {
             $newticket = new SupportTicket();
             $newticket->subject = $model->subject;
             $newticket_message = new SupportTicketMessage();
             $newticket_message->body = $model->body;
             if (!Yii::app()->user->isGuest) {
                 $user = Yii::app()->user->data();
                 $newticket->id_user = $user->id;
                 $newticket_message->id_user = $user->id;
             }
             if (!$newticket->save()) {
                 Yii::app()->user->setFlash('error', Yii::t('translation', 'Unable to create ticket'));
             } else {
                 $newticket_message->id_ticket = $newticket->id;
                 $newticket_message->save();
             }
             Yii::app()->user->setFlash('success', Yii::t('translation', ' Ticket #{ticket_id} Created', array('{ticket_id}' => $newticket->id)));
         }
     }
     $this->render('index', array('model' => $model));
 }
 public function actionCreate()
 {
     $model = new SupportTicket();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['SupportTicket'])) {
         $model->attributes = $_POST['SupportTicket'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->support_ticket_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function actionCreatesupport()
 {
     $model = new SupportTicket();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $model->support_ticket_code = $model->supportCode();
     $model->customer_id = Yii::app()->user->customerId;
     $model->date_added = new CDbExpression('NOW()');
     if (isset($_POST['SupportTicket'])) {
         $model->attributes = $_POST['SupportTicket'];
         if ($model->save()) {
             $this->redirect(array('supports'));
         }
     }
     $this->render('create_support', array('model' => $model));
 }