public function actionComplete($id)
 {
     $model = $this->loadModel($id);
     if (Yii::app()->user->getName() == $model->assignedTo || $model->assignedTo == 'Anyone' || $model->assignedTo == "" || Yii::app()->user->getName() == 'admin') {
         if (isset($_POST['note'])) {
             $model->actionDescription = $model->actionDescription . "\n\n" . $_POST['note'];
         }
         $model = $this->updateChangelog($model, 'Completed');
         $model->save();
         Actions::completeAction($id);
         $notif = new Notifications();
         $notif->record = "Actions:{$model->id}";
         $profile = CActiveRecord::model('ProfileChild')->findByAttributes(array('username' => Yii::app()->user->getName()));
         $notif->text = $profile->fullName . " completed an action.";
         $notif->user = '******';
         $notif->createDate = time();
         $notif->viewed = 0;
         $notif->save();
         $createNew = isset($_GET['createNew']) || isset($_POST['submit']) && $_POST['submit'] == 'completeNew';
         $redirect = isset($_GET['redirect']) || $createNew;
         if ($redirect) {
             if ($model->associationType != 'none' && !$createNew) {
                 // if the action has an association
                 $this->redirect(array($model->associationType . '/view', 'id' => $model->associationId));
                 // go back to the association
             } else {
                 // no association
                 if ($createNew) {
                     $this->redirect(array('/actions/create'));
                 } else {
                     $this->redirect(array('/actions/default/view', 'id' => $model->id));
                 }
                 // view the action
             }
         } else {
             $this->redirect(array('/actions/default/view', 'id' => $model->id));
         }
     } else {
         $this->redirect(array('/actions/invalid'));
     }
 }