· 9 years ago · Jan 16, 2017, 07:10 AM
1<?php // short-code file with button and big calendar(full-calendar)
2
3add_shortcode( 'APCAL', 'appointment_calendar_shortcode' );
4function appointment_calendar_shortcode() {
5 //ob_start();
6 if(get_locale()) {
7 $language = get_locale();
8 if($language) { define('L_LANG',$language); }
9 }
10
11 $AllCalendarSettings = unserialize(get_option('apcal_calendar_settings'));
12 $small_calendar_type = $AllCalendarSettings['small_calendar_type'];
13 if($AllCalendarSettings['calendar_start_day'] != '') {
14 $CalStartDay = $AllCalendarSettings['calendar_start_day'];
15 } else {
16 $CalStartDay = 1;
17 }
18
19 //disable closed business days on small datepicker
20 global $wpdb;
21 $ClosedDays = array();
22 $StartDate = date("Y-m-d");
23 $EndDate = "2035-01-01";
24
25 /*$BusinessHoursTable = $wpdb->prefix . "ap_business_hours";
26 $ClosedBusinessDays = $wpdb->get_results("SELECT * FROM `$BusinessHoursTable` WHERE `close` LIKE 'yes'");
27 if(count($ClosedBusinessDays)) {
28 foreach($ClosedBusinessDays as $ClosedBusinessDay) {
29 $ClosedDays[] = ucfirst(substr($ClosedBusinessDay->day, 0, 3));
30 }
31 }*/
32
33 require_once( plugin_dir_path( __FILE__ ) . 'calendar/tc_calendar.php');
34 $CurrentDate = date("Y-m-d", time());
35 $DatePicker2 = plugins_url('calendar/', __FILE__);
36 $myCalendar = new tc_calendar("date1");
37 foreach($ClosedDays as $Day) {
38 $myCalendar->disabledDay("$Day");
39 }
40 $myCalendar->startDate($CalStartDay);
41 $myCalendar->setIcon($DatePicker2."images/iconCalendar.gif");
42 $myCalendar->setDate(date("d", strtotime($StartDate)), date("m", strtotime($StartDate)), date("Y", strtotime($StartDate)));
43 $myCalendar->setPath($DatePicker2);
44 $myCalendar->setYearInterval(2035,date('Y'));
45 $StartCalendarFrom = date("Y-m-d", strtotime("-1 day", strtotime($StartDate)));
46 $myCalendar->dateAllow($StartCalendarFrom, $EndDate, false);
47 $myCalendar->setOnChange("myChanged()");
48
49 $DateFormat = get_option('apcal_date_format');
50 if($DateFormat == '') $DateFormat = "d-m-Y";
51 $TimeFormat = get_option('apcal_time_format');
52 if($TimeFormat == '') $TimeFormat = "h:i";
53
54 global $wpdb;
55 $AppointmentTableName = $wpdb->prefix . "ap_appointments";
56 $EventTableName = $wpdb->prefix."ap_events";
57 $StaffTable = $wpdb->prefix."ap_staff";
58
59 $current_month_first_date = date("Y-m-01");
60 $laod_recurring_from = date("Y-m-d", strtotime("-3 month", strtotime($current_month_first_date))); //only for recurring app
61
62 //fetch all normal appointments
63 $FetchAllApps_sql = "select `name`, `staff_id`, `start_time`, `end_time`, `date` FROM `$AppointmentTableName` WHERE `recurring` = 'no' AND `date` >= '$current_month_first_date' AND `status` != 'cancelled'";
64
65 //fetch all recurring appointments
66 $FetchAllRApps_sql = "select * FROM `$AppointmentTableName` WHERE `recurring` = 'yes' AND `date` >= '$current_month_first_date' AND `recurring_st_date` >= '$laod_recurring_from' AND `status` != 'cancelled'";
67
68 //fetch all normal events
69 $FetchAllEvent_sql = "select `name`, `start_time`, `end_time`, `start_date`, `end_date`, `repeat` FROM `$EventTableName` where `repeat` = 'N' AND `start_date` >= '$current_month_first_date' ";
70
71 //fetch all recurring events
72 $FetchAllREvent_sql = "select `name`, `start_time`, `end_time`, `start_date`, `end_date`, `repeat` FROM `$EventTableName` where `repeat` != 'N' AND `start_date` >= '$laod_recurring_from' ";
73
74 if($DateFormat == 'd-m-Y') $CalFormat = 'dd';
75 if($DateFormat == 'm-d-Y') $CalFormat = 'dd';
76 if($DateFormat == 'Y-m-d') $CalFormat = 'dd'; //coz yy-mm-dd not parsing in a correct date
77
78 //Set Colors: Get Business Hours and open & close days
79 $BusinessHoursTable = $wpdb->prefix . "ap_business_hours";
80 $AllBusinessHours = $wpdb->get_results("SELECT * FROM `$BusinessHoursTable`");
81
82 $TodayColor = ""; //"#FFFFCC";
83 $HeaderColor = ""; //"#E3E3E3";
84 $OpenDayColor = ""; //"#72FE95";
85 $CloseDayColor = ""; //"#FF4848";
86
87 $MonColor = $OpenDayColor;
88 $TueColor = $OpenDayColor;
89 $WedColor = $OpenDayColor;
90 $ThrColor = $OpenDayColor;
91 $FriColor = $OpenDayColor;
92 $SatColor = $OpenDayColor;
93 $SunColor = $OpenDayColor;
94 foreach($AllBusinessHours as $TodayHours) {
95 if($TodayHours->id == 1 & $TodayHours->close == 'yes') { $MonColor = $CloseDayColor; } else { $MonColor = "";}
96 if($TodayHours->id == 2 & $TodayHours->close == 'yes') { $TueColor = $CloseDayColor; } else { $TueColor = "";}
97 if($TodayHours->id == 3 & $TodayHours->close == 'yes') { $WedColor = $CloseDayColor; } else { $WedColor = "";}
98 if($TodayHours->id == 4 & $TodayHours->close == 'yes') { $ThrColor = $CloseDayColor; } else { $ThrColor = "";}
99 if($TodayHours->id == 5 & $TodayHours->close == 'yes') { $FriColor = $CloseDayColor; } else { $FriColor = "";}
100 if($TodayHours->id == 6 & $TodayHours->close == 'yes') { $SatColor = $CloseDayColor; } else { $SatColor = "";}
101 if($TodayHours->id == 7 & $TodayHours->close == 'yes') { $SunColor = $CloseDayColor; } else { $SunColor = "";}
102 } ?>
103
104 <style>
105 .fc-mon {
106 background-color: <?php echo $MonColor; ?>;
107 }
108 .fc-tue {
109 background-color: <?php echo $TueColor; ?>;
110 }
111 .fc-wed {
112 background-color: <?php echo $WedColor; ?>;
113 }
114 .fc-thu {
115 background-color: <?php echo $ThrColor; ?>;
116 }
117 .fc-fri {
118 background-color: <?php echo $FriColor; ?>;
119 }
120 .fc-sat {
121 background-color: <?php echo $SatColor; ?>;
122 }
123 .fc-sun {
124 background-color: <?php echo $SunColor; ?>;
125 }
126 .fc-today
127 {
128 background-color: <?php echo $TodayColor; ?>;
129 }
130 .fc-widget-header{
131 background-color:<?php echo $HeaderColor; ?>;
132 }
133
134 /* .fc-other-month .fc-day-number { display:none;} */
135
136 .selected {
137 outline:1px solid #FF0000; /* Firefox, Opera, Chrome, IE8+ */
138 background-color:#FFFF99;
139 }
140
141 .error{
142 color: #FF0000;
143 }
144
145 /*first modal- 2nd div conflicts css*/
146 .entry form {
147 text-align: left;
148 }
149 </style>
150
151 <script type='text/javascript'>
152 jQuery(document).ready(function() {
153 jQuery('#calendar').fullCalendar({
154 header: {
155 left: 'prev,next today',
156 center: 'title',
157 right: 'month,agendaWeek,agendaDay'
158 },
159 columnFormat: {
160 //month: 'dd/MM/yyyy',
161 //week: 'ddd dd/MM/yyyy',
162 //day: 'dddd dd/MM/yyyy'
163 },
164 titleFormat: {
165 //month: 'dd-MMM-yyyy',
166 //week: "dd-MM-yyyy [ yyyy]{ '—'[ dd]-MM-yyyy}",
167 //day: 'dddd dd-MM-yyyy'
168 },
169 editable: false,
170 weekends: true,
171 timeFormat: <?php if($TimeFormat == 'h:i') echo "'h:mmtt{-h:mmtt }'"; else echo "'H:mm{-H:mm }'"; ?>,
172 axisFormat: <?php if($TimeFormat == 'h:i') echo "'hh:mm'"; else echo "'HH:mm'"; ?>,
173 firstDay: <?php echo $CalStartDay; ?>,
174 slotMinutes: <?php if($AllCalendarSettings['calendar_slot_time'] != '') echo $AllCalendarSettings['calendar_slot_time']; else echo "15"; ?>,
175 defaultView: '<?php if($AllCalendarSettings['calendar_view'] != '') echo $AllCalendarSettings['calendar_view']; else echo "month"; ?>',
176 minTime: <?php if($AllCalendarSettings['day_start_time'] != '') echo date("G", strtotime($AllCalendarSettings['day_start_time'])); else echo "8"; ?>,
177 maxTime: <?php if($AllCalendarSettings['day_end_time'] != '') echo date("G", strtotime($AllCalendarSettings['day_end_time'])); else echo "20"; ?>,
178 monthNames: ["<?php _e("January", "appointzilla"); ?>","<?php _e("February", "appointzilla"); ?>","<?php _e("March", "appointzilla"); ?>","<?php _e("April", "appointzilla"); ?>","<?php _e("May", "appointzilla"); ?>","<?php _e("June", "appointzilla"); ?>","<?php _e("July", "appointzilla"); ?>", "<?php _e("August", "appointzilla"); ?>", "<?php _e("September", "appointzilla"); ?>", "<?php _e("October", "appointzilla"); ?>", "<?php _e("November", "appointzilla"); ?>", "<?php _e("December", "appointzilla"); ?>" ],
179 monthNamesShort: ["<?php _e("Jan", "appointzilla"); ?>","<?php _e("Feb", "appointzilla"); ?>","<?php _e("Mar", "appointzilla"); ?>","<?php _e("Apr", "appointzilla"); ?>","<?php _e("May", "appointzilla"); ?>","<?php _e("Jun", "appointzilla"); ?>","<?php _e("Jul", "appointzilla"); ?>","<?php _e("Aug", "appointzilla"); ?>","<?php _e("Sept", "appointzilla"); ?>","<?php _e("Oct", "appointzilla"); ?>","<?php _e("nov", "appointzilla"); ?>","<?php _e("Dec", "appointzilla"); ?>"],
180 dayNames: ["<?php _e("Sunday", "appointzilla"); ?>","<?php _e("Monday", "appointzilla"); ?>","<?php _e("Tuesday", "appointzilla"); ?>","<?php _e("Wednesday", "appointzilla"); ?>","<?php _e("Thursday", "appointzilla"); ?>","<?php _e("Friday", "appointzilla"); ?>","<?php _e("Saturday", "appointzilla"); ?>"],
181 dayNamesShort: ["<?php _e("Sun", "appointzilla"); ?>","<?php _e("Mon", "appointzilla"); ?>", "<?php _e("Tue", "appointzilla"); ?>", "<?php _e("Wed", "appointzilla"); ?>", "<?php _e("Thus", "appointzilla"); ?>", "<?php _e("Fri", "appointzilla"); ?>", "<?php _e("Sat", "appointzilla"); ?>"],
182 buttonText: {
183 today: "<?php _e("Today", "appointzilla"); ?>",
184 day: "<?php _e("Day", "appointzilla"); ?>",
185 week:"<?php _e("Week", "appointzilla"); ?>",
186 month:"<?php _e("Month", "appointzilla"); ?>"
187 }, <?php
188 if($DateFormat == 'd-m-Y') $DPFormat = 'dd-mm-yy';
189 if($DateFormat == 'm-d-Y') $DPFormat = 'mm-dd-yy';
190 if($DateFormat == 'Y-m-d') $DPFormat = 'yy-mm-dd'; //coz yy-mm-dd not parsing in a correct date ?>
191 selectable: true,
192 selectHelper: false,
193 select: function(start, end, allDay) {
194
195 var appdate = jQuery.datepicker.formatDate('<?php echo $DPFormat; ?>', new Date(start));
196 var appdate2 = jQuery.datepicker.formatDate('dd-mm-yy', new Date(start));
197 var check = jQuery.fullCalendar.formatDate(start,'yyyy-MM-dd');
198 var today = jQuery.fullCalendar.formatDate(new Date(),'yyyy-MM-dd');
199 if(check < today) {
200 // Its a past date
201 alert("<?php _e("Sorry! Appointment cannot be booked for past dates.", "appointzilla"); ?>");
202 } else {
203 // Its a right date
204 jQuery('#appdate').val(appdate);
205 jQuery('#appdate2').val(appdate2);
206 jQuery('#AppFirstModal').show();
207
208 // date-picker tweaks
209 var i;
210 var startdate = jQuery.datepicker.formatDate('yymm', new Date(start));
211 for(i=1; i<=31; i++) {
212 if(i < 10) i = '0' + i;
213 var nextdate = startdate + i;
214 jQuery('#date1_frame').contents().find('#' + nextdate).removeClass('today select');
215 }
216 var todaydate = jQuery.datepicker.formatDate('yymmdd', new Date());
217 jQuery('#date1_frame').contents().find('#' + todaydate).removeClass('select');
218 var cnvtdate = jQuery.datepicker.formatDate('yymmdd', new Date(start));
219 jQuery('#date1_frame').contents().find('#' + cnvtdate).addClass('today select');
220 }
221 },
222
223 events: [
224 <?php //Loading Normal Appointments On Calendar Start
225 $AllAppointments = $wpdb->get_results($FetchAllApps_sql, OBJECT);
226 if($AllAppointments) {
227 foreach($AllAppointments as $single) {
228 $start = date("H, i", strtotime($single->start_time));
229 $end = date("H, i", strtotime($single->end_time));
230
231 //get staff appointment color code
232 $StaffId = $single->staff_id;
233 $StaffData = $wpdb->get_row("SELECT `color` FROM `$StaffTable` WHERE `id` = '$StaffId'");
234 if(count($StaffData)) {
235 $StaffAppointmentColor = $StaffData->color;
236 } else {
237 $StaffAppointmentColor = "#1fcb4a";
238 }
239
240 // subtract 1 from month digit coz calendar work on month 0-11
241 $y = date ( 'Y' , strtotime( $single->date ) );
242 $m = date ( 'n' , strtotime( $single->date ) ) - 1;
243 $d = date ( 'd' , strtotime( $single->date ) );
244 $date = "$y-$m-$d";
245 $date = str_replace("-",", ", $date); ?>
246 {
247 title: "<?php _e('Booked', 'appointzilla'); ?>",
248 start: new Date(<?php echo "$date, $start"; ?>),
249 end: new Date(<?php echo "$date, $end"; ?>),
250 allDay: false,
251 backgroundColor : '<?php echo $StaffAppointmentColor; ?>',
252 textColor: 'black',
253 }, <?php
254 }
255 }
256 //Loading Appointments On Calendar End
257
258 //Loading Recurring Appointments On Calendar Start
259 $AllRecurringAppointments = $wpdb->get_results($FetchAllRApps_sql, OBJECT);
260 if($AllRecurringAppointments) {
261 foreach($AllRecurringAppointments as $single) {
262
263 //get staff appointment color code
264 $StaffId = $single->staff_id;
265 $StaffData = $wpdb->get_row("SELECT `color` FROM `$StaffTable` WHERE `id` = '$StaffId'");
266 if(count($StaffData)) {
267 $StaffAppointmentColor = $StaffData->color;
268 } else {
269 $StaffAppointmentColor = "#1fcb4a";
270 }
271
272 if($single->recurring_type != 'monthly') {
273 $start_time = date("H, i", strtotime($single->start_time));
274 $end_time= date("H, i", strtotime($single->end_time));
275 $start_date = $single->recurring_st_date;
276 $end_date = $single->recurring_ed_date;
277
278 //if appointment type then calculate RTC(recutting date calulation)
279 if($single->recurring_type == 'PD')
280 $RDC = 1;
281 if($single->recurring_type == 'daily')
282 $RDC = 1;
283 if($single->recurring_type == 'weekly')
284 $RDC = 7;
285
286 //calculate all dates
287 $Alldates = array();
288 $st_dateTS = strtotime($start_date);
289 $ed_dateTS = strtotime($end_date);
290 for ($currentDateTS = $st_dateTS; $currentDateTS <= $ed_dateTS; $currentDateTS += (60 * 60 * 24 * $RDC)) {
291 $currentDateStr = date("Y-m-d",$currentDateTS);
292 $AlldatesArr[] = $currentDateStr;
293
294 // subtract 1 from month digit coz calendar work on month 0-11
295 $y = date ( 'Y' , strtotime( $currentDateStr ) );
296 $m = date ( 'n' , strtotime( $currentDateStr ) ) - 1;
297 $d = date ( 'd' , strtotime( $currentDateStr ) );
298 $eachdate = "$y-$m-$d";
299
300 //change format
301 $eachdate = str_replace("-",", ", $eachdate); ?>
302 {
303 title: "<?php _e('Booked', 'appointzilla'); ?>",
304 start: new Date(<?php echo "$eachdate, $start_time"; ?>),
305 end: new Date(<?php echo "$eachdate, $end_time"; ?>),
306 allDay: false,
307 backgroundColor : "<?php echo $StaffAppointmentColor; ?>",
308 textColor: "",
309 }, <?php
310 }// end of date calculation for
311 } else {
312 $start_time = date("H, i", strtotime($single->start_time));
313 $end_time= date("H, i", strtotime($single->end_time));
314
315 $start_date = $single->recurring_st_date;
316 $end_date = $single->recurring_ed_date;
317
318 $i = 0;
319 do {
320 $NextDate = date("Y-m-d", strtotime("+$i months", strtotime($start_date)));
321 // subtract 1 from $startdate month digit coz calendar work on month 0-11
322 $y = date ( 'Y' , strtotime( $NextDate ) );
323 $m = date ( 'n' , strtotime( $NextDate ) ) - 1;
324 $d = date ( 'd' , strtotime( $NextDate ) );
325 $start_date2 = "$y-$m-$d";
326 $start_date2 = str_replace("-",", ", $start_date2); //changing date format
327 $end_date2 = str_replace("-",", ", $start_date2); ?>
328 {
329 title: "<?php _e('Booked', 'appointzilla'); ?>",
330 start: new Date(<?php echo "$start_date2, $start_time"; ?>),
331 end: new Date(<?php echo "$end_date2, $end_time"; ?>),
332 allDay: false,
333 backgroundColor : "<?php echo $StaffAppointmentColor; ?>",
334 textColor: "",
335 }, <?php
336 $i = $i+1;
337 } while(strtotime($end_date) != strtotime($NextDate));
338 }// end of else
339
340 } // end of fetching single appointment foreach
341 } // end of if
342 //Loading Recurring Appointments On Calendar End
343 ?>
344 {
345 }
346 ]
347 });
348
349 //Modal Form Works
350 //show first modal
351 jQuery('#addappointment').click(function(){
352 jQuery('#AppFirstModal').show();
353 });
354 //hide modal
355 jQuery('#close').click(function(){
356 jQuery('#AppFirstModal').hide();
357 });
358
359 <?php if($DateFormat == 'd-m-Y') $DPFormat = 'dd-mm-yy';
360 if($DateFormat == 'm-d-Y') $DPFormat = 'mm-dd-yy';
361 if($DateFormat == 'Y-m-d') $DPFormat = 'yy-mm-dd'; //coz yy-mm-dd not parsing in a correct date
362
363 if($small_calendar_type == "jquery") {
364 ?>
365 //jQuery UI date picker on modal for
366 document.addnewappointment.appdate.value = jQuery.datepicker.formatDate('<?php echo $DPFormat; ?>', new Date());
367 jQuery(function(){
368 jQuery("#datepicker").datepicker({
369 inline: true,
370 minDate: 0,
371 altField: '#alternate',
372 firstDay: <?php if($AllCalendarSettings['calendar_start_day'] != '') echo $AllCalendarSettings['calendar_start_day']; else echo "0"; ?>,
373 //beforeShowDay: unavailable,
374 onSelect: function(dateText, inst) {
375 var dateAsString = dateText;
376 var seleteddate = jQuery.datepicker.formatDate('<?php echo $DPFormat; ?>', new Date(dateAsString));
377 var seleteddate2 = jQuery.datepicker.formatDate('dd-mm-yy', new Date(dateAsString));
378 document.addnewappointment.appdate.value = seleteddate;
379 document.addnewappointment.appdate2.value = seleteddate2;
380 },
381 });
382 //jQuery( "#datepicker" ).datepicker( jQuery.datepicker.regional[ "af" ] );
383 });
384 <?php } ?>
385
386 //AppFirstModal Validation
387 jQuery('#next1').click(function(){
388 jQuery(".error").hide();
389 if(jQuery('#service').val() == 0)
390 {
391 jQuery("#service").after("<span class='error'><br><strong><?php _e('Select Any Service.', 'appointzilla'); ?></strong><br></span>");
392 return false;
393 }
394 });
395
396 //back button show first modal
397 jQuery('#back').click(function(){
398 jQuery('#AppFirstModal').show();
399 jQuery('#AppSecondModal').hide();
400 });
401
402 });
403
404 //Modal Form Works
405 function LoadSecondModal() {
406 var ServiceId = jQuery('#servicelist').val();
407 var AppDate = jQuery('#appdate2').val();
408 var StaffId = jQuery('#stafflist').val();
409 var SecondData = "ServiceId=" + ServiceId + "&AppDate=" + AppDate + "&StaffId=" + StaffId;
410 jQuery('#loading1').show(); // loading button onclick next1 at first modal
411 jQuery('#next1').hide(); //hide next button
412 jQuery.ajax({
413 dataType : 'html',
414 type: 'GET',
415 url : location.href,
416 cache: false,
417 data : SecondData,
418 complete : function() { },
419 success: function(data) {
420 data = jQuery(data).find('div#AppSecondModalData');
421 jQuery('#loading1').hide();
422 jQuery('#AppFirstModal').hide();
423 jQuery('#AppSecondModal').show();
424 jQuery('#AppSecondModal').html(data);
425 }
426 });
427 }
428
429 //load first modal on click back1
430 function LoadFirstModal() {
431 jQuery('#AppSecondModal').hide()
432 jQuery('#AppFirstModal').show();
433 jQuery('#next1').show();
434 }
435
436 //load second modal on back2 click
437 function LoadSecondModal2() {
438 jQuery('#AppThirdModal').hide();
439 jQuery('#buttondiv').show();
440 jQuery('#AppSecondModal').show();
441 }
442
443 //on new user button click
444 function NewUserBtn() {
445 jQuery('#new-user-div').show();
446 jQuery('#existing-user-div').hide();
447 jQuery('#check-email-result-div').hide();
448 }
449
450 //on existing user button click
451 function ExistingUserBtn() {
452 jQuery('#new-user-div').hide();
453 jQuery('#existing-user-div').show();
454 jQuery('#check-email-div-form').show();
455 }
456
457 //load third modal on-click next2
458 function LoadThirdModal() {
459 //validation on second modal form
460 jQuery('.error').hide();
461 var ServiceId = jQuery('#ServiceId').val();
462 var AppDate = jQuery('#AppDate').val();
463 var StaffId = jQuery('#StaffId').val();
464 var Start_Time = jQuery('input[name=start_time]:radio:checked').val();
465 if(!Start_Time) {
466 jQuery("#time_slot_box").after("<span style='width:auto; margin-left:5%;' class='error'><strong><?php _e('Select any time.', 'appointzilla'); ?></strong></span>");
467 return false;
468 }
469 var ThirdData = "ServiceId=" + ServiceId + "&AppDate=" + AppDate + "&StaffId=" + StaffId + "&StartTime=" + Start_Time ;
470 jQuery('#buttondiv').hide();
471 jQuery('#loading').show();
472 jQuery.ajax({
473 dataType : 'html',
474 type: 'GET',
475 url : location.href,
476 cache: false,
477 data : ThirdData,
478 complete : function() { },
479 success: function(data) {
480 data = jQuery(data).find('div#AppThirdModalData');
481 jQuery('#loading').hide();
482 jQuery('#AppSecondModal').hide();
483 jQuery('#AppThirdModal').show();
484 jQuery('#AppThirdModal').html(data);
485 }
486 });
487 }
488
489
490 //load forth final modal for confirm appointment
491 function CheckValidation(UserType) {
492
493 jQuery('.error').hide();
494 var ServiceId = jQuery('#ServiceId').val();
495 var AppDate = jQuery('#AppDate').val();
496 var StaffId = jQuery('#StaffId').val();
497 var StartTime = jQuery('#StartTime').val();
498
499 /**
500 * new user booking case
501 */
502 if(UserType == "NewUser") {
503 <?php if($AllCalendarSettings['apcal_user_registration'] == "yes"){ ?>
504 var ClientUserName = jQuery("#client-username").val();
505 var ClientPassword = jQuery("#client-password").val();
506 var ClientConfirmPassword = jQuery("#client-confirm-password").val();
507 <?php } ?>
508 var ClientEmail = jQuery("#client-email").val();
509 var ClientFirstName = jQuery("#client-first-name").val();
510 var ClientLastName = jQuery("#client-last-name").val();
511 var ClientPhone = jQuery("#client-phone").val();
512 var ClientSi = jQuery("#client-si").val();
513
514 <?php if($AllCalendarSettings['apcal_user_registration'] == "yes"){ ?>
515 //client username
516 if (ClientUserName == "") {
517 jQuery("#client-username").after("<span class='error'> <br><strong><?php _e('Username required.', 'appointzilla'); ?></strong></span>");
518 return false;
519 } else {
520
521 if(ClientUserName.length < 6) {
522 jQuery("#client-username").after("<span class='error'> <br><strong><?php _e('Choose a strong username.', 'appointzilla'); ?></strong></span>");
523 return false;
524 }
525 var Res = isNaN(ClientUserName);
526 if(Res == false) {
527 jQuery("#client-username").after("<span class='error'> <br><strong><?php _e('Invalid username.', 'appointzilla'); ?></strong></span>");
528 return false;
529 }
530 }
531
532 //client password
533 if (ClientPassword == "") {
534 jQuery("#client-password").after("<span class='error'> <br><strong><?php _e('Password required.', 'appointzilla'); ?></strong></span>");
535 return false;
536 } else {
537
538 if(ClientPassword.length < 6) {
539 jQuery("#client-password").after("<span class='error'> <br><strong><?php _e('Choose a strong password.', 'appointzilla'); ?></strong></span>");
540 return false;
541 }
542 }
543
544 //client confirm password
545 if (ClientConfirmPassword == "") {
546 jQuery("#client-confirm-password").after("<span class='error'> <br><strong><?php _e('Confirm password required.', 'appointzilla'); ?></strong></span>");
547 return false;
548 } else {
549 if(ClientConfirmPassword != ClientPassword) {
550 jQuery("#client-confirm-password").after("<span class='error'> <br><strong><?php _e('Confirm password do not match', 'appointzilla'); ?></strong></span>");
551 return false;
552 }
553 }
554 <?php } ?>
555
556 //client email
557 var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
558 if (ClientEmail == "") {
559 jQuery("#client-email").after("<span class='error'> <br><strong><?php _e('Email required.', 'appointzilla'); ?></strong></span>");
560 return false;
561 } else {
562 if(regex.test(ClientEmail) == false ) {
563 jQuery("#client-email").after("<span class='error'> <br><strong><?php _e('Invalid email.', 'appointzilla'); ?></strong></span>");
564 return false;
565 }
566 }
567
568 //client first name
569 if (ClientFirstName == "") {
570 jQuery("#client-first-name").after("<span class='error'> <br><strong><?php _e('First name required.', 'appointzilla'); ?></strong></span>");
571 return false;
572 } else {
573 var Res = isNaN(ClientFirstName);
574 if(Res == false) {
575 jQuery("#client-first-name").after("<span class='error'> <br><strong><?php _e('Invalid first name.', 'appointzilla'); ?></strong></span>");
576 return false;
577 }
578 var NameRegx = /^[a-zA-Z0-9- ]*$/;
579 if(NameRegx.test(ClientFirstName) == false) {
580 jQuery("#client-first-name").after("<span class='error'> <br><strong><?php _e('No special characters allowed.', 'appointzilla'); ?></strong></span>");
581 return false;
582 }
583 }
584
585 //client last name
586 if (ClientLastName == "") {
587 jQuery("#client-last-name").after("<span class='error'> <br><strong><?php _e('Last name required.', 'appointzilla'); ?></strong></span>");
588 return false;
589 } else {
590 var Res = isNaN(ClientLastName);
591 if(Res == false) {
592 jQuery("#client-last-name").after("<span class='error'> <br><strong><?php _e('Invalid last name.', 'appointzilla'); ?></strong></span>");
593 return false;
594 }
595 var NameRegx = /^[a-zA-Z0-9- ]*$/;
596 if(NameRegx.test(ClientLastName) == false) {
597 jQuery("#client-last-name").after("<span class='error'> <br><strong><?php _e('No special characters allowed.', 'appointzilla'); ?></strong></span>");
598 return false;
599 }
600 }
601
602 //client phone
603 if (ClientPhone == "") {
604 jQuery("#client-phone").after("<span class='error'> <br><strong><?php _e("Phone required. <br>Only Numbers 1234567890.", "appointzilla"); ?></strong></span>");
605 return false;
606 } else {
607 var ClientPhoneRes = isNaN(ClientPhone);
608 if(ClientPhoneRes == true) {
609 jQuery("#client-phone").after("<span class='error'> <br><strong><?php _e("Invalid phone. <br>Numbers only: 1234567890.", "appointzilla"); ?></strong></span>");
610 return false;
611 }
612 }
613
614 var PostData1 = "Action=BookAppointment"+ "&ServiceId=" + ServiceId + "&AppDate=" + AppDate + "&StaffId=" + StaffId + "&StartTime=" + StartTime;
615 <?php if($AllCalendarSettings['apcal_user_registration'] == "yes"){ ?>
616 var PostData2 = "&UserType=" + UserType + "&ClientUserName="+ ClientUserName + "&ClientPassword=" +ClientPassword + "&ClientEmail=" + ClientEmail;
617 <?php } else { ?>
618 var PostData2 = "&UserType=" + UserType + "&ClientEmail=" + ClientEmail;
619 <?php } ?>
620 var PostData3 = "&ClientFirstName=" + ClientFirstName + "&ClientLastName=" + ClientLastName + "&ClientPhone=" + ClientPhone + "&ClientNote=" + ClientSi;
621 var PostData = PostData1 + PostData2 + PostData3;
622
623 jQuery('#new-user-form-btn-div').hide();
624 jQuery('#new-user-form-loading-img').show();
625 }
626
627 /**
628 * existing user booking case
629 */
630 if(UserType == "ExUser") {
631
632 var ClientEmail = jQuery("#ex-client-email").val();
633 var ClientFirstName = jQuery("#ex-client-first-name").val();
634 var ClientLastName = jQuery("#ex-client-last-name").val();
635 var ClientPhone = jQuery("#ex-client-phone").val();
636 var ClientSi = jQuery("#ex-client-si").val();
637
638 //client email
639 var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
640 if (ClientEmail == "") {
641 jQuery("#ex-client-email").after("<span class='error'> <br><strong><?php _e('Email required.', 'appointzilla'); ?></strong></span>");
642 return false;
643 } else {
644 if(regex.test(ClientEmail) == false ) {
645 jQuery("#ex-client-email").after("<span class='error'> <br><strong><?php _e('Invalid email.', 'appointzilla'); ?></strong></span>");
646 return false;
647 }
648 }
649
650 //client first name
651 if (ClientFirstName == "") {
652 jQuery("#ex-client-first-name").after("<span class='error'> <br><strong><?php _e('First name required.', 'appointzilla'); ?></strong></span>");
653 return false;
654 } else {
655 var Res = isNaN(ClientFirstName);
656 if(Res == false) {
657 jQuery("#ex-client-first-name").after("<span class='error'> <br><strong><?php _e('Invalid first name.', 'appointzilla'); ?></strong></span>");
658 return false;
659 }
660 var NameRegx = /^[a-zA-Z0-9- ]*$/;
661 if(NameRegx.test(ClientFirstName) == false) {
662 jQuery("#ex-client-first-name").after("<span class='error'> <br><strong><?php _e('No special characters allowed.', 'appointzilla'); ?></strong></span>");
663 return false;
664 }
665 }
666
667 //client last name
668 if (ClientLastName == "") {
669 jQuery("#ex-client-last-name").after("<span class='error'> <br><strong><?php _e('Last name required.', 'appointzilla'); ?></strong></span>");
670 return false;
671 } else {
672 var Res = isNaN(ClientLastName);
673 if(Res == false) {
674 jQuery("#ex-client-last-name").after("<span class='error'> <br><strong><?php _e('Invalid last name.', 'appointzilla'); ?></strong></span>");
675 return false;
676 }
677 var NameRegx = /^[a-zA-Z0-9- ]*$/;
678 if(NameRegx.test(ClientLastName) == false) {
679 jQuery("#ex-client-last-name").after("<span class='error'> <br><strong><?php _e('No special characters allowed.', 'appointzilla'); ?></strong></span>");
680 return false;
681 }
682 }
683
684 //client phone
685 if (ClientPhone == "") {
686 jQuery("#ex-client-phone").after("<span class='error'> <br><strong><?php _e("Phone required. <br>Only Numbers 1234567890.", "appointzilla"); ?></strong></span>");
687 return false;
688 } else {
689 var ClientPhoneRes = isNaN(ClientPhone);
690 if(ClientPhoneRes == true) {
691 jQuery("#ex-client-phone").after("<span class='error'> <br><strong><?php _e("Invalid phone. <br>Numbers only: 1234567890.", "appointzilla"); ?></strong></span>");
692 return false;
693 }
694 }
695
696 var PostData1 = "Action=BookAppointment"+ "&ServiceId=" + ServiceId + "&AppDate=" + AppDate + "&StaffId=" + StaffId + "&StartTime=" + StartTime;
697 var PostData2 = "&UserType=" + UserType + "&ClientEmail=" + ClientEmail;
698 var PostData3 = "&ClientFirstName=" + ClientFirstName + "&ClientLastName=" + ClientLastName + "&ClientPhone=" + ClientPhone + "&ClientNote=" + ClientSi;
699 var PostData = PostData1 + PostData2 + PostData3;
700
701 jQuery('#ex-user-form-btn-div').hide();
702 jQuery('#ex-user-form-loading-img').show();
703 }
704
705 jQuery.ajax({
706 dataType : 'html',
707 type: 'POST',
708 url : location.href,
709 cache: false,
710 data : PostData,
711 complete : function() { },
712 success: function(data) {
713 data = jQuery(data).find('div#AppForthModalData');
714 jQuery("#new-user-form-loading-img").hide();
715 jQuery("#check-email-div-form").hide();
716 jQuery("#AppThirdModal").hide();
717 jQuery("#AppForthModalFinal").show();
718 jQuery("#AppForthModalFinal").html(data);
719 }
720 });
721 }
722
723 //check existing user
724 function CheckExistingUser() {
725 jQuery(".error").hide();
726 var ClientEmail = jQuery("#check-client-email").val();
727 //client email
728 var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
729 if (ClientEmail == "") {
730 jQuery("#check-client-email").after("<span class='error'> <br><strong><?php _e('Email required.', 'appointzilla'); ?></strong></span>");
731 return false;
732 } else {
733 if(regex.test(ClientEmail) == false ) {
734 jQuery("#check-client-email").after("<span class='error'> <br><strong><?php _e('Invalid email.', 'appointzilla'); ?></strong></span>");
735 return false;
736 }
737 }
738
739 var PostData = "Action=CheckExistingUser" + "&ClientEmail=" + ClientEmail;
740 jQuery("#existing-user-form-btn").hide();
741 jQuery("#existing-user-loading-img").show();
742 jQuery.ajax({
743 dataType : 'html',
744 type: 'POST',
745 url : location.href,
746 cache: false,
747 data : PostData,
748 complete : function() { },
749 success: function(Data) {
750 Data = jQuery(Data).find('div#check-email-result');
751 jQuery("#existing-user-loading-img").hide();
752 jQuery("#check-user").hide();
753 jQuery('#check-email-div-form').hide();
754 jQuery("#check-email-result-div").show();
755 jQuery("#check-email-result-div").html(Data);
756 }
757 });
758 }
759
760 function CloseModelform() {
761 jQuery("#AppForthModalFinal").hide();
762 jQuery("#AppSecondModalData").hide();
763 jQuery("#AppThirdModalData").hide();
764 jQuery("#ex-pay-canceling-img").show();
765 location.href = location.href;
766 }
767
768 function highlightsradio(timeslotspanid) {
769 jQuery('span').removeClass('selected');
770 var spanid = "#" + timeslotspanid;
771 jQuery(spanid).addClass("selected");
772 }
773
774 // failed appointment
775 function failedappointment() {
776 var appid = jQuery('#appid').val();
777 var Datastring = "appstatus=cancel" + "&appid="+ appid;
778 jQuery.ajax({
779 dataType : 'html',
780 type: 'POST',
781 url : location.href,
782 cache: false,
783 data : Datastring,
784 complete : function() { },
785 success: function(data) {
786 jQuery('#AppForthModalFinal').hide();
787 jQuery('#AppSecondModalData').hide();
788 jQuery('#AppThirdModalData').hide();
789 var CurrentUrl = location.href;
790 CurrentUrl=CurrentUrl.replace('failed=failed&appointId='+appid, '');
791 location.href = CurrentUrl;
792 }
793 });
794 }
795
796 //cancel appointment
797 function CancelAppointment() {
798 var appid = jQuery('#appid').val();
799 var DataString = "appstatus=cancel" + "&appid="+ appid;
800 jQuery("#paybuttondiv").hide();
801 jQuery("#pay-canceling-img").show();
802 jQuery.ajax({
803 dataType : 'html',
804 type: 'POST',
805 url : location.href,
806 cache: false,
807 data : DataString,
808 complete : function() { },
809 success: function() {
810 jQuery('#AppForthModalFinal').hide();
811 jQuery('#AppSecondModalData').hide();
812 jQuery('#AppThirdModalData').hide();
813 window.location.reload();
814 }
815 });
816 }
817
818 //apply coupon code
819 function ApplyCoupon() {
820 var CouponCode = jQuery("#coupon-code").val();
821 if(CouponCode == "") {
822 alert("<?php _e("Enter any coupon code.", "appointzilla"); ?>");
823 jQuery("#coupon-code").focus();
824 return false;
825 } else {
826 var PostData = "Action=apply-coupon" + "&CouponCode=" + CouponCode;
827 jQuery("#loading-img").show();
828 jQuery.ajax({
829 dataType : 'html',
830 type: 'POST',
831 url : location.href,
832 cache: false,
833 data : PostData,
834 complete : function() { },
835 success: function(ReturnedData) {
836 ReturnedData = jQuery(ReturnedData).find("div#coupon-result");
837 jQuery("#loading-img").hide();
838 jQuery("#apply-coupon-div").hide();
839 jQuery("#show-coupon-result").html(ReturnedData);
840 jQuery("#show-coupon-result").show();
841 var CouponCodeValue = jQuery("#coupon-code-div").text();
842 var DicountRateValue = jQuery("#discount-rate-div").text();
843 jQuery("input[name=custom]").val(CouponCodeValue);
844 jQuery("input[name=discount_rate]").val(DicountRateValue);
845 }
846 });
847 }
848 }
849
850 //try another coupon code
851 function TryAgain() {
852 jQuery("#apply-coupon-div").show();
853 jQuery("#show-coupon-result").hide();
854 }
855
856 //try again booking
857 function TryAgainBooking() {
858 jQuery("#check-email-result-div").hide();
859 jQuery("#check-user").show();
860 jQuery('#check-email-div-form').show();
861 jQuery("#existing-user-form-btn").show();
862 }
863
864 //cancel appointment
865 function Canceling() {
866 jQuery("#ex-user-form-btn-div").hide();
867 jQuery("#ex-canceling-img").show();
868 location.reload();
869 }
870
871 // on paypal pay button click
872 function PayWithPaypal(){
873 jQuery('#show-redirecting-msg').show();
874 jQuery('#paybuttondiv').hide();
875 }
876 </script>
877
878 <!---Display Booking Instruction--->
879 <?php if($AllCalendarSettings['apcal_booking_instructions']) { ?>
880 <div id="bookinginstructions" align="center">
881 <?php echo $AllCalendarSettings['apcal_booking_instructions']; ?>
882 </div>
883 <?php } ?>
884
885 <!---Schedule An Appointment Button--->
886 <div id="bkbtndiv" align="center" style="padding:10px;">
887 <button name="addappointment" class="apcal_btn apcal_btn-large apcal_btn-primary" type="submit" id="addappointment">
888 <strong><i class="icon-calendar icon-white"></i> <?php if(isset($AllCalendarSettings['booking_button_text'])) {
889 echo $AllCalendarSettings['booking_button_text'];
890 } else {
891 _e("Schedule New Appointment", 'appointzilla');
892 } ?>
893 </strong>
894 </button>
895 </button>
896 </div>
897
898 <!---Show appointment calendar--->
899 <div id='calendar'>
900 <div style="text-align: right; font-size: small;">Appointment Calendar Premium Powered By: <a href="http://appointzilla.com/" title="Online Appointment Scheduling Plugin For WordPress" target="_blank">AppointZilla</a></div>
901 </div>
902
903 <!---AppFirstModal For Schedule New Appointment--->
904 <div id="AppFirstModal" style="display:none;">
905 <div class="apcal_modal" id="myModal" style="z-index:10000;">
906 <form action="" method="post" name="addnewappointment" id="addnewappointment">
907 <div class="apcal_modal-info">
908 <div class="apcal_alert apcal_alert-info">
909 <a href="#bookinginstructions" style="float:right; margin-right:4px; margin-top:12px;" id="close"><i class="icon-remove"></i></a>
910 <p><strong><?php _e('Schedule New Appointment', 'appointzilla'); ?></strong></p>
911 <div><?php _e('Step 1. Select Date & Service', 'appointzilla'); ?></div>
912 </div>
913 </div>
914
915 <div class="apcal_modal-body">
916 <div id="firdiv" style="float:left; height:210px; width:260px; padding-bottom:30px;">
917 <!--JS Datepicker -->
918 <?php if($small_calendar_type == "jquery") { ?>
919 <div id="datepicker"></div>
920 <?php } ?>
921 <!--PHP Datepicker-->
922 <?php
923 if($DateFormat == 'd-m-Y') $CalFormat = 'DD-MM-YYYY';
924 if($DateFormat == 'm-d-Y') $CalFormat = 'MM-DD-YYYY';
925 if($DateFormat == 'Y-m-d') $CalFormat = 'YYYY-MM-DD'; //coz yy-mm-dd not
926 if($small_calendar_type == "php") {
927 $myCalendar->writeScript();
928 }
929 ?>
930 <script>
931 function myChanged() {
932 var x = document.getElementById('date1').value;
933 var x2 = document.getElementById('date1').value;
934 x = moment(x).format('<?php echo $CalFormat; ?>');
935 x2 = moment(x2).format('DD-MM-YYYY');
936 document.getElementById('appdate').value = x;
937 document.getElementById('appdate2').value = x2;
938 }
939 </script>
940 </div>
941
942 <div id="secdiv" style="float:right; margin-right:5%; width:40%" >
943 <strong><?php _e('Your Appointment Date:', 'appointzilla'); ?> </strong><br>
944 <input name="appdate" id="appdate" type="text" readonly="" style="height:30px; width:100%; padding-left: 15px;" value="<?php echo date($DateFormat, strtotime($StartDate)); ?>" /><br>
945 <input name="appdate2" id="appdate2" type="hidden" readonly="" style="height:30px; width:100%" value="<?php echo date("Y-m-d", strtotime($StartDate)); ?>" />
946 <?php global $wpdb;
947 $CategoryTable = $wpdb->prefix."ap_service_category";
948 $FindCategorySQL ="SELECT * FROM `$CategoryTable` order by `name` ASC";
949 $AllCategory = $wpdb->get_results($FindCategorySQL, OBJECT); ?>
950
951 <style type="text/css"> .mycss { font-weight:bold; } </style>
952 <strong><?php _e('Select Service:', 'appointzilla'); ?></strong><br>
953 <select name="servicelist" id="servicelist" style="width:100%">
954 <option value="0"><?php _e('Select Service', 'appointzilla'); ?></option>
955 <?php $cal_admin_currency_id = get_option('cal_admin_currency');
956 if($cal_admin_currency_id) {
957 $CurrencyTableName = $wpdb->prefix . "ap_currency";
958 $cal_admin_currency = $wpdb->get_row("SELECT `symbol` FROM `$CurrencyTableName` WHERE `id` = '$cal_admin_currency_id'");
959 $cal_admin_currency = $cal_admin_currency->symbol;
960 } else {
961 $cal_admin_currency = "$";
962 }
963
964 if($AllCalendarSettings['show_service_cost'] == 'yes') $ShowCost = 1; else $ShowCost = 0;
965 if($AllCalendarSettings['show_service_duration'] == 'yes') $ShowDuration = 1; else $ShowDuration = 0;
966 $ServiceTable = $wpdb->prefix."ap_services";
967 foreach($AllCategory as $Category) {
968 echo "<option value='$Category->id' disabled class='mycss'>".ucwords($Category->name)."</option>";
969 $FindServiceSQL = "SELECT * FROM `$ServiceTable` WHERE `availability` = 'yes' and `category_id` = '$Category->id' order by `name` ASC";
970 $AllService = $wpdb->get_results($FindServiceSQL, OBJECT);
971 if(count($AllService)) {
972 foreach($AllService as $Service) { ?>
973 <option value="<?php echo $Service->id; ?>">
974 <?php echo ucwords($Service->name);
975 if($ShowDuration || $ShowCost) echo " (";
976 if($ShowDuration) { echo $Service->duration."min"; } if($ShowDuration && $ShowCost) echo "/";
977 if($ShowCost) { echo $cal_admin_currency. $Service->cost; }
978 if($ShowDuration || $ShowCost) echo ")"; ?>
979 </option><?php
980 }
981 } else {
982 echo "<option disabled> ".ucwords(__('No service in this category', 'appointzilla'))."</option>";
983 }
984 } ?>
985 </select>
986 <br>
987 <script type="text/javascript">
988 //load staff according to service - start
989 jQuery('#servicelist').change(function(){
990
991 var ServiceId = jQuery("select#servicelist").val();
992 if(ServiceId > 0) {
993 jQuery('#loading-staff').show();
994 jQuery('#staff').hide();
995 var FirstData = "ServiceId=" + ServiceId;
996 jQuery.ajax({
997 dataType : 'html',
998 type: 'GET',
999 url : location.href,
1000 data : FirstData,
1001 complete : function() { },
1002 success: function(data) {
1003 data=jQuery(data).find('div#stfflistdiv');
1004 jQuery('#staff').show();
1005 jQuery('#loading-staff').hide();
1006 jQuery('#staff').html(data);
1007 }
1008 });
1009 } else {
1010 jQuery('#staff').hide();
1011 }
1012 });
1013 </script>
1014 <div id="loading-staff" style="display:none;"><?php _e('Loading Staff...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" /></div>
1015 <div id="staff"></div>
1016 </div><!--#secdiv-->
1017 </div><!--#modal-body-->
1018 </form>
1019 </div>
1020 </div>
1021 <!---AppSecondModal For Schedule New Appointment--->
1022
1023 <!---AppSecondModal For Schedule New Appointment--->
1024 <div id="AppSecondModal" style="display:none;"></div>
1025 <!---AppSecondModal For Schedule New Appointment End--->
1026
1027 <!---AppThirdModal For Schedule New Appointment--->
1028 <div id="AppThirdModal" style="display:none;"></div>
1029 <!---AppThirdModal For Schedule New Appointment End--->
1030 <div id="AppForthModalFinal" style="display:none;">
1031
1032 </div>
1033 <!---AppThirdModal For Schedule New Appointment End--->
1034
1035 <!--date-picker js -->
1036 <script src="<?php echo plugins_url('/menu-pages/datepicker-assets/js/jquery.ui.datepicker.js', __FILE__); ?>" type="text/javascript"></script>
1037
1038 <!---Loading staff ajax return code--->
1039 <?php if(isset($_GET['ServiceId'])) { ?>
1040 <!---load bootstrap css--->
1041 <link rel='stylesheet' type='text/css' href='<?php echo plugins_url('/bootstrap-assets/css/bootstrap.css', __FILE__); ?>' />
1042 <div id="stfflistdiv">
1043 <?php
1044 $ServiceID = $_GET['ServiceId'];
1045 if($ServiceID) {
1046 $ServiceTable = $wpdb->prefix . "ap_services";
1047 $StaffTable = $wpdb->prefix . "ap_staff";
1048 $AllStaffIdList = $wpdb->get_row("SELECT `staff_id` FROM `$ServiceTable` WHERE `id` = '$ServiceID'", OBJECT);
1049 $AllStaffIdList = unserialize($AllStaffIdList->staff_id);
1050 if(count($AllStaffIdList) > 1) {
1051 ?>
1052 <strong><?php _e('Select Staff:', 'appointzilla'); ?></strong><br>
1053 <select name='stafflist' id='stafflist' style="width:100%">
1054 <?php //get all staff id list by service id
1055
1056 if(count($AllStaffIdList)) {
1057 foreach($AllStaffIdList as $StaffId) {
1058 $StaffDetails = $wpdb->get_row("SELECT `id`, `name` FROM `$StaffTable` WHERE `id` = '$StaffId'", OBJECT);
1059 echo "<option value='".$StaffDetails->id."'> ".ucwords($StaffDetails->name)."</option>";
1060 }
1061 } else {
1062 echo "<option value='1'>".__("No Staff Assigned")."</option>";
1063 }
1064 ?>
1065 </select>
1066 <br>
1067 <?php
1068 } else { // end of count > 1
1069 if(count($AllStaffIdList)) {
1070 foreach($AllStaffIdList as $StaffId) {
1071 $StaffDetails = $wpdb->get_row("SELECT `id`, `name` FROM `$StaffTable` WHERE `id` = '$StaffId'", OBJECT);
1072 echo "<input type='hidden' name='stafflist' id='stafflist' value='$StaffDetails->id'>";
1073 }
1074 }
1075 } // end of count > 1 else
1076 ?>
1077 <button type="button" class="apcal_btn" id="next1" name="next1" onclick="LoadSecondModal()"><?php _e('Next', 'appointzilla'); ?> <i class="icon-arrow-right"></i></button>
1078 <div id="loading1" style="display:none;"><?php _e('Loading...', 'appointzilla'); ?><img src="<?php echo plugins_url("images/loading.gif", __FILE__); ?>" /></div>
1079 <?php } //end of service id if ?>
1080 </div><?php
1081 } ?>
1082
1083
1084 <!---loading second modal form ajax return code--->
1085 <?php require_once('shortcode-time-slot-calculation.php'); ?>
1086 <!---loading second modal form ajax return code--->
1087
1088
1089 <!---loading third modal form ajax return code--->
1090 <?php
1091 if( isset($_GET['StartTime']) && isset($_GET['StaffId']) ) { ?>
1092 <div id="AppThirdModalData">
1093 <div class="apcal_modal" id="AppThirdModal" style="z-index:10000;">
1094 <input name="ServiceId" id="ServiceId" type="hidden" value="<?php if(isset($_GET['ServiceId'])) { echo $_GET['ServiceId']; } ?>" />
1095 <input name="StaffId" id="StaffId" type="hidden" value="<?php if(isset($_GET['StaffId'])) { echo $_GET['StaffId']; } ?>" />
1096 <input name="AppDate" id="AppDate" type="hidden" value="<?php if(isset($_GET['AppDate'])) { echo $_GET['AppDate']; } ?>" />
1097 <input name="StartTime" id="StartTime" type="hidden" value="<?php if(isset($_GET['StartTime'])) { echo $_GET['StartTime']; } ?>" />
1098 <input name="EndTime" id="EndTime" type="hidden" value="<?php if(isset($_GET['EndTime'])) { echo $_GET['EndTime']; } ?>" />
1099 <input name="RecurringType" id="RecurringType" type="hidden" value="<?php if(isset($_GET['RecurringType'])) { echo $_GET['RecurringType']; } ?>" />
1100 <input name="RecurringStartDate" id="RecurringStartDate" type="hidden" value="<?php if(isset($_GET['recurring_start_date'])) { echo $_GET['recurring_start_date']; } ?>" />
1101 <input name="RecurringEndDate" id="RecurringEndDate" type="hidden" value="<?php if(isset($_GET['recurring_end_date'])) { echo $_GET['recurring_end_date']; } ?>" />
1102
1103 <div class="apcal_modal-info">
1104 <a href="" onclick="CloseModelform()" style="float:right; margin-right:40px; margin-top:21px;" id="close" ><i class="icon-remove"></i></a>
1105 <div class="apcal_alert apcal_alert-info">
1106 <p><strong><?php _e('Schedule New Appointment', 'appointzilla'); ?></strong></p>
1107 <?php _e('Step 3. Complete Your Booking', 'appointzilla'); ?>
1108 </div>
1109 </div>
1110
1111 <div class="apcal_modal-body">
1112 <?php if($AllCalendarSettings['apcal_user_registration'] == "yes") { ?>
1113 <!--check user div-->
1114 <div id="check-user">
1115 <table width="100%" class="table">
1116 <tr>
1117 <td colspan="3">
1118 <button id="new-user" name="new-user" class="apcal_btn apcal_btn-info" onclick="return NewUserBtn();"><i class="fa fa-user"></i> <?php _e("New User", "appointzilla"); ?></button>
1119 <button id="existing-user" name="existing-user" class="apcal_btn apcal_btn-info" onclick="return ExistingUserBtn();"><i class="fa fa-sign-in"></i> <?php _e("Existing User", "appointzilla"); ?></button>
1120 <button type="button" class="apcal_btn" id="back2" name="back2" onclick="LoadSecondModal2()" style="float: right;"><i class="icon-arrow-left"></i> <?php _e('Back', 'appointzilla'); ?></button>
1121 </td>
1122 </tr>
1123 </table>
1124 </div>
1125
1126 <!--new user div-->
1127 <div id="new-user-div" style="display: none;">
1128 <table width="100%" class="table">
1129 <tr>
1130 <th scope="row"><?php _e('Username', 'appointzilla'); ?></th>
1131 <td><strong>:</strong></td>
1132 <td><input name="client-username" type="text" id="client-username" style="height:30px;" /></td>
1133 </tr>
1134 <tr>
1135 <th scope="row"><?php _e('Password', 'appointzilla'); ?></th>
1136 <td><strong>:</strong></td>
1137 <td><input name="client-password" type="password" id="client-password" style="height:30px;" /></td>
1138 </tr>
1139 <tr>
1140 <th scope="row"><?php _e('Confirm Password', 'appointzilla'); ?></th>
1141 <td><strong>:</strong></td>
1142 <td><input name="client-confirm-password" type="password" id="client-confirm-password" style="height:30px;" /></td>
1143 </tr>
1144 <tr>
1145 <th scope="row"><?php _e('Email', 'appointzilla'); ?></th>
1146 <td><strong>:</strong></td>
1147 <td><input name="client-email" type="text" id="client-email" style="height:30px;" /></td>
1148 </tr>
1149 <tr>
1150 <th scope="row"><?php _e('First Name', 'appointzilla'); ?></th>
1151 <td><strong>:</strong></td>
1152 <td><input name="client-first-name" type="text" id="client-first-name" style="height:30px;" /></td>
1153 </tr>
1154 <tr>
1155 <th scope="row"><?php _e('Last Name', 'appointzilla'); ?></th>
1156 <td><strong>:</strong></td>
1157 <td><input name="client-last-name" type="text" id="client-last-name" style="height:30px;" /></td>
1158 </tr>
1159 <tr>
1160 <th scope="row"><?php _e('Phone', 'appointzilla'); ?></th>
1161 <td><strong>:</strong></td>
1162 <td><input name="client-phone" type="text" id="client-phone" style="height:30px;" maxlength="14"/></td>
1163 </tr>
1164 <tr>
1165 <th scope="row"><?php _e('Special Instruction', 'appointzilla'); ?></th>
1166 <td><strong>:</strong></td>
1167 <td><textarea name="client-si" id="client-si"></textarea></td>
1168 </tr>
1169 <tr>
1170 <td> </td>
1171 <td> </td>
1172 <td>
1173 <div id="new-user-form-btn-div">
1174 <button type="button" class="apcal_btn apcal_btn-success" id="book-now" name="book-now" onclick="return CheckValidation('NewUser')"><i class="icon-ok icon-white"></i> <?php _e('Book Now', 'appointzilla'); ?></button>
1175 </div>
1176 <div id="new-user-form-loading-img" style="display:none;"><?php _e('Scheduling appointment, please wait...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" /></div>
1177 </td>
1178 </tr>
1179 </table>
1180 </div>
1181
1182 <!--existing user div-->
1183 <div id="existing-user-div" style="display: none;">
1184
1185 <!--div for display existing user search details-->
1186 <div id="check-email-div-form" style="display: none;">
1187 <table width="100%" class="table">
1188 <tr>
1189 <th scope="row"><?php _e('Email', 'appointzilla'); ?></th>
1190 <td><strong>:</strong></td>
1191 <td><input name="check-client-email" type="text" id="check-client-email" style="height:30px;" /></td>
1192 </tr>
1193 <tr>
1194 <td> </td>
1195 <td> </td>
1196 <td>
1197 <div id="existing-user-form-btn">
1198 <button type="button" class="apcal_btn apcal_btn-success" id="check-existing-user" name="check-existing-user" onclick="return CheckExistingUser();"><i class="icon-search icon-white"></i> <?php _e('Search Email', 'appointzilla'); ?></button>
1199 </div>
1200 <div id="existing-user-loading-img" style="display:none;"><?php _e('Searching, please wait...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" /></div>
1201 </td>
1202 </tr>
1203 </table>
1204 </div>
1205
1206 <!--div for display existing user search details-->
1207 <div id="check-email-result-div" style="display: none;">
1208
1209 </div>
1210 </div>
1211 <?php } else { // end of if registration enable ?>
1212 <!--user registration not enable-->
1213 <div id="no-user-registration">
1214 <table width="100%" class="table">
1215 <tr>
1216 <th scope="row"><?php _e('Email', 'appointzilla'); ?></th>
1217 <td><strong>:</strong></td>
1218 <td><input name="client-email" type="text" id="client-email" style="height:30px;" /></td>
1219 </tr>
1220 <tr>
1221 <th scope="row"><?php _e('First Name', 'appointzilla'); ?></th>
1222 <td><strong>:</strong></td>
1223 <td><input name="client-first-name" type="text" id="client-first-name" style="height:30px;" /></td>
1224 </tr>
1225 <tr>
1226 <th scope="row"><?php _e('Last Name', 'appointzilla'); ?></th>
1227 <td><strong>:</strong></td>
1228 <td><input name="client-last-name" type="text" id="client-last-name" style="height:30px;" /></td>
1229 </tr>
1230 <tr>
1231 <th scope="row"><?php _e('Phone', 'appointzilla'); ?></th>
1232 <td><strong>:</strong></td>
1233 <td><input name="client-phone" type="text" id="client-phone" style="height:30px;" maxlength="14"/></td>
1234 </tr>
1235 <tr>
1236 <th scope="row"><?php _e('Special Instruction', 'appointzilla'); ?></th>
1237 <td><strong>:</strong></td>
1238 <td><textarea name="client-si" id="client-si"></textarea></td>
1239 </tr>
1240 <tr>
1241 <td> </td>
1242 <td> </td>
1243 <td>
1244 <div id="new-user-form-btn-div">
1245 <button type="button" class="apcal_btn" id="back2" name="back2" onclick="LoadSecondModal2()"><i class="icon-arrow-left"></i> <?php _e('Back', 'appointzilla'); ?></button>
1246 <button type="button" class="apcal_btn apcal_btn-success" id="book-now" name="book-now" onclick="return CheckValidation('NewUser')"><i class="icon-ok icon-white"></i> <?php _e('Book Now', 'appointzilla'); ?></button>
1247 </div>
1248 <div id="new-user-form-loading-img" style="display:none;"><?php _e('Scheduling appointment, please wait...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" /></div>
1249 </td>
1250 </tr>
1251 </table>
1252 </div>
1253 <?php } ?>
1254 </div><!--end modal-body-->
1255 </div>
1256 </div><?php
1257 } ?>
1258
1259 <!---saving appointments--->
1260 <?php if( isset($_POST['Action'])) {
1261 $Action = $_POST['Action'];
1262 $UserType = $_POST['UserType'];
1263 if($Action == "BookAppointment") {
1264 //print_r($_POST); die;
1265 $ServiceId = $_POST['ServiceId'];
1266 $StaffId = $_POST['StaffId'];
1267 $AppDateNo = $_POST['AppDate'];
1268
1269 $ClientEmail = $_POST['ClientEmail'];
1270 $ClientFirstName = sanitize_text_field($_POST['ClientFirstName']);
1271 $ClientLastName = sanitize_text_field($_POST['ClientLastName']);
1272 $ClientName = $ClientFirstName ." ". $ClientLastName;
1273 $ClientPhone = $_POST['ClientPhone'];
1274 $ClientNote = $_POST['ClientNote'];
1275 $AppointmentKey = md5(date("F j, Y, g:i a"));
1276 $AppDate = date("Y-m-d", strtotime($AppDateNo));
1277 $StartTime = $_POST['StartTime'];
1278
1279 //check user registration yes/no
1280 if($AllCalendarSettings['apcal_user_registration'] == "yes"){
1281 if($UserType == "NewUser") {
1282 $ClientUserName = $_POST['ClientUserName'];
1283 $ClientPassword = $_POST['ClientPassword'];
1284
1285 //create new user profile as subscriber
1286 $UserId = username_exists( $ClientUserName );
1287 if ( !$UserId and email_exists($ClientEmail) == false ) {
1288 $UserId = wp_create_user( $ClientUserName, $ClientPassword, $ClientEmail );
1289 if($UserId) {
1290 update_user_meta( $UserId, 'first_name', $_POST['ClientFirstName']);
1291 update_user_meta( $UserId, 'last_name', $_POST['ClientLastName']);
1292 add_user_meta( $UserId, 'client_phone', $ClientPhone);
1293 add_user_meta( $UserId, 'client_note', $ClientNote);
1294 }
1295 } else {
1296 _e("User already exists", "appointzilla");
1297 }
1298 }
1299
1300 if($UserType == "ExUser") {
1301 //update existing user profile as subscriber
1302 $UserId = email_exists($ClientEmail);
1303 if($UserId) {
1304 update_user_meta( $UserId, 'first_name', $ClientFirstName);
1305 update_user_meta( $UserId, 'last_name', $ClientLastName);
1306 update_user_meta( $UserId, 'client_phone', $ClientPhone);
1307 update_user_meta( $UserId, 'client_note', $ClientNote);
1308 } else {
1309 _e("User already exists", "appointzilla");
1310 }
1311 }
1312 } // end of check user registration
1313
1314 //fetch service detail calculation EndTime and Service name
1315 $ServiceTableName = $wpdb->prefix . "ap_services";
1316 $ServiceName = $wpdb->get_row("SELECT * FROM `$ServiceTableName` WHERE `id` = '$ServiceId' ");
1317 $ServiceDuration = $ServiceName->duration;
1318
1319 $StartTimeTimestamp = strtotime($StartTime);
1320 //calculate end time according to service duration
1321 $CalculateTime = strtotime("+$ServiceDuration minutes", $StartTimeTimestamp);
1322 $EndTime = date('h:i A', $CalculateTime );
1323
1324 if(isset($AllCalendarSettings['apcal_new_appointment_status'])) {
1325 $Status = $AllCalendarSettings['apcal_new_appointment_status'];
1326 } else {
1327 $Status = "pending";
1328 }
1329 $AppointmentBy = "user";
1330 $Recurring = "no";
1331 $RecurringType = "none";
1332 $RecurringStartDate = $AppDate;
1333 $RecurringEndDate = $AppDate;
1334 $PaymentStatus = "unpaid";
1335
1336 global $wpdb;
1337 $AppointmentsTable = $wpdb->prefix ."ap_appointments";
1338 $CreateAppointments = "INSERT INTO `$AppointmentsTable` (`id` ,`name` ,`email` ,`service_id` ,`staff_id` ,`phone` ,`start_time` ,`end_time` ,`date` ,`note` , `appointment_key` ,`status` ,`recurring` ,`recurring_type` ,`recurring_st_date` ,`recurring_ed_date` ,`appointment_by`, `payment_status`) VALUES ('NULL', '$ClientName', '$ClientEmail', '$ServiceId', '$StaffId', '$ClientPhone', '$StartTime', '$EndTime', '$AppDate', '$ClientNote', '$AppointmentKey', '$Status', '$Recurring', '$RecurringType', '$RecurringStartDate', '$RecurringEndDate', '$AppointmentBy', '$PaymentStatus');";
1339 if($wpdb->query($CreateAppointments)) {
1340 $LastAppointmentId = $wpdb->insert_id;; ?>
1341 <div id="AppForthModalData">
1342 <?php global $wpdb;
1343 $ClientTable = $wpdb->prefix."ap_clients";
1344 $ExistClientDetails = $wpdb->get_row("SELECT * FROM `$ClientTable` WHERE `email` = '$ClientEmail' ");
1345 if(count($ExistClientDetails)) {
1346 // update exiting client deatils
1347 $ExistClientId = $ExistClientDetails->id;
1348 $update_client = "UPDATE `$ClientTable` SET `name` = '$ClientName', `email` = '$ClientEmail', `phone` = '$ClientPhone', `note` = '$ClientNote' WHERE `id` = '$ExistClientId' ;";
1349 if($wpdb->query($update_client)) {
1350 $LastClientId = $ExistClientId;
1351 } else {
1352 // if now data filed modified then
1353 $LastClientId = $ExistClientId;
1354 }
1355 } else {
1356 // insert new client deatils
1357 $InsertClient = "INSERT INTO `$ClientTable` (`id` ,`name` ,`email` ,`phone` ,`note`) VALUES ('NULL', '$ClientName', '$ClientEmail', '$ClientPhone', '$ClientNote');";
1358 if($wpdb->query($InsertClient)) {
1359 //$LastClientId = mysql_insert_id();
1360 $LastClientId = $wpdb->insert_id;
1361
1362 }
1363 } ?>
1364
1365 <div class="apcal_modal" id="AppForthModal" style="z-index:10000;">
1366 <div class="apcal_modal-info">
1367 <div style="float:right; margin-top:5px; margin-right:10px;"></div>
1368 <div class="apcal_alert apcal_alert-info">
1369 <p><?php _e('Thank You. Your appointment has been scheduled.', 'appointzilla'); ?></p>
1370 </div><!--end modal-info-->
1371
1372 <div class="apcal_modal-body">
1373 <style>
1374 .table th, .table td {
1375 padding: 4px;;
1376 }
1377 </style>
1378 <strong><?php _e('Your Appointment Details', 'appointzilla'); ?></strong>
1379 <input type="hidden" id="appid" name="appid" value="<?php echo $LastAppointmentId; ?>" />
1380 <table width="100%" class="table">
1381 <tr>
1382 <th width="26%" scope="row"><?php _e('Name', 'appointzilla'); ?></th>
1383 <td width="1%"><strong>:</strong></td>
1384 <td width="73%"><?php echo ucwords($ClientName); ?></td>
1385 </tr>
1386 <tr>
1387 <th width="26%" scope="row"><?php _e('Email', 'appointzilla'); ?></th>
1388 <td width="1%"><strong>:</strong></td>
1389 <td width="73%"><?php echo $ClientEmail; ?></td>
1390 </tr>
1391 <tr>
1392 <th width="26%" scope="row"><?php _e('Phone', 'appointzilla'); ?></th>
1393 <td width="1%"><strong>:</strong></td>
1394 <td width="73%"><?php echo $ClientPhone; ?></td>
1395 </tr>
1396 <tr>
1397 <th width="26%" scope="row"><?php _e('Service', 'appointzilla'); ?></th>
1398 <td width="1%"><strong>:</strong></td>
1399 <td width="73%"><?php echo ucwords($ServiceName->name); ?></td>
1400 </tr>
1401 <tr>
1402 <th width="26%" scope="row"><?php _e('Staff', 'appointzilla'); ?></th>
1403 <td width="1%"><strong>:</strong></td>
1404 <td width="73%">
1405 <?php $StaffTableName = $wpdb->prefix . "ap_staff";
1406 $StaffName = $wpdb->get_row("SELECT `name` FROM `$StaffTableName` WHERE `id` = '$StaffId' ");
1407 echo ucwords($StaffName->name); ?>
1408 </td>
1409 </tr>
1410 <tr>
1411 <th width="26%" scope="row"><?php _e('Date', 'appointzilla'); ?></th>
1412 <td width="1%"><strong>:</strong></td>
1413 <td width="73%"><?php echo date($DateFormat, strtotime($AppDate)); ?></td>
1414 </tr>
1415 <tr>
1416 <?php if($TimeFormat == "h:i") $InfoTimeFormat = "h:i A"; else $InfoTimeFormat = "H:i"; ?>
1417 <th width="26%" scope="row"><?php _e('Time', 'appointzilla'); ?></th>
1418 <td width="1%"><strong>:</strong></td>
1419 <td width="73%"><?php echo date($InfoTimeFormat, strtotime($StartTime))." - ".date($InfoTimeFormat, strtotime($EndTime)); ?></td>
1420 </tr>
1421 <tr>
1422 <th width="26%" scope="row"><?php _e('Status', 'appointzilla'); ?></th>
1423 <td width="1%"><strong>:</strong></td>
1424 <td width="73%"><?php echo _e(ucfirst($Status),'appointzilla'); ?></td>
1425 </tr>
1426 <?php
1427 //get service details for payment purpose & also check payment settings
1428 global $wpdb;
1429 $ServiceTableName = $wpdb->prefix . 'ap_services';
1430 $ServiceDetails = $wpdb->get_row("SELECT * FROM `$ServiceTableName` WHERE `id` = '$ServiceId'");
1431 $AcceptPayment = $ServiceDetails->accept_payment;
1432 $PaymentType = $ServiceDetails->payment_type;
1433 $ap_payment_email = get_option('ap_payment_email');
1434 $ap_payment_gateway_status = get_option('ap_payment_gateway_status');
1435 if($AcceptPayment == "yes" && $PaymentType == "full" && $ap_payment_email && $ap_payment_gateway_status == "yes") {
1436 ?>
1437 <tr>
1438 <th width="26%" scope="row"><?php _e('Coupon Code', 'appointzilla'); ?></th>
1439 <td width="1%"><strong>:</strong></td>
1440 <td width="73%">
1441 <div id="apply-coupon-div">
1442 <input type="text" id="coupon-code" name="coupon-code" maxlength="15" style="width: 120px;">
1443 <button id="apply-coupon" name="apply-coupon" class="apcal_btn apcal_btn-small apcal_btn-info" onclick="return ApplyCoupon();" style="margin-top: -10px;"><i class="icon-tags icon-white"></i> <?php _e('Apply', 'appointzilla'); ?></button>
1444 </div>
1445
1446 <div id="loading-img" style="display:none;"><?php _e('Applying...', 'appointzilla'); ?><img src="<?php echo plugins_url("images/loading.gif", __FILE__); ?>" /></div>
1447 <div id="show-coupon-result" style="display:none;"></div>
1448 </td>
1449 </tr>
1450 <?php } ?>
1451 <tr>
1452 <td colspan="3">
1453 <?php $Check1 = 0; $Check2 = 0; $Check3 = 0;
1454 /**
1455 * Paypal Payment Process
1456 **/
1457 //get service details for payment purpose
1458 global $wpdb;
1459 $ServiceTableName = $wpdb->prefix . 'ap_services';
1460 $ServiceDetails = $wpdb->get_row("SELECT * FROM `$ServiceTableName` WHERE `id` = '$ServiceId'");
1461
1462 //get currency code
1463 $CurrencyId = get_option('cal_admin_currency');
1464 if($CurrencyId != '') {
1465 $CurrencyTableName = $wpdb->prefix."ap_currency";
1466 $CurrencyDetails = $wpdb->get_row("SELECT `code` FROM `$CurrencyTableName` WHERE `id` = '$CurrencyId'");
1467 $CurrencyCode = $CurrencyDetails->code;
1468 } else {
1469 $CurrencyCode = 'USD';
1470 }
1471
1472 $Protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';
1473 $SuccessCurrentUrl = $Protocol.$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
1474 $FailedCurrentUrl = $SuccessCurrentUrl."?&failed=failed&appointId=".$LastAppointmentId;
1475
1476 //check payment is 'yes'
1477 if($ap_payment_gateway_status == 'yes') {
1478
1479 //check service is paid
1480 if($ServiceDetails->accept_payment == 'yes') {
1481 //check payment type
1482 if($ServiceDetails->payment_type == 'percentage') {
1483 $PayCost = $ServiceDetails->cost;
1484 $percentage = $ServiceDetails->percentage_ammount;
1485 $PayCost = ($PayCost * $percentage) /100;
1486 } else {
1487 $PayCost = $ServiceDetails->cost;
1488 }
1489
1490 $ApPaymentEmail = get_option('ap_payment_email');
1491 if($ApPaymentEmail) {
1492 // default discount value
1493 $DiscountRate = 0;
1494
1495 // Include the paypal library
1496 require_once ('menu-pages/paypal-api/Scientechpaypal.php');
1497 $ScientechPaypal = new Scientechpaypal();
1498 $ScientechPaypal->TakePayment($ApPaymentEmail, $CurrencyCode, $SuccessCurrentUrl, $FailedCurrentUrl, $ServiceDetails->name, $PayCost, $LastAppointmentId, $DiscountRate);
1499 } else {
1500 $Check3 = 1;
1501 }
1502 } else {
1503 $Check2 = 1;
1504 }
1505 } else {
1506 $Check1 = 1;
1507 }
1508
1509 // send notification if any of check == 1
1510 if($Check1 || $Check2 || $Check3) { ?>
1511 <button type="submit" class="apcal_btn apcal_btn" onclick="CloseModelform()" style="margin-left:80%"><i class="icon-ok"></i> <?php _e('Done', 'appointzilla'); ?></button>
1512 <?php $BlogName = get_bloginfo('name');
1513 if($LastAppointmentId && $LastClientId) {
1514 $AppId = $LastAppointmentId;
1515 $ServiceId = $ServiceId;
1516 $StaffId = $StaffId;
1517 $ClientId = $LastClientId;
1518 //include notification class
1519 require_once('menu-pages/notification-class.php');
1520 $Notification = new Notification();
1521 $Notification->notifyadmin($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
1522 $Notification->notifyclient($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
1523 if(get_option('staff_notification_status') == 'on') {
1524 $Notification->notifystaff($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
1525 }
1526 }
1527 }
1528
1529 //if status is approved then sync appointment
1530 if($Status == 'approved') {
1531
1532 //add service name with event title($name)
1533 //$ServiceTable = $wpdb->prefix . "ap_services";
1534 //$ServiceData = $wpdb->get_row("SELECT * FROM `$ServiceTable` WHERE `id` = '$ServiceId'");
1535 //$name = $name."(".$ServiceData->name.")";
1536
1537 /***
1538 * admin appointment sync
1539 */
1540 $CalData = get_option('google_caelndar_settings_details');
1541 if($CalData['google_calendar_client_id'] != '' && $CalData['google_calendar_secret_key'] != '') {
1542 $StartTime = date("H:i", strtotime($StartTime));
1543 $EndTime = date("H:i", strtotime($EndTime));
1544 $AppDate = date("Y-m-d", strtotime($AppDate));
1545 $ClientNote = strip_tags($ClientNote);
1546
1547 $ClientId = $CalData['google_calendar_client_id'];
1548 $ClientSecretId = $CalData['google_calendar_secret_key'];
1549 $RedirectUri = $CalData['google_calendar_redirect_uri'];
1550 require_once('menu-pages/google-appointment-sync-class.php');
1551
1552 //global $wpdb;
1553 $AppointmentSyncTableName = $wpdb->prefix . "ap_appointment_sync";
1554 // insert this appointment event on calendar
1555 $GoogleAppointmentSync = new GoogleAppointmentSync($ClientId, $ClientSecretId, $RedirectUri);
1556 $tag = "Appointment with: ";
1557 $OAuth = $GoogleAppointmentSync->NormalSync($ClientName, $AppDate, $StartTime, $EndTime, $ClientNote, $tag);
1558 //insert appintment sync details
1559 $OAuth = serialize($OAuth);
1560 $wpdb->query("INSERT INTO `$AppointmentSyncTableName` ( `id` , `app_id` , `app_sync_details` ) VALUES ( NULL , '$AppId', '$OAuth' )");
1561 } // end of google calendar setting
1562
1563 /***
1564 * staff appointment sync
1565 */
1566 $StaffAppointmentSyncSettings = unserialize(get_option("staff_google_calendar_sync_settings_".$StaffId));
1567 if($StaffAppointmentSyncSettings['StaffGoogleCalendarClientId'] != "" && $StaffAppointmentSyncSettings['StaffGoogleCalendarSecret']) {
1568 $StaffGoogleEmail = $StaffAppointmentSyncSettings['StaffGoogleEmail'];
1569 $StaffGoogleCalendarClientId = $StaffAppointmentSyncSettings['StaffGoogleCalendarClientId'];
1570 $StaffGoogleCalendarSecret = $StaffAppointmentSyncSettings['StaffGoogleCalendarSecret'];
1571 $StaffGoogleCalendarRedirectUris = $StaffAppointmentSyncSettings['StaffGoogleCalendarRedirectUris'];
1572 require_once('menu-pages/google-staff-appointment-sync-class.php');
1573
1574 // add this staff appointment event on his google calendar
1575 $StaffGoogleAppointmentSync = new StaffGoogleAppointmentSync($StaffGoogleCalendarClientId, $StaffGoogleCalendarSecret, $StaffGoogleCalendarRedirectUris);
1576 $Tag = __("Appointment with: ", "appointzilla");
1577 $StaffOAuth = $StaffGoogleAppointmentSync->NormalStaffAppointmentSync($StaffId, $ClientName, $AppDate, $StartTime, $EndTime, $ClientNote, $Tag);
1578
1579 //insert staff appointment sync details
1580 global $wpdb;
1581 $StaffAppointmentSyncTable = $wpdb->prefix . "ap_staff_appointment_sync";
1582 $StaffOAuth = serialize($StaffOAuth);
1583 $wpdb->query("INSERT INTO `$StaffAppointmentSyncTable` ( `id` , `app_id` , `staff_sync_details` ) VALUES ( NULL , '$AppId', '$StaffOAuth' )");
1584 }//end of staff appointment sync
1585
1586 //unset payment post variables
1587 //unset($_POST['address_status']); unset($_POST['payer_id']);
1588
1589 } // end of sync appointment is approved
1590 ?>
1591 <div id="ex-pay-canceling-img" style="display:none;"><?php _e('Refreshing, Please wait...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" /></div>
1592 <div id="loading-staff" style="display:none;">
1593 <?php _e('Loading Staff...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" />
1594 </div>
1595 </td>
1596 </tr>
1597 </table>
1598 </div>
1599 </div>
1600 </div>
1601 <?php
1602 }//query if
1603 }
1604 }// saving appointment if
1605
1606
1607 // Payment success
1608 if( isset($_POST['address_status']) && isset($_POST['payer_id']) ) {
1609 global $wpdb;
1610 $AppointmentTableName = $wpdb->prefix . "ap_appointments";
1611 $PaymentTableName = $wpdb->prefix . 'ap_payment_transaction';
1612 $ClientTableName = $wpdb->prefix . 'ap_clients';
1613 $CouponsCodesTable = $wpdb->prefix ."apcal_pre_coupons_codes";
1614 //print_r($_POST);
1615 $PaymentDetails = serialize($_POST);
1616 $appId = $_POST['item_number'];
1617
1618 //get client id by appointment id
1619 $ClientEmail = $wpdb->get_row("SELECT `email` FROM `$AppointmentTableName` WHERE `id` = '$appId'");
1620 $FetchClientEmail = $wpdb->get_row("SELECT `id` FROM `$ClientTableName` WHERE `email` = '$ClientEmail->email'");
1621 $clientId = $FetchClientEmail->id;
1622
1623 $amount = $_POST['mc_gross'];
1624 $date = $_POST['payment_date'];
1625 $status = $_POST['address_status'];
1626 $txn_id = $_POST['txn_id'];
1627 $gateway = 'paypal';
1628
1629 $wpdb->query("INSERT INTO `$PaymentTableName` (`id`, `app_id`, `client_id`, `ammount`, `date`, `status`, `txn_id`, `gateway`, `other_fields`) VALUES (NULL, '$appId', '$clientId', '$amount', '$date', '$status', '$txn_id', '$gateway', '$PaymentDetails');");
1630 $AppointmentId = $_POST['item_number'];
1631 $AppointmentRow = $wpdb->get_row("SELECT * FROM `$AppointmentTableName` WHERE `id` = '$AppointmentId'");
1632 if(count($AppointmentRow)) {
1633 $name = $AppointmentRow->name;
1634 $ServiceId = $AppointmentRow->service_id;
1635 $StaffId = $AppointmentRow->staff_id;
1636 $StartTime = $AppointmentRow->start_time;
1637 $EndTime = $AppointmentRow->end_time;
1638 $Client_name = $AppointmentRow->name;
1639 $Client_Email = $AppointmentRow->email;
1640 $Client_Phone = $AppointmentRow->phone;
1641 $Client_Note = $AppointmentRow->note;
1642 $AppDate = $AppointmentRow->date;
1643 $Status = 'approved';
1644 $AppointmentKey = $AppointmentRow->appointment_key;
1645
1646 //update appointment status n payment status
1647 $PaymentStatus = $_POST['payment_status'];
1648 $AppointmentRow = $wpdb->query("UPDATE `$AppointmentTableName` SET `status` = '$Status', `payment_status` = 'paid' WHERE `id` = '$AppointmentId' ");
1649
1650 $BlogName = get_bloginfo();
1651 if($AppointmentId && $clientId) {
1652 $AppId = $AppointmentId;
1653 $ServiceId = $ServiceId;
1654 $StaffId = $StaffId;
1655 $ClientId = $clientId;
1656 //include notification class
1657 require_once('menu-pages/notification-class.php');
1658 $Notification = new Notification();
1659 $Notification->notifyadmin($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
1660 $Notification->notifyclient($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
1661 if(get_option('staff_notification_status') == "on") {
1662 $Notification->notifystaff($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
1663 }
1664 }
1665
1666 //if status is approved then sync appointment
1667 if($Status == 'approved') {
1668
1669 //add service name with event title($name)
1670 //$ServiceTable = $wpdb->prefix . "ap_services";
1671 //$ServiceData = $wpdb->get_row("SELECT * FROM `$ServiceTable` WHERE `id` = '$ServiceId'");
1672 //$name = $name."(".$ServiceData->name.")";
1673
1674 /**
1675 * Admin appointment google sync
1676 */
1677 $CalData = get_option('google_caelndar_settings_details');
1678 if($CalData['google_calendar_client_id'] != '' && $CalData['google_calendar_secret_key'] != '') {
1679 $start_time = date("H:i", strtotime($StartTime));
1680 $end_time = date("H:i", strtotime($EndTime));
1681 $appointmentdate = date("Y-m-d", strtotime($AppDate));
1682 $note = strip_tags($Client_Note);
1683
1684 $ClientId = $CalData['google_calendar_client_id'];
1685 $ClientSecretId = $CalData['google_calendar_secret_key'];
1686 $RedirectUri = $CalData['google_calendar_redirect_uri'];
1687 require_once('menu-pages/google-appointment-sync-class.php');
1688
1689 //global $wpdb;
1690 $AppointmentSyncTableName = $wpdb->prefix . "ap_appointment_sync";
1691 // insert this appointment event on calendar
1692 $GoogleAppointmentSync = new GoogleAppointmentSync($ClientId, $ClientSecretId, $RedirectUri);
1693 $tag = "Appointment with: ";
1694 $OAuth = $GoogleAppointmentSync->NormalSync($name, $appointmentdate, $start_time, $end_time, $note, $tag);
1695 //insert appintment sync details
1696 $OAuth = serialize($OAuth);
1697 $wpdb->query("INSERT INTO `$AppointmentSyncTableName` ( `id` , `app_id` , `app_sync_details` )
1698 VALUES ( NULL , '$AppointmentId', '$OAuth' );");
1699 } // end of google calendar setting
1700
1701 /**
1702 * Staff appointment google sync
1703 */
1704 $StaffAppointmentSyncSettings = unserialize(get_option("staff_google_calendar_sync_settings_".$StaffId));
1705 if($StaffAppointmentSyncSettings['StaffGoogleCalendarClientId'] != "" && $StaffAppointmentSyncSettings['StaffGoogleCalendarSecret']) {
1706 $StaffGoogleEmail = $StaffAppointmentSyncSettings['StaffGoogleEmail'];
1707 $StaffGoogleCalendarClientId = $StaffAppointmentSyncSettings['StaffGoogleCalendarClientId'];
1708 $StaffGoogleCalendarSecret = $StaffAppointmentSyncSettings['StaffGoogleCalendarSecret'];
1709 $StaffGoogleCalendarRedirectUris = $StaffAppointmentSyncSettings['StaffGoogleCalendarRedirectUris'];
1710 require_once('menu-pages/google-staff-appointment-sync-class.php');
1711
1712 $start_time = date("H:i", strtotime($StartTime));
1713 $end_time = date("H:i", strtotime($EndTime));
1714 $appointmentdate = date("Y-m-d", strtotime($AppDate));
1715 $note = strip_tags($Client_Note);
1716 // add this staff appointment event on his google calendar
1717 $StaffGoogleAppointmentSync = new StaffGoogleAppointmentSync($StaffGoogleCalendarClientId, $StaffGoogleCalendarSecret, $StaffGoogleCalendarRedirectUris);
1718 $Tag = __("Appointment with: ", "appointzilla");
1719 $StaffOAuth = $StaffGoogleAppointmentSync->NormalStaffAppointmentSync($StaffId, $name, $appointmentdate, $start_time, $end_time, $note, $Tag);
1720
1721 //insert staff appointment sync details
1722 global $wpdb;
1723 $StaffAppointmentSyncTable = $wpdb->prefix . "ap_staff_appointment_sync";
1724 $StaffOAuth = serialize($StaffOAuth);
1725 $wpdb->query("INSERT INTO `$StaffAppointmentSyncTable` ( `id` , `app_id` , `staff_sync_details` ) VALUES ( NULL , '$AppId', '$StaffOAuth' )");
1726 }//end of staff appointment sync
1727
1728 //unset payment post variables
1729 unset($_POST['address_status']); unset($_POST['payer_id']);
1730
1731 } // end of sync appointment is approved ?>
1732 <div class="apcal_modal" id="AppForthModal" style="z-index:10000;">
1733 <div class="apcal_modal-info">
1734 <div style="float:right; margin-top:5px; margin-right:10px;">
1735 <div align="center"><a href="" onclick="CloseModelform()" id="close" ><i class="icon-remove"></i></a></div>
1736 </div>
1737 <div class="apcal_alert apcal_alert-info">
1738 <h4 ><?php _e('Payment Successfully Processed', 'appointzilla'); ?></h4>
1739 </div>
1740 <div class="apcal_modal-body">
1741 <div class="apcal_alert apcal_alert-success">
1742 <strong><?php _e('Payment received and your appointment has been confirmed.', 'appointzilla'); ?></strong><br />
1743 <strong><?php _e('Thank you for scheduling appointment with us.', 'appointzilla'); ?></strong>
1744 <?php
1745 //if payment confirmed(done) then increment coupon used count value
1746 if($status == "confirmed") {
1747 $PaymentDetails = unserialize($PaymentDetails);
1748 if(isset($PaymentDetails['custom'])) {
1749 $CouponCode = $PaymentDetails['custom'];
1750 //check coupon exist or not
1751 $CouponsData = $wpdb->get_row("SELECT * FROM `$CouponsCodesTable` WHERE `coupon_code` LIKE '$CouponCode'");
1752 if(count($CouponsData)) {
1753 //increment total used count
1754 $CouponId = $CouponsData->id;
1755 $UsedCount = $CouponsData->used_count + 1;
1756 $wpdb->query("UPDATE `$CouponsCodesTable` SET `used_count` = '$UsedCount' WHERE `id` = '$CouponId' ");
1757 }
1758 }
1759 }
1760 ?>
1761 </div>
1762 <button type='button' onclick='CloseModelform()' name='close' id='close' value='Done' class='apcal_btn'><i class="icon-ok"></i> <?php _e('Done', 'appointzilla'); ?></button>
1763 </div>
1764 <div>
1765 </div>
1766 </div>
1767 <?php
1768 } // end of AppointmentRow
1769 } // end of Payment success
1770
1771 // Payment process failed
1772 if( isset($_GET['failed']) && isset($_GET['appointId'])) { ?>
1773 <div class="apcal_modal" id="AppForthModal" style="z-index:10000;">
1774 <div class="apcal_modal-info" style="padding-bottom:20px;">
1775 <div style="float:right; margin-top:5px; margin-right:10px;">
1776 <a href="#" onclick="CloseModelformfailed()" id="close" ><i class="icon-remove"></i></a>
1777 </div>
1778 <input type="hidden" name="appid" id="appid" value="<?php echo $_GET['appointId']; ?>" />
1779 <div class="apcal_alert apcal_alert-info">
1780 <h4><?php _e('Payment Failed', 'appointzilla'); ?></h4>
1781 </div>
1782 <div style=" margin-left:20px; padding-right:20px;">
1783 <div class="apcal_alert apcal_alert-error">
1784 <?php _e('Sorry! Appointment booking was not successful.', 'appointzilla'); ?>
1785 </div>
1786 <button type='button' onclick='return failedappointment();' name='close' id='close' value='close' class='apcal_btn'><i class="icon-repeat"></i> <?php _e('Try Again', 'appointzilla'); ?></button>
1787 </div>
1788 </div>
1789 </div><?php
1790 }
1791
1792 // cancel appointment
1793 if(isset($_POST['appid']) && isset($_POST['appstatus']) ) {
1794 $appid = $_POST['appid'];
1795 global $wpdb;
1796 $apptabname = $wpdb->prefix."ap_appointments";
1797 $wpdb->query("UPDATE `$apptabname` SET `status` = 'cancelled' WHERE `id` = '$appid' ;");
1798 }
1799
1800 //applying coupon code
1801 if(isset($_POST['Action'])) {
1802 $Action = $_POST['Action'];
1803 if($Action == "apply-coupon") {
1804 if(isset($_POST['CouponCode'])) {
1805 $CouponCode = strtolower($_POST['CouponCode']);
1806 } else {
1807 $CouponCode = "";
1808 }
1809 if($CouponCode){
1810 global $wpdb;
1811 $Discount = 0;
1812 $CouponsCodesTable = $wpdb->prefix . "apcal_pre_coupons_codes";
1813 //Search Coupon
1814 $CouponDetails = $wpdb->get_row("SELECT * FROM `$CouponsCodesTable` WHERE `coupon_code` LIKE '$CouponCode'");
1815 if(count($CouponDetails)) {
1816 //check coupon expire
1817 $DateTodayTs = strtotime(date("Y-m-d"));
1818 $ExpireDateTs = strtotime(date("Y-m-d", strtotime($CouponDetails->expire)));
1819 $TotalUses = $CouponDetails->total_uses;
1820 $UsedCount = $CouponDetails->used_count;
1821 $Discount = $CouponDetails->discount;
1822 if($DateTodayTs > $ExpireDateTs) {
1823 //coupon expired
1824 ?><div id="coupon-result"><div id="discount-rate-div" style="display: none;"><?php echo $Discount = 0; ?></div><?php echo strtoupper("<strong>$CouponCode</strong> "); _e("coupon code expired.", "appointzilla"); ?> <a id="try-another" onclick="return TryAgain();"><?php _e("Try Another", "appointzilla"); ?></a></div><?php
1825 } else if($UsedCount >= $TotalUses) {
1826 //ckeck used count
1827 ?><div id="coupon-result"><div id="discount-rate-div" style="display: none;"><?php echo $Discount = 0; ?></div><?php echo strtoupper("<strong>$CouponCode</strong> "); _e("coupon code expired.", "appointzilla"); ?> <a id="try-another" onclick="return TryAgain();"><?php _e("Try Another", "appointzilla"); ?></a></div><?php
1828 } else {
1829 //coupon valid and appied
1830 ?><div id="coupon-result">
1831 <div id="coupon-code-div" style="display: none;"><?php echo $CouponCode; ?></div>
1832 <div id="discount-rate-div" style="display: none;"><?php echo $Discount; ?></div>
1833 <?php echo strtoupper("<strong>$CouponCode</strong> "); _e("coupon code applied.", "appointzilla"); ?> <a id="try-another" onclick="return TryAgain();"><?php _e("Change", "appointzilla"); ?></a>
1834 </div><?php
1835 }
1836 } else {
1837 ?>
1838 <div id="coupon-result">
1839 <div id="discount-rate-div" style="display: none;"><?php echo $Discount; ?></div>
1840 <?php echo strtoupper("<strong>$CouponCode</strong> "); _e("coupon code is invalid.", "appointzilla"); ?>
1841 <a id="try-another" onclick="return TryAgain();"><?php _e("Try Another", "appointzilla"); ?></a>
1842 </div>
1843 <?php
1844 }
1845 }
1846 }//end of if action
1847 }
1848
1849 //check existing user
1850 if(isset($_POST['Action'])) {
1851 $Action = $_POST['Action'];
1852 if($Action == "CheckExistingUser") {
1853 ?><div id="check-email-result"><?php
1854 $ClientEmail = $_POST['ClientEmail'];
1855 $ClientId = email_exists( $ClientEmail );
1856 if( $ClientId = email_exists( $ClientEmail )) {
1857 //fetch user details
1858 $ClientDetails = get_userdata( $ClientId );
1859 //print_r($ClientDetails);
1860 $FirstName = "";
1861 $LastName = "";
1862 $Phone = "";
1863 $ClientNote = "";
1864 $UserMetaData = get_user_meta( $ClientId );
1865 if(count($UserMetaData)) {
1866 if(isset($UserMetaData['first_name'][0])) {
1867 $FirstName = ucwords($UserMetaData['first_name'][0]);
1868 }
1869 if(isset($UserMetaData['last_name'][0])) {
1870 $LastName = ucwords($UserMetaData['last_name'][0]);
1871 }
1872 if(isset($UserMetaData['client_phone'][0])) {
1873 $Phone = $UserMetaData['client_phone'][0];
1874 }
1875 if(isset($UserMetaData['client_note'][0])) {
1876 $ClientNote = ucfirst($UserMetaData['client_note'][0]);
1877 }
1878 }
1879 ?>
1880 <input type="hidden" id="client-id" name="client-id" value="<?php echo $ClientId; ?>">
1881 <table width="100%" class="table">
1882 <tr>
1883 <th scope="row"><?php _e('Email', 'appointzilla'); ?></th>
1884 <td><strong>:</strong></td>
1885 <td><input name="ex-client-email" type="text" id="ex-client-email" style="height:30px;" value="<?php echo $ClientEmail; ?>" readonly="" /></td>
1886 </tr>
1887 <tr>
1888 <th scope="row"><?php _e('First Name', 'appointzilla'); ?></th>
1889 <td><strong>:</strong></td>
1890 <td><input name="ex-client-first-name" type="text" id="ex-client-first-name" style="height:30px;" value="<?php echo $FirstName; ?>"/></td>
1891 </tr>
1892 <tr>
1893 <th scope="row"><?php _e('Last Name', 'appointzilla'); ?></th>
1894 <td><strong>:</strong></td>
1895 <td><input name="ex-client-last-name" type="text" id="ex-client-last-name" style="height:30px;" value="<?php echo $LastName; ?>" /></td>
1896 </tr>
1897 <tr>
1898 <th scope="row"><?php _e('Phone', 'appointzilla'); ?></th>
1899 <td><strong>:</strong></td>
1900 <td><input name="ex-client-phone" type="text" id="ex-client-phone" style="height:30px;" value="<?php echo $Phone; ?>" maxlength="14"/></td>
1901 </tr>
1902 <tr>
1903 <th scope="row"><?php _e('Special Instruction', 'appointzilla'); ?></th>
1904 <td><strong>:</strong></td>
1905 <td><textarea name="ex-client-si" id="ex-client-si"><?php echo $ClientNote; ?></textarea></td>
1906 </tr>
1907 <tr>
1908 <td> </td>
1909 <td> </td>
1910 <td>
1911 <div id="ex-user-form-btn-div">
1912 <button type="button" class="apcal_btn apcal_btn-success" id="ex-book-now" name="ex-book-now" onclick="return CheckValidation('ExUser');"><i class="icon-ok icon-white"></i> <?php _e('Book Now', 'appointzilla'); ?></button>
1913 <button type="button" class="apcal_btn apcal_btn-danger" id="ex-cancel-app" name="ex-cancel-app" onclick="return Canceling();"><i class="icon-remove icon-white"></i> <?php _e('Cancel', 'appointzilla'); ?></button>
1914 </div>
1915 <div id="ex-user-form-loading-img" style="display:none;"><?php _e('Scheduling appointment, please wait...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" /></div>
1916 <div id="ex-canceling-img" style="display:none;"><?php _e('Refreshing, Please wait...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" /></div>
1917 </td>
1918 </tr>
1919 </table>
1920 <?php
1921 } else { ?>
1922 <table width="100%" class="table">
1923 <tr>
1924 <td colspan="3">
1925 <?php _e("Sorry! No record found.","appointzilla"); ?>
1926 <button type="button" onclick="return TryAgainBooking();" class="apcal_btn apcal_btn-danger"><i class="fa fa-mail-reply"></i> Try Again</button>
1927 </td>
1928 </tr>
1929 </table>
1930 <?php
1931 }
1932 ?></div><?php
1933 }
1934 }
1935 /*$output_string = ob_get_contents();
1936 ob_end_clean();
1937 return $output_string;*/
1938}//end of short code function
1939?>