' media='print' /> prefix . "ap_appointments"; $AddAppointment_sql ="INSERT INTO $table_name ( `id` , `name` , `email` , `service_id` , `phone` , `start_time` , `end_time` , `date` , `note` , `appointment_key` , `status` , `appointment_by` ) VALUES (NULL , '$name', '$email', '$serviceid', '$phone', '$start_time', '$end_time', '$appointmentdate', '$note', '$appointment_key', '$status', '$appointment_by');"; if($wpdb->query($AddAppointment_sql)) { ?>
Thank you for scheduling appointment with us.
A confirmation mail will be forward to you soon after admin approval.
prefix."ap_services"; $ServiceData = $wpdb->get_row("SELECT * FROM `$ServiceTable` WHERE `id` = '$serviceid'", OBJECT); //email subject and body $subject_to_recipent = "$BlogName: Your Appointment Confirmation Mail."; $body_for_recipent = "

Dear ".ucwords($name).".

Thank you for scheduling appointment with $BlogName.

Your Appointment Details As:

Appointment For: ".ucwords($ServiceData->name)."
Appointment Note: $note
Appointment Status: Pending
Appointment Date: $appointmentdate
Appointment Time: $start_time To $end_time
Appointment Key: $appointment_key

You will get a confirmation mail once admin accepts the appointment.

Best Regards

$BlogName "; $subject_to_admin = "$BlogName: One New Appointment Has Been Arrived."; $body_for_admin = "Dear Admin,

One New Appointment Scheduled By '".ucwords($name)."'.

Appointment Details As:


Appointment By: ".ucwords($name)."
Appointment For: ".ucwords($ServiceData->name)."
Appointment Status: Pending
Appointment Date: $appointmentdate
Appointment Time: $start_time To $end_time
Appointment Note: $note
Appointment Key: $appointment_key
Take Action: Approve Appointment OR Cancel Appointment

Login to manage appointment at $BlogName dashboard: Login

Best Regards

$BlogName "; $AdminEmailDetails = unserialize(get_option('emaildetails')); $recipent_email = $email; //send notification & checking mail type // WP MAIL if(get_option('emailtype') == 'wpmail') { $wpmail_body_for_recipent = " Dear ".ucwords($name).", Thank you for scheduling appointment with $BlogName. Your Appointment Details As: Appointment For: ".ucwords($ServiceData->name)." Appointment Note: $note Appointment Status: Pending Appointment Date: $appointmentdate Appointment Time: $start_time To $end_time Appointment Key: $appointment_key Your appointment will be appove by admin. And approval mail will be sent to you soon.

Best Regards

$BlogName "; $wpmail_body_for_admin = " Dear Admin, One New Appointment Scheduled By '".ucwords($name)."'. Appointment Details As: Appointment By: ".ucwords($name)." Appointment For: ".ucwords($ServiceData->name)." Appointment Status: Pending Appointment Date: $appointmentdate Appointment Time: $start_time To $end_time Appointment Note: $note Appointment Key: $appointment_key Take Action: Approve Appointment: $MangeAppointmentUrl OR Cancel Appointment: $MangeAppointmentUrl Login to manage appointment at $BlogName dashboard: $BlogUrl

Best Regards

$BlogName "; $admin_email = $AdminEmailDetails['wpemail']; $headers[] = "From: Admin <$admin_email>"; //recipent mail wp_mail( $recipent_email, $subject_to_recipent, $wpmail_body_for_recipent, $headers, $attachments = '' ); // admin mail wp_mail( $admin_email, $subject_to_admin, $wpmail_body_for_admin, $headers, $attachments = '' ); } //PHP email if(get_option('emailtype') == 'phpmail') { $phpmail_body_for_recipent = " Dear ".ucwords($name).", Thank you for scheduling appointment with $BlogName. Your Appointment Details As: Appointment For: ".ucwords($ServiceData->name)." Appointment Note: $note Appointment Status: Pending Appointment Date: $appointmentdate Appointment Time: $start_time To $end_time Appointment Key: $appointment_key Your appointment will be appove by admin. And approval mail will be sent to you soon.

Best Regards

$BlogName "; $phpmail_body_for_admin = " Dear Admin, One New Appointment Scheduled By '".ucwords($name)."'. Appointment Details As: Appointment By: ".ucwords($name)." Appointment For: ".ucwords($ServiceData->name)." Appointment Status: Pending Appointment Date: $appointmentdate Appointment Time: $start_time To $end_time Appointment Note: $note Appointment Key: $appointment_key Take Action: Approve Appointment: $MangeAppointmentUrl OR Cancel Appointment: $MangeAppointmentUrl Login to manage appointment at $BlogName dashboard: $BlogUrl

Best Regards

$BlogName "; $admin_email = $AdminEmailDetails['phpemail']; $headers = "From: Admin <$admin_email>" . //client mail mail($recipent_email, $subject_to_recipent, $phpmail_body_for_recipent, $headers); // admin mail mail( $admin_email, $subject_to_admin, $phpmail_body_for_admin, $headers); } if(get_option('emailtype') == 'smtp') { $admin_email = $AdminEmailDetails['smtpemail']; include('menu-pages/notification/Email.php'); $admin_email = $AdminEmailDetails['smtpemail']; $hostname = $AdminEmailDetails['hostname']; $portno = $AdminEmailDetails['portno']; $smtpemail = $AdminEmailDetails['smtpemail']; $password = $AdminEmailDetails['password']; $recipent_email = $email; $Email = new Email; $Email->notifyadmin($hostname, $portno, $smtpemail, $password, $admin_email, $subject_to_admin, $body_for_admin, $BlogName); $Email->notifyclient($hostname, $portno, $smtpemail, $password, $admin_email, $recipent_email, $subject_to_recipent, $body_for_recipent, $BlogName); } } } ?>
Appointment Calendar Powered By: AppointZilla

prefix."ap_services"; $FindService_sql = "SELECT `name`, `duration` FROM `$ServiceTableName` WHERE `id` = '$ServiceId'"; $ServiceData = $wpdb->get_row($FindService_sql, OBJECT); $ServiceDuration = $ServiceData->duration; $AppointmentDate = date("Y-m-d", strtotime($_GET['AppDate'])); //assign selected date by user $AllCalendarSettings = unserialize(get_option('apcal_calendar_settings')); $Biz_start_time = $AllCalendarSettings['day_start_time']; $Biz_end_time = $AllCalendarSettings['day_end_time']; if(isset($AllCalendarSettings['apcal_booking_time_slot'])) { $UserDefineTimeSlot = $AllCalendarSettings['apcal_booking_time_slot']; } else { $UserDefineTimeSlot = $ServiceDuration; } $AllSlotTimesList = array(); $Enable = array(); $AppPreviousTimes = array(); $AppNextTimes = array(); $AppBetweenTimes = array(); $EventPreviousTimes = array(); $EventBetweenTimes = array(); $DisableSlotsTimes = array(); $BusinessEndCheck =array(); $AllSlotTimesList_User = array(); $TodaysAllDayEvent = 0; $TimeOffTableName = $wpdb->prefix."ap_events"; //if today is any allday timeoff then show msg no time avilable today $TodaysAllDayFetchEvents_sql = "SELECT `start_time`, `end_time`, `repeat`, `start_date`, `end_date` FROM `$TimeOffTableName` WHERE date('$AppointmentDate') between `start_date` AND `end_date` AND `allday` = '1'"; $TodaysAllDayEventData = $wpdb->get_results($TodaysAllDayFetchEvents_sql, OBJECT); //check if appointment date in any recurring timeoff date foreach($TodaysAllDayEventData as $SingleTimeOff) { // none check if($SingleTimeOff->repeat == 'N') { $TodaysAllDayEvent = 1; } // daily check if($SingleTimeOff->repeat == 'D') { $TodaysAllDayEvent = 1; } // weekly check if($SingleTimeOff->repeat == 'W') { $EventStartDate = $SingleTimeOff->start_date; $diff = ( strtotime($EventStartDate) - strtotime($AppointmentDate) )/60/60/24; if(($diff % 7) == 0) { $TodaysAllDayEvent = 1; } } //bi-weekly check if($SingleTimeOff->repeat == 'BW') { $EventStartDate = $SingleTimeOff->start_date; $diff = ( strtotime($EventStartDate) - strtotime($AppointmentDate) )/60/60/24; if(($diff % 14) == 0) { $TodaysAllDayEvent = 1; } } //monthly check if($SingleTimeOff->repeat == 'M') { // calculate all monthly dates $EventStartDate = $SingleTimeOff->start_date; $EventEndDate = $SingleTimeOff->end_date; $i = 0; do { $NextDate = date("Y-m-d", strtotime("+$i months", strtotime($EventStartDate))); $AllEventMonthlyDates[] = $NextDate; $i = $i+1; } while(strtotime($EventEndDate) != strtotime($NextDate)); //check appointmentdate in $AllEventMonthlyDates if(in_array($AppointmentDate, $AllEventMonthlyDates)) { $TodaysAllDayEvent = 1; } } }//end of event fetching forech if($TodaysAllDayEvent) { ?>
". __("Available Time For", "appointzilla") ." '$ServiceData->name' ". __("On", "appointzilla"). " '".date("l, jS F Y", strtotime($AppointmentDate))."'
"; //Caluculate all time slots according to today's biz hours $start = strtotime($Biz_start_time); $end = strtotime($Biz_end_time); if($UserDefineTimeSlot) { $UserTimeSlot = $UserDefineTimeSlot; }else { $UserTimeSlot = 30; } for( $i = $start; $i < $end; $i += (60*$UserTimeSlot)) { $AllSlotTimesList_User[] = date('h:i A', $i); } // Buniness end chek $Business_end = strtotime($Biz_end_time); $ServiceDuration_Biss= $ServiceDuration-5; $ServiceDuration_Biss = $ServiceDuration_Biss *60; $EndStartTime = $Business_end - $ServiceDuration_Biss; for( $i = $EndStartTime; $i < $Business_end; $i += (60*5)) { $BusinessEndCheck[] = date('h:i A', $i); } // Create Business Time slot for calculation for( $i = $start; $i < $end; $i += (60*5)) { $AllSlotTimesList[] = date('h:i A', $i); } //Fetch All today's appointments and calculate disable slots $AppointmentTableName = $wpdb->prefix."ap_appointments"; $AllAppointments_sql = "SELECT `start_time`, `end_time` FROM `$AppointmentTableName` WHERE `date`= '$AppointmentDate'"; $AllAppointmentsData = $wpdb->get_results($AllAppointments_sql, OBJECT); if($AllAppointmentsData) { foreach($AllAppointmentsData as $Appointment) { $AppStartTimes[] = date('h:i A', strtotime( $Appointment->start_time ) ); $AppEndTimes[] = date('h:i A', strtotime( $Appointment->end_time ) ); //now calculate 5min slots between appointment's start_time & end_time $start_et = strtotime($Appointment->start_time); $end_et = strtotime($Appointment->end_time); for( $i = $start_et; $i < $end_et; $i += (60*(5))) //make 15-10=5min slot { $AppBetweenTimes[] = date('h:i A', $i); } } //calculating Next & Previous time of booked appointments foreach($AllSlotTimesList as $single) { if(in_array($single, $AppStartTimes)) { //get next time $time = $single; $event_length = $ServiceDuration-5; // Service duration time - slot time $timestamp = strtotime("$time"); $endtime = strtotime("+$event_length minutes", $timestamp); $next_time = date('h:i A', $endtime); //echo "
"; //calculate next time $start = strtotime($single); $end = strtotime($next_time); for( $i = $start; $i <= $end; $i += (60*(5))) //making 5min diffrance slot { $AppNextTimes[] = date('h:i A', $i); } //calculate previous time $time1 = $single; $event_length1 = $ServiceDuration-5; // 60min Service duration time - 15 slot time $timestamp1 = strtotime("$time1"); $endtime1 = strtotime("-$event_length1 minutes", $timestamp1); $next_time1 = date('h:i A', $endtime1); $start1 = strtotime($next_time1); $end1 = strtotime($single); for( $i = $start1; $i <= $end1; $i += (60*(5))) //making 5min diff slot { $AppPreviousTimes[] = date('h:i A', $i); } } } //end calculating Next & Previous time of booked appointments } // end if $AllAppointmentsData //Fetch All today's timeoff and calculate disable slots $EventTableName = $wpdb->prefix."ap_events"; $AllEventts_sql = "SELECT `start_time`, `end_time` FROM `$EventTableName` WHERE date('$AppointmentDate') between `start_date` AND `end_date` AND `allday` = '0' AND `repeat` != 'W' AND `repeat` != 'BW' AND `repeat` != 'M'"; $AllEventsData = $wpdb->get_results($AllEventts_sql, OBJECT); if($AllEventsData) { foreach($AllEventsData as $Event) { //calculate previous time (event start time to back serviceduration-5) $minustime = $ServiceDuration - 5; $start = date('h:i A', strtotime("-$minustime minutes", strtotime($Event->start_time))); $start = strtotime($start); $end = $Event->start_time; $end = strtotime($end); for( $i = $start; $i <= $end; $i += (60*(5))) //making 5min diffrance slot { $EventPreviousTimes[] = date('h:i A', $i); } //calculating between time (start - end) $start_et = strtotime($Event->start_time); $end_et = strtotime($Event->end_time); for( $i = $start_et; $i < $end_et; $i += (60*(5))) //making 5min slot { $EventBetweenTimes[] = date('h:i A', $i); } } } //Fetch All 'WEEKLY' timeoff and calculate disable slots $EventTableName = $wpdb->prefix."ap_events"; $AllEventts_sql = "SELECT `start_time`, `end_time`, `start_date`, `end_date` FROM `$EventTableName` WHERE date('$AppointmentDate') between `start_date` AND `end_date` AND `allday` = '0' AND `repeat` = 'W'"; $AllEventsData = $wpdb->get_results($AllEventts_sql, OBJECT); if($AllEventsData) { foreach($AllEventsData as $Event) { //calculate all weekly dates between recurring_start_date - recurring_end_date $Current_Re_Start_Date = $Event->start_date; $Current_Re_End_Date = $Event->end_date; $Current_Re_Start_Date = strtotime($Current_Re_Start_Date); $Current_Re_End_Date = strtotime($Current_Re_End_Date); //make weekly dates for( $i = $Current_Re_Start_Date; $i <= $Current_Re_End_Date; $i += (60 * 60 * 24 * 7)) { $AllEventWeelylyDates[] = date('Y-m-d', $i); } if(in_array($AppointmentDate, $AllEventWeelylyDates)) { //calculate previous time (event start time to back serviceduration-5) $minustime = $ServiceDuration - 5; $start = date('h:i A', strtotime("-$minustime minutes", strtotime($Event->start_time))); $start = strtotime($start); $end = $Event->start_time; $end = strtotime($end); for( $i = $start; $i <= $end; $i += (60*(5))) //making 5min diffrance slot { $EventPreviousTimes[] = date('h:i A', $i); } //calculating between time (start - end) $start_et = strtotime($Event->start_time); $end_et = strtotime($Event->end_time); for( $i = $start_et; $i < $end_et; $i += (60*(5))) //making 5min slot { $EventBetweenTimes[] = date('h:i A', $i); } } } } //Fetch All 'BI-WEEKLY' timeoff and calculate disable slots $EventTableName = $wpdb->prefix."ap_events"; $AllEventts_sql = "SELECT `start_time`, `end_time`, `start_date`, `end_date` FROM `$EventTableName` WHERE date('$AppointmentDate') between `start_date` AND `end_date` AND `allday` = '0' AND `repeat` = 'BW'"; $AllEventsData = $wpdb->get_results($AllEventts_sql, OBJECT); if($AllEventsData) { foreach($AllEventsData as $Event) { //calculate all weekly dates between recurring_start_date - recurring_end_date $Current_Re_Start_Date = $Event->start_date; $Current_Re_End_Date = $Event->end_date; $Current_Re_Start_Date = strtotime($Current_Re_Start_Date); $Current_Re_End_Date = strtotime($Current_Re_End_Date); //make bi-weekly dates for( $i = $Current_Re_Start_Date; $i <= $Current_Re_End_Date; $i += (60 * 60 * 24 * 14)) { $AllEventBiWeelylyDates[] = date('Y-m-d', $i); } if(in_array($AppointmentDate, $AllEventBiWeelylyDates)) { //calculate previous time (event start time to back serviceduration-5) $minustime = $ServiceDuration - 5; $start = date('h:i A', strtotime("-$minustime minutes", strtotime($Event->start_time))); $start = strtotime($start); $end = $Event->start_time; $end = strtotime($end); for( $i = $start; $i <= $end; $i += (60*(5))) //making 5min diffrance slot { $EventPreviousTimes[] = date('h:i A', $i); } //calculating between time (start - end) $start_et = strtotime($Event->start_time); $end_et = strtotime($Event->end_time); for( $i = $start_et; $i < $end_et; $i += (60*(5))) //making 5min slot { $EventBetweenTimes[] = date('h:i A', $i); } } } } //Fetch All 'MONTHLY' timeoff and calculate disable slots $EventTableName = $wpdb->prefix."ap_events"; $AllEventts_sql = "SELECT `start_time`, `end_time`, `start_date`, `end_date` FROM `$EventTableName` WHERE date('$AppointmentDate') between `start_date` AND `end_date` AND `allday` = '0' AND `repeat` = 'M'"; $AllEventsData = $wpdb->get_results($AllEventts_sql, OBJECT); if($AllEventsData) { foreach($AllEventsData as $Event) { //calculate all weekly dates between recurring_start_date - recurring_end_date $Current_Re_Start_Date = $Event->start_date; $Current_Re_End_Date = $Event->end_date; $i = 0; do { $NextDate = date("Y-m-d", strtotime("+$i months", strtotime($Current_Re_Start_Date))); $AllEventMonthlyDates[] = $NextDate; $i = $i+1; } while(strtotime($Current_Re_End_Date) != strtotime($NextDate)); if(in_array($AppointmentDate, $AllEventMonthlyDates)) { //calculate previous time (event start time to back serviceduration-5) $minustime = $ServiceDuration - 5; $start = date('h:i A', strtotime("-$minustime minutes", strtotime($Event->start_time))); $start = strtotime($start); $end = $Event->start_time; $end = strtotime($end); for( $i = $start; $i <= $end; $i += (60*(5))) //making 5min diffrance slot { $EventPreviousTimes[] = date('h:i A', $i); } $start_et = strtotime($Event->start_time); $end_et = strtotime($Event->end_time); for( $i = $start_et; $i < $end_et; $i += (60*(5))) //making 5min slot { $EventBetweenTimes[] = date('h:i A', $i); } } } } $DisableSlotsTimes = array_merge($AppBetweenTimes, $AppPreviousTimes, $EventPreviousTimes, $EventBetweenTimes, $BusinessEndCheck); unset($AppBetweenTimes); unset($AppPreviousTimes); unset($AppNextTimes); unset($EventBetweenTimes); unset($BusinessEndCheck); // comaper All Business Time sloat with with DisableSlotsTimes foreach($AllSlotTimesList as $Single) { if(in_array($Single, $DisableSlotsTimes)) { $Disable[] = $Single; } else { $Enable[] = $Single; } }// end foreach foreach($AllSlotTimesList_User as $Single) // Show All Enable Time Slot { if(isset($Enable)) { if(in_array($Single, $Enable)) { // disable slots ?>
 
 

:
:
:
: