Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nail-spa-project-meloncd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160014
nail-spa-project-meloncd
Commits
cd0bbbe7
Commit
cd0bbbe7
authored
1 month ago
by
65160014
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parent
cd5edd8a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/bookingController.js
+15
-7
15 additions, 7 deletions
controllers/bookingController.js
views/customer/bookingSummary.ejs
+1
-1
1 addition, 1 deletion
views/customer/bookingSummary.ejs
with
16 additions
and
8 deletions
controllers/bookingController.js
+
15
−
7
View file @
cd0bbbe7
...
...
@@ -119,15 +119,22 @@ exports.bookingSummary = async (req, res) => {
if
(
!
appointmentId
)
{
return
res
.
status
(
400
).
send
(
"
ไม่พบรหัสการจอง
"
);
}
// ดึงข้อมูลการจอง
const
appointment
=
await
bookingModel
.
getAppointmentById
(
appointmentId
);
// ดึงข้อมูลผู้ใช้
// พยายามดึงข้อมูลการจองจากตารางหลัก
let
appointment
=
await
bookingModel
.
getAppointmentById
(
appointmentId
);
// ถ้าไม่พบ ลองดึงจากตารางประวัติ (appointment_history)
if
(
!
appointment
)
{
appointment
=
await
bookingModel
.
getAppointmentFromHistoryById
(
appointmentId
);
if
(
!
appointment
)
{
throw
new
Error
(
"
ไม่พบการจอง
"
);
}
}
const
user
=
await
bookingModel
.
getUserById
(
appointment
.
user_id
);
// ดึงข้อมูลบริการ
const
service
=
await
bookingModel
.
getServiceById
(
appointment
.
service_id
);
// ดึงข้อมูล booking slot
const
slot
=
await
bookingModel
.
getBookingSlotById
(
appointment
.
booking_slot_id
);
// Render หน้า bookingSummary.ejs พร้อมส่งข้อมูลที่ต้องการ
res
.
render
(
'
customer/bookingSummary
'
,
{
appointment
,
user
,
service
,
slot
});
}
catch
(
error
)
{
console
.
error
(
error
);
...
...
@@ -135,6 +142,7 @@ exports.bookingSummary = async (req, res) => {
}
};
exports
.
getAllAppointmentPage
=
async
(
req
,
res
)
=>
{
try
{
const
user_id
=
req
.
session
.
userId
;
...
...
@@ -171,7 +179,7 @@ exports.cancelAppointment = async (req, res) => {
if
(
paymentStatus
===
'
Pending
'
)
{
// ย้ายข้อมูลไป appointment_history พร้อม `payment_status`
await
bookingModel
.
addToHistory
(
appointmentId
);
res
.
send
(
'
ยกเลิกการจองสำเร็จ และย้ายไปยังประวัติการนัดหมาย
'
);
res
.
redirect
(
'
/customer/allAppointments
'
);
}
else
{
res
.
status
(
400
).
send
(
'
ไม่สามารถยกเลิกการจองได้ เนื่องจากการชำระเงินเสร็จสมบูรณ์
'
);
}
...
...
This diff is collapsed.
Click to expand it.
views/customer/bookingSummary.ejs
+
1
−
1
View file @
cd0bbbe7
...
...
@@ -89,8 +89,8 @@
<p><strong>
ชื่อผู้จอง:
</strong>
<
%=
user.first_name
%
>
<
%=
user.last_name
%
></p>
<p><strong>
บริการ:
</strong>
<
%=
service.service_name
%
></p>
<p><strong>
วันที่เข้ารับบริการ:
</strong>
<
%=
new
Date
(
slot.date
).
toLocaleDateString
('
th-TH
')
%
></p>
<!-- Display only date -->
<p><strong>
สถานะการจอง:
</strong>
<
%=
appointment.appointment_status
%
></p>
<!-- Display appointment status -->
<p><strong>
เวลาเข้ารับบริการ:
</strong>
<
%=
slot.start_time
%
></p>
<p><strong>
สถานะการจอง:
</strong>
<
%=
appointment.appointment_status
%
></p>
<!-- Display appointment status -->
<p
class=
"alert-info"
>
กรุณามาก่อนเวลา 10 นาที
</p>
</div>
<div
class=
"actions"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment