diff --git a/app/Http/Controllers/ParkDetailController.php b/app/Http/Controllers/ParkDetailController.php
new file mode 100644
index 0000000..bde4c8e
--- /dev/null
+++ b/app/Http/Controllers/ParkDetailController.php
@@ -0,0 +1,87 @@
+where('park_id', $park_id)->first();
+ Log::debug('park:', (array)$park);
+ $zones = DB::table('zone')
+ ->leftJoin('psection', 'zone.psection_id', '=', 'psection.psection_id')
+ ->leftJoin('ptype', 'zone.ptype_id', '=', 'ptype.ptype_id')
+ ->select('zone.*', 'psection.psection_subject', 'ptype.ptype_subject')
+ ->where('zone.park_id', $park_id)
+ ->get();
+ Log::debug('zones:', $zones->toArray());
+ $reserves = DB::table('reserve')
+ ->join('zone', function ($join) {
+ $join->on('reserve.psection_id', '=', 'zone.psection_id')
+ ->on('reserve.ptype_id', '=', 'zone.ptype_id');
+ })
+ ->join('ptype', 'zone.ptype_id', '=', 'ptype.ptype_id')
+ ->where('reserve.park_id', $park_id)
+ ->where('reserve.valid_flag', 1)
+ ->select('reserve.*', 'ptype.ptype_subject')
+ ->get();
+ Log::debug('reserves:', $reserves->toArray());
+
+ $zoneStandardSum = [];
+ /*foreach ($zones as $zone) {
+ $psectionId = $zone->psection_id;
+ if (!isset($zoneStandardSum[$psectionId])) {
+ $zoneStandardSum[$psectionId] = 0;
+ }
+ $zoneStandardSum[$psectionId] += $zone->zone_standard;
+ }*/
+ $zoneStandardSum = [];
+ foreach ($zones as $zone) {
+ $key = $zone->psection_subject; // 「自転車」「原付」など
+ if (!isset($zoneStandardSum[$key])) {
+ $zoneStandardSum[$key] = 0;
+ }
+ $zoneStandardSum[$key] += $zone->zone_standard;
+ }
+ Log::debug('zoneStandardSum:', $zoneStandardSum);
+
+ // 空き台数集計用配列
+ $vacancyData = [];
+ foreach ($zones as $zone) {
+ $key = $zone->psection_id . '_' . $zone->ptype_subject;
+ if (!isset($vacancyData[$key])) {
+ $vacancyData[$key] = 0;
+ }
+ // zone_tolerance - zone_number を合計
+ $vacancyData[$key] += ($zone->zone_tolerance - $zone->zone_number);
+ }
+ Log::debug('vacancyData:', $vacancyData);
+
+ // reserve件数分を減算
+ foreach ($reserves as $reserve) {
+ $key = $reserve->psection_id . '_' . $reserve->ptype_subject;
+ if (isset($vacancyData[$key])) {
+ $vacancyData[$key] -= 1; // 1件分減算
+ }
+ }
+
+ // 更新期間取得
+ $city_grace_periods = DB::table('city')
+ ->select('city_id', 'update_grace_period_start_date', 'update_grace_period_start_time', 'update_grace_period_end_date', 'update_grace_period_end_time')
+ ->whereIn('city_id', function ($query) {
+ $query->select('city_id')->from('park');
+ })
+ ->get()
+ ->keyBy('city_id');
+ Log::debug('city_grace_periods:', $city_grace_periods->toArray());
+
+ // 必要なら他テーブルJOINや追加情報も取得
+ return response()->json([
+ 'html' => view('regular_contract.park_detail', compact('park', 'zones', 'reserves', 'zoneStandardSum', 'vacancyData', 'city_grace_periods'))->render()
+ ]);
+ }
+}
diff --git a/app/Http/Controllers/RegularContractController.php b/app/Http/Controllers/RegularContractController.php
index e22f916..5d650aa 100644
--- a/app/Http/Controllers/RegularContractController.php
+++ b/app/Http/Controllers/RegularContractController.php
@@ -396,8 +396,6 @@ class RegularContractController extends Controller
// 必要な各マスタ情報を取得
$user = DB::table('user')->where('user_id', $user_id)->first();
$contract = DB::table('regular_contract')->where('contract_id', $contract_id)->first();
- // $city_id = DB::table('park')->where('park_id', $contract->park_id)->value('city_id');
- //$city_name = DB::table('city')->where('city_id', $city_id)->value('city_name');
$park = DB::table('park')->where('park_id', $contract->park_id)->first();
$city = DB::table('city')->where('city_id', $park->city_id)->first();
$regular_type = DB::table('regular_type')->where('city_id', $city->city_id)->first();
diff --git a/app/Http/Controllers/RegularContractCreateController.php b/app/Http/Controllers/RegularContractCreateController.php
new file mode 100644
index 0000000..13850a4
--- /dev/null
+++ b/app/Http/Controllers/RegularContractCreateController.php
@@ -0,0 +1,793 @@
+where('user_id', $user_id)->first();
+
+ // 市町村名(park→city JOINで重複排除)
+ $cities = DB::table('park')
+ ->join('city', 'park.city_id', '=', 'city.city_id')
+ ->select('city.city_id', 'city.city_name')
+ ->distinct()
+ ->get();
+
+ // city_idごとの更新可能期間情報を取得
+ $city_grace_periods = DB::table('city')
+ ->select('city_id', 'update_grace_period_start_date', 'update_grace_period_start_time', 'update_grace_period_end_date', 'update_grace_period_end_time')
+ ->get()
+ ->keyBy('city_id');
+
+ // 駅名(stationテーブルのstation_neighbor_station全件)
+ $stations = DB::table('station')
+ ->select('station_neighbor_station')
+ ->distinct()
+ ->get();
+
+ // 駐輪場名(parkテーブルのpark_name全件)
+ $parks = DB::table('park')
+ ->select('park_id', 'park_name')
+ ->distinct()
+ ->get();
+
+ // テーブル表示用データ(park/city/station JOIN, park_id昇順, 10件ずつページング)
+ $page = request()->input('page', 1);
+ $perPage = 10;
+ $city_id = request()->input('city_id');
+ $station_name = request()->input('station_neighbor_station');
+ $park_id = request()->input('park_id');
+
+ $query = DB::table('park')
+ ->join('city', 'park.city_id', '=', 'city.city_id')
+ ->leftJoin('station', 'park.park_id', '=', 'station.park_id')
+ ->select(
+ 'park.park_id',
+ 'park.park_name',
+ 'park.park_ruby',
+ 'city.city_name',
+ 'city.city_id',
+ 'station.station_neighbor_station',
+ 'station.station_name_ruby'
+ );
+
+ if ($city_id) {
+ $query->where('city.city_id', $city_id);
+ }
+ if ($station_name) {
+ $query->where('station.station_neighbor_station', $station_name);
+ }
+ if ($park_id) {
+ $query->where('park.park_id', $park_id);
+ }
+
+ // 並び替えパラメータ取得
+ $sort = request()->input('sort', 'park_id');
+ $order = request()->input('order', 'asc');
+ $sortable = [
+ 'park_ruby' => 'park.park_ruby',
+ 'city_id' => 'city.city_id',
+ 'station_name_ruby' => 'station.station_name_ruby',
+ 'park_id' => 'park.park_id',
+ ];
+ if (isset($sortable[$sort])) {
+ $query->orderBy($sortable[$sort], $order);
+ } else {
+ $query->orderBy('park.park_id', 'asc');
+ }
+
+ $total = $query->count();
+ $parks_table = $query->skip(($page - 1) * $perPage)->take($perPage)->get();
+
+ // zoneテーブルデータを取得(psectionテーブルとJOINしてpsection_subjectも取得)
+ $zones = DB::table('zone')
+ ->leftJoin('psection', 'zone.psection_id', '=', 'psection.psection_id')
+ ->select('zone.zone_id', 'zone.park_id', 'zone.psection_id', 'zone.zone_number', 'zone.zone_tolerance', 'psection.psection_subject')
+ ->get()
+ ->groupBy('park_id');
+
+ // 空き予約マスタデータを取得
+ $reserve = DB::table('reserve')
+ ->select('reserve_id', 'park_id', 'psection_id')
+ ->where('valid_flag', 1)
+ ->get()
+ ->groupBy('park_id');
+
+ \Log::info('新規定期契約-駐輪場選択画面にアクセス', [
+ 'user_id' => $user_id,
+ ]);
+
+ return view('regular_contract.create', [
+ 'active_menu' => 'SWC-8-1', // この画面のID
+ 'user_name' => $user ? $user->user_name : '', // ユーザー名(ヘッダー用)
+ 'cities' => $cities,
+ 'stations' => $stations,
+ 'parks' => $parks,
+ 'parks_table' => $parks_table,
+ 'parks_table_total' => $total,
+ 'parks_table_page' => $page,
+ 'parks_table_perPage' => $perPage,
+ 'zones' => $zones,
+ 'city_grace_periods' => $city_grace_periods,
+ 'reserve' => $reserve,
+ ]);
+ }
+
+ public function regulationCheck(Request $request)
+ {
+ // GETパラメータを取得
+ $parkId = $request->query('park_id');
+ $psectionId = $request->query('psection_id');
+ $ptypeId = $request->query('ptype_id');
+
+ // 必要なDB処理やロジック
+ $park_regulation = DB::table('park')->where('park_id', $parkId)->value('parking_regulations_flag');
+
+ if ($park_regulation == 1) {
+ // 駐輪規定画面へ
+ return redirect()->route('regular_contract.regulation', [
+ 'park_id' => $parkId,
+ 'psection_id' => $psectionId,
+ 'ptype_id' => $ptypeId,
+ ]);
+ } else {
+ // 契約情報入力画面へ
+ return redirect()->route('regular_contract.input', [
+ 'park_id' => $parkId,
+ 'psection_id' => $psectionId,
+ 'ptype_id' => $ptypeId,
+ ]);
+ }
+ }
+
+ public function showRegulation(Request $request)
+ {
+ $user_id = session('user_id');
+ if (!$user_id) {
+ return redirect('/login');
+ }
+ $user_name = DB::table('user')->where('user_id', $user_id)->value('user_name');
+
+ // 必要なパラメータ取得
+ $parkId = $request->query('park_id');
+ $psectionId = $request->query('psection_id');
+ $ptypeId = $request->query('ptype_id');
+
+ $park_name = DB::table('park')->where('park_id', $parkId)->value('park_name');
+ $psection_subject = DB::table('psection')->where('psection_id', $psectionId)->value('psection_subject');
+ $ptype_subject = DB::table('ptype')->where('ptype_id', $ptypeId)->value('ptype_subject');
+ $regulations_text = DB::table('parking_regulations')
+ ->where('park_id', $parkId)
+ ->where('psection_id', $psectionId)
+ ->where('ptype_id', $ptypeId)
+ ->value('regulations_text');
+
+ \Log::info('駐輪規定確認画面にアクセス', [
+ 'user_id' => $user_id,
+ ]);
+
+ return view('regular_contract.regulation', [
+ 'park_id' => $parkId,
+ 'park_name' => $park_name,
+ 'psection_id' => $psectionId,
+ 'psection_subject' => $psection_subject,
+ 'ptype_id' => $ptypeId,
+ 'ptype_subject' => $ptype_subject,
+ 'regulations_text' => $regulations_text,
+ 'active_menu' => 'SWC-8-1', // この画面のID
+ 'user_name' => $user_name, // ユーザー名(ヘッダー用)
+ ]);
+ }
+
+ public function insertRegulation(Request $request)
+ {
+ $user_id = session('user_id');
+ if (!$user_id) {
+ return redirect('/login');
+ }
+ $park_id = $request->input('park_id');
+ $psection_id = $request->input('psection_id');
+ $ptype_id = $request->input('ptype_id');
+
+ DB::table('parking_regulations_read')->insert([
+ 'park_id' => $park_id,
+ 'psection_id' => $psection_id,
+ 'ptype_id' => $ptype_id,
+ 'user_id' => $user_id,
+ 'created_at' => now(),
+ ]);
+
+ // 契約入力画面へリダイレクト
+ return redirect()->route('regular_contract.input', [
+ 'park_id' => $park_id,
+ 'psection_id' => $psection_id,
+ 'ptype_id' => $ptype_id,
+ ]);
+ }
+
+ // 契約入力画面表示
+ public function showContractForm(Request $request)
+ {
+ $user_id = session('user_id');
+ if (!$user_id) {
+ return redirect('/login');
+ }
+ $user = DB::table('user')->where('user_id', $user_id)->first();
+ $park_id = $request->query('park_id');
+ $park = DB::table('park')->where('park_id', $park_id)->first();
+ $psection_id = $request->query('psection_id');
+ $ptype_id = $request->query('ptype_id');
+ $city_id = DB::table('park')->where('park_id', $park_id)->value('city_id');
+ $terms_text = DB::table('terms')->where('city_id', $city_id)->value('terms_text');
+ // 利用者区分をusertypeテーブルから取得
+ $user_category = '';
+ if (isset($user->user_categoryid)) {
+ $usertype = DB::table('usertype')
+ ->where('user_categoryid', $user->user_categoryid)
+ ->first();
+ if ($usertype && isset($usertype->usertype_subject1)) {
+ $user_category = $usertype->usertype_subject1;
+ }
+ }
+ $user->user_homephone = explode('-', $user->user_homephone ?? '');
+ $user->user_mobile = explode('-', $user->user_mobile ?? '');
+ $user->user_regident_zip_1 = substr($user->user_regident_zip ?? '', 0, 3);
+ $user->user_regident_zip_2 = substr($user->user_regident_zip ?? '', 3, 4);
+ $user->user_relate_zip_1 = substr($user->user_relate_zip ?? '', 0, 3);
+ $user->user_relate_zip_2 = substr($user->user_relate_zip ?? '', 3, 4);
+
+ \Log::info('新規定期契約-契約情報入力画面にアクセス', [
+ 'user_id' => $user_id,
+ ]);
+
+ session()->forget('show_terms_modal');
+
+ return view('regular_contract.input', [
+ 'park' => $park,
+ 'psection_id' => $psection_id,
+ 'ptype_id' => $ptype_id,
+ 'terms_text' => $terms_text,
+ 'user' => $user,
+ 'user_name' => $user->user_name, // ユーザー名(ヘッダー用)
+ 'active_menu' => 'SWC-8-1', // この画面のID
+ 'user_category' => $user_category,
+ 'show_terms_modal' => true,
+ ]);
+ }
+ public function inputCheck(Request $request)
+ {
+ $user_id = session('user_id');
+ if (!$user_id) {
+ return redirect('/login');
+ }
+ $user = DB::table('user')->where('user_id', $user_id)->first();
+
+ $park_id = $request->input('park_id');
+ $park = DB::table('park')->where('park_id', $park_id)->first();
+
+ // バリデーションルール
+ $rules = [
+ 'user_phonetic' => ['required', 'regex:/^[ァ-ヶー \s]+$/u'],
+ 'user_regident_zip_1' => 'required|digits:3',
+ 'user_regident_zip_2' => 'required|digits:4',
+ 'user_regident_pre' => [
+ 'required',
+ Rule::in([
+ '北海道',
+ '青森県',
+ '岩手県',
+ '宮城県',
+ '秋田県',
+ '山形県',
+ '福島県',
+ '茨城県',
+ '栃木県',
+ '群馬県',
+ '埼玉県',
+ '千葉県',
+ '東京都',
+ '神奈川県',
+ '新潟県',
+ '富山県',
+ '石川県',
+ '福井県',
+ '山梨県',
+ '長野県',
+ '岐阜県',
+ '静岡県',
+ '愛知県',
+ '三重県',
+ '滋賀県',
+ '京都府',
+ '大阪府',
+ '兵庫県',
+ '奈良県',
+ '和歌山県',
+ '鳥取県',
+ '島根県',
+ '岡山県',
+ '広島県',
+ '山口県',
+ '徳島県',
+ '香川県',
+ '愛媛県',
+ '高知県',
+ '福岡県',
+ '佐賀県',
+ '長崎県',
+ '熊本県',
+ '大分県',
+ '宮崎県',
+ '鹿児島県',
+ '沖縄県'
+ ]),
+ ],
+ 'user_regident_city' => ['required', 'string', 'max:20', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
+ 'user_regident_add' => ['required', 'string', 'max:50', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
+ 'user_homephone.*' => 'nullable|digits_between:1,5',
+ 'user_mobile.*' => 'nullable|digits_between:1,5',
+ 'user_submail' => 'nullable|email|different:user_primemail|max:80',
+ 'user_category' => ['required', Rule::in(['一般', '学生'])],
+ 'contract_reduction' => ['required', Rule::in(['はい', 'いいえ'])],
+ 'user_relate_zip_1' => 'nullable|digits:3',
+ 'user_relate_zip_2' => 'nullable|digits:4',
+ 'user_relate_pre' => [
+ 'nullable',
+ Rule::in([
+ '北海道',
+ '青森県',
+ '岩手県',
+ '宮城県',
+ '秋田県',
+ '山形県',
+ '福島県',
+ '茨城県',
+ '栃木県',
+ '群馬県',
+ '埼玉県',
+ '千葉県',
+ '東京都',
+ '神奈川県',
+ '新潟県',
+ '富山県',
+ '石川県',
+ '福井県',
+ '山梨県',
+ '長野県',
+ '岐阜県',
+ '静岡県',
+ '愛知県',
+ '三重県',
+ '滋賀県',
+ '京都府',
+ '大阪府',
+ '兵庫県',
+ '奈良県',
+ '和歌山県',
+ '鳥取県',
+ '島根県',
+ '岡山県',
+ '広島県',
+ '山口県',
+ '徳島県',
+ '香川県',
+ '愛媛県',
+ '高知県',
+ '福岡県',
+ '佐賀県',
+ '長崎県',
+ '熊本県',
+ '大分県',
+ '宮崎県',
+ '鹿児島県',
+ '沖縄県'
+ ]),
+ ],
+ 'user_relate_city' => ['nullable', 'string', 'max:20', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
+ 'user_relate_add' => ['nullable', 'string', 'max:50', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
+ ];
+ // 性別欄が表示されている場合のみ必須
+ if ((int)$park->gender_display_flag === 1) {
+ $rules['user_gender'] = ['required', Rule::in(['男性', '女性'])];
+ }
+ // 生年月日欄が表示されている場合のみ必須
+ if ((int)$park->bd_display_flag === 1) {
+ $rules['user_birthdate'] = ['required', 'date'];
+ }
+ // 防犯登録番号欄が表示されている場合のみ必須
+ if ((int)$park->securityreg_display_flag === 1) {
+ $rules['user_securitynum'] = ['required', 'max:50', 'regex:/^[a-zA-Z0-9]+$/'];
+ }
+ // 利用者区分ごとの追加バリデーション
+ if ($request->input('user_category') === '学生') {
+ $rules['user_school'] = ['required', 'string', 'max:50', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'];
+ $rules['user_graduate'] = ['required', 'date'];
+ } else {
+ $rules['user_workplace'] = ['nullable', 'string', 'max:50', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'];
+ }
+ $messages = [
+ 'user_phonetic.required' => 'フリガナが入力されていません。',
+ 'user_phonetic.regex' => 'フリガナはカタカナでご入力ください。',
+ 'user_gender.required' => '性別が入力されていません。',
+ 'user_gender.in' => '性別は「男性」または「女性」を選択してください。',
+ 'user_regident_zip_1.required' => '居住所の郵便番号(前半3桁)が入力されていません。',
+ 'user_regident_zip_2.required' => '居住所の郵便番号(後半4桁)が入力されていません。',
+ 'user_regident_zip_1.digits' => '居住所の郵便番号(前半3桁)は3桁の数字で入力してください。',
+ 'user_regident_zip_2.digits' => '居住所の郵便番号(後半4桁)は4桁の数字で入力してください。',
+ 'user_regident_pre.required' => '居住所の都道府県が選択されていません。',
+ 'user_regident_pre.in' => '都道府県は選択肢から選んでください。',
+ 'user_regident_city.required' => '居住所の市区町村が入力されていません。',
+ 'user_regident_city.max' => '居住所の市区町村は20文字以内で入力してください。',
+ 'user_regident_city.regex' => '居住所の市区町村に絵文字などの特殊文字は使用できません。',
+ 'user_regident_add.required' => '居住所の住所が入力されていません。',
+ 'user_regident_add.max' => '居住所の住所は50文字以内で入力してください。',
+ 'user_regident_add.regex' => '居住所の住所に絵文字などの特殊文字は使用できません。',
+ 'user_birthdate.required' => '生年月日が入力されていません。',
+ 'user_birthdate.date' => '生年月日は正しい日付で入力してください。',
+ 'user_homephone.*.digits_between' => '自宅電話番号はそれぞれ1~5桁の数字で入力してください。',
+ 'user_mobile.*.digits_between' => '携帯電話番号はそれぞれ1~5桁の数字で入力してください。',
+ 'user_submail.email' => '予備メールアドレスは正しい形式で入力してください。',
+ 'user_submail.max' => '予備メールアドレスは80文字以内で入力してください。',
+ 'user_submail.different' => 'メールアドレスと予備メールアドレスに同じアドレスを入力できません。',
+ 'user_category.required' => '利用者区分は必須です。',
+ 'user_category.in' => '利用者区分の値が不正です。',
+ 'contract_reduction.required' => '減免が選択されていません。',
+ 'contract_reduction.in' => '減免の値が不正です。',
+ 'user_workplace.max' => '勤務先は50文字以内で入力してください。',
+ 'user_workplace.regex' => '勤務先に絵文字などの特殊文字は使用できません。',
+ 'user_school.required' => '学校名が入力されていません。',
+ 'user_school.max' => '学校名は50文字以内で入力してください。',
+ 'user_school.regex' => '学校名に絵文字などの特殊文字は使用できません。',
+ 'user_graduate.required' => '卒業年月日が入力されていません。',
+ 'user_graduate.date' => '卒業年月日は正しい日付で入力してください。',
+ 'user_relate_zip_1.digits' => '住所の郵便番号(前半3桁)は3桁の数字で入力してください。',
+ 'user_relate_zip_2.digits' => '住所の郵便番号(後半4桁)は4桁の数字で入力してください。',
+ 'user_relate_pre.in' => '住所の都道府県は選択肢から選んでください。',
+ 'user_relate_city.max' => '住所の市区町村は20文字以内で入力してください。',
+ 'user_relate_city.regex' => '住所の市区町村に絵文字などの特殊文字は使用できません。',
+ 'user_relate_add.max' => '住所は50文字以内で入力してください。',
+ 'user_relate_add.regex' => '住所に絵文字などの特殊文字は使用できません。',
+ 'user_securitynum.required' => '防犯登録番号が入力されていません。',
+ 'user_securitynum.max' => '防犯登録番号は50文字以内で入力してください。',
+ 'user_securitynum.regex' => '防犯登録番号は英数字のみで入力してください。',
+ ];
+ try {
+ $validated = $request->validate($rules, $messages);
+ } catch (ValidationException $e) {
+ return Redirect()->back()
+ ->withErrors($e->validator)
+ ->withInput($request->except('_token') + ['show_terms_modal' => false]);
+ }
+
+ if (empty(implode('', $request->input('user_homephone', []))) && empty(implode('', $request->input('user_mobile', [])))) {
+ return redirect()->back()
+ ->withErrors(['user_homephone' => '自宅電話番号または携帯電話番号のいずれかは必須です'])
+ ->withInput($request->except('_token') + ['show_terms_modal' => false]);
+ }
+
+ $city = DB::table('city')->where('city_id', $park->city_id)->first();
+ $matched = (mb_strpos($request->user_regident_city, $city->city_name) !== false);
+ if ($matched === true) {
+ $ward_residents = 1;
+ DB::table('user')
+ ->where('user_id', $user->user_id)
+ ->update(['ward_residents' => $ward_residents]);
+ } else {
+ $contract_allowable_city_name = DB::table('contract_allowable_city')->where('city_id', $city->city_id)->value('contract_allowable_city_name');
+ $matched_allowable = (mb_strpos($request->user_regident_city, $contract_allowable_city_name) !== false);
+ if ($matched_allowable) {
+ $ward_residents = 0;
+ DB::table('user')
+ ->where('user_id', $user->user_id)
+ ->update(['ward_residents' => $ward_residents]);
+ } else {
+ return redirect()->back()->withErrors(['契約対象地域にお住まいでないためお申込みできません'])->withInput()->with(['show_terms_modal' => false]);
+ }
+ }
+ if ($ward_residents == 1) {
+ $usertype_subject2 = '区民';
+ } else {
+ $usertype_subject2 = '区民外';
+ }
+
+ $user_categoryid = DB::table('usertype')
+ ->where('usertype_subject1', $request->user_category)
+ ->where('usertype_subject2', $usertype_subject2)
+ ->value('user_categoryid');
+
+ $updateData = [
+ 'user_categoryid' => $user_categoryid,
+ 'user_phonetic' => $request->user_phonetic,
+ 'user_mobile' => implode('-', $request->input('user_mobile', [])),
+ 'user_homephone' => implode('-', $request->input('user_homephone', [])),
+ 'user_submail' => $request->filled('user_submail') ? $request->user_submail : null,
+ 'user_regident_zip' => $request->user_regident_zip_1 . $request->user_regident_zip_2,
+ 'user_regident_pre' => $request->user_regident_pre,
+ 'user_regident_city' => $request->user_regident_city,
+ 'user_regident_add' => $request->user_regident_add,
+ 'user_relate_zip' => ($request->filled('user_relate_zip_1') && $request->filled('user_relate_zip_2')) ? ($request->user_relate_zip_1 . $request->user_relate_zip_2) : null,
+ 'user_relate_pre' => $request->filled('user_relate_pre') ? $request->user_relate_pre : null,
+ 'user_relate_city' => $request->filled('user_relate_city') ? $request->user_relate_city : null,
+ 'user_relate_add' => $request->filled('user_relate_add') ? $request->user_relate_add : null,
+ 'ward_residents' => $ward_residents,
+ 'user_workplace' => $request->user_category === '一般' ? $request->user_workplace : null,
+ 'user_school' => $request->user_category === '学生' ? $request->user_school : null,
+ 'user_graduate' => $request->user_category === '学生' ? $request->user_graduate : null,
+ 'updated_at' => now()
+ ];
+
+ // 性別欄が表示されている場合のみ追加
+ if (!empty($park->gender_display_flag) && $park->gender_display_flag == 1) {
+ $updateData['user_gender'] = $request->user_gender;
+ }
+
+ // 生年月日欄が表示されている場合のみ追加
+ if (!empty($park->bd_display_flag) && $park->bd_display_flag == 1) {
+ $updateData['user_birthdate'] = $request->user_birthdate;
+ $updateData['user_age'] = $request->user_age;
+ }
+
+ DB::table('user')
+ ->where('user_id', $user->user_id)
+ ->update($updateData);
+
+ $zone_id = DB::table('zone')
+ ->where('park_id', $request->park_id)
+ ->where('ptype_id', $request->ptype_id)
+ ->where('psection_id', $request->psection_id)
+ ->orderBy('zone_sort', 'asc')
+ ->value('zone_id');
+
+ $contract_id = DB::table('regular_contract')->insertGetId([
+ 'created_at' => now(),
+ 'updated_at' => now(),
+ 'user_id' => $user->user_id,
+ 'user_categoryid' => $user_categoryid,
+ 'park_id' => $park->park_id,
+ 'contract_created_at' => now(),
+ 'contract_reduction' => $ward_residents,
+ 'update_flag' => 2,
+ 'contract_cancel_flag' => 0,
+ 'psection_id' => $request->psection_id,
+ 'ptype_id' => $request->ptype_id,
+ 'zone_id' => $zone_id
+ ]);
+
+ $contractUpdateData = [
+ 'contract_qr_id' => DB::raw("TO_BASE64(AES_ENCRYPT($contract_id, 'LJLASR4FAS34SAADFA72ASDFALLSDRGT'))")
+ ];
+ // 防犯登録番号が表示されている場合のみ追加
+ if (!empty($park->securityreg_display_flag) && $park->securityreg_display_flag == 1) {
+ $contractUpdateData['user_securitynum'] = $request->user_securitynum;
+ }
+
+ DB::table('regular_contract')
+ ->where('contract_id', $contract_id)
+ ->update($contractUpdateData);
+
+ return redirect()->route('regular_contract.upload_identity_create', [
+ 'contract_id' => $contract_id,
+ ]);
+ }
+
+ public function showUploadIdentityCreate(Request $request)
+ {
+ $user_id = session('user_id');
+ if (!$user_id) {
+ return redirect('/login');
+ }
+ $user_name = DB::table('user')->where('user_id', $user_id)->value('user_name');
+ $contract = DB::table('regular_contract')->where('contract_id', $request->contract_id)->first();
+
+ \Log::info('新規定期契約-本人確認書類アップロード画面にアクセス', [
+ 'user_id' => $user_id,
+ ]);
+
+ return view('regular_contract.upload_identity_create', [
+ 'contract_id' => $request->contract_id,
+ 'park_id' => $contract->park_id,
+ 'psection_id' => $contract->psection_id,
+ 'ptype_id' => $contract->ptype_id,
+ 'user_name' => $user_name,
+ 'active_menu' => 'SWC-8-1'
+ ]);
+ }
+ public function confirmUploadIdentity(Request $request, $contract_id)
+ {
+ $user_id = session('user_id');
+ if (!$user_id) {
+ return redirect('/login');
+ }
+
+ $validator = Validator::make($request->all(), [
+ 'idcard_type' => 'required',
+ 'user_idcard' => 'required|file|mimes:jpg,jpeg,png,pdf',
+ ], [
+ 'idcard_type.required' => '本人確認書類の種類を選択してください。',
+ 'user_idcard.required' => '本人確認書類のおもて画像をアップロードしてください。',
+ 'user_idcard.file' => '本人確認書類のおもて画像はファイルで指定してください。',
+ 'user_idcard.mimes' => 'アップロードできるファイル形式はjpg、jpeg、png、pdfのみです。',
+ ]);
+ if ($validator->fails()) {
+ return redirect()->route('regular_contract.upload_identity_create', [
+ 'contract_id' => $contract_id,
+ ])
+ ->withErrors($validator)
+ ->withInput();
+ }
+
+ // おもて画像保存
+ $front = $request->file('user_idcard');
+ $filename_front = uniqid('photo1_') . '.' . $front->getClientOriginalExtension();
+ $front->storeAs('photo', $filename_front, 'public');
+ // userテーブルに保存 本人確認書類チェック済フラグや更新日時も更新項目に追加
+ $updateData = [
+ 'photo_filename1' => $filename_front,
+ 'user_idcard' => $request->idcard_type,
+ 'user_idcard_chk_flag' => 1,
+ 'updated_at' => now(),
+ ];
+ // ウラ画像がある場合保存し更新項目に追加
+ if ($request->hasFile('user_idcard2')) {
+ $back = $request->file('user_idcard2');
+ $filename_back = uniqid('photo2_') . '.' . $back->getClientOriginalExtension();
+ $back->storeAs('photo', $filename_back, 'public');
+ $updateData['photo_filename2'] = $filename_back;
+ }
+ DB::table('user')->where('user_id', $user_id)->update($updateData);
+ $user = DB::table('user')->where('user_id', $user_id)->first();
+ $park = DB::table('park')->where('park_id', $request->park_id)->first();
+ $psection = DB::table('psection')->where('psection_id', $request->psection_id)->first();
+ $usertype = DB::table('usertype')->where('user_categoryid', $user->user_categoryid)->first();
+
+ \Log::info('新規定期契約-契約情報確認画面にアクセス', [
+ 'user_id' => $user_id,
+ ]);
+
+ return view('regular_contract.create_confirm', [
+ 'contract_id' => $request->contract_id,
+ 'user' => $user,
+ 'park' => $park,
+ 'psection' => $psection,
+ 'usertype' => $usertype,
+ 'user_name' => $user->user_name,
+ 'active_menu' => 'SWC-8-1'
+ ]);
+ }
+
+ public function createConfirmNext($contract_id)
+ {
+ $user_id = session('user_id');
+ if (!$user_id) {
+ return redirect('/login');
+ }
+ $user = DB::table('user')->where('user_id', $user_id)->first();
+
+ // 本人確認自動処理結果を取得
+ if ($user && $user->user_idcard_chk_flag == 2) {
+ // 本人確認OKの場合は利用期間選択画面へ
+ // 必要な各マスタ情報を取得
+ $contract = DB::table('regular_contract')->where('contract_id', $contract_id)->first();
+ $park = DB::table('park')->where('park_id', $contract->park_id)->first();
+ $city = DB::table('city')->where('city_id', $park->city_id)->first();
+ $regular_type = DB::table('regular_type')->where('city_id', $city->city_id)->first();
+ $usertype = DB::table('usertype')->where('user_categoryid', $contract->user_categoryid)->first();
+
+ // 2重化しているマスタのため現在のテーブル名を取得
+ $master_setting = DB::table('setting')->value('web_master');
+ $tableName = 'price' . $master_setting;
+
+ // 利用者区分に応じた逆利用フラグを取得
+ $inverse_use_flag_column = ($usertype->usertype_subject1 == '一般') ? 'inverse_use_flag1' : 'inverse_use_flag2';
+ $inverse_use_flag = $park->$inverse_use_flag_column;
+
+ if ($inverse_use_flag == 0) {
+ // regident_cityまたはrelate_cityが一致するか
+ $is_same = (
+ strpos($user->user_regident_city, $city->city_name) !== false ||
+ strpos($user->user_relate_city, $city->city_name) !== false
+ );
+ } else {
+ // regident_cityのみ一致するか
+ $is_same = (strpos($user->user_regident_city, $city->city_name) !== false);
+ }
+
+ $target_subject2 = $is_same ? '区民' : '区民外';
+ $user_categoryid = DB::table('usertype')
+ ->where('usertype_subject1', $usertype->usertype_subject1)
+ ->where('usertype_subject2', $target_subject2)
+ ->where('usertype_subject3', $usertype->usertype_subject3)
+ ->value('user_categoryid');
+
+ // 駐輪場所マスタから料金を取得
+ $prices = DB::table($tableName)
+ ->where('park_id', $contract->park_id)
+ ->where('psection_id', $contract->psection_id)
+ ->where('ptype_id', $contract->ptype_id)
+ ->where('user_categoryid', $user_categoryid)
+ ->get();
+
+ \Log::info('利用期間選択画面にアクセス', [
+ 'user_id' => $user_id,
+ ]);
+
+ // 利用期間選択画面へ遷移
+ return view('regular_contract.create_select_period', [
+ 'active_menu' => 'SWC-4-1', // マイページメニューの選択状態用
+ 'user_name' => $user->user_name, // ユーザー名(ヘッダー用)
+ 'contract_id' => $contract_id,
+ 'regular_type' => $regular_type,
+ 'prices' => $prices,
+ ]);
+ } else {
+ // NGの場合は本人確認書類確認中画面へ
+ \Log::info('本人確認書類確認中画面にアクセス', [
+ 'user_id' => $user_id,
+ ]);
+ return view('regular_contract.create_idcard_checking', [
+ 'active_menu' => 'SWC-8-1', // マイページメニューの選択状態用
+ 'user_name' => $user->user_name, // ユーザー名(ヘッダー用)
+ ]);
+ }
+ }
+
+ public function selectPeriod(Request $request)
+ {
+ $user_id = session('user_id');
+ if (!$user_id) {
+ return redirect('/login');
+ }
+
+ // 期間選択チェック
+ $request->validate([
+ 'month' => 'required',
+ ], [
+ 'month.required' => '契約期間が選択されていません。',
+ ]);
+
+ $contract_id = $request->input('contract_id');
+ $month = $request->input('month');
+ $price = $request->input('price_' . $month);
+
+ \Log::info('契約期間更新処理', [
+ 'month' => $month,
+ 'price' => $price,
+ ]);
+ $today = now();
+ $day = $today->day;
+ if ($day <= 19) {
+ // 今月の1日
+ $contract_periods = $today->copy()->startOfMonth()->format('Y-m-d');
+ } else {
+ // 翌月の1日
+ $contract_periods = $today->copy()->addMonth()->startOfMonth()->format('Y-m-d');
+ }
+ $contract_periode = Carbon::parse($contract_periods)->addMonths($month - 1)->endOfMonth()->format('Y-m-d');
+ // 契約更新
+ DB::table('regular_contract')->where('contract_id', $contract_id)->update([
+ 'enable_months' => $month,
+ 'billing_amount' => $price,
+ 'contract_periods' => $contract_periods,
+ 'contract_periode' => $contract_periode,
+ 'updated_at' => now(),
+ ]);
+
+ // 完了後はウェルネット決済画面(仮)へリダイレクト
+ return redirect()->route('wellnet.payment');
+ }
+}
diff --git a/public/assets/js/commons.js b/public/assets/js/commons.js
index baee260..ef0a3b2 100644
--- a/public/assets/js/commons.js
+++ b/public/assets/js/commons.js
@@ -1,88 +1,87 @@
/* ハンバーガーメニュー開閉
============================*/
-$(function() {
- //ナビメニューボタンの開く・閉じる
- $('#nav-menu-btn').on('click', function() {
+$(function () {
+ //ナビメニューボタンの開く・閉じる
+ $('#nav-menu-btn').on('click', function () {
$('#nav-menu-btn span').toggleClass('typcn-th-menu');
$('#nav-menu-btn span').toggleClass('typcn-times');
});
- //ナビメニューボタンの「開く・閉じる」文字変更
- var flg = "default";
- $('#my-menu-btn').click(function(){
- if(flg == "default"){
- $(this).text("マイメニューを閉じる");
- flg = "changed";
- }else{
- $(this).text("マイメニューを開く");
- flg = "default";
- }
- });
+ //ナビメニューボタンの「開く・閉じる」文字変更
+ var flg = "default";
+ $('#my-menu-btn').click(function () {
+ if (flg == "default") {
+ $(this).text("マイメニューを閉じる");
+ flg = "changed";
+ } else {
+ $(this).text("マイメニューを開く");
+ flg = "default";
+ }
+ });
});
/* slick slider
============================*/
-$(function() {
+$(function () {
$('.slider_1-1').slick({
- infinite: true,
- dots:true,
- arrows: true,
- slidesToShow: 1,
- slidesToScroll: 1,
- responsive: [{
- breakpoint: 992,
- settings: {
- slidesToShow: 1,
- slidesToScroll: 1,
- }
- }]
- });
+ infinite: true,
+ dots: true,
+ arrows: true,
+ slidesToShow: 1,
+ slidesToScroll: 1,
+ responsive: [{
+ breakpoint: 992,
+ settings: {
+ slidesToShow: 1,
+ slidesToScroll: 1,
+ }
+ }]
+ });
$('.slider_2-1').slick({
- infinite: true,
- dots:true,
- arrows: true,
- slidesToShow: 2,
- slidesToScroll: 2,
- responsive: [{
- breakpoint: 992,
- settings: {
- slidesToShow: 1,
- slidesToScroll: 1,
- }
- }]
- });
+ infinite: true,
+ dots: true,
+ arrows: true,
+ slidesToShow: 2,
+ slidesToScroll: 2,
+ responsive: [{
+ breakpoint: 992,
+ settings: {
+ slidesToShow: 1,
+ slidesToScroll: 1,
+ }
+ }]
+ });
$('.info-slider_1-1').slick({
- infinite: true,
- dots: false,
- arrows: true,
- slidesToShow: 1,
- slidesToScroll: 1,
- responsive: [{
- breakpoint: 992,
- settings: {
- slidesToShow: 1,
- slidesToScroll: 1,
- }
- }]
- });
+ infinite: true,
+ dots: false,
+ arrows: true,
+ slidesToShow: 1,
+ slidesToScroll: 1,
+ responsive: [{
+ breakpoint: 992,
+ settings: {
+ slidesToShow: 1,
+ slidesToScroll: 1,
+ }
+ }]
+ });
});
/* jquery.tablesorter(空き駐輪場検索)
============================*/
- $(document).ready(function()
- {
- $("#searchTable").tablesorter({
- sortList: [[0,0]]
- });
- }
- );
+$(document).ready(function () {
+ $("#searchTable").tablesorter({
+ sortList: [[0, 0]]
+ });
+}
+);
/* 文字の拡大・縮小
============================*/
-$(function() {
- //文字サイズ・大きく
- $('#scale-control-area .btn-success').on('click', function() {
+$(function () {
+ //文字サイズ・大きく
+ $('#scale-control-area .btn-success').on('click', function () {
$(this).toggleClass('d-none');
$('#scale-control-area .btn-submit').toggleClass('d-none');
$('#scale-control-area .btn-secondary').addClass('d-none');
@@ -91,26 +90,80 @@ $(function() {
$('#font-scale').removeClass('f-bigger');
$('#font-scale').removeClass('f-small');
});
- //文字サイズ・さらに大きく
- $('#scale-control-area .btn-submit').on('click', function() {
+ //文字サイズ・さらに大きく
+ $('#scale-control-area .btn-submit').on('click', function () {
$('#scale-control-area .btn-success').toggleClass('d-none');
$('#font-scale').addClass('f-bigger');
$('#font-scale').removeClass('f-big');
$('#font-scale').removeClass('f-small');
});
- //文字サイズ・小さく
- $('#scale-control-area .btn-secondary').on('click', function() {
+ //文字サイズ・小さく
+ $('#scale-control-area .btn-secondary').on('click', function () {
$(this).toggleClass('d-none');
$('#scale-control-area .btn-cancel').toggleClass('d-none');
$('#font-scale').addClass('f-small');
$('#font-scale').removeClass('f-bigger');
$('#font-scale').removeClass('f-big');
});
- //文字サイズ・元のサイズへ
- $('#scale-control-area .btn-cancel').on('click', function() {
+ //文字サイズ・元のサイズへ
+ $('#scale-control-area .btn-cancel').on('click', function () {
$('#scale-control-area .btn-secondary').toggleClass('d-none');
$('#font-scale').removeClass('f-bigger');
$('#font-scale').removeClass('f-big');
$('#font-scale').removeClass('f-small');
});
-});
\ No newline at end of file
+});
+
+// 駐輪場詳細ポップアップ
+$(document).on('click', '.btn-popup', function () {
+ var parkId = $(this).data('park-id');
+ $.ajax({
+ url: '/api/park-detail/' + parkId,
+ method: 'GET',
+ success: function (data) {
+ $('#modalArea').html(data.html); // モーダル全体を挿入
+ $('#parkDetailModal').modal('show'); // モーダルを表示
+ },
+ error: function () {
+ alert('詳細情報の取得に失敗しました');
+ }
+ });
+});
+
+$(document).on('click', '.btn-reserve', function (e) {
+ e.preventDefault();
+ var parkId = $(this).data('park-id');
+ var psectionId = $(this).data('psection-id');
+ var ptypeId = $(this).data('ptype-id');
+
+ $.confirm({
+ title: '確認',
+ content: 'こちらの駐輪場を予約しますか?
お申込みいただく各自治体の条例等によって、駐輪場までの距離制限等によりご契約いただけない場合がございます。
予めご了承くださいますようお願いいたします。',
+ buttons: {
+ OK: function () {
+ // GETパラメータでregulationメソッドに遷移
+ location.href = '/park-waitlist/create?park_id=' + parkId + '&psection_id=' + psectionId + '&ptype_id=' + ptypeId;
+ },
+ キャンセル: function () { }
+ }
+ });
+});
+
+$(document).on('click', '.btn-contract', function (e) {
+ e.preventDefault();
+ var parkId = $(this).data('park-id');
+ var psectionId = $(this).data('psection-id');
+ var ptypeId = $(this).data('ptype-id');
+
+ $.confirm({
+ title: '確認',
+ content: 'こちらの駐輪場で定期契約を申し込みますか?',
+ buttons: {
+ OK: function () {
+ // GETパラメータでregulationCheckメソッドに遷移
+ location.href = '/regular-contract/regulationCheck?park_id=' + parkId + '&psection_id=' + psectionId + '&ptype_id=' + ptypeId;
+ },
+ キャンセル: function () { }
+ }
+ });
+});
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php
index a02655b..6aed38d 100644
--- a/resources/views/layouts/app.blade.php
+++ b/resources/views/layouts/app.blade.php
@@ -46,18 +46,12 @@
{{-- フッター --}}
@include('partials.footer')
-
-
+
-
-
-
+
@yield('scripts')