PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
← All changes | app/Services/SummaryReportService.php +29 -8 1.5.01 → 2.5.0 View file →
@@ -24,15 +24,27 @@
24 24 if ($status != 'yes' || ($frequency == 'weekly' && $sendingDay != $currentDay)) {
25 25 return;
26 26 }
27 27
28 - $reportDays = $frequency == 'daily' ? 1 : 7;
28 + $lastSend = get_option('fcom_last_summary_email_send');
29 + $interval = ($frequency == 'daily') ? DAY_IN_SECONDS : WEEK_IN_SECONDS;
30 + if ($lastSend && (current_time('timestamp') - strtotime($lastSend)) < $interval) {
31 + return;
32 + }
29 33
30 - $reportDateFrom = gmdate('Y-m-d', time() - $reportDays * 60 * 60 * 24);
34 + $reportDays = $frequency == 'daily' ? 1 : 7;
31 35
32 - $totalBooked = Booking::where('end_time', '>', $reportDateFrom)->count();
33 - $totalCompleted = Booking::where('created_at', '>', $reportDateFrom)->where('status', 'completed')->count();
36 + $reportDateFrom = gmdate('Y-m-d H:i:s', strtotime("-$reportDays days"));
34 37
38 + $totalBooked = Booking::where('created_at', '>=', $reportDateFrom)
39 + ->where('created_at', '<=', gmdate('Y-m-d H:i:s'))
40 + ->count();
41 +
42 + $totalCompleted = Booking::where('end_time', '>=', $reportDateFrom)
43 + ->where('end_time', '<=', gmdate('Y-m-d H:i:s'))
44 + ->where('status', 'completed')
45 + ->count();
46 +
35 47 if (!$totalBooked && !$totalCompleted) {
36 48 return;
37 49 }
38 50
@@ -42,16 +54,25 @@
42 54 'totalBooked' => $totalBooked,
43 55 'totalCompleted' => $totalCompleted,
44 56 ];
45 57
46 - $adminEmail = str_replace('{{wp.admin_email}}', get_option('admin_email'), $adminEmail);
47 -
58 + $adminEmail = str_replace('{{wp.admin_email}}', (string) get_option('admin_email', ''), $adminEmail);
48 59 if(!$adminEmail) {
49 60 return;
50 61 }
51 62
52 - // translators: %d is replaced with the number of days
53 - $emailSubject = sprintf(esc_html__('Email Summary of Your Bookings (Last %d Days)', 'fluent-booking'), $reportDays);
63 + update_option('fcom_last_summary_email_send', current_time('mysql'));
64 +
65 + $emailSubject = sprintf(
66 + // translators: %d: number of days for which the summary is being reported
67 + esc_html(_n(
68 + 'Email Summary of Your Bookings (Last %d Day)',
69 + 'Email Summary of Your Bookings (Last %d Days)',
70 + $reportDays,
71 + 'fluent-booking'
72 + )),
73 + $reportDays
74 + );
54 75
55 76 $emailBody = (string)App::make('view')->make('emails.summary_report', $data);
56 77
57 78 $emogrifier = new Emogrifier($emailBody);