Plugin Directory

Changeset 3448971


Ignore:
Timestamp:
01/28/2026 07:20:22 PM (2 months ago)
Author:
bookingor
Message:

updating files

Location:
bookingor/trunk/app/Frontend
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • bookingor/trunk/app/Frontend/Controller/Booking/BookingControlFront.php

    r3444926 r3448971  
    44
    55use Bookingor\Integrations\Email\EmailNotification;
    6 use Bookingor\Integrations\Whatsapp\WhatsappIntegration;
    7 use Bookingor\Integrations\PayPal\PayPalIntegration;
    8 use Bookingor\Integrations\Twilio\TwilioIntegration;
    9 use PHPMailer\PHPMailer\Exception;
    106use Bookingor\Helper\HelperControl;
    11 use Omnipay\Omnipay;
    12 use Omnipay\PayPal\ExpressGateway;
    13 use PHPMailer\PHPMailer\PHPMailer;
    147
    158
     
    6760            $js = map_deep(wp_unslash($_POST['design_final_booking'] ?? ""), 'sanitize_text_field');
    6861            $timeZoneName = $js['timeZoneName'] ?? "";
    69             $extra_customer = isset($js['extra_details']) ? $js['extra_details'] : null;
    7062            if (get_option('bookingor_settings_woocommerce_payment_active') === 'on' && !empty($js['wc_product_id'])) {
    7163                $order_id = get_query_var('order-received');
     
    7466
    7567            // user logged in
    76             if (is_user_logged_in() && in_array('bookingor_customer', wp_get_current_user()->roles) || in_array('administrator', wp_get_current_user()->roles)) {
     68            if (is_user_logged_in() && in_array('administrator', wp_get_current_user()->roles)) {
    7769                $current_user = wp_get_current_user();
    7870                $user_email = $current_user->user_email;
     
    9789                }
    9890                $customer_id = $wpdb->insert_id;
    99                 if (!empty($js['repeat_details']) && isset($js['repeat_details'])) {
    100                     foreach ($js['repeat_details'] as $key => $value) {
    101                         self::$bookingorDb->insert(
    102                             $booked_customer,
    103                             array(
    104                                 'customer_get_id' => $customer_id,
    105                                 'service_get_id' => $js['get_service_id'],
    106                                 'staff_get_id' => isset($js['get_staff_id']) ? $js['get_staff_id'] : null,
    107                                 'category_get_id' => isset($js['category_id']) ? $js['category_id'] : null,
    108                                 'location_get_id' => isset($js['location_get_id']) ? $js['location_get_id'] : null,
    109                                 'people_count' => $js['selected_max_capacity'],
    110                                 'start_time' => HelperControl::convert12To24($js['get_start_time'] ?? ""),
    111                                 'end_time' => HelperControl::convert12To24($js['get_end_time'] ?? ""),
    112                                 'duration_service' => $js['service_duration'],
    113                                 'picked_date' => $value['date'],
    114                                 'picked_date_end' => date('Y-m-d', strtotime($value['date'] . ' ' . HelperControl::convert12To24($js['get_start_time']) . ' + ' . $js['service_duration'] ?? "" . ' minutes')),
    115                                 'discount_get_price' => '',
    116                                 'extra_get_price' => isset($js['extra_total_price']) ? $js['extra_total_price'] : 0,
    117                                 'service_get_price' => $value['repeat_cost'] ?? "",
    118                                 'tax_get_price' => $js['service_tax'] ?? "",
    119                                 'payment_method' => $customer_payment_design,
    120                                 'token_code' => sanitize_text_field(wp_unslash($_POST['nonce'])),
    121                                 'appoint_status' => $default_booking_status
    122                             ),
    123                         );
    124                         $booked_id = $wpdb->insert_id;
    125                         foreach ($extra_customer as $extra_details) {
    126                             $extra_id = $extra_details['extra_id'];
    127                             $extra_name = $extra_details['extra_name'];
    128                             $extra_duration = $extra_details['extra_duration'];
    129                             $extra_price = $extra_details['extra_price'];
    130                             $extra_qty = $extra_details['extra_qty'];
    131                             self::$bookingorDb->insert(
    132                                 $extra_booked,
    133                                 array(
    134                                     'get_book_id' => $booked_id,
    135                                     'extra_get_id' => $extra_id,
    136                                     'extra_get_price' => $extra_duration,
    137                                     'extra_get_price' => $extra_price,
    138                                     'extra_get_max_qty' => $extra_qty
    139                                 )
    140                             );
    141                         }
    142                         if ($customer_payment_design === 'on-visit') {
    143                             self::$bookingorDb->insert(
    144                                 $customer_payment_data,
    145                                 array(
    146                                     'customer_get_id' => $customer_id,
    147                                     'book_get_id' => $booked_id,
    148                                     'payment_method' => $customer_payment_design,
    149                                     'payment_status' => 'pending',
    150                                     'paid_amount' => '',
    151                                 ),
    152                             );
    153                         }
    154                     }
    155                 }
     91
    15692                self::$bookingorDb->insert(
    15793                    $booked_customer,
     
    199135                    );
    200136                }
    201                 if ($customer_payment_design === "paypal") {
    202                     if (is_plugin_active('bookingor-paypal-addon/bookingor-paypal-addon.php')) {
    203                         require_once(ABSPATH . 'wp-content/plugins/bookingor-paypal-addon/admin/include/paypal-control.php');
    204 
    205                         if (class_exists('BK_NGOR_paypal_controller')) {
    206                             $paypal_payment = new BK_NGOR_paypal_controller();
    207 
    208                             $result = $paypal_payment->makePayment($js['sum_total_cost'], $f_currency_symbol);
    209                             echo wp_json_encode($result);
    210                         }
    211                     }
    212                 }
    213 
    214                 if (!empty($extra_customer) && isset($extra_customer)) {
    215                     foreach ($extra_customer as $extra_details) {
    216                         $extra_id = $extra_details['extra_id'];
    217                         $extra_name = $extra_details['extra_name'];
    218                         $extra_duration = $extra_details['extra_duration'];
    219                         $extra_price = $extra_details['extra_price'];
    220                         $extra_qty = $extra_details['extra_qty'];
    221                         self::$bookingorDb->insert(
    222                             $extra_booked,
    223                             array(
    224                                 'get_book_id' => $booked_id,
    225                                 'extra_get_id' => $extra_id,
    226                                 'extra_get_price' => $extra_duration,
    227                                 'extra_get_price' => $extra_price,
    228                                 'extra_get_max_qty' => $extra_qty
    229                             )
    230                         );
    231                     }
    232                 }
    233 
    234                
     137
    235138
    236139                $customer_full_name = $customer_first_name . ' ' . $customer_last_name;
     
    244147                        %1\$s WHERE
    245148                        name_action = '%2\$s' and type = 'email'", $notifications, $email_check)
    246                 );
    247 
    248 
    249 
    250                 // sms content cutomer
    251                 $sms_content_customer = self::$bookingorDb->get_row(
    252                     self::$bookingorDb->prepare("SELECT
    253                         id, name_action, name, subject, text, send_to,  type, paid_amount, tax_charges, coupon_id, book_date,
    254                         book_time, status FROM
    255                         %1\$s WHERE
    256                         name_action = '%2\$s' and type = 'sms'", $notifications, $sms_check_customer)
    257                 );
    258 
    259                 $sms_content_staff = self::$bookingorDb->get_row(
    260                     self::$bookingorDb->prepare("SELECT
    261                         id, name_action, name, subject, text, send_to,  type, paid_amount, tax_charges, coupon_id, book_date,
    262                         book_time, status FROM
    263                         %1\$s WHERE
    264                         name_action = '%2\$s' and type = 'sms'", $notifications, $sms_check_staff)
    265                 );
    266 
    267 
    268                 //Whatsapp content customer
    269                 $whatsapp_content_customer = self::$bookingorDb->get_row(
    270                     self::$bookingorDb->prepare("SELECT
    271                         id, name_action, name, subject, text, send_to,  type, paid_amount, tax_charges, coupon_id, book_date,
    272                         book_time, status FROM
    273                         %1\$s WHERE
    274                         name_action = '%2\$s' and type = 'whatsapp'", $notifications, $get_whatsapp_action_customer)
    275                 );
    276 
    277                 $whatsapp_content_staff = self::$bookingorDb->get_row(
    278                     self::$bookingorDb->prepare("SELECT
    279                         id, name_action, name, subject, text, send_to,  type, paid_amount, tax_charges, coupon_id, book_date,
    280                         book_time, status FROM
    281                         %1\$s WHERE
    282                         name_action = '%2\$s' and type = 'whatsapp'", $notifications, $get_whatsapp_action_staff)
    283149                );
    284150
     
    338204                    }
    339205                }
    340                 if (class_exists('Bookingor\Integrations\Twilio\TwilioIntegration') && get_option('bookingor_settings_twilio_active') === 'on') {
    341                     $body_customer_sms = TwilioIntegration::string_Placeholder_variable(
    342                         $categoryString,
    343                         $serviceString,
    344                         $staffString,
    345                         $customerString,
    346                         $bookedString,
    347                         $locationString,
    348                         $businessString,
    349                         $sms_content_customer->text
    350                     );
    351                     $body_staff_sms = TwilioIntegration::string_Placeholder_variable(
    352                         $categoryString,
    353                         $serviceString,
    354                         $staffString,
    355                         $customerString,
    356                         $bookedString,
    357                         $locationString,
    358                         $businessString,
    359                         $sms_content_staff->text
    360                     );
    361 
    362                     TwilioIntegration::sendSMSNotification($customer_phone, $body_customer_sms);
    363                     TwilioIntegration::sendSMSNotification($js['get_staff_phone'], $body_staff_sms);
    364 
    365                     // require_once(ABSPATH . 'wp-content/plugins/bookingor-sms/includes/integrations/twilio-integration/twilio-integration.php');
    366                 }
    367 
    368                 if (class_exists('Bookingor\Integrations\Whatsapp\WhatsappIntegration')) {
    369                     $body_customer_whatsapp = WhatsappIntegration::string_Placeholder_variable(
    370                         $categoryString,
    371                         $serviceString,
    372                         $staffString,
    373                         $customerString,
    374                         $bookedString,
    375                         $locationString,
    376                         $businessString,
    377                         $whatsapp_content_customer->text
    378                     );
    379                     $subject_customer_whatsapp = WhatsappIntegration::string_Placeholder_variable(
    380                         $categoryString,
    381                         $serviceString,
    382                         $staffString,
    383                         $customerString,
    384                         $bookedString,
    385                         $locationString,
    386                         $businessString,
    387                         $whatsapp_content_customer->subject
    388                     );
    389 
    390                     $body_staff_whatsapp = WhatsappIntegration::string_Placeholder_variable(
    391                         $categoryString,
    392                         $serviceString,
    393                         $staffString,
    394                         $customerString,
    395                         $bookedString,
    396                         $locationString,
    397                         $businessString,
    398                         $whatsapp_content_staff->text
    399                     );
    400 
    401                     $subject_staff_whatsapp = WhatsappIntegration::string_Placeholder_variable(
    402                         $categoryString,
    403                         $serviceString,
    404                         $staffString,
    405                         $customerString,
    406                         $bookedString,
    407                         $locationString,
    408                         $businessString,
    409                         $whatsapp_content_staff->subject
    410                     );
    411 
    412                     $headerVariables = [
    413                         'service_name' => "Yoga Class"
    414                     ];
    415                     // print_r($body_staff_whatsapp);
    416 
    417                     // $bodyVariables = [
    418                     //  'customer_first_name' => "John",
    419                     //  'customer_last_name' => "Doe",
    420                     //  'service_name' => "Yoga Class",
    421                     //  'business_name' => "Wellness Center"
    422                     // ];
    423                     // WhatsappIntegration::sendMessage($customer_phone);
    424                     WhatsappIntegration::sendTemplateMessage($customer_phone, $get_whatsapp_action_customer, $subject_customer_whatsapp, $body_customer_whatsapp);
    425                     WhatsappIntegration::sendTemplateMessage($js['get_staff_phone'], $get_whatsapp_action_staff, $subject_staff_whatsapp, $body_staff_whatsapp);
    426                 }
    427 
    428 
    429                 // Google Calendar Integration
    430                 if (class_exists('Bookingor\Integrations\GoogleCalendar\GoogleCalendarIntegration') && isset($js['get_staff_id'])) {
    431                     // Get staff Google Calendar credentials
    432                     $staff_data = self::$bookingorDb->get_row(
    433                         $wpdb->prepare(
    434                             "SELECT google_access_token, google_calendar_id, google_time_zone FROM {$wpdb->prefix}bookingor_staff_add WHERE staff_id = %d",
    435                             $js['get_staff_id']
    436                         ),
    437                         ARRAY_A
    438                     );
    439                     $google_calender_title_text = get_option("bookingor_settings_google_calendar_event_title");
    440                     $google_calender_description = get_option("bookingor_settings_google_calendar_event_description");
    441                     $google_calender_event_title = GoogleCalendarIntegration::string_Placeholder_variable(
    442                         $categoryString,
    443                         $serviceString,
    444                         $staffString,
    445                         $customerString,
    446                         $bookedString,
    447                         $locationString,
    448                         $businessString,
    449                         $google_calender_title_text
    450                     );
    451 
    452                     $google_calender_event_description = GoogleCalendarIntegration::string_Placeholder_variable(
    453                         $categoryString,
    454                         $serviceString,
    455                         $staffString,
    456                         $customerString,
    457                         $bookedString,
    458                         $locationString,
    459                         $businessString,
    460                         $google_calender_description
    461                     );
    462 
    463 
    464                     // print_r($google_calender_title_text . $google_calender_event_title);
    465                     // print_r($google_calender_event_description . $google_calender_event_description);
    466                     // exit;
    467 
    468                     if (!empty($staff_data['google_access_token']) && !empty($staff_data['google_calendar_id'])) {
    469                         try {
    470 
    471                             $googleCalendar = new GoogleCalendarIntegration();
    472                             $googleCalendar->set_Access_Token($staff_data['google_access_token']);
    473 
    474 
    475 
    476                             // Prepare event data
    477                             $service_name = $google_calender_event_title;
    478                             $location_name = $js['get_location_name'] ?? '';
    479                             $description = $google_calender_event_description;
    480 
    481                             // Format datetime for Google Calendar (RFC3339)
    482                             $start_datetime = date('Y-m-d\TH:i:s', strtotime($js['get_full_date'] . ' ' . HelperControl::convert12To24($js['get_start_time'] ?? '')));
    483                             $end_datetime = date('Y-m-d\TH:i:s', strtotime($js['get_full_date'] . ' ' . HelperControl::convert12To24($js['get_end_time'] ?? '')));
    484                             $wp_timezone = get_option('timezone_string') ?: 'UTC';
    485                             $timezone = !empty($staff_data['google_time_zone']) ? $staff_data['google_time_zone'] : $wp_timezone;
    486 
    487                             // Create the event
    488                             $event_id = $googleCalendar->createEvent(
    489                                 $service_name,
    490                                 $location_name,
    491                                 $description,
    492                                 $start_datetime,
    493                                 $timezone,
    494                                 $end_datetime
    495                             );
    496 
    497                             if ($event_id) {
    498                                 error_log('Google Calendar event created successfully: ' . $event_id);
    499                             }
    500                         } catch (\Exception $e) {
    501                             error_log('Google Calendar event creation failed: ' . $e->getMessage());
    502                         }
    503                     }
    504                 }
    505 
    506 
    507                 if (class_exists('BK_NGOR_Zoom_Controller')) {
    508                     $zoom_title_text = get_option("bookingor_settings_zoom_meeting_title");
    509                     $zoom_agenda_text = get_option("bookingor_settings_zoom_meeting_description");
    510                     $body_meeting_title = BK_NGOR_Zoom_Controller::string_Placeholder_variable(
    511                         $categoryString,
    512                         $serviceString,
    513                         $staffString,
    514                         $customerString,
    515                         $bookedString,
    516                         $locationString,
    517                         $businessString,
    518                         $zoom_title_text
    519                     );
    520 
    521                     $zoom_agenda = BK_NGOR_Zoom_Controller::string_Placeholder_variable(
    522                         $categoryString,
    523                         $serviceString,
    524                         $staffString,
    525                         $customerString,
    526                         $bookedString,
    527                         $locationString,
    528                         $businessString,
    529                         $zoom_agenda_text
    530                     );
    531 
    532                     $meetingData = [
    533                         'topic' => $body_meeting_title,
    534                         'start_time' => '2023-03-01T14:00:00Z',
    535                         'duration' => $js['service_duration'],
    536                         'timezone' => 'America/New_York',
    537                         'password' => '123456',
    538                         'agenda' => $zoom_agenda,
    539                         // Add other meeting settings as needed
    540                     ];
    541 
    542 
    543                     $response = BK_NGOR_Zoom_Controller::createMeeting($js['zoom_user_id'], $meetingData);
    544 
    545 
    546                     $zoom_data = array(
    547                         'start_url' => $response['start_url'],
    548                         'join_url' => $response['join_url'],
    549                         'id' => $response['id'],
    550                         'password' => $response['password']
    551                     );
    552                     $json_zoom_data = wp_json_encode($zoom_data);
    553 
    554                     self::$bookingorDb->update(
    555                         $booked_customer,
    556                         array(
    557                             'zoom_meeting_id' => $json_zoom_data,
    558                         ),
    559                         array('book_id' => $booked_id),
    560                     );
    561                 }
    562 
    563206
    564207
     
    605248                    array('book_id' => $booked_id),
    606249                );
    607                 if (get_option('bookingor_settings_customer_create_account') === 'on') {
    608                     $user_id = wp_insert_user(
    609                         array(
    610                             'user_login' => $customer_first_name . '_' . $customer_id,
    611                             'user_pass' => $customer_password,
    612                             'first_name' => $customer_first_name,
    613                             'last_name' => $customer_last_name,
    614                             'user_email' => $customer_email_address,
    615                             'role' => 'bookingor_customer',
    616                             'user_status' => 1,
    617                             'user_registered' => current_time('mysql'),
    618                             'user_activation_key' => wp_generate_password(20, true)
    619                         )
    620                     );
    621                     if (!is_wp_error($user_id)) {
    622                         add_user_meta($user_id, 'first_name', $customer_first_name);
    623                         add_user_meta($user_id, 'last_name', $customer_last_name);
    624                         $subject_customer = 'Your new account password';
    625                         $message = 'Your password is: ' . $customer_password;
    626                         if (!empty(get_option("bookingor_settings_email_type"))) {
    627                             EmailNotification::sendEmail($customer_email_address, $subject_customer, $message);
    628                         }
    629                     } else {
    630                     }
    631                 }
    632                 if (!empty($js['repeat_details'])) {
    633                     foreach ($js['repeat_details'] as $key => $value) {
    634                         self::$bookingorDb->insert(
    635                             $booked_customer,
    636                             array(
    637                                 'customer_get_id' => $customer_id,
    638                                 'service_get_id' => $js['get_service_id'],
    639                                 'staff_get_id' => isset($js['get_staff_id']) ? $js['get_staff_id'] : null,
    640                                 'category_get_id' => isset($js['category_id']) ? $js['category_id'] : null,
    641                                 'location_get_id' => isset($js['location_get_id']) ? $js['location_get_id'] : null,
    642                                 'people_count' => $js['selected_max_capacity'],
    643                                 'start_time' => HelperControl::convert12To24($js['get_start_time'] ?? ""),
    644                                 'end_time' => HelperControl::convert12To24($js['get_end_time'] ?? ""),
    645                                 'duration_service' => $js['service_duration'],
    646                                 'picked_date' => $value['date'],
    647                                 'picked_date_end' => date('Y-m-d', strtotime($value['date'] . ' ' . HelperControl::convert12To24($js['get_start_time']) . ' + ' . $js['service_duration'] . ' minutes')),
    648                                 'discount_get_price' => '',
    649                                 'extra_get_price' => isset($js['extra_total_price']) ? $js['extra_total_price'] : 0,
    650                                 'service_get_price' => $value['repeatPrice'] ?? "",
    651                                 'tax_get_price' => $js['service_tax'] ?? "",
    652                                 'token_code' => sanitize_text_field(wp_unslash($_POST['nonce'])),
    653                                 'payment_method' => $customer_payment_design,
    654                                 'appoint_status' => $default_booking_status
    655                             ),
    656                         );
    657                     }
    658                 }
    659                 if (!empty($extra_customer) && isset($extra_customer)) {
    660                     foreach ($extra_customer as $extra_details) {
    661                         $extra_id = $extra_details['extra_id'];
    662                         $extra_name = $extra_details['extra_name'];
    663                         $extra_duration = $extra_details['extra_duration'];
    664                         $extra_price = $extra_details['extra_price'];
    665                         $extra_qty = $extra_details['extra_qty'];
    666                         self::$bookingorDb->insert(
    667                             $extra_booked,
    668                             array(
    669                                 'get_book_id' => $booked_id,
    670                                 'extra_get_id' => $extra_id,
    671                                 'extra_get_price' => $extra_duration,
    672                                 'extra_get_price' => $extra_price,
    673                                 'extra_get_max_qty' => $extra_qty
    674                             )
    675                         );
    676                     }
    677                 }
     250
    678251                if ($customer_payment_design === 'on-visit') {
    679252                    self::$bookingorDb->insert(
     
    709282
    710283
    711                 // sms content cutomer
    712                 $sms_content_customer = self::$bookingorDb->get_row(
    713                     self::$bookingorDb->prepare("SELECT
    714                         id, name_action, name, subject, text, send_to,  type, paid_amount, tax_charges, coupon_id, book_date,
    715                         book_time, status FROM
    716                         %1\$s WHERE
    717                         name_action = '%2\$s' and type = 'sms'", $notifications, $sms_check_customer)
    718                 );
    719 
    720                 $sms_content_staff = self::$bookingorDb->get_row(
    721                     self::$bookingorDb->prepare("SELECT
    722                         id, name_action, name, subject, text, send_to,  type, paid_amount, tax_charges, coupon_id, book_date,
    723                         book_time, status FROM
    724                         %1\$s WHERE
    725                         name_action = '%2\$s' and type = 'sms'", $notifications, $sms_check_staff)
    726                 );
    727 
    728                 $whatsapp_content_customer = self::$bookingorDb->get_row(
    729                     self::$bookingorDb->prepare("SELECT
    730                         id, name_action, name, subject, text, send_to,  type, paid_amount, tax_charges, coupon_id, book_date,
    731                         book_time, status FROM
    732                         %1\$s WHERE
    733                         name_action = '%2\$s' and type = 'whatsapp'", $notifications, $get_whatsapp_action_customer)
    734                 );
    735 
    736                 $whatsapp_content_staff = self::$bookingorDb->get_row(
    737                     self::$bookingorDb->prepare("SELECT
    738                         id, name_action, name, subject, text, send_to,  type, paid_amount, tax_charges, coupon_id, book_date,
    739                         book_time, status FROM
    740                         %1\$s WHERE
    741                         name_action = '%2\$s' and type = 'whatsapp'", $notifications, $get_whatsapp_action_staff)
    742                 );
     284
     285
    743286
    744287                $categoryString = [];
     
    765308                    EmailNotification::sendEmail($js['get_staff_email'] ?? "", $subject_staff, $body_staff);
    766309                }
    767 
    768                 if (class_exists('Bookingor\Integrations\Twilio\TwilioIntegration') && get_option('bookingor_settings_twilio_active') === 'on') {
    769                     $body_customer_sms = TwilioIntegration::string_Placeholder_variable(
    770                         $categoryString,
    771                         $serviceString,
    772                         $staffString,
    773                         $customerString,
    774                         $bookedString,
    775                         $locationString,
    776                         $businessString,
    777                         $sms_content_customer->text
    778                     );
    779 
    780                     $body_staff_sms = TwilioIntegration::string_Placeholder_variable(
    781                         $categoryString,
    782                         $serviceString,
    783                         $staffString,
    784                         $customerString,
    785                         $bookedString,
    786                         $locationString,
    787                         $businessString,
    788                         $sms_content_staff->text
    789                     );
    790 
    791                     TwilioIntegration::sendSMSNotification($customer_phone, $body_customer_sms);
    792                     TwilioIntegration::sendSMSNotification($js['get_staff_phone'], $body_staff_sms);
    793                 }
    794 
    795 
    796                 if (class_exists('Bookingor\Integrations\Whatsapp\WhatsappIntegration')) {
    797                     $body_customer_whatsapp = WhatsappIntegration::string_Placeholder_variable(
    798                         $categoryString,
    799                         $serviceString,
    800                         $staffString,
    801                         $customerString,
    802                         $bookedString,
    803                         $locationString,
    804                         $businessString,
    805                         $whatsapp_content_customer->text
    806                     );
    807                     $subject_customer_whatsapp = WhatsappIntegration::string_Placeholder_variable(
    808                         $categoryString,
    809                         $serviceString,
    810                         $staffString,
    811                         $customerString,
    812                         $bookedString,
    813                         $locationString,
    814                         $businessString,
    815                         $whatsapp_content_customer->subject
    816                     );
    817 
    818                     $body_staff_whatsapp = WhatsappIntegration::string_Placeholder_variable(
    819                         $categoryString,
    820                         $serviceString,
    821                         $staffString,
    822                         $customerString,
    823                         $bookedString,
    824                         $locationString,
    825                         $businessString,
    826                         $whatsapp_content_staff->text
    827                     );
    828 
    829                     $subject_staff_whatsapp = WhatsappIntegration::string_Placeholder_variable(
    830                         $categoryString,
    831                         $serviceString,
    832                         $staffString,
    833                         $customerString,
    834                         $bookedString,
    835                         $locationString,
    836                         $businessString,
    837                         $whatsapp_content_staff->subject
    838                     );
    839 
    840                     WhatsappIntegration::sendTemplateMessage($customer_phone, $get_whatsapp_action_customer, $subject_customer_whatsapp, $body_customer_whatsapp);
    841                     WhatsappIntegration::sendTemplateMessage($js['get_staff_phone'], $get_whatsapp_action_staff, $subject_staff_whatsapp, $body_staff_whatsapp);
    842                 }
    843 
    844 
    845                 // Google Calendar Integration without login
    846                 if (class_exists('Bookingor\Integrations\GoogleCalendar\GoogleCalendarIntegration') && isset($js['get_staff_id'])) {
    847                     // Get staff Google Calendar credentials
    848                     $staff_data = self::$bookingorDb->get_row(
    849                         $wpdb->prepare(
    850                             "SELECT google_access_token, google_calendar_id, google_time_zone FROM {$wpdb->prefix}bookingor_staff_add WHERE staff_id = %d",
    851                             $js['get_staff_id']
    852                         ),
    853                         ARRAY_A
    854                     );
    855                     $google_calender_title_text = get_option("bookingor_settings_google_calendar_event_title");
    856                     $google_calender_description = get_option("bookingor_settings_google_calendar_event_description");
    857                     $google_calender_event_title = GoogleCalendarIntegration::string_Placeholder_variable(
    858                         $categoryString,
    859                         $serviceString,
    860                         $staffString,
    861                         $customerString,
    862                         $bookedString,
    863                         $locationString,
    864                         $businessString,
    865                         $google_calender_title_text
    866                     );
    867 
    868                     $google_calender_event_description = GoogleCalendarIntegration::string_Placeholder_variable(
    869                         $categoryString,
    870                         $serviceString,
    871                         $staffString,
    872                         $customerString,
    873                         $bookedString,
    874                         $locationString,
    875                         $businessString,
    876                         $google_calender_description
    877                     );
    878 
    879 
    880                     // print_r($google_calender_title_text . $google_calender_event_title);
    881                     // print_r($google_calender_event_description . $google_calender_event_description);
    882                     // exit;
    883 
    884                     if (!empty($staff_data['google_access_token']) && !empty($staff_data['google_calendar_id'])) {
    885                         try {
    886 
    887                             $googleCalendar = new GoogleCalendarIntegration();
    888                             $googleCalendar->set_Access_Token($staff_data['google_access_token']);
    889 
    890 
    891 
    892                             // Prepare event data
    893                             $service_name = $google_calender_event_title;
    894                             $location_name = $js['get_location_name'] ?? '';
    895                             $description = $google_calender_event_description;
    896 
    897                             // Format datetime for Google Calendar (RFC3339)
    898                             $start_datetime = date('Y-m-d\TH:i:s', strtotime($js['get_full_date'] . ' ' . HelperControl::convert12To24($js['get_start_time'] ?? '')));
    899                             $end_datetime = date('Y-m-d\TH:i:s', strtotime($js['get_full_date'] . ' ' . HelperControl::convert12To24($js['get_end_time'] ?? '')));
    900                             $wp_timezone = get_option('timezone_string') ?: 'UTC';
    901                             $timezone = !empty($staff_data['google_time_zone']) ? $staff_data['google_time_zone'] : $wp_timezone;
    902 
    903                             // Create the event
    904                             $event_id = $googleCalendar->createEvent(
    905                                 $service_name,
    906                                 $location_name,
    907                                 $description,
    908                                 $start_datetime,
    909                                 $timezone,
    910                                 $end_datetime
    911                             );
    912 
    913                             if ($event_id) {
    914                                 error_log('Google Calendar event created successfully: ' . $event_id);
    915                             }
    916                         } catch (\Exception $e) {
    917                             error_log('Google Calendar event creation failed: ' . $e->getMessage());
    918                         }
    919                     }
    920                 }
    921 
    922 
    923                 if (class_exists('BK_NGOR_Zoom_Controller')) {
    924                     $zoom_title_text = get_option("bookingor_settings_zoom_meeting_title");
    925                     $zoom_agenda_text = get_option("bookingor_settings_zoom_meeting_description");
    926                     $body_meeting_title = BK_NGOR_Zoom_Controller::string_Placeholder_variable(
    927                         $categoryString,
    928                         $serviceString,
    929                         $staffString,
    930                         $customerString,
    931                         $bookedString,
    932                         $locationString,
    933                         $businessString,
    934                         $zoom_title_text
    935                     );
    936 
    937                     $zoom_agenda = BK_NGOR_Zoom_Controller::string_Placeholder_variable(
    938                         $categoryString,
    939                         $serviceString,
    940                         $staffString,
    941                         $customerString,
    942                         $bookedString,
    943                         $locationString,
    944                         $businessString,
    945                         $zoom_agenda_text
    946                     );
    947 
    948                     $meetingData = [
    949                         'topic' => $body_meeting_title,
    950                         'start_time' => '2023-03-01T14:00:00Z',
    951                         'duration' => $js['service_duration'],
    952                         'timezone' => 'America/New_York',
    953                         'password' => '123456',
    954                         'agenda' => $zoom_agenda,
    955                         // Add other meeting settings as needed
    956                     ];
    957 
    958 
    959                     $response = BK_NGOR_Zoom_Controller::createMeeting($js['zoom_user_id'], $meetingData);
    960 
    961 
    962                     $zoom_data = array(
    963                         'start_url' => $response['start_url'],
    964                         'join_url' => $response['join_url'],
    965                         'id' => $response['id'],
    966                         'password' => $response['password']
    967                     );
    968                     $json_zoom_data = wp_json_encode($zoom_data);
    969 
    970                     self::$bookingorDb->update(
    971                         $booked_customer,
    972                         array(
    973                             'zoom_meeting_id' => $json_zoom_data,
    974                         ),
    975                         array('book_id' => $booked_id),
    976                     );
    977                 }
    978310            }
    979311        }
  • bookingor/trunk/app/Frontend/View/Templates/Services/woocommerce-service-5.php

    r3446143 r3448971  
    2727        <option value=""><?php esc_html_e("Select ", "bookingor"); ?><?php echo esc_html(get_option('bookingor_settings_service_name')); ?></option>
    2828        <?php foreach (ServiceControlFront::bp_front_services_view() as $key =>  $data) { ?>
    29           <option data-staff-get-id="<?php echo esc_attr($data['staff_get_id']); ?>" data-location-get-id="<?php echo esc_attr($data['location_get_id']); ?>" data-service-id="<?php echo esc_attr($data['service_id']); ?>" data-category-get-id="<?php echo esc_attr($data['category_get_id']); ?>" data-extra-get-id="<?php echo esc_attr($data['extra_id']); ?>" data-repeat-status="<?php echo esc_attr($data['recurring_status']); ?>" value="<?php echo esc_attr($data['name']); ?>"><?php echo esc_html($data['name']); ?><?php if (get_option('bookingor_settings_service_price_show') === 'on') { ?>
     29          <option data-staff-get-id="<?php echo esc_attr($data['staff_get_id']); ?>" data-location-get-id="<?php echo esc_attr($data['location_get_id']); ?>" data-service-id="<?php echo esc_attr($data['service_id']); ?>" data-category-get-id="<?php echo esc_attr($data['category_get_id']); ?>" data-repeat-status="<?php echo esc_attr($data['recurring_status']); ?>" value="<?php echo esc_attr($data['name']); ?>"><?php echo esc_html($data['name']); ?><?php if (get_option('bookingor_settings_service_price_show') === 'on') { ?>
    3030            ( <?php echo esc_html(get_option('bookingor_settings_currency_symbol')); ?>
    3131            <?php echo esc_html(HelperControl::priceDecimal($data['price'])); ?> )
  • bookingor/trunk/app/Frontend/View/Templates/design-5.php

    r3448942 r3448971  
    106106                <option value=""><?php esc_html_e("Select ", "bookingor"); ?><?php echo esc_html(get_option('bookingor_settings_service_name')); ?></option>
    107107                <?php foreach (ServiceControlFront::bp_front_services_view() as $key => $value) { ?>
    108                   <option data-staff-get-id="<?php echo esc_attr($value->staff_get_id); ?>" data-location-get-id="<?php echo esc_attr($value->location_get_id); ?>" data-service-id="<?php echo esc_attr($value->service_id); ?>" data-category-get-id="<?php echo esc_attr($value->category_get_id); ?>" data-extra-get-id="<?php echo esc_attr($value->extra_id); ?>" data-repeat-status="<?php echo esc_attr($value->recurring_status); ?>" value="<?php echo esc_attr($value->service_name); ?>"><?php echo esc_html($value->service_name); ?><?php if (get_option('bookingor_settings_service_price_show') === 'on') { ?>
     108                  <option data-staff-get-id="<?php echo esc_attr($value->staff_get_id); ?>" data-location-get-id="<?php echo esc_attr($value->location_get_id); ?>" data-service-id="<?php echo esc_attr($value->service_id); ?>" data-category-get-id="<?php echo esc_attr($value->category_get_id); ?>" value="<?php echo esc_attr($value->service_name); ?>"><?php echo esc_html($value->service_name); ?><?php if (get_option('bookingor_settings_service_price_show') === 'on') { ?>
    109109                    ( <?php echo esc_html(get_option('bookingor_settings_currency_symbol')); ?>
    110110                    <?php echo esc_html(HelperControl::priceDecimal($value->service_cost)); ?> )
Note: See TracChangeset for help on using the changeset viewer.