public function actionAddManagement()
 {
     $this->authenUser();
     $this->authenManagement();
     $formAddManagement = new formAddManagement();
     $addManagement = new Management();
     $systemCities = SystemCity::model()->findAll();
     $systemCitiesData = $this->generateSystemCities($systemCities);
     $managementUserLevels = ManagementUserLevel::model()->findAll();
     if (isset($_POST['formAddManagement'])) {
         $addManagement->attributes = $_POST['formAddManagement'];
         $addManagement->regDate();
         $userLevel = $_POST['formAddManagement']['level'];
         $addManagement->management_user_level_id = $userLevel;
         //print_r($_POST['formAddManagement']);
         $addManagement->save();
         //store the record for management user
         if ($addManagement->mid != NULL) {
             $managementAddress = $_POST['formAddManagement']['address'];
             $managementCity = $_POST['formAddManagement']['city'];
             if ($managementAddress != '' || $managementCity != '') {
                 $addManagementAddress = new ManagementAddress();
                 $addManagementAddress->management_mid = $addManagement->mid;
                 if ($managementAddress != '') {
                     $addManagementAddress->address = $managementAddress;
                 }
                 if ($managementCity != '') {
                     $addManagementAddress->system_city_id = $managementCity;
                 }
                 $addManagementAddress->save();
                 // store the record for specific mangement address
                 $this->redirect(array('manage/viewManagement', 'managementId' => $addManagement->mid));
             }
         }
         Yii::app()->end();
     }
     $formAddManagement->generatePassword();
     $this->render('addManagement', array('formAddManagement' => $formAddManagement, 'systemCitiesData' => $systemCitiesData, 'managementUserLevels' => $this->generateSystemCities($managementUserLevels)));
 }