/**
  * Creates a new Membership model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Membership();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Composition model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($matchId = null, $teamId = null)
 {
     $model = new Composition();
     if (!isset($matchId) || !isset($teamId)) {
         throw new \yii\web\BadRequestHttpException('Unidentified matchId and teamId');
     }
     $match = Match::findOne($matchId);
     $team = Team::findOne($teamId);
     if (!isset($match) || !isset($team)) {
         throw new \yii\web\BadRequestHttpException('Unidentified match and team models');
     }
     $model->command_id = $teamId;
     $model->match_id = $matchId;
     $model->is_basis = 1;
     $contractTeams = Team::getContractTeams();
     if (in_array($teamId, $contractTeams)) {
         $model->contract_type = Composition::CONTRACT_TYPE;
         $contractModel = new Contract();
         $contractModel->season_id = $match->season_id;
         $contractModel->is_active = 1;
     } else {
         $model->contract_type = Composition::MEMBERSHIP_TYPE;
         $contractModel = new Membership();
     }
     $contractModel->command_id = $teamId;
     if ($model->load(Yii::$app->request->post()) && $contractModel->load(Yii::$app->request->post()) && $contractModel->validate()) {
         if ($contractModel->save(false)) {
             $model->contract_id = $contractModel->id;
             $model->number = $contractModel->number;
             $model->save();
         }
         if (Yii::$app->request->isAjax) {
             $out = ['success' => 'true'];
             return Json::encode($out);
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         if (Yii::$app->request->isAjax) {
             return $this->renderAjax('create', ['model' => $model, 'contractModel' => $contractModel]);
         }
         return $this->render('create', ['model' => $model, 'contractModel' => $contractModel]);
     }
 }
Ejemplo n.º 3
0
 /**
  * Creates a new Membership model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Membership();
     $queryStrArr = Yii::$app->request->post();
     if (!empty($queryStrArr)) {
         $model->load($queryStrArr);
         $model->membership_unique_id = Yii::$app->UtilHelper->randString(10);
         $model->membership_date_of_joining = date('d/m/Y');
         $model->membership_status = "1";
         $upload_file = $model->uploadFile();
         if ($upload_file !== false) {
             $path = $model->getUploadedFile();
             $upload_file->saveAs($path);
         }
         if ($model->save()) {
             return $this->redirect(['view', 'id' => (string) $model->_id]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Ejemplo n.º 4
0
 /**
  * Signs user up.
  *
  * @return mixed
  */
 public function actionSignup()
 {
     $model = new Membership();
     $user = new User();
     if ($model->load(Yii::$app->request->post())) {
         $postReq = Yii::$app->request->post();
         $user->username = $postReq['User']['username'];
         $user->email = $postReq['User']['email'];
         $user->new_password = $postReq['User']['new_password'];
         $user->setPassword();
         $user->save();
         $model->membership_login_id = $user->id;
         if ($model->save()) {
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model, 'user' => $user]);
 }