public function actionIndex() { $model = new Tickets(); if (isset($_GET['Tickets'])) { $model->setAttributes($_GET['Tickets']); } $dataProvider = $model->search(); $this->render('//tickets/index', array('dataProvider' => $dataProvider, 'gs' => CHtml::listData(Gs::model()->cache(60)->findAll(), 'id', 'name'), 'categories' => CHtml::listData(TicketsCategories::model()->cache(60)->findAll(), 'id', 'title'), 'model' => $model)); }
/** * Create a new ticket */ public function actionCreate() { // Initiate Model $model = new Tickets(); $model->assignedtoid = ''; if (isset($_POST['Tickets'])) { $model->setScenario('ticketupdate'); $model->setAttributes($_POST['Tickets']); // Was the form submitted? if (isset($_POST['submit'])) { // Bug: assigntoid cannot be null if (!$model->assignedtoid) { $model->assignedtoid = 0; } if ($model->save()) { $comment = new TicketComments(); $comment->content = $model->content; $comment->ticketid = $model->id; $comment->firstcomment = 1; $comment->save(); // Update ticket id $model->lastcommentid = $comment->id; $model->update(); // Mark flash and redirect Functions::setFlash(Yii::t('tickets', 'Tickets: Ticket Created.')); $this->redirect(array('/tickets')); } } } // make sure we display the name of the if (isset($_POST['Tickets']['assignedtoid'])) { $model->assignedtoid = $_POST['Tickets']['assignedtoid']; } // Add title $title = Yii::t('tickets', 'Creating A Ticket'); $this->pageTitle[] = $title; $this->render('create', array('model' => $model, 'title' => $title)); }