コード例 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($personid, $reload = "")
 {
     $model = new Personspeciality();
     $model->PersonID = (int) $personid;
     $this->_setDefaults($model);
     $valid = true;
     if (isset($_GET['idRequest'])) {
         try {
             $pr = Person::model()->findByPk($personid);
             $idReq = intval($_GET['idRequest']);
             $res = WebServices::findRequestsByCodeU($pr->codeU, $idReq);
             $sbj = WebServices::findRequestsSubjects($idReq);
             $model->loadRequestFromJsqon($res, $sbj);
         } catch (Exception $ex) {
             Yii::log($ex->getMessage());
             Yii::app()->user->setFlash("specmessage", $ex->getMessage());
         }
     }
     if (isset($_GET['Personspeciality'])) {
         $renderForm = "_form";
         //if (isset($_GET['Personspeciality']['GraduatedUniversitieID'])){
         if (!empty($_GET['Personspeciality']['QualificationID']) && $_GET['Personspeciality']['QualificationID'] > 1 && ($_GET['Personspeciality']['SepcialityID'] != 70686 && $_GET['Personspeciality']['SepcialityID'] != 90661)) {
             $model->scenario = "SHORTFORM";
             $renderForm = "_formShort";
             $model->CausalityID = 100;
         }
         $model->attributes = $_GET['Personspeciality'];
         if (intval($model->EntranceTypeID) == 1) {
             $model->Exam1ID = null;
             $model->Exam1Ball = null;
             $model->Exam2ID = null;
             $model->Exam2Ball = null;
             $model->Exam3ID = null;
             $model->Exam3Ball = null;
             $model->CausalityID = null;
         } elseif (intval($model->EntranceTypeID) == 2) {
             //                $model->DocumentSubject1 = null;
             //                $model->DocumentSubject2 = null;
             //                $model->DocumentSubject3 = null;
         }
         if (!$reload) {
             $valid = $model->validate() && $valid;
             if (!$valid) {
                 //debug ($model->PersonID);
                 echo CJSON::encode(array("result" => "error", "data" => $this->renderPartial($renderForm, array('model' => $model), true)));
                 Yii::app()->end();
             } else {
                 if ($model->save()) {
                     //debug ($model->PersonID);
                     $person = Person::model()->findByPk($model->PersonID);
                 }
                 echo CJSON::encode(array("result" => "success", "data" => $this->renderPartial("//person/tabs/_spec", array('models' => $person->specs, 'personid' => $model->PersonID), true)));
                 Yii::app()->end();
             }
         } else {
             echo CJSON::encode(array("result" => "success", "data" => $this->renderPartial("_formShort", array('model' => $model), true)));
             Yii::app()->end();
         }
     }
     $this->renderPartial('_Modal', array('model' => $model, 'personid' => $model->PersonID));
 }