增加後台圖檔旋轉功能。加強報名地址檢查。修正前台文字。增加前後台報名欄位。設定報名欄位TWID為UNIQUE。修正前台報名可以連續送出的問題。
This commit is contained in:
@ -21,11 +21,14 @@ class IframeField
|
||||
? $options['url'](CrudPanelFacade::getFacadeRoot())
|
||||
: ($options['url'] ?? null);
|
||||
|
||||
$imageRotation90Url = str_replace('/storage/', '/storage/image-rotation90/', $url);
|
||||
|
||||
$field = [
|
||||
'name' => $name,
|
||||
'label' => $label,
|
||||
'type' => 'iframe',
|
||||
'url' => $url, // URL to display in iframe
|
||||
'image-rotation-url' => $imageRotation90Url,
|
||||
'width' => $options['width'] ?? '', // Iframe width
|
||||
'height' => $options['height'] ?? '', // Iframe height
|
||||
'extra_attributes' => $options['extra_attributes'] ?? [], // Additional iframe attributes
|
||||
|
@ -51,7 +51,7 @@ class EventHealthAllowanceCrudController extends CrudController
|
||||
'name' => 'check_state',
|
||||
'label' => '審核狀態',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖', '4' => '重覆資料(僅標記)'],
|
||||
],
|
||||
[
|
||||
'name' => 'hospital_name',
|
||||
@ -143,7 +143,7 @@ class EventHealthAllowanceCrudController extends CrudController
|
||||
'name' => 'check_state',
|
||||
'label' => '審核狀態',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖', '4' => '重覆資料(僅標記)'],
|
||||
],
|
||||
[
|
||||
'name' => 'twid',
|
||||
@ -207,7 +207,7 @@ class EventHealthAllowanceCrudController extends CrudController
|
||||
'name' => 'check_state',
|
||||
'label' => "審核狀態",
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖', '4' => '重覆資料(僅標記)'],
|
||||
'allows_null' => false,
|
||||
'default' => '1',
|
||||
],
|
||||
|
@ -50,7 +50,13 @@ class EventImprovedHealthCrudController extends CrudController
|
||||
'name' => 'check_state',
|
||||
'label' => '審核狀態',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖', '4' => '重覆資料(僅標記)'],
|
||||
],
|
||||
[
|
||||
'name' => 'disease_type',
|
||||
'label' => '疾病類別',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '代謝症候群', '2' => '糖尿病', '3' => '初期慢性腎臟病', '4' => '糖尿病及初期慢性腎臟病'],
|
||||
],
|
||||
[
|
||||
'name' => 'hospital_name',
|
||||
@ -102,11 +108,21 @@ class EventImprovedHealthCrudController extends CrudController
|
||||
1 => '未審核',
|
||||
2 => '通過 〇',
|
||||
3 => '未通過 ✖'
|
||||
|
||||
])
|
||||
->whenActive(function($value) {
|
||||
CRUD::addClause('where', 'check_state', $value);
|
||||
});
|
||||
CRUD::filter('疾病類別')
|
||||
->type('dropdown')
|
||||
->values([
|
||||
1 => '代謝症候群',
|
||||
2 => '糖尿病',
|
||||
3 => '初期慢性腎臟病',
|
||||
4 => '糖尿病及初期慢性腎臟病'
|
||||
])
|
||||
->whenActive(function($value) {
|
||||
CRUD::addClause('where', 'disease_type', $value);
|
||||
});
|
||||
CRUD::filter('ID')
|
||||
->type('text')
|
||||
->whenActive(function($value) {
|
||||
@ -142,7 +158,7 @@ class EventImprovedHealthCrudController extends CrudController
|
||||
'name' => 'check_state',
|
||||
'label' => '審核狀態',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖', '4' => '重覆資料(僅標記)'],
|
||||
],
|
||||
[
|
||||
'name' => 'twid',
|
||||
@ -154,6 +170,12 @@ class EventImprovedHealthCrudController extends CrudController
|
||||
'label' => '姓名',
|
||||
'type' => 'text'
|
||||
],
|
||||
[
|
||||
'name' => 'disease_type',
|
||||
'label' => '疾病類別',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '代謝症候群', '2' => '糖尿病', '3' => '初期慢性腎臟病', '4' => '糖尿病及初期慢性腎臟病'],
|
||||
],
|
||||
[
|
||||
'name' => 'hospital_name',
|
||||
'label' => '就醫院所',
|
||||
@ -172,6 +194,12 @@ class EventImprovedHealthCrudController extends CrudController
|
||||
{
|
||||
CRUD::setValidation(EventImprovedHealthRequest::class);
|
||||
$this->crud->addFields([
|
||||
[
|
||||
'name' => 'disease_type',
|
||||
'label' => '疾病類別',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '代謝症候群', '2' => '糖尿病', '3' => '初期慢性腎臟病', '4' => '糖尿病及初期慢性腎臟病'],
|
||||
],
|
||||
[
|
||||
'name' => 'hospital_name',
|
||||
'label' => '就醫院所',
|
||||
@ -206,7 +234,7 @@ class EventImprovedHealthCrudController extends CrudController
|
||||
'name' => 'check_state',
|
||||
'label' => "審核狀態",
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖', '4' => '重覆資料(僅標記)'],
|
||||
'allows_null' => false,
|
||||
'default' => '1',
|
||||
],
|
||||
@ -311,6 +339,9 @@ class EventImprovedHealthCrudController extends CrudController
|
||||
$response = $this->traitUpdate();
|
||||
// do something after save
|
||||
$entry = $this->crud->getCurrentEntry();
|
||||
|
||||
$diseaseTypes = ['1' => '代謝症候群', '2' => '糖尿病', '3' => '初期慢性腎臟病', '4' => '糖尿病及初期慢性腎臟病'];
|
||||
|
||||
if ($entry->check_state != $org_check_state) {
|
||||
switch($entry->check_state) {
|
||||
case '2': //過通
|
||||
@ -320,6 +351,7 @@ class EventImprovedHealthCrudController extends CrudController
|
||||
"body" => "恭喜您審核通過!"
|
||||
."\n\n登記資料:"
|
||||
."\n流水號: B-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
|
||||
."\n疾病類別:".$diseaseTypes[$entry->disease_type]
|
||||
."\n就醫院所:".$entry->hospital_name
|
||||
."\n姓名:".$entry->name
|
||||
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
|
||||
@ -343,6 +375,7 @@ class EventImprovedHealthCrudController extends CrudController
|
||||
."\n理由:".$entry->check_reson
|
||||
."\n\n登記資料:"
|
||||
."\n流水號: B-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
|
||||
."\n疾病類別:".$diseaseTypes[$entry->disease_type]
|
||||
."\n就醫院所:".$entry->hospital_name
|
||||
."\n姓名:".$entry->name
|
||||
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
|
||||
|
@ -51,7 +51,7 @@ class EventMetabolismCrudController extends CrudController
|
||||
'name' => 'check_state',
|
||||
'label' => '審核狀態',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖', '4' => '重覆資料(僅標記)'],
|
||||
],
|
||||
[
|
||||
'name' => 'hospital_name',
|
||||
@ -143,7 +143,7 @@ class EventMetabolismCrudController extends CrudController
|
||||
'name' => 'check_state',
|
||||
'label' => '審核狀態',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖', '4' => '重覆資料(僅標記)'],
|
||||
],
|
||||
[
|
||||
'name' => 'twid',
|
||||
@ -208,7 +208,7 @@ class EventMetabolismCrudController extends CrudController
|
||||
'name' => 'check_state',
|
||||
'label' => "審核狀態",
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖', '4' => '重覆資料(僅標記)'],
|
||||
'allows_null' => false,
|
||||
'default' => '1',
|
||||
],
|
||||
|
@ -6,6 +6,8 @@ use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Intervention\Image\Drivers\Gd\Driver;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
@ -38,4 +40,43 @@ class StorageController extends Controller
|
||||
'Content-Security-Policy' => "frame-ancestors 'self'", // Allow iframe on same domain
|
||||
]);
|
||||
}
|
||||
|
||||
public function imageRotation90(Request $request, $file_path)
|
||||
{
|
||||
$allowed_directory = 'uploads';
|
||||
$file_path = str_replace(['../', '..\\'], '', $file_path);
|
||||
$full_path = storage_path("app/{$allowed_directory}/{$file_path}");
|
||||
|
||||
if (is_dir($full_path)) {
|
||||
throw new NotFoundHttpException('檔案不存在');
|
||||
}
|
||||
|
||||
if (!Storage::disk('local')->exists("{$allowed_directory}/{$file_path}")) {
|
||||
throw new NotFoundHttpException('檔案不存在');
|
||||
}
|
||||
|
||||
$real_path = realpath($full_path);
|
||||
$allowed_base_path = realpath(storage_path("app/{$allowed_directory}"));
|
||||
if (!$real_path || strpos($real_path, $allowed_base_path) !== 0) {
|
||||
throw new AccessDeniedHttpException('無權訪問該檔案');
|
||||
}
|
||||
$mime_type = mime_content_type($full_path) ?: 'application/octet-stream';
|
||||
|
||||
$allowedMimeTypes = [
|
||||
'image/png', // PNG
|
||||
'image/jpeg', // JPG/JPEG
|
||||
'image/git' // git
|
||||
];
|
||||
|
||||
if (!in_array($mime_type, $allowedMimeTypes)) {
|
||||
throw new \Exception('檔案類型錯誤,只接受.jpg/.jpeg/.png/.gif');
|
||||
}
|
||||
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($full_path);
|
||||
$image = $image->rotate(-90);
|
||||
$image->save(quality:100);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,11 @@ class HealthAllowanceFillFormController extends Controller
|
||||
} else {
|
||||
$enable = false;
|
||||
}
|
||||
|
||||
$passCount = EventHealthAllowance::where('check_state', 2)->count();
|
||||
if ($passCount >= $eventInfo['limit']) {
|
||||
$enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
return view('health_allowance', [
|
||||
@ -95,6 +100,11 @@ class HealthAllowanceFillFormController extends Controller
|
||||
} else {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
|
||||
$passCount = EventHealthAllowance::where('check_state', 2)->count();
|
||||
if ($passCount >= $eventInfo['limit']) {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
@ -54,6 +54,11 @@ class ImprovedHealthFillFormController extends Controller
|
||||
} else {
|
||||
$enable = false;
|
||||
}
|
||||
|
||||
$passCount = EventImprovedHealth::where('check_state', 2)->count();
|
||||
if ($passCount >= $eventInfo['limit']) {
|
||||
$enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
return view('improved_health', [
|
||||
@ -96,6 +101,10 @@ class ImprovedHealthFillFormController extends Controller
|
||||
} else {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
$passCount = EventImprovedHealth::where('check_state', 2)->count();
|
||||
if ($passCount >= $eventInfo['limit']) {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
@ -116,6 +125,7 @@ class ImprovedHealthFillFormController extends Controller
|
||||
if ($eventItem->check_state == 2) {
|
||||
throw new \Exception('您已經登記審查通過。');
|
||||
}
|
||||
$eventItem->disease_type = $request->input('disease_type');
|
||||
$eventItem->hospital_name = $request->input('hospital_name');
|
||||
$eventItem->name = $request->input('name');
|
||||
$eventItem->phone = $request->input('phone');
|
||||
|
@ -53,6 +53,11 @@ class MetabolismFillFormController extends Controller
|
||||
} else {
|
||||
$enable = false;
|
||||
}
|
||||
|
||||
$passCount = EventMetabolism::where('check_state', 2)->count();
|
||||
if ($passCount >= $eventInfo['limit']) {
|
||||
$enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
return view('metabolism', [
|
||||
@ -95,6 +100,11 @@ class MetabolismFillFormController extends Controller
|
||||
} else {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
|
||||
$passCount = EventMetabolism::where('check_state', 2)->count();
|
||||
if ($passCount >= $eventInfo['limit']) {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
@ -51,7 +51,7 @@ class EventHealthAllowanceRequest extends FormRequest
|
||||
return [
|
||||
'twid.is_n_i' => '身份證字號驗證有誤',
|
||||
'phone.phone' => '行動電話驗證有誤',
|
||||
'address.regex' => '收件地址格式有誤,請填寫完整。',
|
||||
'address.regex' => '收件地址格式有誤,請確定「縣/市」、「鄉/鎮/市/區」、「村/里」及「地址」是否正確。',
|
||||
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
|
||||
];
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ class EventImprovedHealthRequest extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'disease_type' => 'required',
|
||||
'hospital_name' => 'required|min:2',
|
||||
'name' => 'required|min:1|max:128',
|
||||
'twid' => 'required|isNI',
|
||||
@ -44,6 +45,7 @@ class EventImprovedHealthRequest extends FormRequest
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'disease_type' => '疾病類別',
|
||||
'hospital_name' => '就醫院所',
|
||||
'name' => '姓名',
|
||||
'twid' => '身份證字號',
|
||||
@ -63,7 +65,7 @@ class EventImprovedHealthRequest extends FormRequest
|
||||
return [
|
||||
'twid.is_n_i' => '身份證字號驗證有誤',
|
||||
'phone.phone' => '行動電話驗證有誤',
|
||||
'address.regex' => '收件地址格式有誤,請填寫完整。',
|
||||
'address.regex' => '收件地址格式有誤,請確定「縣/市」、「鄉/鎮/市/區」、「村/里」及「地址」是否正確。',
|
||||
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
|
||||
];
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class EventMetabolismRequest extends FormRequest
|
||||
return [
|
||||
'twid.is_n_i' => '身份證字號驗證有誤',
|
||||
'phone.phone' => '行動電話驗證有誤',
|
||||
'address.regex' => '收件地址格式有誤,請填寫完整。',
|
||||
'address.regex' => '收件地址格式有誤,請確定「縣/市」、「鄉/鎮/市/區」、「村/里」及「地址」是否正確。',
|
||||
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
|
||||
];
|
||||
}
|
||||
|
@ -158,6 +158,10 @@
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#dataForm').submit(function(){
|
||||
$(this).find(':input[type=submit]').prop('disabled', true);
|
||||
});
|
||||
|
||||
$('#regTwid').on('change', function(){
|
||||
var val = $(this).val();
|
||||
val = toHalfWidth(val);
|
||||
|
@ -34,6 +34,35 @@
|
||||
@endif
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">疾病類別</label>
|
||||
<div class="form-control" >
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="disease_type" id="diseaseType1" value="1" {{ old('disease_type') == "1" ? 'checked' : '' }} required>
|
||||
<label class="form-check-label" for="diseaseType1">
|
||||
代謝症候群
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="disease_type" id="diseaseType2" value="2" {{ old('disease_type') == "2" ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="diseaseType2">
|
||||
糖尿病
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="disease_type" id="diseaseType3" value="3" {{ old('disease_type') == "3" ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="diseaseType3">
|
||||
初期慢性腎臟病
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="disease_type" id="diseaseType4" value="4" {{ old('disease_type') == "4" ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="diseaseType4">
|
||||
糖尿病及初期慢性腎臟病
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="regHospitalName" class="form-label">就醫院所</label>
|
||||
<input type="text" class="form-control" id="regHospitalName" name="hospital_name" required value="{{ old('hospital_name') }}" placeholder="範例:XX醫院">
|
||||
@ -154,6 +183,10 @@
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#dataForm').submit(function(){
|
||||
$(this).find(':input[type=submit]').prop('disabled', true);
|
||||
});
|
||||
|
||||
$('#regTwid').on('change', function(){
|
||||
var val = $(this).val();
|
||||
val = toHalfWidth(val);
|
||||
|
@ -16,7 +16,7 @@
|
||||
<div class="col-md-8 main-area">
|
||||
<ul>
|
||||
<li>
|
||||
桃園市政府:<a href="https://www.tycg.gov.tw/" target="_blank">https://www.tycg.gov.tw/</a>
|
||||
桃園市政府衛生局:<a href="https://www.tycg.gov.tw/" target="_blank">https://www.tycg.gov.tw/</a>
|
||||
</li>
|
||||
<li>
|
||||
桃園市政府衛生局官方FB:<a href="https://zh-tw.facebook.com/tychbfans" target="_blank">https://zh-tw.facebook.com/tychbfans</a>
|
||||
|
@ -132,6 +132,9 @@
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#dataForm').submit(function(){
|
||||
$(this).find(':input[type=submit]').prop('disabled', true);
|
||||
});
|
||||
|
||||
$('#regTwid').on('change', function(){
|
||||
var val = $(this).val();
|
||||
|
@ -23,12 +23,15 @@
|
||||
></embed>
|
||||
|
||||
@else
|
||||
<a href="{{ $field['url'] }}" data-lightbox="uploadImages">
|
||||
<a href="{{ $field['url'] }}" class="lightboxBtn" data-lightbox="uploadImages">
|
||||
<img style="border: solid gray 1px"
|
||||
src="{{ $field['url'] }}"
|
||||
height="{{ $field['height'] ?? '' }}"
|
||||
/>
|
||||
</a>
|
||||
@if (isset($field['image-rotation-url']))
|
||||
<br><a class="btn" onclick="var self = this; $.ajax({async: false, url:'{{ $field['image-rotation-url'] }}', method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRF-TOKEN': $('meta[name=\'csrf-token\']').attr('content')}, error: function(jqXHR, textStatus, errorThrown){alert('錯誤:' + errorThrown);}, success: function(data) { var elem = $(self).parent().find('img'); var src=$(elem).attr('src').split('?')[0] + '?' + (new Date().getTime()).toString(); $(elem).attr('src', src); $(elem).parent().attr('href', src); } });">旋轉圖片</a>
|
||||
@endif
|
||||
@endif
|
||||
@if(isset($field['hint']))
|
||||
<p class="help-block">{!! $field['hint'] !!}</p>
|
||||
|
@ -19,6 +19,10 @@ Route::group([
|
||||
Route::get('storage/{file_path}', [App\Http\Controllers\Admin\StorageController::class, 'serve'])
|
||||
->where('file_path', '.*') // Allow multi-level paths (e.g., documents/subfolder/file.pdf)
|
||||
->name('storage.serve');
|
||||
Route::post('storage/image-rotation90/{file_path}', [App\Http\Controllers\Admin\StorageController::class, 'imageRotation90'])
|
||||
->where('file_path', '.*') // Allow multi-level paths (e.g., documents/subfolder/file.pdf)
|
||||
->name('storage.image-rotation90');
|
||||
|
||||
Route::crud('user', 'UserCrudController');
|
||||
Route::crud('event-registration-info', 'EventRegistrationInfoCrudController');
|
||||
Route::crud('event-metabolism', 'EventMetabolismCrudController');
|
||||
|
Reference in New Issue
Block a user