public function resendVerify(Requests\ResetCheck $request) { $user_data = RegisterUsers::where('email', $request->get('email'))->where('pid', $request->get('pid'))->where('reg_verify', 0)->get(); if (isset($user_data[0])) { $phone = RegisterDetails::where('account_id', $user_data[0]->id)->get(); $rand = $user_data[0]->verify_code; /* Send the SMS to Users */ $date = date("YmdHis"); $pwd_file = fopen(public_path('msg_tmp/') . $date . $rand . ".txt", "a"); $content = "ccucc," . $phone[0]->phone . ",夥伴您好:驗證碼:" . $rand . "請填入系統送出註冊並填報名資訊,始完成報名。驗證網站:https://goo.gl/kfvpCT,"; $content = iconv('UTF-8', 'Big5', $content); fwrite($pwd_file, $content); fclose($pwd_file); $chk_file = fopen(public_path('msg_tmp/') . $date . $rand . ".chk", "a"); fclose($chk_file); $conn_id = ftp_connect("210.71.253.195"); $login_result = ftp_login($conn_id, "sms", "sms"); if ($login_result) { ftp_put($conn_id, $date . $rand . ".txt", public_path('msg_tmp/') . $date . $rand . ".txt", FTP_ASCII); ftp_put($conn_id, $date . $rand . ".chk", public_path('msg_tmp/') . $date . $rand . ".chk", FTP_ASCII); } $email = $user_data[0]->email; $name = $phone[0]->name; /* Send the Mail to Users */ Mail::send('emails.welcome', ['code' => $rand], function ($message) use($email, $name) { $message->from('*****@*****.**', '105偏鄉教師寒假教學專業成長研習'); $message->to($email, $name)->subject('【驗證通知信】105偏鄉教師寒假教學專業成長研習'); }); return redirect()->intended('/verify'); } else { return view('auth.reset')->with('alert_failed', true); } }
public function selectSubject() { $user_data = RegisterUsers::where('email', Auth::user()->email)->get(); $user_details = RegisterDetails::where('account_id', $user_data[0]->id)->get(); $user_reg_subject_1 = RegisterSubjects::where('account_id', $user_data[0]->id)->get(); $user_reg_subject_1_displayName = SubjectList::where('subject_id', isset($user_reg_subject_1[0]) ? $user_reg_subject_1[0]->reg_subject_1 : 0)->get(); $user_reg_subject_2 = RegisterSubjects2::where('account_id', $user_data[0]->id)->get(); $user_reg_subject_2_displayName = SubjectList::where('subject_id', isset($user_reg_subject_2[0]) ? $user_reg_subject_2[0]->reg_subject_2 : 0)->get(); $settings_value = Settings::all(); if ($settings_value[0]->value <= Carbon::now() && $settings_value[1]->value >= Carbon::now()) { return view('general.select-subject', compact('user_details', 'user_data', 'user_reg_subject_1', 'user_reg_subject_2', 'user_reg_subject_1_displayName', 'user_reg_subject_2_displayName')); } else { return view('errors.RegisterInValid'); } }
public function setSelect() { /* * Priority all selected. */ $subject_list = SubjectList::where('subject_id', '<', 20000)->get(); foreach ($subject_list as $subject_first_day) { $all_capacity = $subject_first_day->subject_normal; $subject_code = $subject_first_day->subject_id; $priority_count = RegisterSubjects::where('reg_subject_1', $subject_code)->where('priority', '1')->update(['already_pick_1' => 1, 'ps' => 'PRIORITY']); $left_capacity = $all_capacity - $priority_count; $far = $left_capacity / 2; $reg_data = RegisterSubjects::where('reg_subject_1', $subject_code)->where('already_pick_1', '!=', '1')->get(); foreach ($reg_data as $reg_data_details) { $user_details = RegisterDetails::where('account_id', $reg_data_details->account_id)->get(); $user_far = FarSchool::where('sf_school_id', $user_details[0]->school)->count(); if ($user_far == 1) { RegisterSubjects::where('account_id', $reg_data_details->account_id)->update(['already_pick_1' => 1, 'ps' => 'FAR']); $far--; } if ($far == 0) { break; } } $count = RegisterSubjects::where('reg_subject_1', $subject_code)->where('already_pick_1', 1)->count(); $normal = $all_capacity - $count; $reg_data = RegisterSubjects::where('reg_subject_1', $subject_code)->where('already_pick_1', '!=', '1')->get(); foreach ($reg_data as $reg_data_details) { RegisterSubjects::where('account_id', $reg_data_details->account_id)->update(['already_pick_1' => 1, 'ps' => 'P_NORMAL']); $normal--; if ($normal == 0) { break; } } } $subject_list = SubjectList::where('subject_id', '>', 20000)->get(); foreach ($subject_list as $subject_second_day) { $all_capacity = $subject_second_day->subject_normal; $subject_code = $subject_second_day->subject_id; $priority_count = RegisterSubjects2::where('reg_subject_2', $subject_code)->where('priority', '1')->update(['already_pick_2' => 1, 'ps' => 'PRIORITY']); $left_capacity = $all_capacity - $priority_count; $far = $left_capacity / 2; $reg_data = RegisterSubjects2::where('reg_subject_2', $subject_code)->where('already_pick_2', '!=', '1')->get(); foreach ($reg_data as $reg_data_details) { $user_details = RegisterDetails::where('account_id', $reg_data_details->account_id)->get(); $user_far = FarSchool::where('sf_school_id', $user_details[0]->school)->count(); if ($user_far == 1) { RegisterSubjects2::where('account_id', $reg_data_details->account_id)->update(['already_pick_2' => 1, 'ps' => 'FAR']); $far--; } if ($far == 0) { break; } } $count = RegisterSubjects2::where('reg_subject_2', $subject_code)->where('already_pick_2', 1)->count(); $normal = $all_capacity - $count; $reg_data = RegisterSubjects2::where('reg_subject_2', $subject_code)->where('already_pick_2', '!=', '1')->get(); foreach ($reg_data as $reg_data_details) { RegisterSubjects2::where('account_id', $reg_data_details->account_id)->update(['already_pick_2' => 1, 'ps' => 'P_NORMAL']); $normal--; if ($normal == 0) { break; } } } /* Giving Registration Number */ $subject_list = SubjectList::where('subject_id', '<', 20000)->get(); foreach ($subject_list as $subject_first_day) { if ($subject_first_day->subject_id == 10001) { $first_one = RegisterSubjects::where('reg_subject_1', $subject_first_day->subject_id)->where('already_pick_1', 1)->where('ps', 'PRIORITY')->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'A' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } $first_one = RegisterSubjects::where('reg_subject_1', $subject_first_day->subject_id)->where('already_pick_1', 1)->where('ps', '!=', 'PRIORITY')->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'B' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } } if ($subject_first_day->subject_id == 10004) { $first_one = RegisterSubjects::where('reg_subject_1', $subject_first_day->subject_id)->where('already_pick_1', 1)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'E' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } } if ($subject_first_day->subject_id == 10009 || $subject_first_day->subject_id == 10006 || $subject_first_day->subject_id == 10007 || $subject_first_day->subject_id == 10008) { $first_one = RegisterSubjects::where('reg_subject_1', 10009)->where('already_pick_1', 1)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'F' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } $first_one = RegisterSubjects::where('reg_subject_1', 10008)->where('already_pick_1', 1)->get(); foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'F' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } $first_one = RegisterSubjects::where('reg_subject_1', 10007)->where('already_pick_1', 1)->get(); foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'F' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } $first_one = RegisterSubjects::where('reg_subject_1', 10006)->where('already_pick_1', 1)->get(); foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'E' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } } if ($subject_first_day->subject_id == 10002) { $first_one = RegisterSubjects::where('reg_subject_1', $subject_first_day->subject_id)->where('already_pick_1', 1)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'H' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } } if ($subject_first_day->subject_id == 10002) { $first_one = RegisterSubjects::where('reg_subject_1', $subject_first_day->subject_id)->where('already_pick_1', 1)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'H' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } } if ($subject_first_day->subject_id == 10003) { $first_one = RegisterSubjects::where('reg_subject_1', $subject_first_day->subject_id)->where('already_pick_1', 1)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'G' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } } if ($subject_first_day->subject_id == 10005) { $first_one = RegisterSubjects::where('reg_subject_1', $subject_first_day->subject_id)->where('already_pick_1', 1)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'L' . $value; RegisterSubjects::where('account_id', $first_one_things->account_id)->where('reg_subject_1', $first_one_things->reg_subject_1)->update(['stu_id' => $value]); } } } $subject_list = SubjectList::where('subject_id', '>', 20000)->get(); foreach ($subject_list as $subject_first_day) { if ($subject_first_day->subject_id == 20004) { $first_one = RegisterSubjects2::where('reg_subject_2', $subject_first_day->subject_id)->where('already_pick_2', 1)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'C' . $value; RegisterSubjects2::where('account_id', $first_one_things->account_id)->where('reg_subject_2', $first_one_things->reg_subject_2)->update(['stu_id' => $value]); } } if ($subject_first_day->subject_id == 20001) { $first_one = RegisterSubjects2::where('reg_subject_2', $subject_first_day->subject_id)->where('already_pick_2', 1)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'D' . $value; RegisterSubjects2::where('account_id', $first_one_things->account_id)->where('reg_subject_2', $first_one_things->reg_subject_2)->update(['stu_id' => $value]); } } if ($subject_first_day->subject_id == 20005) { $first_one = RegisterSubjects2::where('reg_subject_2', $subject_first_day->subject_id)->where('already_pick_2', 1)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'I' . $value; RegisterSubjects2::where('account_id', $first_one_things->account_id)->where('reg_subject_2', $first_one_things->reg_subject_2)->update(['stu_id' => $value]); } } if ($subject_first_day->subject_id == 20002 || $subject_first_day->subject_id == 20003) { $first_one = RegisterSubjects2::where('ps', 'PRIORITY')->where('already_pick_2', 1)->where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'J' . $value; RegisterSubjects2::where('account_id', $first_one_things->account_id)->where('reg_subject_2', $first_one_things->reg_subject_2)->update(['stu_id' => $value]); } $first_one = RegisterSubjects2::where('ps', '!=', 'PRIORITY')->where('already_pick_2', 1)->where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->get(); $reg = 0; foreach ($first_one as $first_one_things) { $reg++; $value = str_pad($reg, 3, '0', STR_PAD_LEFT); $value = 'K' . $value; RegisterSubjects2::where('account_id', $first_one_things->account_id)->where('reg_subject_2', $first_one_things->reg_subject_2)->update(['stu_id' => $value]); } } } return 'SUCCESS'; }
public function PriorityMemberQuery() { $select_count = SelectList::all()->count(); $select_list = SelectList::all(); $count = 0; for ($i = 0; $i < $select_count; $i++) { if (isset($select_list[0]->pid)) { $count += RegisterUsers::where('pid', $select_list[0]->pid)->take(1)->count(); } elseif (isset($select_list[0]->email)) { $count += RegisterUsers::where('email', $select_list[0]->email)->take(1)->count(); } elseif (isset($select_list[0]->phone)) { $count += RegisterDetails::where('phone', $select_list[0]->phone)->take(1)->count(); } elseif (isset($select_list[0]->phone)) { $count += RegisterDetails::where('name', $select_list[0]->name)->take(1)->count(); } } }