/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new PriceTier();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (Yii::app()->user->checkAccess('item.create')) {
         if (isset($_POST['PriceTier'])) {
             $model->attributes = $_POST['PriceTier'];
             if ($model->validate()) {
                 $transaction = $model->dbConnection->beginTransaction();
                 try {
                     $model->modified_date = date('Y-m-d H:i:s');
                     if ($model->save()) {
                         $transaction->commit();
                         Yii::app()->clientScript->scriptMap['jquery.js'] = false;
                         echo CJSON::encode(array('status' => 'success', 'div' => "<div class=alert alert-info fade in> Successfully added ! </div>"));
                         Yii::app()->end();
                     }
                 } catch (Exception $e) {
                     $transaction->rollback();
                     print_r($e);
                 }
             }
         }
         if (Yii::app()->request->isAjaxRequest) {
             $cs = Yii::app()->clientScript;
             $cs->scriptMap = array('jquery.js' => false, 'bootstrap.js' => false, 'jquery.min.js' => false, 'bootstrap.notify.js' => false, 'bootstrap.bootbox.min.js' => false);
             echo CJSON::encode(array('status' => 'render', 'div' => $this->renderPartial('_form', array('model' => $model), true, true)));
             Yii::app()->end();
         } else {
             $this->render('update', array('model' => $model));
         }
     } else {
         throw new CHttpException(403, 'You are not authorized to perform this action');
     }
 }