PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / v3 / src / assets / js / admin / appointment.js
ameliabooking / v3 / src / assets / js / admin Last commit date
admin.js 5 days ago appointment.js 5 days ago booking.js 5 days ago customers.js 5 days ago event.js 5 days ago package.js 5 days ago payment.js 5 days ago socialAuthOptions.js 5 days ago status.js 5 days ago useReactiveCustomize.js 5 days ago
appointment.js
107 lines
1 import { useConvertedUtcToLocalDateTime } from '../common/date'
2
3 function useAppointmentDuration(store, appointment) {
4 let service = store.getters['entities/getService'](appointment.serviceId)
5
6 let largestBookingDuration = 0
7
8 let largestBookingExtrasDuration = 0
9
10 appointment.bookings.forEach((booking) => {
11 if (['approved', 'pending'].includes(booking.status)) {
12 let bookingDuration = booking.duration ? booking.duration : service.duration
13
14 if (bookingDuration > largestBookingDuration) {
15 largestBookingDuration = bookingDuration
16 }
17
18 let bookingExtrasDuration = 0
19
20 booking.extras.forEach((bookingExtra) => {
21 let extra = service.extras.find((i) => i.id === bookingExtra.extraId)
22
23 bookingExtrasDuration += extra.duration * bookingExtra.quantity
24 })
25
26 if (bookingExtrasDuration > largestBookingExtrasDuration) {
27 largestBookingExtrasDuration = bookingExtrasDuration
28 }
29 }
30 })
31
32 return largestBookingDuration + largestBookingExtrasDuration
33 }
34
35 function useParsedAppointments(appointments, timeZone, allBookings) {
36 for (let dateString in appointments) {
37 appointments[dateString].appointments.forEach((appointment) => {
38 let appointmentCustomerBookings = {}
39
40 appointment.bookings.forEach((booking) => {
41 if (!(booking.customerId in appointmentCustomerBookings)) {
42 appointmentCustomerBookings[booking.customerId] = []
43 }
44
45 appointmentCustomerBookings[booking.customerId][booking.id] = booking.status
46 })
47
48 let customerBookings = {}
49
50 for (let customerId in appointmentCustomerBookings) {
51 for (let bookingId in appointmentCustomerBookings[customerId]) {
52 if (
53 !(customerId in customerBookings) ||
54 appointmentCustomerBookings[customerId][bookingId] === 'approved' ||
55 appointmentCustomerBookings[customerId][bookingId] === 'pending'
56 ) {
57 customerBookings[customerId] = bookingId
58 }
59 }
60 }
61
62 appointment.bookings.forEach((booking) => {
63 if (
64 booking.customerId in customerBookings &&
65 parseInt(booking.id) !== parseInt(customerBookings[booking.customerId])
66 ) {
67 return
68 }
69
70 if (timeZone === '') {
71 appointment.bookingStart = useConvertedUtcToLocalDateTime(appointment.bookingStart)
72 appointment.bookingEnd = useConvertedUtcToLocalDateTime(appointment.bookingEnd)
73 }
74
75 if (!allBookings) {
76 appointment.bookings = [booking]
77 }
78 })
79 })
80 }
81
82 if (timeZone === '') {
83 let parsedGroupedAppointments = {}
84
85 for (let dateString in appointments) {
86 appointments[dateString].appointments.forEach((appointment) => {
87 let appointmentDateString = appointment.bookingStart.split(' ')[0]
88
89 if (!(appointmentDateString in parsedGroupedAppointments)) {
90 parsedGroupedAppointments[appointmentDateString] = {
91 appointments: [appointment],
92 date: appointmentDateString,
93 }
94 } else {
95 parsedGroupedAppointments[appointmentDateString].appointments.push(appointment)
96 }
97 })
98 }
99
100 return parsedGroupedAppointments
101 }
102
103 return appointments
104 }
105
106 export { useAppointmentDuration, useParsedAppointments }
107