public function updateUser($UserID) { $params = []; if ($this->dayOfBirth == 0) { $params['error'] = 'dayOfBirth'; return $params; } if ($this->monthOfBirth == 0) { $params['error'] = 'monthOfBirth'; return $params; } if ($this->yearOfBirth == 0) { $params['error'] = 'yearOfBirth'; return $params; } $params["userID"] = $UserID; $params["familyName"] = $this->secondName; $params["firstName"] = $this->firstName; $params["patronymic"] = $this->thirdName; $params["login"] = $this->username; $params["password"] = Yii::$app->crypto->encrypt($this->password); $params["gender"] = $this->gender; $params["birthday"] = $this->yearOfBirth . '-' . DateModel::checkLen($this->monthOfBirth) . '-' . DateModel::checkLen($this->dayOfBirth); $params["phoneNumber"] = $this->phoneNumber; $params["phoneCountry"] = $this->country; $params["remark"] = $this->yearOfBirth . '-' . DateModel::checkLen($this->monthOfBirth) . '-' . DateModel::checkLen($this->dayOfBirth); $params = Yii::$app->businesslayer->update_user($params); $params['error'] = 0; $params['Password'] = $this->password; return $params; }
public static function initDateFields($model) { $date = DateModel::parseDate($model->birthday); $model->dayOfBirth = $date['day']; $model->monthOfBirth = $date['month']; $model->yearOfBirth = $date['year']; return $model; }
public function actionIndex() { if (!Yii::$app->user->getIsGuest()) { $model = new UserForm(['scenario' => 'personalArea']); if ($model->load(Yii::$app->request->post())) { $model->id = Yii::$app->user->identity->id; $error = $model->updateUser($model->id); if ($error) { Yii::$app->session->setFlash('error', Yii::t('registration', $error . '_err_msg')); } } else { $model->getById(Yii::$app->user->identity->id); $model = DateModel::initDateFields($model); } $title = ''; $orders = UserOrder::findByUserId($model->id); if (count($orders['new']) + count($orders['accepted']) == 0) { $title = 'У Вас нет активных школ'; } else { foreach ($orders['new'] as $order) { $school = Yii::$app->businesslayer->schools->getById($order->schoolId); $group = Yii::$app->businesslayer->groups->getById($order->groupId); $title = $title . 'Ваша заявка рассматривается в Школу: ' . $school['SchoolName'] . ' Группу: ' . $group['GroupName'] . '<br>'; } foreach ($orders['accepted'] as $order) { $school = Yii::$app->businesslayer->schools->getById($order->schoolId); $group = Yii::$app->businesslayer->groups->getById($order->groupId); $title = $title . 'Вы состоите в Школе: ' . $school['SchoolName'] . ' Группе: ' . $group['GroupName'] . '<br>'; } } return $this->render('index', ['model' => $model, 'title' => $title]); } return $this->goHome(); /* if(!Yii::$app->user->getIsGuest()) { $model = new GuestlkForm(); if($model->load(Yii::$app->request->post())) { if(isset($_POST['savechanges-button'])) { $uid = Yii::$app->user->getId(); //$model->updateUser($uid); $userData = $model->updateUser($uid); if(!$userData['error']) { $model->initParams($userData); return $this->render('index', [ 'model' => $model, ]); } else { Yii::$app->session->setFlash('error', Yii::t('registration',$userData['error'].'_err_msg')); $model->userId = Yii::$app->user->getId(); return $this->render('index', [ 'model' => $model, ]); } } } $userData = UserIdentity::getUserData($username); $model->initParams($userData); return $this->render('index', [ 'model' => $model, ]); } else return $this->goHome(); */ }
public function registerUser() { if (strlen($this->school) == 0) { return 'school'; } if (strlen($this->group) == 0) { return 'group'; } $params = []; $params["familyName"] = $this->secondName; $params["firstName"] = $this->firstName; $params["patronymic"] = $this->thirdName; $params["login"] = $this->username; $params["password"] = Yii::$app->crypto->encript($this->password); $params["gender"] = $this->gender; $params["birthday"] = $this->yearOfBirth . '-' . DateModel::checkLen($this->monthOfBirth) . '-' . DateModel::checkLen($this->dayOfBirth); $params["phoneNumber"] = $this->phoneNumber; $params["phoneCountry"] = $this->country; $params["remark"] = $this->yearOfBirth . '-' . DateModel::checkLen($this->monthOfBirth) . '-' . DateModel::checkLen($this->dayOfBirth); $newUserID = Yii::$app->businesslayer->register_user($params); $this->sendRequest($newUserID); return 0; }
</h4> </div> <div class="col-lg-offset-1 col-lg-11"> <?php echo $form->field($model, 'dayOfBirth')->dropDownList(DateModel::getDays(), ['prompt' => 'День']); ?> </div> <div class="col-lg-offset-1 col-lg-11"> <?php echo $form->field($model, 'monthOfBirth')->textArea()->label(false)->dropDownList(DateModel::getMonths(), ['prompt' => 'Месяц']); ?> </div> <div class="col-lg-offset-1 col-lg-11"> <?php echo $form->field($model, 'yearOfBirth')->textArea()->label(false)->dropDownList(DateModel::getYears(), ['prompt' => 'Год']); ?> </div> </div> <?php echo $form->field($model, 'phoneInput'); ?> <?php echo $form->field($model, 'country')->dropDownList(CountryModel::getCountries()); ?> <?php echo $form->field($model, 'school', ['selectors' => ['input' => '#cat-id']])->dropDownList(School::getDropDownList(), ['id' => 'cat-id', 'prompt' => 'Выберите школу']); ?> <!--?= $form->field($model, 'school')->dropDownList(['1'=>'test','2'=>School::getDropDownList()], ['id'=>'cat-id'])?-->
public function insertUser() { $params = []; if (strlen($this->school) == 0 || $this->school == 0) { return 'school'; } if (strlen($this->group) == 0 || $this->group == 0) { return 'group'; } if ($this->dayOfBirth == 0) { return 'dayOfBirth'; } if ($this->monthOfBirth == 0) { return 'monthOfBirth'; } if ($this->yearOfBirth == 0) { return 'yearOfBirth'; } $params["familyName"] = $this->familyName; $params["firstName"] = $this->firstName; $params["patronymic"] = $this->patronymic; $params["login"] = $this->login; $params["password"] = $this->password; $params["gender"] = $this->gender; $params["birthday"] = $this->yearOfBirth . '-' . DateModel::checkLen($this->monthOfBirth) . '-' . DateModel::checkLen($this->dayOfBirth); $params["phoneNumber"] = $this->phoneInput; $params["phoneCountry"] = $this->country; $params["remark"] = '-'; Yii::$app->businesslayer->users->insert($params); return 0; }