Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : SummaryReportService.php
<?php

namespace FluentBooking\App\Services;

use FluentBooking\App\App;
use FluentBooking\App\Services\Helper;
use FluentBooking\App\Models\Booking;
use FluentBooking\Framework\Support\Arr;
use FluentBooking\App\Services\Libs\Emogrifier\Emogrifier;

class SummaryReportService
{
    public static function maybeSendSummary()
    {
        $notificationSettings = Helper::getGlobalSettings('administration');

        $currentDay = strtolower(gmdate('D'));

        $status     = Arr::get($notificationSettings, 'summary_notification');
        $frequency  = Arr::get($notificationSettings, 'notification_frequency');
        $adminEmail = Arr::get($notificationSettings, 'admin_email');
        $sendingDay = Arr::get($notificationSettings, 'notification_day');

        if ($status != 'yes' || ($frequency == 'weekly' && $sendingDay != $currentDay)) {
            return;
        }
        $reportDays = $frequency == 'daily' ? 1 : 7;

        $reportDateFrom = gmdate('Y-m-d H:i:s', strtotime("-$reportDays days"));

        $totalBooked = Booking::where('created_at', '>=', $reportDateFrom)
            ->where('created_at', '<=', gmdate('Y-m-d H:i:s'))
            ->count();

        $totalCompleted = Booking::where('end_time', '>=', $reportDateFrom)
            ->where('end_time', '<=', gmdate('Y-m-d H:i:s'))
            ->where('status', 'completed')
            ->count();

        if (!$totalBooked && !$totalCompleted) {
            return;
        }

        $data = [
            'days'           => $reportDays,
            'frequency'      => $frequency,
            'totalBooked'    => $totalBooked,
            'totalCompleted' => $totalCompleted,
        ];

        $adminEmail = str_replace('{{wp.admin_email}}', get_option('admin_email'), $adminEmail);

        if(!$adminEmail) {
            return;
        }

        // translators: %d is replaced with the number of days
        $emailSubject = sprintf(esc_html__('Email Summary of Your Bookings (Last %d Days)', 'fluent-booking'), $reportDays);

        $emailBody = (string)App::make('view')->make('emails.summary_report', $data);

        $emogrifier = new Emogrifier($emailBody);
        $emogrifier->disableInvisibleNodeRemoval();
        $emailBbody = (string)$emogrifier->emogrify();

        return Mailer::send($adminEmail, $emailSubject, $emailBbody);
    }
}
© 2026 GrazzMean-Shell