Ejemplo n.º 1
0
 public function actionAvtoparkAdd($id = 0)
 {
     if (!empty($id)) {
         $Transport = Transport::model()->findByPk($id);
         if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $Transport->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->avtopark != '1' || $Transport->user_id != Yii::app()->user->id)) {
             throw new CHttpException(403);
         }
     } else {
         if (!Yii::app()->user->checkAccess('admin') && Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY && Yii::app()->getUser()->getProfile()->modules->avtopark != '1') {
             throw new CHttpException(403);
         }
         $Transport = new Transport();
     }
     if (isset($_POST['save'])) {
         $Transport->setAttributes($_POST['Transport'], false);
         if ($Transport->validate()) {
             $Transport->save();
             $Transport->setRelations($_POST['Transport']);
             if (isset($_POST['photos'])) {
                 $Transport->setPhoto($_POST['photos']);
             }
             $this->redirect('/cabinet/avtopark/');
         }
     }
     $track = null;
     $points = [];
     Yii::import('application.modules.tracking.models.*');
     if ($Transport->tracking_on && $Transport->tracking_password) {
         $points = Tracking::model()->getDataForCurrentTrack($Transport->transport_id);
     }
     $this->render('avtoparkAdd', ['Transport' => $Transport, 'points' => $points]);
 }