public function updatemember() { $inputs = Input::all(); // Send information for Validation before saving data into DB // Sending this id is the trick to avoid unique conflicts while updating $validator = Membersvalidator::validator($inputs, $inputs['id']); // if the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::to('member')->withErrors($validator)->withInput(Input::all()); // send back the input } else { // update our member data $member = Member::find($inputs['id']); if ($member != null) { $member->name = $inputs['name']; $member->email = $inputs['email']; $member->phone = $inputs['phone']; $member->dob = $inputs['dob']; $member->save(); } // Update done so just forget from sessions update and Redirect to main page Session::forget('update'); // We setup a cookie of recent change to show graphically user to a recent change in any field on home table // And will delete this cookie on home page using javascript setcookie("updatedUser", $inputs['email'], time() + 3600); // 3600 = cookie life is 1 hour return Redirect::to('/'); } }
public static function member() { if (isset($_SESSION['member'])) { return Member::find($_SESSION['member']); } return null; }
public function search($params) { $query = Member::find()->indexBy('id'); $query->poll_id($this->poll_id); $query->distinct(); // also possible is to group by member.id to get only the unique member entries. //$query->addGroupBy($this->tableName().'.id'); // $query->with('codes.vote'); // old join //$query->joinWith('codes', false, 'LEFT JOIN'); //$query->joinWith('codes.vote', true, 'LEFT JOIN'); // $query->joinWith(['relationname' => function ($query) { // $query->from(['alias' => 'tablename']); // }]); // $query->joinWith(['codes' => function ($query) { // $query->from(['codes' => 'code']); // }]); $query->joinWith(['codes.vote']); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['name' => SORT_ASC]], 'pagination' => ['pageSize' => 20]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'group', $this->group]); //if code CODE_STATUS_INVALID_UNUSED is searched also search for CODE_STATUS_INVALID_USED if ($this->getAttribute('codes.code_status') == Code::CODE_STATUS_INVALID_UNUSED) { $query->andWhere([Code::tableName() . '.code_status' => [Code::CODE_STATUS_INVALID_UNUSED, Code::CODE_STATUS_INVALID_USED]]); } else { $query->andFilterWhere(['=', Code::tableName() . '.code_status', $this->getAttribute('codes.code_status')]); } return $dataProvider; }
public function validasi($memberID) { $member = Member::find($memberID); $member->Validated = 1; $member->update(); header('Location: ' . base . "/Member/show/0"); }
/** * Show the application dashboard. * * @return Response */ public function getIndex(Request $request) { //return $sub; Session::put('month', $this->monthName()); if (isset($request->c)) { if (Session::has('member')) { $member = Member::find(Session::get('member')->id); $property = $member->properties()->where('code', '=', $request->c)->first(); Session::put('property', $property); return view('property.index'); } } else { if (Session::has('hotel')) { if (Session::has('member')) { $property = Property::where("code", '=', Session::get('hotel'))->first(); Session::put('property', $property); return view('property.index'); } } else { if (Session::has('property')) { return view('property.index'); } else { return redirect('/member/property'); } } } }
public function prosesPinjam() { $pesan = ""; $error = false; $member = $_POST['member']; $item = $_POST['item']; if ($member == "") { $error = true; $pesan .= "Member ID harus diisi<br />"; } else { $mbr = Member::find($member); if (!isset($mbr)) { $error = true; $pesan .= "Member tidak terdaftar<br />"; } else { //cek sudah melakukan peminjaman berapa kali $count = $mbr->pinjams()->where('TanggalKembali', null)->get()->count(); if ($count > 3) { $error = true; $pesan .= "Terlalu banyak meminjam<br />"; } } } if ($item == "") { $error = true; $pesan .= "Item ID harus diisi<br />"; } else { $itm = Item::find($item); //var_dump($itm); if (!isset($itm)) { $error = true; $pesan .= "Item tidak terdaftar<br />"; } elseif ($itm->ItemStatus != 'available') { $error = true; $pesan .= "Item tidak tersedia<br />"; } } if (!$error) { $pesan = "berhasil"; $pinjam = new Peminjaman(); $pinjam->ItemID = $item; $pinjam->MemberID = $member; $pinjam->PetugasID = $this->petugas->PetugasID; $pinjam->TanggalPinjam = Carbon::now(); $pinjam->TanggalHarusKembali = Carbon::now()->addWeek(1); $pinjam->TanggalKembali = null; $pinjam->save(); $itm = Item::find($item); $itm->ItemStatus = 'borrowed'; $itm->update(); } $_SESSION['msg'] = $pesan; $_SESSION['error'] = $error; header("Location: " . base . "/Transaksi/peminjaman"); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Member::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]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'mobile', $this->mobile])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'summary', $this->summary])->andFilterWhere(['like', 'pic', $this->pic]); return $dataProvider; }
public function actionSendsingle($member_id) { $member = Member::find()->primary_key($member_id)->poll_searchOptions($this->getPollSearchOptions())->one(); if ($member === null) { throw new NotFoundHttpException(Yii::t('app/error', 'The requested page does not exist.')); } $email = new EmailForm(); if ($email->load(Yii::$app->request->post()) && $email->validate()) { if ($this->sendEmailToMember($email, $member)) { Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Email sent successfully.')); } else { Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Failed to send email.')); } } return $this->redirect(['member/view', 'id' => $member->id]); }
public function actionLogin() { if (!empty($_POST)) { $username = $_POST['username']; $password = $_POST['password']; $member = Member::find()->where(['username' => $username, 'password' => $password])->one(); if (!empty($member)) { $session = new Session(); $session->open(); $session->set('member_id', $member->id); $session->set('member_name', $member->name); return $this->redirect(['memberhome']); } else { return $this->redirect(['index']); } } }
public function actionAssign($id) { $model = $this->findModel($id); $dataProvider = new ActiveDataProvider(['query' => ProjectAssignments::find()]); $dataProviderForMember = new ActiveDataProvider(['query' => Member::find()]); if (isset($_GET['selected_user_id'])) { $new_list = $_GET['selected_user_id']; } else { $new_list = []; } if (isset($_GET['old_list'])) { $old_list = $_GET['old_list']; } else { $old_list = []; } $model->assignCompositeProjectList($old_list, $new_list); return $this->render('view', ['model' => $this->findModel($id), 'dataProvider' => $dataProvider, 'dataProviderForMember' => $dataProviderForMember]); }
public function actionRegister() { $email = $_REQUEST['email']; $passwd = md5($_REQUEST['password']); $memeber_type = $_REQUEST['member_type']; $member_name = $_REQUEST['member_name']; $member_phone = $_REQUEST['member_phone']; $model = new Member(); $model->email = $email; $model->password = $passwd; $model->member_type = $memeber_type; $model->member_name = $member_name; $model->member_phone = $member_phone; if ($model->save()) { $arr = $model->find()->where(['email' => $email])->asArray()->one(); $res = array('code' => '10200', 'mess' => 'success', 'stat' => '200', 'data' => $arr); } else { $res = array('code' => '10204', 'mess' => 'The request is error', 'stat' => '100', 'data' => ""); } exit(json_encode($res)); }
public function actionMembergen($n) { set_time_limit(360); $total = $count = Member::find()->count(); $groupNum = 0; while ($n > $groupNum) { $groupNum++; $members = array_fill($total + 1, rand(100, 200), []); foreach ($members as $id => &$member) { $member = new Member(); $member->_id = $id; $member->name = 'member_' . $groupNum . '_' . $id; } unset($member); foreach ($members as $id => $member) { $friendIds = array_rand($members, rand(3, 5)); foreach ($friendIds as $friendId) { $member->addFriend($members[$friendId]); } } if ($total) { foreach ($members as $member) { $distantFriendIds = array_map(function () use($total) { return rand(1, $total); }, array_fill(0, rand(3, 5), null)); $distantFriends = Member::findByIds($distantFriendIds)->all(); foreach ($distantFriends as $friend) { $friend->addFriend($member)->save(); } } } foreach ($members as $member) { $member->save(); } $total += count($members); echo $groupNum . "\t| " . count($members) . " <br>\n"; } echo "\n<br>Created " . ($total - $count); echo "\n<br>Total " . $total; }
public function postCreateProperty(Request $request) { $messages = ['name.required' => 'กรุณาใส่ชื่อกิจการของท่าน', 'name.unique' => 'ชื่อนี้มีผู้ใช้แล้ว', 'address.required' => 'กรุณากรอกที่อยู่กิจการของท่าน', 'description.required' => 'กรุณาอธิบายกิจการของคุณ', 'tel.required' => 'กรุณาใส่เบอร์ติดต่อ', 'tel.numeric' => 'เบอร์ติดต่อของท่านมีตัวอักษร', 'email.required' => 'กรุณาใส่อีเมล์', 'email.email' => 'กรุณาใส่อีเมล์ให้ถูกต้อง', 'email.unique' => 'กรุณาใส่อีเมล์ให้ถูกต้อง']; $validator = Validator::make($request->all(), ['name' => 'required|unique:ch_property,name', 'address' => 'required', 'description' => 'required', 'tel' => 'required|numeric', 'email' => 'required|email|unique:ch_property,email'], $messages); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput(); } if (Session::get('member')->type <= 1) { return redirect()->back()->withErrors(['บัญชีผู้ใช้ของคุณเป็นเวอร์ชั่นทดลอง ไม่สามารถสร้างกิจการได้มากกว่า 1 กิจการ'])->withInput(); } $member = \App\Models\Member::find(Session::get('member')->id); $property = new \App\Models\Property(); $property->name = $request->name; $property->address = $request->address; $property->tel = $request->tel; $property->email = $request->email; $member->properties()->save($property); $code = 'A' . str_pad(Session::get('member')->id, 4, "0", STR_PAD_LEFT) . str_pad($property->id, 2, "0", STR_PAD_LEFT); $property->code = $code; $property->save(); return redirect('/member/property'); }
/** * Finds the Member model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Member the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { //if (($model = Member::findOne($id)) !== null) { if (($model = Member::find()->primary_key($id)->poll_searchOptions($this->getPollSearchOptions())->one()) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('app/error', 'The requested page does not exist.')); } }
public function actionMove() { $info1 = new Info22(); $company = new Company(); $offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; $rs = $info1->find()->offset($offset)->limit(100)->orderBy('itemid ASC')->all(); if ($rs) { /* foreach($rs as $v){ $company = Company::find()->select(['telephone','fax','mail','address']) ->where('username="******"')->asArray()->one(); if($company){ $v['telephone'] = $company['telephone']; $v['fax'] = $company['fax']; $v['email'] = $company['mail']; $v['address'] = $company['address']; $v->update(false); } }*/ foreach ($rs as $v) { $member = Member::find()->select(['truename', 'qq'])->where('username="******"')->asArray()->one(); if ($member) { $v['truename'] = $member['truename']; $v['qq'] = $member['qq']; $v->update(false); } } $num = $offset + 100; return $this->render('move', ['num' => $num]); } else { echo '0k!!!!!!!!!!'; } }
public function delete($id) { $member = Member::find($id); $member->delete(); return redirect('member'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Member::find($id)->delete(); return redirect('members'); }
public function actionPeople() { $this->getView()->title = '公司团队'; $people = Member::find()->all(); return $this->render('people', ['people' => $people]); }
/** * Find Member by given id * * @param int $id * * @return \Illuminate\Support\Collection|null|static|Member */ public function findMemberById($id) { return Member::find($id); }
/** * Lists all Member models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Member::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }