change address rule, email content and admin event crud

This commit is contained in:
Eric Li
2025-06-16 18:37:36 +08:00
parent b12cd07419
commit 32b04d09c3
29 changed files with 1139 additions and 122 deletions

View File

@ -23,6 +23,7 @@ class EventHealthAllowanceCrudController extends CrudController
//use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
use \RedSquirrelStudio\LaravelBackpackExportOperation\ExportOperation;
/**
@ -37,6 +38,57 @@ class EventHealthAllowanceCrudController extends CrudController
CRUD::setEntityNameStrings('活動:反轉代謝新人生', '活動:反轉代謝新人生');
}
protected function setupExportOperation()
{
CRUD::addColumns([
[
'name' => 'id',
'label' => 'ID',
'type' => 'text',
'prefix' => 'A-'
],
[
'name' => 'check_state',
'label' => '審核狀態',
'type' => 'select_from_array',
'options' => ['1' => '未審核  ', '2' => '通過  ', '3' => '未通過 ✖'],
],
[
'name' => 'hospital_name',
'label' => '就醫院所',
'type' => 'text',
],
[
'name' => 'name',
'label' => '姓名',
'type' => 'text',
],
[
'name' => 'twid',
'label' => '身份證',
'type' => 'text',
],
[
'name' => 'phone',
'label' => '手機號碼',
'type' => 'text',
],
[
'name' => 'email',
'label' => 'Email',
'type' => 'text',
],
[
'name' => 'address',
'label' => '地址',
'type' => 'textarea',
],
]);
$this->setupListOperation();
$this->disableUserConfiguration();
}
/**
* Define what happens when the List operation is loaded.
*
@ -45,7 +97,42 @@ class EventHealthAllowanceCrudController extends CrudController
*/
protected function setupListOperation()
{
CRUD::filter('審核狀態')
->type('dropdown')
->values([
1 => '未審核',
2 => '通過  〇',
3 => '未通過 ✖'
])
->whenActive(function($value) {
CRUD::addClause('where', 'check_state', $value);
});
CRUD::filter('ID')
->type('text')
->whenActive(function($value) {
CRUD::addClause('where', 'id', $value);
});
CRUD::filter('就醫院所')
->type('text')
->whenActive(function($value) {
CRUD::addClause('where', 'hospital_name', 'LIKE', "%$value%");
});
CRUD::filter('姓名')
->type('text')
->whenActive(function($value) {
CRUD::addClause('where', 'name', 'LIKE', "%$value%");
});
$this->crud->addColumns([
[
'name' => 'id',
'label' => '報名流水號',
'type' => 'text',
'value' => function($entry) {
return 'C-'. str_pad($entry->id, 6, '0', STR_PAD_LEFT);
}
],
[
'name' => 'created_at',
'label' => '登記時間',
@ -68,7 +155,11 @@ class EventHealthAllowanceCrudController extends CrudController
'label' => '姓名',
'type' => 'text'
],
[
'name' => 'hospital_name',
'label' => '就醫院所',
'type' => 'text',
],
]);
}
@ -142,7 +233,7 @@ class EventHealthAllowanceCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->record_card_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -157,7 +248,7 @@ class EventHealthAllowanceCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->twid_front_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -172,7 +263,7 @@ class EventHealthAllowanceCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->twid_back_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -187,7 +278,7 @@ class EventHealthAllowanceCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->exam_1st_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -202,7 +293,7 @@ class EventHealthAllowanceCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->exam_2nd_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -230,12 +321,15 @@ class EventHealthAllowanceCrudController extends CrudController
"title" => "反轉代謝新人生 皮蛇疫苗加碼補 審核通過!",
"body" => "恭喜您審核通過!"
."\n\n登記資料:"
."\n流水號: C-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".$entry->name
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
."\n行動電話:".$entry->phone
."\n電子信箱:".$entry->email
."\n收件地址:".$entry->address
."\n\n中獎公告本活動將於10月抽出得獎名單並公告於「活動網站/最新消息」及「桃園市政府衛生局網站/訊息公告/最新消息」。"
,
]));
} catch (Exception $ex) {
@ -250,6 +344,7 @@ class EventHealthAllowanceCrudController extends CrudController
."\n請依以下理由重新上活動網站登記"
."\n理由:".$entry->check_reson
."\n\n登記資料:"
."\n流水號: C-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".$entry->name
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)

View File

@ -23,6 +23,7 @@ class EventImprovedHealthCrudController extends CrudController
//use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
use \RedSquirrelStudio\LaravelBackpackExportOperation\ExportOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
@ -36,6 +37,57 @@ class EventImprovedHealthCrudController extends CrudController
CRUD::setEntityNameStrings('活動健康達標GO', '活動健康達標GO');
}
protected function setupExportOperation()
{
CRUD::addColumns([
[
'name' => 'id',
'label' => 'ID',
'type' => 'text',
'prefix' => 'A-'
],
[
'name' => 'check_state',
'label' => '審核狀態',
'type' => 'select_from_array',
'options' => ['1' => '未審核  ', '2' => '通過  ', '3' => '未通過 ✖'],
],
[
'name' => 'hospital_name',
'label' => '就醫院所',
'type' => 'text',
],
[
'name' => 'name',
'label' => '姓名',
'type' => 'text',
],
[
'name' => 'twid',
'label' => '身份證',
'type' => 'text',
],
[
'name' => 'phone',
'label' => '手機號碼',
'type' => 'text',
],
[
'name' => 'email',
'label' => 'Email',
'type' => 'text',
],
[
'name' => 'address',
'label' => '地址',
'type' => 'textarea',
],
]);
$this->setupListOperation();
$this->disableUserConfiguration();
}
/**
* Define what happens when the List operation is loaded.
*
@ -44,7 +96,42 @@ class EventImprovedHealthCrudController extends CrudController
*/
protected function setupListOperation()
{
CRUD::filter('審核狀態')
->type('dropdown')
->values([
1 => '未審核',
2 => '通過  〇',
3 => '未通過 ✖'
])
->whenActive(function($value) {
CRUD::addClause('where', 'check_state', $value);
});
CRUD::filter('ID')
->type('text')
->whenActive(function($value) {
CRUD::addClause('where', 'id', $value);
});
CRUD::filter('就醫院所')
->type('text')
->whenActive(function($value) {
CRUD::addClause('where', 'hospital_name', 'LIKE', "%$value%");
});
CRUD::filter('姓名')
->type('text')
->whenActive(function($value) {
CRUD::addClause('where', 'name', 'LIKE', "%$value%");
});
$this->crud->addColumns([
[
'name' => 'id',
'label' => '報名流水號',
'type' => 'text',
'value' => function($entry) {
return 'B-'. str_pad($entry->id, 6, '0', STR_PAD_LEFT);
}
],
[
'name' => 'created_at',
'label' => '登記時間',
@ -67,7 +154,11 @@ class EventImprovedHealthCrudController extends CrudController
'label' => '姓名',
'type' => 'text'
],
[
'name' => 'hospital_name',
'label' => '就醫院所',
'type' => 'text',
],
]);
}
@ -140,7 +231,7 @@ class EventImprovedHealthCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->record_card_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -155,7 +246,7 @@ class EventImprovedHealthCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->twid_front_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -170,7 +261,7 @@ class EventImprovedHealthCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->twid_back_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -185,7 +276,22 @@ class EventImprovedHealthCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->exam_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
'extra_attributes' => [
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
'allow' => 'fullscreen',
],
'hint' => '',
]);
CRUD::iframe('exam2_img_src', '檢查報告2', [
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->exam2_img_src);
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -213,12 +319,15 @@ class EventImprovedHealthCrudController extends CrudController
"title" => "健康達標GO 大獎汽車不是夢 審核通過!",
"body" => "恭喜您審核通過!"
."\n\n登記資料:"
."\n流水號: B-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".$entry->name
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
."\n行動電話:".$entry->phone
."\n電子信箱:".$entry->email
."\n收件地址:".$entry->address
."\n\n中獎公告本活動將於10月抽出得獎名單並公告於「活動網站/最新消息」及「桃園市政府衛生局網站/訊息公告/最新消息」。"
,
]));
} catch (Exception $ex) {
@ -233,6 +342,7 @@ class EventImprovedHealthCrudController extends CrudController
."\n請依以下理由重新上活動網站登記"
."\n理由:".$entry->check_reson
."\n\n登記資料:"
."\n流水號: B-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".$entry->name
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)

View File

@ -23,6 +23,7 @@ class EventMetabolismCrudController extends CrudController
//use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
use \RedSquirrelStudio\LaravelBackpackExportOperation\ExportOperation;
/**
@ -37,6 +38,57 @@ class EventMetabolismCrudController extends CrudController
CRUD::setEntityNameStrings('活動:符合代謝新收案', '活動:符合代謝新收案');
}
protected function setupExportOperation()
{
CRUD::addColumns([
[
'name' => 'id',
'label' => 'ID',
'type' => 'text',
'prefix' => 'A-'
],
[
'name' => 'check_state',
'label' => '審核狀態',
'type' => 'select_from_array',
'options' => ['1' => '未審核  ', '2' => '通過  ', '3' => '未通過 ✖'],
],
[
'name' => 'hospital_name',
'label' => '就醫院所',
'type' => 'text',
],
[
'name' => 'name',
'label' => '姓名',
'type' => 'text',
],
[
'name' => 'twid',
'label' => '身份證',
'type' => 'text',
],
[
'name' => 'phone',
'label' => '手機號碼',
'type' => 'text',
],
[
'name' => 'email',
'label' => 'Email',
'type' => 'text',
],
[
'name' => 'address',
'label' => '地址',
'type' => 'textarea',
],
]);
$this->setupListOperation();
$this->disableUserConfiguration();
}
/**
* Define what happens when the List operation is loaded.
*
@ -45,7 +97,42 @@ class EventMetabolismCrudController extends CrudController
*/
protected function setupListOperation()
{
CRUD::filter('審核狀態')
->type('dropdown')
->values([
1 => '未審核',
2 => '通過  〇',
3 => '未通過 ✖'
])
->whenActive(function($value) {
CRUD::addClause('where', 'check_state', $value);
});
CRUD::filter('ID')
->type('text')
->whenActive(function($value) {
CRUD::addClause('where', 'id', $value);
});
CRUD::filter('就醫院所')
->type('text')
->whenActive(function($value) {
CRUD::addClause('where', 'hospital_name', 'LIKE', "%$value%");
});
CRUD::filter('姓名')
->type('text')
->whenActive(function($value) {
CRUD::addClause('where', 'name', 'LIKE', "%$value%");
});
$this->crud->addColumns([
[
'name' => 'id',
'label' => '報名流水號',
'type' => 'text',
'value' => function($entry) {
return 'A-'. str_pad($entry->id, 6, '0', STR_PAD_LEFT);
}
],
[
'name' => 'created_at',
'label' => '登記時間',
@ -68,6 +155,11 @@ class EventMetabolismCrudController extends CrudController
'label' => '姓名',
'type' => 'text'
],
[
'name' => 'hospital_name',
'label' => '就醫院所',
'type' => 'text',
],
]);
}
@ -142,7 +234,7 @@ class EventMetabolismCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->record_card_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -157,7 +249,7 @@ class EventMetabolismCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->twid_front_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -172,7 +264,7 @@ class EventMetabolismCrudController extends CrudController
'url' => function ($crud) {
$entry = $crud->getCurrentEntry();
$path = str_replace("uploads/", "", $entry->twid_back_img_src);
return $path ? route('storage.serve', $path) : "about:blank";
return $path ? route('storage.serve', $path) : "";
},
'width' => '400px',
'height' => '300px',
@ -201,12 +293,15 @@ class EventMetabolismCrudController extends CrudController
"title" => "符合代謝新收案 早鳥報名最划算 審核通過!",
"body" => "恭喜您審核通過!"
."\n\n登記資料:"
."\n流水號: A-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".$entry->name
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
."\n行動電話:".$entry->phone
."\n電子信箱:".$entry->email
."\n收件地址:".$entry->address
."\n\n中獎公告本活動將於10月抽出得獎名單並公告於「活動網站/最新消息」及「桃園市政府衛生局網站/訊息公告/最新消息」。"
."\n禮券發送方式說明凡報名經審核通過者我們將於3個工作天內將 7-ELEVEN 電子禮券序號寄送至您報名時所填寫的電子信箱,敬請留意收信。"
,
]));
} catch (Exception $ex) {
@ -221,6 +316,7 @@ class EventMetabolismCrudController extends CrudController
."\n請依以下理由重新上活動網站登記"
."\n理由:".$entry->check_reson
."\n\n登記資料:"
."\n流水號: A-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".$entry->name
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)

View File

@ -351,6 +351,7 @@ class HealthAllowanceFillFormController extends Controller
Mail::to($request->input('email'))->send(new EventNotifyMail([
"title" => "反轉代謝新人生 皮蛇疫苗加碼補 登記成功!",
"body" => "登記資料:"
."\n流水號: C-".str_pad($eventItem->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$request->input('hospital_name')
."\n姓名:".$request->input('name')
."\n身份證字號:".substr($request->input('twid'),0,2)."xxxx".substr($request->input('twid'),-4)

View File

@ -261,6 +261,36 @@ class ImprovedHealthFillFormController extends Controller
throw new \Exception('請上傳檢查報告。');
}
$fileName = $request->input('fileExam2FileName');
if ($fileName && $request->filled('fileExam2Base64')) {
$fileBase64 = $request->input('fileExam2Base64');
$fileData = base64_decode($fileBase64);
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
if (!in_array($fileExt, $acceptExt)) {
throw new \Exception('檢查報告檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
}
$mimeType = $finfo->buffer($fileData);
if (!in_array($mimeType, $allowedMimeTypes)) {
throw new \Exception('檢查報告檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
}
if ($mimeType != 'application/pdf') {
$image = $manager->read($fileData);
$image->scaleDown(2048, 2048);
$fileData = $image->toJpeg(50);
$fileExt = 'jpg';
}
if ($eventItem->exam2_img_src) {
try {
Storage::disk('local')->delete($eventItem->exam2_img_src);
} catch (\Exception $ex2) {
}
}
$fileName = $eventItem->twid . "_Exam2_" . $uploadTime . "." . $fileExt;
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
$eventItem->exam2_img_src = $uploadPath.'/'.$fileName;
}
// $file = $request->file('fileRecordCard');
// if ($file) {
// $fileExt = $file->getClientOriginalExtension();
@ -310,6 +340,7 @@ class ImprovedHealthFillFormController extends Controller
Mail::to($request->input('email'))->send(new EventNotifyMail([
"title" => "健康達標GO 大獎汽車不是夢 登記成功!",
"body" => "登記資料:"
."\n流水號: B-".str_pad($eventItem->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$request->input('hospital_name')
."\n姓名:".$request->input('name')
."\n身份證字號:".substr($request->input('twid'),0,2)."xxxx".substr($request->input('twid'),-4)

View File

@ -267,6 +267,7 @@ class MetabolismFillFormController extends Controller
Mail::to($request->input('email'))->send(new EventNotifyMail([
"title" => "符合代謝新收案 早鳥報名最划算 登記成功!",
"body" => "登記資料:"
."\n流水號: A-".str_pad($eventItem->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$request->input('hospital_name')
."\n姓名:".$request->input('name')
."\n身份證字號:".substr($request->input('twid'),0,2)."xxxx".substr($request->input('twid'),-4)

View File

@ -19,7 +19,7 @@ class EventHealthAllowanceRequest extends FormRequest
'twid' => 'required|isNI',
'phone' => 'required|phone:TW',
'email' => 'required|email',
'address' => 'required|min:5',
'address' => ['required','regex:/^(\d{3})\s+([\p{Han}]{2,4}[縣市])\s+([\p{Han}]{2,4}[鎮鄉市區])\s+([\p{Han}]+[里村])\s+(.+)$/u'],
'check_reson' => 'required_if:check_state,3',
];
}
@ -51,6 +51,7 @@ class EventHealthAllowanceRequest extends FormRequest
return [
'twid.is_n_i' => '身份證字號驗證有誤',
'phone.phone' => '行動電話驗證有誤',
'address.regex' => '收件地址格式有誤,請填寫完整。',
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
];
}

View File

@ -31,7 +31,7 @@ class EventImprovedHealthRequest extends FormRequest
'twid' => 'required|isNI',
'phone' => 'required|phone:TW',
'email' => 'required|email',
'address' => 'required|min:5',
'address' => ['required','regex:/^(\d{3})\s+([\p{Han}]{2,4}[縣市])\s+([\p{Han}]{2,4}[鎮鄉市區])\s+([\p{Han}]+[里村])\s+(.+)$/u'],
'check_reson' => 'required_if:check_state,3',
];
}
@ -63,6 +63,7 @@ class EventImprovedHealthRequest extends FormRequest
return [
'twid.is_n_i' => '身份證字號驗證有誤',
'phone.phone' => '行動電話驗證有誤',
'address.regex' => '收件地址格式有誤,請填寫完整。',
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
];
}

View File

@ -31,7 +31,7 @@ class EventMetabolismRequest extends FormRequest
'twid' => 'required|isNI',
'phone' => 'required|phone:TW',
'email' => 'required|email',
'address' => 'required|min:5',
'address' => ['required','regex:/^(\d{3})\s+([\p{Han}]{2,4}[縣市])\s+([\p{Han}]{2,4}[鎮鄉市區])\s+([\p{Han}]+[里村])\s+(.+)$/u'],
'check_reson' => 'required_if:check_state,3',
];
}
@ -63,6 +63,7 @@ class EventMetabolismRequest extends FormRequest
return [
'twid.is_n_i' => '身份證字號驗證有誤',
'phone.phone' => '行動電話驗證有誤',
'address.regex' => '收件地址格式有誤,請填寫完整。',
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
];
}