This commit is contained in:
parent
aa91bc6617
commit
ae331335f8
@ -128,25 +128,6 @@ class ContractAllowableCityController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 詳細参照(表示のみ)
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
$record = ContractAllowableCity::getByPk($id);
|
||||
if (!$record) {
|
||||
return redirect()->route('contract_allowable_cities')->with('error', 'データが存在しません');
|
||||
}
|
||||
|
||||
return view('admin.contract_allowable_cities.edit', [
|
||||
'record' => $record,
|
||||
'cityList' => City::getList(),
|
||||
'parkList' => Park::getList(),
|
||||
'mode' => 'info'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一括削除(単一・複数対応)
|
||||
*/
|
||||
@ -174,37 +155,50 @@ class ContractAllowableCityController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* CSVエクスポート
|
||||
* 契約許容市区マスタ CSVエクスポート
|
||||
*/
|
||||
public function export(Request $request)
|
||||
{
|
||||
$filename = 'contract_allowable_cities_' . now()->format('Ymd_His') . '.csv';
|
||||
$filename = '契約許容市区マスタ_' . now()->format('YmdHis') . '.csv';
|
||||
|
||||
// 検索条件でデータ取得
|
||||
$list = ContractAllowableCity::search($request->all());
|
||||
|
||||
// CSVファイル作成
|
||||
$file = fopen($filename, 'w+');
|
||||
fwrite($file, "\xEF\xBB\xBF"); // UTF-8 BOM追加
|
||||
|
||||
// ヘッダー行
|
||||
$columns = [
|
||||
'契約許容市区ID',
|
||||
'市区ID',
|
||||
'許容市区名',
|
||||
'駐輪場ID',
|
||||
'隣接区フラグ'
|
||||
];
|
||||
fputcsv($file, $columns);
|
||||
|
||||
// データ行
|
||||
foreach ($list as $item) {
|
||||
fputcsv($file, [
|
||||
$item->contract_allowable_city_id,
|
||||
$item->city_id,
|
||||
$item->contract_allowable_city_name,
|
||||
$item->park_id,
|
||||
$item->same_district_flag == 0 ? '隣接市' : 'その他',
|
||||
]);
|
||||
}
|
||||
|
||||
fclose($file);
|
||||
|
||||
// ヘッダー設定
|
||||
$headers = [
|
||||
'Content-Type' => 'text/csv',
|
||||
'Content-Disposition' => "attachment; filename=\"$filename\"",
|
||||
"Content-Type" => "text/csv; charset=UTF-8",
|
||||
"Content-Disposition" => "attachment; filename={$filename}",
|
||||
];
|
||||
|
||||
return new StreamedResponse(function () use ($list) {
|
||||
$handle = fopen('php://output', 'w');
|
||||
|
||||
// ヘッダー
|
||||
fputcsv($handle, ['契約許容市区ID', '市区ID', '許容市区名', '駐輪場ID', '隣接区フラグ']);
|
||||
|
||||
foreach ($list as $item) {
|
||||
fputcsv($handle, [
|
||||
$item->contract_allowable_city_id,
|
||||
$item->city_id,
|
||||
$item->contract_allowable_city_name,
|
||||
$item->park_id,
|
||||
$item->same_district_flag == 0 ? '隣接市' : 'その他'
|
||||
]);
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
}, 200, $headers);
|
||||
// ダウンロード後に一時ファイル削除
|
||||
return response()->download($filename, $filename, $headers)->deleteFileAfterSend(true);
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@
|
||||
<!-- バリデーションエラー表示 -->
|
||||
@if ($errors->any())
|
||||
<div class="form-group col-12">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
|
||||
@ -146,46 +146,4 @@
|
||||
<!-- ▲ 単一テーブル構成ここまで -->
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
// 並び替え
|
||||
$('.sorting').click(function () {
|
||||
var sortColumn = $(this).attr('sort');
|
||||
var currentSortType = $('#sort_type').val();
|
||||
var newSortType = (sortColumn === $('#sort').val() && currentSortType === 'asc') ? 'desc' : 'asc';
|
||||
$('#sort').val(sortColumn);
|
||||
$('#sort_type').val(newSortType);
|
||||
$('#list-form').submit();
|
||||
});
|
||||
|
||||
// 全選択チェック
|
||||
$('#checkbox_all').change(function () {
|
||||
$('.checkbox').prop('checked', this.checked);
|
||||
});
|
||||
|
||||
// 削除ボタン
|
||||
$('#delete').click(function () {
|
||||
if ($('.checkbox:checked').length === 0) {
|
||||
alert('削除する項目を選択してください。');
|
||||
return false;
|
||||
}
|
||||
if (confirm('選択された項目を削除しますか?')) {
|
||||
$('#form_delete').submit();
|
||||
}
|
||||
});
|
||||
|
||||
// CSV出力
|
||||
$('#export_csv').click(function () {
|
||||
var action = $(this).attr('action');
|
||||
var form = $('#list-form');
|
||||
var originalAction = form.attr('action');
|
||||
form.attr('action', action);
|
||||
form.find('[name="isExport"]').remove();
|
||||
form.append('<input type="hidden" name="isExport" value="1">');
|
||||
form.submit();
|
||||
form.attr('action', originalAction);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<div class="col-sm-10">
|
||||
<input type="text"
|
||||
name="ptype_id"
|
||||
class="form-control"
|
||||
class="form-control form-control-lg"
|
||||
value="{{ $record->ptype_id }}"
|
||||
readonly>
|
||||
</div>
|
||||
@ -41,7 +41,7 @@
|
||||
<div class="col-sm-10">
|
||||
<input type="text"
|
||||
name="ptype_subject"
|
||||
class="form-control"
|
||||
class="form-control form-control-lg"
|
||||
value="{{ $isEdit ? old('ptype_subject', $record->ptype_subject ?? '') : '' }}"
|
||||
placeholder="{{ __('validation.attributes.psection_subject') }}"
|
||||
required>
|
||||
@ -54,7 +54,7 @@
|
||||
<div class="col-sm-10">
|
||||
<input type="text"
|
||||
name="floor_sort"
|
||||
class="form-control"
|
||||
class="form-control form-control-lg"
|
||||
value="{{ $isEdit ? old('floor_sort', $record->floor_sort ?? '') : '' }}"
|
||||
placeholder="{{ __('validation.attributes.floor_sort') }}">
|
||||
</div>
|
||||
@ -66,7 +66,7 @@
|
||||
<div class="col-sm-10">
|
||||
<input type="text"
|
||||
name="ptype_remarks"
|
||||
class="form-control"
|
||||
class="form-control form-control-lg"
|
||||
value="{{ $isEdit ? old('ptype_remarks', $record->ptype_remarks ?? '') : '' }}"
|
||||
placeholder="{{ $isEdit ? '' : __('validation.attributes.ptype_remarks') }}">
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user