/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new User();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->password = getHash($model->password);
         if (Yii::app()->user->isFranchiseAdmin()) {
             $model->franchise = Yii::app()->user->franchise;
             $model->role_id = 2;
         }
         if (Yii::app()->user->isAdmin()) {
             $franchise = new Franchise();
             $franchise->name = $model->username;
             $franchise->save();
             $model->franchise = $franchise->id;
             $model->role_id = 3;
         }
         if ($model->save()) {
             //                $this->redirect(array('view', 'id' => $model->id));
             $this->redirect(array('user/admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Franchise();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Franchise'])) {
         $model->attributes = $_POST['Franchise'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }