prefix . "apt_staff"; $settings_table = $wpdb->prefix . "apt_settings"; if ( isset( $_REQUEST['client_name'] ) && isset( $_POST['calendar_file_nonce'] ) ) { if ( ! wp_verify_nonce( $_POST['calendar_file_nonce'], 'calendar_file_nonce' ) ) { die(); } $client_name = sanitize_text_field( $_REQUEST['client_name'] ); $staff_member = "1"; $service_type = sanitize_text_field( $_REQUEST['service_type'] ); $contact = sanitize_text_field( $_REQUEST['contact'] ); if ( isset( $_REQUEST['booking_date'] ) ) { $newDate = sanitize_text_field( $_REQUEST['booking_date'] ); echo $booking_date = date( "Y-m-d", strtotime( $newDate ) ); } else { echo $booking_date = " "; } $start_time = sanitize_text_field( $_REQUEST['start_time'] ); $end_time = sanitize_text_field( $_REQUEST['end_time'] ); $client_email = sanitize_text_field( $_REQUEST['client_email'] ); $appointment_status = sanitize_text_field( $_REQUEST['appointment_status'] ); $payment_status = sanitize_text_field( $_REQUEST['payment_status'] ); $repeat = "Non"; $re_days = "1"; $re_weeks = "1"; $re_months = "1"; $re_start_date = " "; $re_end_date = " "; $service_price = sanitize_text_field( $_REQUEST['service_price'] ); $staff_email_details = $wpdb->get_col( "SELECT staff_email from $staff_table where id='$staff_member'" ); $staff_email = $staff_email_details[0]; $staff_name_details = $wpdb->get_col( "SELECT staff_member_name from $staff_table where id='$staff_member'" ); $staff_member_name = $staff_name_details[0]; $settings_payment_currency = $wpdb->get_col( "SELECT currency from $settings_table" ); $payment_currency = $settings_payment_currency[0]; $wpdb->insert( $wpdb->prefix . 'apt_appointments', array( 'client_name' => $client_name, 'staff_member' => $staff_member, 'service_type' => $service_type, 'contact' => $contact, 'booking_date' => $booking_date, 'start_time' => $start_time, 'end_time' => $end_time, 'status' => $appointment_status, 'payment_status' => $payment_status, 'client_email' => $client_email, 'repeat_appointment' => $repeat, 're_days' => $re_days, 're_weeks' => $re_weeks, 're_months' => $re_months, 're_start_date' => $re_start_date, 're_end_date' => $re_end_date, 'staff_email' => $staff_email, 'appt_booked_by' => 'by_admin', ) ); $wpdb->insert( $wpdb->prefix . 'apt_payment', array( 'payment_type' => 'Cash', 'customer' => $client_name, 'customer_email' => $client_email, 'staff' => $staff_member_name, 'appointment_date' => $booking_date, 'service' => $service_type, 'amount' => $service_price . ' ' . $payment_currency, 'status' => $payment_status, ) ); } if ( isset( $_REQUEST['staff_id'] ) ) { $staff_id = sanitize_text_field( $_REQUEST['staff_id'] ); $wpdb->update( $wpdb->prefix . 'apt_appointments', array( 'staff_id' => $staff_id, ), array( 'staff_member' => $staff_id ) ); } if ( isset( $_REQUEST['staff_service'] ) ) { $staff_service = sanitize_text_field( $_REQUEST['staff_service'] ); $wpdb->update( $wpdb->prefix . 'apt_settings', array( 'staff_service' => $staff_service, ), array( 'id' => 1 ) ); } if ( isset( $_REQUEST['staff_id'] ) ) { $staff_id = sanitize_text_field( $_REQUEST['staff_id'] ); $wpdb->update( $wpdb->prefix . 'apt_settings', array( 'staff_id' => $staff_id, ), array( 'id' => 1 ) ); } if ( isset( $_REQUEST['staff_date'] ) ) { $staff_date = sanitize_text_field( $_REQUEST['staff_date'] ); $wpdb->update( $wpdb->prefix . 'apt_settings', array( 'staff_date' => $staff_date, ), array( 'id' => 1 ) ); } if ( isset( $_REQUEST['delete_id'] ) ) { $del = sanitize_text_field( $_REQUEST['delete_id'] ); $wpdb->delete( $wpdb->prefix . 'apt_appointments', array( 'id' => $del ) ); } if ( isset( $_REQUEST['edit_client_id'] ) ) { $edit_client_id = sanitize_text_field( $_REQUEST['edit_client_id'] ); $edit_client_name = sanitize_text_field( $_REQUEST['edit_client_name'] ); $edit_staff_member = sanitize_text_field( $_REQUEST['edit_staff_member'] ); $edit_service_type = sanitize_text_field( $_REQUEST['edit_service_type'] ); $edit_contact = sanitize_text_field( $_REQUEST['edit_contact'] ); if ( isset( $_REQUEST['edit_booking_date'] ) ) { $newDate = sanitize_text_field( $_REQUEST['edit_booking_date'] ); echo $edit_booking_date = date( "Y-m-d", strtotime( $newDate ) ); } else { echo $edit_booking_date = " "; } $edit_start_time = sanitize_text_field( $_REQUEST['edit_start_time'] ); $edit_end_time = sanitize_text_field( $_REQUEST['edit_end_time'] ); $edit_appointment_status = sanitize_text_field( $_REQUEST['edit_status'] ); $edit_payment_status = sanitize_text_field( $_REQUEST['edit_payment_status'] ); $repeat_cl = "Non"; $re_days_cl = "1"; $re_weeks_cl = "1"; $re_months_cl = "1"; $re_start_date_cl = " "; $re_end_date_cl = " "; $staff_details = $wpdb->get_col( "SELECT staff_email from $staff_table where id='$edit_staff_member'" ); $edit_staff_email = $staff_details[0]; $wpdb->update( $wpdb->prefix . 'apt_appointments', array( 'client_name' => $edit_client_name, 'staff_member' => $edit_staff_member, 'service_type' => $edit_service_type, 'contact' => $edit_contact, 'booking_date' => $edit_booking_date, 'start_time' => $edit_start_time, 'end_time' => $edit_end_time, 'status' => $edit_appointment_status, 'payment_status' => $edit_payment_status, 'repeat_appointment' => $repeat_cl, 're_days' => $re_days_cl, 're_weeks' => $re_weeks_cl, 're_months' => $re_months_cl, 're_start_date' => $re_start_date_cl, 'staff_email' => $edit_staff_email, 're_end_date' => $re_end_date_cl, ), array( 'id' => $edit_client_id ) ); } $appointment_service_details = $wpdb->get_results( "SELECT * from $wpdb->prefix" . "apt_services" ); $appointment_setting_details = $wpdb->get_results( "SELECT * from $wpdb->prefix" . "apt_settings" ); $appointment_calender_details = $wpdb->get_col( "SELECT client_name from $wpdb->prefix" . "apt_appointments" ); $appointment_calender_details = array_unique( $appointment_calender_details ); $appointment_calender_details_date = $wpdb->get_col( "SELECT booking_date from $wpdb->prefix" . "apt_appointments" ); $appointment_calender_details_date = array_unique( $appointment_calender_details_date ); $appointment_calender_staff_member = $wpdb->get_col( "SELECT staff_member from $wpdb->prefix" . "apt_appointments" ); $appointment_calender_staff_member = array_unique( $appointment_calender_staff_member ); $appointment_calender_service = $wpdb->get_col( "SELECT service_type from $wpdb->prefix" . "apt_appointments" ); $appointment_calender_service = array_unique( $appointment_calender_service ); $appointment_category_details = $wpdb->get_results( "SELECT * from $wpdb->prefix" . "apt_category" ); $appointment_customer_details = $wpdb->get_results( "SELECT * from $wpdb->prefix" . "apt_clients" ); $appointment_staff_details = $wpdb->get_results( "select * from $wpdb->prefix" . "apt_staff" ); $appearence_cal_font_style = $wpdb->get_row( "SELECT * from $wpdb->prefix" . "apt_settings" ); $cal_font_style = $appearence_cal_font_style->cal_font_style; $cal_theme_style = $appearence_cal_font_style->cal_theme_style; $cal_date_format = $appearence_cal_font_style->cal_date_format; $cal_time_format = $appearence_cal_font_style->cal_time_format; $cal_view = $appearence_cal_font_style->cal_view; $cal_first_day = $appearence_cal_font_style->cal_first_day; $cal_pending_color = $appearence_cal_font_style->cal_pending_color; $cal_approved_color = $appearence_cal_font_style->cal_approved_color; $cal_off_time_color = $appearence_cal_font_style->cal_off_time_color; $cal_font_style = $appearence_cal_font_style->cal_font_style; $cal_pending_color = $appearence_cal_font_style->cal_pending_color; $cal_approved_color = $appearence_cal_font_style->cal_approved_color; $cal_cancelled_color = $appearence_cal_font_style->cal_cancelled_color; $cal_completed_color = $appearence_cal_font_style->cal_completed_color; $cal_off_time_color = $appearence_cal_font_style->cal_off_time_color; $ap_holiday_fecthes = $wpdb->get_results( "select * from $wpdb->prefix" . "apt_holidays" ); ?>