コード例 #1
0
ファイル: UserAdminController.php プロジェクト: AtaBashir/ams
 /**
  * Creates a new user model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new user();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->usr_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
ファイル: EmailController.php プロジェクト: guanrui111/niuke2
 public function actionDdd()
 {
     //接收到值
     $user = $_POST['user'];
     $email = $_POST['email'];
     $class = $_POST['class'];
     $emails = new user();
     $emails->user = $user;
     $emails->email = $email;
     $emails->class = $class;
     if ($emails->save()) {
         echo "<script>alert('添加成功');location.href='index.php?r=email/index'</script>";
     } else {
         echo "<script>alert('添加失败');location.href='index.php?r=email/index'</script>";
     }
 }
コード例 #3
0
ファイル: FormUser.php プロジェクト: 44132145/TechFunder
 public function CheckEmailInBD($attribute)
 {
     $userObj = user::find()->where(['email' => $this->{$attribute}])->one();
     if ($userObj !== null) {
         $this->addError($attribute, 'email all ready taken');
     }
 }
コード例 #4
0
 /**
  * Finds the user model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return user the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = user::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
ファイル: UsersSearch.php プロジェクト: aekkapun/dlt-tcplch
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = user::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
コード例 #6
0
ファイル: userSearch.php プロジェクト: saqbest/social.dev
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = user::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'online' => $this->online]);
     $query->andFilterWhere(['or', ['like', 'first_name', $this->userFullName], ['like', 'last_name', $this->userFullName]])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['and', ['>=', '((UNIX_TIMESTAMP()-UNIX_TIMESTAMP(`bd_date`))/60/60/24/365)', $this->min_year], ['<=', '((UNIX_TIMESTAMP()-UNIX_TIMESTAMP(`bd_date`))/60/60/24/365)', $this->max_year]])->andFilterWhere(['like', 'country', $this->country]);
     return $dataProvider;
 }
コード例 #7
0
ファイル: login.php プロジェクト: jlemm45/noteApp
<?php

/**
 * Created by PhpStorm.
 * User: Jaden Lemmon
 * Date: 2/11/16
 * Time: 1:02 PM
 */
use app\models\user;
$user = new user();
if ($user->logIn($data->username, $data->password)) {
    echo 'success';
} else {
    echo 'error';
}
コード例 #8
0
ファイル: Users.php プロジェクト: shamim258038/myMvc
 public function editShow($id)
 {
     return view('userEditForm', user::find($id));
 }
コード例 #9
0
ファイル: RefController.php プロジェクト: Arokh09/it-service
 public function actionSaveUserData($user_id, $user_login, $user_fio, $user_position, $user_address, $user_phone, $user_roles, $user_password)
 {
     $auth = yii::$app->authManager;
     $roles = json_decode($user_roles);
     $transaction = user::getDb()->beginTransaction();
     $user = user::findOne($user_id);
     $user->name = $user_login;
     $user->FIO = $user_fio;
     $user->position = $user_position;
     $user->address = $user_address;
     $user->phone = $user_phone;
     if (!$user_password == '') {
         $hash = Yii::$app->getSecurity()->generatePasswordHash($user_password);
         $user->password_hash = $hash;
     }
     $auth->revokeAll($user_id);
     foreach ($roles as $role) {
         if ($auth->getRole($role)) {
             $oRole = $auth->getRole($role);
             $auth->assign($oRole, $user_id);
         }
     }
     if ($user->save()) {
         echo 'Изменения сохранены';
         $transaction->commit();
         //print_r($auth -> getAssignments($user_id));
     } else {
         echo 'Изменения НЕ СОХРАНЕНЫ';
     }
     $transaction->rollBack();
     //else print_r($user -> getErrors());
 }
コード例 #10
0
ファイル: User.php プロジェクト: ut8ia/radioDoc
 /**
  * @param \nodge\eauth\ServiceBase $service
  * @return User
  * @throws ErrorException
  */
 public static function findByEAuth($service)
 {
     if (!$service->getIsAuthenticated()) {
         throw new ErrorException('EAuth user should be authenticated before creating identity.');
     }
     $service_id = $service->getServiceName() . '-' . $service->getId();
     // find user auth
     $user_auth = AuthRecords::find()->where(["id" => $service_id])->one();
     // make new auth record and create user
     if (!isset($user_auth->user_id)) {
         $attributes = $service->getAttributes();
         $nameFromService = isset($attributes['name']) ? $attributes['name'] : null;
         // add user
         $model = new User();
         $model->username = $nameFromService ? $nameFromService : $service_id;
         $model->auth_key = md5($service_id);
         // set default pass for direct account access
         $password = $model->generatePass();
         $model->password_hash = Yii::$app->security->generatePasswordHash($password);
         $model->save();
         $user_id = $model->id;
         // add auth
         $new_auth = new AuthRecords();
         $new_auth->id = $service_id;
         $new_auth->user_id = $user_id;
         $new_auth->attributes = serialize($service->getAttributes());
         $new_auth->save();
     } else {
         $user_id = $user_auth->user_id;
     }
     return user::findIdentity($user_id);
 }
コード例 #11
0
ファイル: index.php プロジェクト: Arokh09/it-service
				<?php 
echo DatePicker::widget(['name' => 'tickets_date', 'value' => date('Y-m-d'), 'language' => 'ru', 'dateFormat' => 'yyyy-MM-dd', 'id' => 'tickets_date', 'class' => 'form-control']);
?>
			&nbsp &nbsp &nbsp <input id = "autoupdate_checkbox" type="checkbox" onClick = "autoupdate()"> Обновлять ежеминутно
			<br>
			<div class="panel-group" id = "tickets">

			</div>
		</div>


		<div class = "col-md-3 main">
			<strong><span id = 'add_device_legend' style = 'display: block; float: left'>Блокнот &nbsp &nbsp &nbsp <span id = "saved_sign" style = "display : none; color : green">Сохранено</span><span id = "not_saved_sign" style = "display : none; color : red;">Не сохранено</span></span></strong>
			<br>
			<textarea class = "form-control" id = "note" rows = "20" onInput = "save_note($(this).val())"><?php 
$user = user::findOne(Yii::$app->user->id);
echo $user->note;
?>
</textarea>
		</div>

		<div class="col-md-4">
			<strong><span id = 'add_device_legend' style = 'display: block; float: left'>Картриджи</span></strong> &nbsp &nbsp
			<?php 
echo DatePicker::widget(['name' => 'cart_out_date', 'value' => date('Y-m-d'), 'language' => 'ru', 'dateFormat' => 'yyyy-MM-dd', 'id' => 'cart_out_date']);
?>
			<br>
			<div class="panel panel-default">
				<div class="panel-heading">
					<table style = "width : 100%">
						<tr>
コード例 #12
0
 public function actionGetNote()
 {
     $user = user::findOne(Yii::$app->user->id);
     return $user->note;
 }
コード例 #13
0
ファイル: ViewController.php プロジェクト: Arokh09/it-service
 public function actionGetDevicesJson($room_id, $set_id = 11, $is_history)
 {
     if ($is_history === 'true') {
         $is_history = true;
     } else {
         $is_history = false;
     }
     $ggg = array();
     $cond_array = array();
     $ggg['devices'] = array();
     // справочник типов устройств
     $types = deviceType::find(['id', 'value'])->all();
     foreach ($types as $type) {
         $types_array[] = ['id' => $type['id'], 'value' => $type['value']];
     }
     $ggg['device_types'] = $types_array;
     // справочник состояний
     $conditions = conditions::find()->all();
     foreach ($conditions as $condition) {
         $cond_array[$condition['id']] = $condition['value'];
     }
     $ggg['conditions'] = $cond_array;
     // справочник партий
     $consignments = consignment::find()->all();
     $consignments_array = [];
     foreach ($consignments as $consignment) {
         $consignments_array[$consignment['id']] = $consignment['name'];
     }
     $ggg['consignments'] = $consignments_array;
     // адрес комплекта
     $addr_set = sets::findOne($set_id);
     //$addr_dep = department::findOne($addr_set ->department_id);
     //$addr_build = building::findOne($addr_set -> building_id);
     //$addr_room = room::findOne($addr_set -> room_id);
     $addr_room = room::findOne($addr_set->room_id);
     $addr_build = building::findOne($addr_room->building_id);
     $addr_dep = department::findOne($addr_build->department_id);
     $ggg['area'] = array("department" => $addr_dep->value, "building" => $addr_build->value, "room" => $addr_room->value, "set" => $addr_set->name);
     // устройства
     // актуальные или из истории
     if ($is_history) {
         //$history_sets = sets::find($set_id) -> asArray() -> all();
         //$history_sets = ArrayHelper::getColumn($history_sets, 'id');
         //$history_sets = array_unique($history_sets);
         //$devices_in_history = deviceHistory::find( ['set_id' => $history_sets] ) -> asArray() -> all();
         $devices_in_history = deviceHistory::find()->where(['set_id' => $set_id, 'room_id' => $room_id])->all();
         foreach ($devices_in_history as $device_in_history) {
             $device = device::findOne($device_in_history->device_id);
             // -------------------------------------------------------------------------------------------------------------------------------------
             //$dev_add_usr = user::find(['id' => $device -> add_username_id])-> one();
             if (user::findOne($device_in_history->user_id)) {
                 $dev_add_usr = user::findOne($device_in_history->user_id);
                 $dev_add_user_name = $dev_add_usr->name;
             } else {
                 $dev_add_user_name = 'Неизвестно';
             }
             //print_r($dev_add_usr);
             $dev_model = model::findOne($device->model_id);
             //print_r($dev_model);
             $dev_type = deviceType::findOne($dev_model->type_id);
             $dev_mark = trademarks::findOne($dev_model->mark_id);
             array_push($ggg['devices'], array("add_date" => $device_in_history->date, "add_user" => $dev_add_user_name, "device_id" => $device_in_history->id, "device_model" => $dev_model->value, "device_type" => $dev_type->value, "device_trademark" => $dev_mark->value, "device_inv_no" => $device->inv_no, "device_ser_no" => $device->serial_no, "device_condition_id" => $device->condition_id, "device_consignment_id" => $device->consignment_id, "device_comment" => $device->comment));
             // если тип устройства - системный блок.
             $sys_unit = sysUnitSpec::find(['device_id' => $device->id])->one();
             $set_have_sys_unit = 0;
             if ($dev_type->id == 3) {
                 if ($set_have_sys_unit == 0) {
                     $ggg['sys_unit_spec'] = array();
                     $ggg['sys_unit_po'] = array();
                 }
                 $set_have_sys_unit = 1;
                 array_push($ggg['sys_unit_spec'], array("device_id" => $device->id, "cpu_id" => $sys_unit->cpu_id, "ram" => $sys_unit->RAM, "hdd" => $sys_unit->HDD));
                 $sys_unit_po = po::find(['device_id' => $device->id])->one();
                 array_push($ggg['sys_unit_po'], array("device_id" => $device->id, "type_id" => $sys_unit_po->type_id, "name_id" => $sys_unit_po->name_id, "licensed" => $sys_unit_po->licensed));
             }
             if ($set_have_sys_unit) {
                 // справочник процессоров
                 $cpus = cpu::findAll(['active' => '1']);
                 foreach ($cpus as $cpu) {
                     $cpu_ref_array[$cpu['id']] = $cpu['name'];
                 }
                 $ggg['cpu'] = $cpu_ref_array;
                 // справочник операционок
                 $po_os = po_name::findAll(['active' => '1', 'po_type_id' => '1']);
                 foreach ($po_os as $po) {
                     $po_os_ref_array[$po['id']] = $po['po_name'];
                 }
                 $ggg['po_os'] = $po_os_ref_array;
                 //  справочник офисных пакетов
                 $po_office = po_name::findAll(['active' => '1', 'po_type_id' => '2']);
                 foreach ($po_office as $po) {
                     $po_office_ref_array[$po['id']] = $po['po_name'];
                 }
                 $ggg['po_office'] = $po_office_ref_array;
                 // справочник антивирусов
                 $po_antivirus = po_name::findAll(['active' => '1', 'po_type_id' => '3']);
                 foreach ($po_antivirus as $po) {
                     $po_antivirus_ref_array[$po['id']] = $po['po_name'];
                 }
                 $ggg['po_antivirus'] = $po_antivirus_ref_array;
                 // справочник Специального ПО
                 $po_special = po_name::findAll(['active' => '1', 'po_type_id' => '4']);
                 foreach ($po_special as $po) {
                     $po_special_ref_array[$po['id']] = $po['po_name'];
                 }
                 $ggg['po_special'] = $po_special_ref_array;
             }
             // --------------------------------------------------------------------------------------------------------------------------------------------------
         }
         //$set_devices = device::findAll(['id' => ArrayHelper::getColumn($devices_in_history, 'device_id')]);
     } else {
         $set_devices = device::findAll(['set_id' => $set_id, 'active' => true]);
         foreach ($set_devices as $device) {
             //$dev_add_usr = user::find(['id' => $device -> add_username_id])-> one();
             if ($dev_add_usr = user::findOne($device->add_username_id)) {
                 $dev_add_user_name = $dev_add_usr->name;
             } else {
                 $dev_add_user_name = 'Неизвестно';
             }
             //print_r($dev_add_usr);
             $dev_model = model::findOne($device->model_id);
             //print_r($dev_model);
             $dev_type = deviceType::findOne($dev_model->type_id);
             $dev_mark = trademarks::findOne($dev_model->mark_id);
             array_push($ggg['devices'], array("add_date" => $device->add_date, "add_user" => $dev_add_user_name, "device_id" => $device->id, "device_model" => $dev_model->value, "device_type" => $dev_type->value, "device_trademark" => $dev_mark->value, "device_inv_no" => $device->inv_no, "device_ser_no" => $device->serial_no, "device_condition_id" => $device->condition_id, "device_consignment_id" => $device->consignment_id, "device_comment" => $device->comment));
             // если тип устройства - системный блок.
             $sys_unit = sysUnitSpec::find(['device_id' => $device->id])->one();
             $set_have_sys_unit = 0;
             if ($dev_type->id == 3) {
                 if ($set_have_sys_unit == 0) {
                     $ggg['sys_unit_spec'] = array();
                     $ggg['sys_unit_po'] = array();
                 }
                 $set_have_sys_unit = 1;
                 array_push($ggg['sys_unit_spec'], array("device_id" => $device->id, "cpu_id" => $sys_unit->cpu_id, "ram" => $sys_unit->RAM, "hdd" => $sys_unit->HDD));
                 $sys_unit_po = po::find(['device_id' => $device->id])->one();
                 array_push($ggg['sys_unit_po'], array("device_id" => $device->id, "type_id" => $sys_unit_po->type_id, "name_id" => $sys_unit_po->name_id, "licensed" => $sys_unit_po->licensed));
             }
             if ($set_have_sys_unit) {
                 // справочник процессоров
                 $cpus = cpu::findAll(['active' => '1']);
                 foreach ($cpus as $cpu) {
                     $cpu_ref_array[$cpu['id']] = $cpu['name'];
                 }
                 $ggg['cpu'] = $cpu_ref_array;
                 // справочник операционок
                 $po_os = po_name::findAll(['active' => '1', 'po_type_id' => '1']);
                 foreach ($po_os as $po) {
                     $po_os_ref_array[$po['id']] = $po['po_name'];
                 }
                 $ggg['po_os'] = $po_os_ref_array;
                 //  справочник офисных пакетов
                 $po_office = po_name::findAll(['active' => '1', 'po_type_id' => '2']);
                 foreach ($po_office as $po) {
                     $po_office_ref_array[$po['id']] = $po['po_name'];
                 }
                 $ggg['po_office'] = $po_office_ref_array;
                 // справочник антивирусов
                 $po_antivirus = po_name::findAll(['active' => '1', 'po_type_id' => '3']);
                 foreach ($po_antivirus as $po) {
                     $po_antivirus_ref_array[$po['id']] = $po['po_name'];
                 }
                 $ggg['po_antivirus'] = $po_antivirus_ref_array;
                 // справочник Специального ПО
                 $po_special = po_name::findAll(['active' => '1', 'po_type_id' => '4']);
                 foreach ($po_special as $po) {
                     $po_special_ref_array[$po['id']] = $po['po_name'];
                 }
                 $ggg['po_special'] = $po_special_ref_array;
             }
         }
     }
     echo json_encode($ggg);
 }
コード例 #14
0
ファイル: FindController.php プロジェクト: Arokh09/it-service
 public function actionGetDevicesJson($consignment_id = 0, $search_str = '')
 {
     $search_str = trim($search_str);
     $ggg = array();
     $cond_array = array();
     $ggg['devices'] = array();
     // справочник типов устройств
     $types = deviceType::find(['id', 'value'])->all();
     foreach ($types as $type) {
         $types_array[] = ['id' => $type['id'], 'value' => $type['value']];
     }
     $ggg['device_types'] = $types_array;
     // справочник состояний
     $conditions = conditions::find()->all();
     foreach ($conditions as $condition) {
         $cond_array[$condition['id']] = $condition['value'];
     }
     $ggg['conditions'] = $cond_array;
     // справочник партий
     $consignments = consignment::find()->all();
     $consignments_array = [];
     foreach ($consignments as $consignment) {
         $consignments_array[$consignment['id']] = $consignment['name'];
     }
     $ggg['consignments'] = $consignments_array;
     // устройства
     if ($consignment_id == 0) {
         $set_devices = device::find()->filterWhere(['like', 'inv_no', $search_str])->all();
     } else {
         $set_devices = device::findAll(['consignment_id' => $consignment_id]);
     }
     foreach ($set_devices as $device) {
         //$dev_add_usr = user::find(['id' => $device -> add_username_id])-> one();
         $dev_add_usr = user::findOne($device->add_username_id);
         if ($dev_add_usr) {
             $dev_add_usr_name = $dev_add_usr->name;
         } else {
             $dev_add_usr_name = '';
         }
         //print_r($dev_add_usr);
         $dev_model = model::findOne($device->model_id);
         //print_r($dev_model);
         $dev_type = deviceType::findOne($dev_model->type_id);
         $dev_mark = trademarks::findOne($dev_model->mark_id);
         // адрес устройства
         $dev_set_id = $device->set_id;
         $addr_set = sets::findOne($dev_set_id);
         $addr_room = room::findOne($addr_set->room_id);
         $addr_build = building::findOne($addr_room->building_id);
         $addr_dep = department::findOne($addr_build->department_id);
         $dev_addr_str = $addr_dep->value . ' -> ' . $addr_build->value . ' -> ' . $addr_room->value . ' -> ' . $addr_set->name;
         array_push($ggg['devices'], array("add_date" => $device->add_date, "add_user" => $dev_add_usr_name, "device_id" => $device->id, "device_model" => $dev_model->value, "device_type" => $dev_type->value, "device_trademark" => $dev_mark->value, "device_inv_no" => $device->inv_no, "device_ser_no" => $device->serial_no, "device_condition_id" => $device->condition_id, "device_consignment_id" => $device->consignment_id, "device_comment" => $device->comment, "device_address" => $dev_addr_str));
         // если тип устройства - системный блок.
         $sys_unit = sysUnitSpec::find(['device_id' => $device->id])->one();
         $set_have_sys_unit = 0;
         if ($dev_type->id == 3) {
             if ($set_have_sys_unit == 0) {
                 $ggg['sys_unit_spec'] = array();
                 $ggg['sys_unit_po'] = array();
             }
             $set_have_sys_unit = 1;
             array_push($ggg['sys_unit_spec'], array("device_id" => $device->id, "cpu_id" => $sys_unit->cpu_id, "ram" => $sys_unit->RAM, "hdd" => $sys_unit->HDD));
             $sys_unit_po = po::find(['device_id' => $device->id])->one();
             array_push($ggg['sys_unit_po'], array("device_id" => $device->id, "type_id" => $sys_unit_po->type_id, "name_id" => $sys_unit_po->name_id, "licensed" => $sys_unit_po->licensed));
         }
         if ($set_have_sys_unit) {
             // справочник процессоров
             $cpus = cpu::findAll(['active' => '1']);
             foreach ($cpus as $cpu) {
                 $cpu_ref_array[$cpu['id']] = $cpu['name'];
             }
             $ggg['cpu'] = $cpu_ref_array;
             // справочник операционок
             $po_os = po_name::findAll(['active' => '1', 'po_type_id' => '1']);
             foreach ($po_os as $po) {
                 $po_os_ref_array[$po['id']] = $po['po_name'];
             }
             $ggg['po_os'] = $po_os_ref_array;
             //  справочник офисных пакетов
             $po_office = po_name::findAll(['active' => '1', 'po_type_id' => '2']);
             foreach ($po_office as $po) {
                 $po_office_ref_array[$po['id']] = $po['po_name'];
             }
             $ggg['po_office'] = $po_office_ref_array;
             // справочник антивирусов
             $po_antivirus = po_name::findAll(['active' => '1', 'po_type_id' => '3']);
             foreach ($po_antivirus as $po) {
                 $po_antivirus_ref_array[$po['id']] = $po['po_name'];
             }
             $ggg['po_antivirus'] = $po_antivirus_ref_array;
             // справочник Специального ПО
             $po_special = po_name::findAll(['active' => '1', 'po_type_id' => '4']);
             foreach ($po_special as $po) {
                 $po_special_ref_array[$po['id']] = $po['po_name'];
             }
             $ggg['po_special'] = $po_special_ref_array;
         }
     }
     echo json_encode($ggg);
 }
コード例 #15
0
ファイル: RegForm.php プロジェクト: ylevkovich/files-yii2
 public function rules()
 {
     return [[['login', 'pass', 'email'], 'required', 'message' => 'Please choose this field'], [['login', 'pass', 'email', 'authKey'], 'string', 'max' => 255], ['login', 'unique', 'targetClass' => user::className(), 'message' => 'this login already exist.'], ['email', 'email'], ['email', 'unique', 'targetClass' => user::className(), 'message' => 'this email already exist.']];
 }