public function actionDoctorSet() { $Doctor = new Doctor(); $Doctor->set_prop_from_arr($_REQUEST); $Doctor->set(); if (Core::hasError() === false) { $ar['success_txt'] = 'Запись успешно сохранена'; } Core::encode_echo($ar); }
public function actionInit() { $transaction = \yii::$app->db->getTransaction(); if (!$transaction) { $transaction = \Yii::$app->db->beginTransaction(); } try { $auth = \Yii::$app->authManager; $auth->init(); $auth->removeAll(); $role_adm = $auth->createRole('role_adm'); $role_adm_boss = $auth->createRole('role_adm_boss'); $auth->add($role_adm); $auth->add($role_adm_boss); $adm = $auth->createPermission('adm'); // доступ к администрированию проекта $adm_user = $auth->createPermission('adm_user'); // управление учетными записями, всеми $adm_hosp = $auth->createPermission('adm_hosp'); // управление больгицами, всеми $auth->add($adm); $auth->add($adm_user); $auth->add($adm_hosp); $auth->addChild($role_adm, $adm); $auth->addChild($role_adm_boss, $role_adm); $auth->addChild($role_adm_boss, $adm_user); $auth->addChild($role_adm_boss, $adm_hosp); $role_doctor = $auth->createRole('role_doctor'); $role_doctor_boss = $auth->createRole('role_doctor_boss'); $auth->add($role_doctor); $auth->add($role_doctor_boss); $doctor = $auth->createPermission('doctor'); // докторский доступ $doctor_user = $auth->createPermission('doctor_user'); // // управление учетными записями, докторскими $doctor_control = $auth->createPermission('doctor_control'); // доступ к контрольной отчетности $auth->add($doctor); $auth->add($doctor_user); $auth->add($doctor_control); $auth->addChild($role_doctor, $doctor); $auth->addChild($role_doctor_boss, $role_doctor); $auth->addChild($role_doctor_boss, $doctor_user); $auth->addChild($role_doctor_boss, $doctor_control); if (\app\component\Core::hasError() === false) { $transaction->commit(); } else { $transaction->rollBack(); } } catch (Exception $e) { $transaction->rollBack(); } }
public function actionSet() { $Mam = new Mam(); $Mam->set_prop_from_arr($_REQUEST); $user = Doctor::getInstance()->get(\Yii::$app->user->id); $Mam->hosp_id = $user['hosp_id']; $Mam->doctor_id = $user['id']; $Mam->set(); if (Core::hasError() === false) { $ar['success_txt'] = 'Запись успешно сохранена'; } Core::encode_echo($ar); }
public function set() { $this->city_id = $this->city_id > 0 ? $this->city_id : null; $this->id = $this->id > 0 ? $this->id : null; $this->fld_name['city_id'] = 'Город'; $this->fld_name['name'] = 'Название'; $this->fld_name['num'] = 'Номер'; $this->fld_name['address'] = 'Адрес'; $ar = ['city_id' => 'req', 'name' => 'req', 'num' => 'req', 'address' => 'req']; $this->validate_ar($ar); if (Core::hasError() === true) { return; } $transaction = \yii::$app->db->getTransaction(); if (!$transaction) { $transaction = \Yii::$app->db->beginTransaction(); } try { $fld = $params = []; $fld['city_id'] = $this->city_id; $fld['name'] = $this->name; $fld['num'] = $this->num; $fld['address'] = $this->address; $fld['note'] = $this->note; if ($this->id === null) { \yii::$app->db->createCommand()->insert('lib_hosp', $fld)->execute(); $this->id = \yii::$app->db->getLastInsertID('lib_hosp_id_seq'); } else { $params['id'] = $this->id; $where = 'id=:id'; \yii::$app->db->createCommand()->update('lib_hosp', $fld, $where, $params)->execute(); } if (\app\component\Core::hasError() === false) { $transaction->commit(); } else { $transaction->rollBack(); } } catch (Exception $e) { $transaction->rollBack(); } }
public function set() { $this->id = $this->id > 0 ? $this->id : null; $this->doctor_id = $this->doctor_id > 0 ? $this->doctor_id : null; $this->hosp_id = $this->hosp_id > 0 ? $this->hosp_id : null; if ($this->phone != '') { $this->phone = preg_replace('/[^0-9]/', '', $this->phone); $cnt = mb_strlen($this->phone); if ($cnt != 11) { Core::error("Поле <strong>Телефон</strong> должно состоять из 10 цифр + код страны", 'phone'); } } $this->fld_name['hosp_id'] = 'Больница'; $this->fld_name['dt_bd_format'] = 'День рождения'; $ar = ['name_f' => 'req', 'name_i' => 'req', 'name_o' => 'req', 'dt_bd_format' => 'req', 'hosp_id' => 'req']; $this->validate_ar($ar); if (Core::hasError() === true) { return; } list($d, $m, $Y) = explode('.', $this->dt_bd_format); $this->dt_bd = Core::format_date($Y, $m, $d, 'Y-m-d'); if ($this->pas_kogda_dt_format != '') { list($d, $m, $Y) = explode('.', $this->pas_kogda_dt_format); $this->pas_kogda_dt = Core::format_date($Y, $m, $d, 'Y-m-d'); } else { $this->pas_kogda_dt = null; } $fld = $params = []; $fld['hosp_id'] = $this->hosp_id; $fld['doctor_id'] = $this->doctor_id; $fld['name_f'] = $this->name_f; $fld['name_i'] = $this->name_i; $fld['name_o'] = $this->name_o; $fld['phone'] = $this->phone; $fld['dt_bd'] = $this->dt_bd; $fld['add_oblast_id'] = $this->add_oblast_id; $fld['add_city_id'] = $this->add_city_id; $fld['add_street'] = $this->add_street; $fld['add_d'] = $this->add_d; $fld['add_k'] = $this->add_k; $fld['add_kv'] = $this->add_kv; $fld['pas_ser'] = $this->pas_ser; $fld['pas_num'] = $this->pas_num; $fld['pas_kem'] = $this->pas_kem; $fld['pas_kogda_dt'] = $this->pas_kogda_dt; $fld['pas_add_oblast_id'] = $this->pas_add_oblast_id; $fld['pas_add_city_id'] = $this->pas_add_city_id; $fld['pas_add_street'] = $this->pas_add_street; $fld['pas_add_d'] = $this->pas_add_d; $fld['pas_add_k'] = $this->pas_add_k; $fld['pas_add_kv'] = $this->pas_add_kv; $fld['ank_soc'] = $this->ank_soc; $fld['ank_obraz'] = $this->ank_obraz; $fld['ank_sem'] = $this->ank_sem; $fld['ank_d'] = $this->ank_d; $fld['ank_like'] = $this->ank_like; foreach ($this->var_vred['data'] as $key => $item) { $fld['vred_' . $key] = $this->vred[$key]; } foreach ($this->var_prof['data'] as $key => $item) { $fld['prof_' . $key] = $this->prof[$key]; } $fld['prof_month'] = $this->prof_month; if ($this->id === null) { $fld_auth = []; $fld_auth['t'] = 'mam'; $fld_auth['role'] = null; \yii::$app->db->createCommand()->insert('auth', $fld_auth)->execute(); $this->id = \yii::$app->db->getLastInsertID('auth_id_seq'); $fld['auth_id'] = $this->id; \yii::$app->db->createCommand()->insert('auth_mam', $fld)->execute(); } else { $params['auth_id'] = $this->id; $where = 'auth_id=:auth_id'; \yii::$app->db->createCommand()->update('auth_mam', $fld, $where, $params)->execute(); } }
?> <title><?php echo Html::encode($this->title); ?> </title> <?php $this->head(); ?> </head> <body> <?php $this->beginBody(); ?> <?php if (\app\component\Core::hasError() === true) { ?> <div class="col-xs-12 col-lg-offset-6"> <div class="alert alert-danger" role="alert"> <?php echo \app\component\Core::viewError(); ?> </div> </div> <div class="clearfix"></div> <?php } ?> <?php echo $content;
public function set() { $this->id = $this->id > 0 ? $this->id : null; $this->role = $this->role != '' ? $this->role : null; if ($this->email == '') { Core::error("Поле <strong>E-mail</strong> обязательно к заполнению", 'email'); } else { $sql = 'Select count(*) from auth_adm where email=:email and (auth_id<>:id or :id is null)'; $params = []; $params['email'] = $this->email; $params['id'] = $this->id; $cnt = \yii::$app->db->createCommand($sql, $params)->queryScalar(); if ($cnt > 0) { Core::error('E-mail <strong>"' . $this->email . '"</strong> уже есть в базе', 'email'); } else { $EmailValidator = new \yii\validators\EmailValidator(); if (!$EmailValidator->validate($this->email)) { Core::error('Некорректное поле <strong>"E-mail"</strong>', 'email'); } } } if ($this->pw == '') { Core::error("Поле <strong>Пароль</strong> обязательно к заполнению", 'pw'); } if ($this->name_f == '') { Core::error("Поле <strong>ФАМИЛИЯ</strong> обязательно к заполнению", 'name_f'); } if ($this->name_i == '') { Core::error("Поле <strong>ИМЯ</strong> обязательно к заполнению", 'name_i'); } if (Core::hasError() === true) { return; } $transaction = \yii::$app->db->getTransaction(); if (!$transaction) { $transaction = \Yii::$app->db->beginTransaction(); } try { if ($this->id === null) { $fld = []; $fld['t'] = 'adm'; $fld['role'] = $this->role; \yii::$app->db->createCommand()->insert('auth', $fld)->execute(); $this->id = \yii::$app->db->getLastInsertID('auth_id_seq'); $fld = []; $fld['auth_id'] = $this->id; $fld['email'] = $this->email; $fld['pw'] = $this->pw; $fld['name_f'] = $this->name_f; $fld['name_i'] = $this->name_i; $fld['name_o'] = $this->name_o; \yii::$app->db->createCommand()->insert('auth_adm', $fld)->execute(); } else { $this->upd_role($this->id, $this->role); $fld = $params = []; $fld['pw'] = $this->pw; $fld['name_f'] = $this->name_f; $fld['name_i'] = $this->name_i; $fld['name_o'] = $this->name_o; $params['auth_id'] = $this->id; $where = 'auth_id=:auth_id'; \yii::$app->db->createCommand()->update('auth_adm', $fld, $where, $params)->execute(); } $this->upd_perm($this->id, $this->perm); if (\app\component\Core::hasError() === false) { $transaction->commit(); } else { $transaction->rollBack(); } } catch (Exception $e) { $transaction->rollBack(); } }