/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Zakaz();
     if (!isset($model->unixtime)) {
         $model->unixtime = time();
     }
     if (User::model()->isManager() || User::model()->isAdmin()) {
         $model->is_active = 1;
     } else {
         $model->status = 1;
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Zakaz'])) {
         $model->attributes = $_POST['Zakaz'];
         if (!(User::model()->isManager() || User::model()->isAdmin())) {
             $model->user_id = Yii::app()->user->id;
             $model->dbmanager_informed = date('d.m.Y H:i');
             $model->dbdate = date('d.m.Y H:i');
             $d1 = date_create();
             $d2 = date_create($model->dbmax_exec_date);
             $d1->modify('+' . intval(date_diff($d1, $d2)->days / 2) . ' days');
             $model->dbauthor_informed = $d1->format('d.m.Y H:i');
         }
         if ($model->save()) {
             if (!(User::model()->isManager() || User::model()->isAdmin())) {
                 EventHelper::createOrder($model->id);
             }
             $this->moveFiles($model->unixtime, $model->id);
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }