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/Integrations/FluentCRM/FluentCrmInit.php +21 -8 2.1.1 → 2.5.0 View file →
@@ -6,8 +6,9 @@
6 6 use FluentBooking\Framework\Support\Arr;
7 7 use FluentBooking\App\Services\DateTimeHelper;
8 8 use FluentCrm\App\Models\Subscriber;
9 9 use FluentCrm\App\Services\Html\TableBuilder;
10 +use FluentCrm\App\Services\PermissionManager as CrmPermissionManager;
10 11
11 12 class FluentCrmInit
12 13 {
13 14 public function __construct()
@@ -58,9 +59,9 @@
58 59 }
59 60
60 61 public function getProfileSection($sections, Subscriber $contact)
61 62 {
62 - if (!current_user_can('fcrm_read_contacts') && !current_user_can('manage_options')) {
63 + if (!CrmPermissionManager::currentUserCan('fcrm_read_contacts')) {
63 64 return $sections;
64 65 }
65 66
66 67 $sections['heading'] = __('Bookings (Fluent Booking)', 'fluent-booking');
@@ -74,9 +75,9 @@
74 75
75 76 $total = (clone $base)->count();
76 77
77 78 $meetings = (clone $base)
78 - ->with(['slot', 'calendar'])
79 + ->with(['slot', 'calendar', 'calendar.metas'])
79 80 ->orderBy('start_time', 'DESC')
80 81 ->limit($limit)
81 82 ->get();
82 83
@@ -105,10 +106,12 @@
105 106 'action' => ['label' => __('Action', 'fluent-booking'), 'width' => '100px'],
106 107 ],
107 108 ], $meetings, $contact);
108 109
110 + $bookButton = $this->getBookAppointmentButton($contact);
111 +
109 112 if (empty($response['data'])) {
110 - $sections['content_html'] = '<p style="padding:0 20px;">' . esc_html__('No scheduled meetings found for this contact.', 'fluent-booking') . '</p>';
113 + $sections['content_html'] = $bookButton . '<p style="padding:0 20px;">' . esc_html__('No scheduled meetings found for this contact.', 'fluent-booking') . '</p>';
111 114 return $sections;
112 115 }
113 116
114 117 $header = [];
@@ -121,13 +124,23 @@
121 124 foreach ($response['data'] as $row) {
122 125 $table->addRow($row);
123 126 }
124 127
125 - $sections['content_html'] = $table->getHtml() . $this->getViewAllLink($contact, $total, $limit);
128 + $sections['content_html'] = $bookButton . $table->getHtml() . $this->getViewAllLink($contact, $total, $limit);
126 129
127 130 return $sections;
128 131 }
129 132
133 + private function getBookAppointmentButton(Subscriber $contact)
134 + {
135 + $url = admin_url('admin.php?page=fluent-booking#/scheduled-events?new_booking=1&crm_contact_id=' . (int) $contact->id);
136 +
137 + return '<p class="fcal_crm_book_appointment" style="padding:0px 20px;margin-top:-36px;text-align:end;">'
138 + . '<a class="el-button el-button--small" target="_blank" rel="noopener noreferrer" href="' . esc_url($url) . '">'
139 + . esc_html__('Book Appointment', 'fluent-booking')
140 + . '</a></p>';
141 + }
142 +
130 143 private function mapMeetingRow($meeting, $host)
131 144 {
132 145 $groupRef = $meeting->group_id ?: $meeting->id;
133 146
@@ -132,11 +145,11 @@
132 145 $groupRef = $meeting->group_id ?: $meeting->id;
133 146
134 147 return [
135 148 'id' => '#' . $groupRef,
136 - 'title' => $this->getBookingTitle($meeting, $host),
137 - 'status' => $meeting->status,
138 - 'meeting_at' => $this->getFormattedTime($meeting),
149 + 'title' => esc_html($this->getBookingTitle($meeting, $host)),
150 + 'status' => esc_html($meeting->status),
151 + 'meeting_at' => esc_html($this->getFormattedTime($meeting)),
139 152 'action' => $this->getActionUrl($meeting),
140 153 ];
141 154 }
142 155
@@ -162,9 +175,9 @@
162 175 }
163 176
164 177 private function getFormattedTime($meeting)
165 178 {
166 - return DateTimeHelper::convertToTimeZone($meeting->start_time, 'utc', $meeting->calendar->author_timezone, 'j M Y, g:i A');
179 + return DateTimeHelper::convertToTimeZone($meeting->start_time, 'UTC', $meeting->calendar->author_timezone, 'j M Y, g:i A');
167 180 }
168 181
169 182 private function getBookingTitle($meeting, $host = null)
170 183 {