Guest User

Untitled

a guest
Feb 11th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 108.11 KB | None | 0 0
  1. <?php // short-code file with button and big calendar(full-calendar)
  2.  
  3. add_shortcode( 'APCAL', 'appointment_calendar_shortcode' );
  4. function 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]{ '&#8212;'[ 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'>&nbsp;<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'>&nbsp;<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'>&nbsp;<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'>&nbsp;<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'>&nbsp;<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'>&nbsp;<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'>&nbsp;<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'>&nbsp;<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'>&nbsp;<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'>&nbsp;<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'>&nbsp;<br><strong><?php _e('Invalid first name.', 'appointzilla'); ?></strong></span>");
  576. return false;
  577. }
  578.  
  579. }
  580.  
  581. //client last name
  582. if (ClientLastName == "") {
  583. jQuery("#client-last-name").after("<span class='error'>&nbsp;<br><strong><?php _e('Last name required.', 'appointzilla'); ?></strong></span>");
  584. return false;
  585. } else {
  586. var Res = isNaN(ClientLastName);
  587. if(Res == false) {
  588. jQuery("#client-last-name").after("<span class='error'>&nbsp;<br><strong><?php _e('Invalid last name.', 'appointzilla'); ?></strong></span>");
  589. return false;
  590. }
  591.  
  592. }
  593.  
  594. //client phone
  595. if (ClientPhone == "") {
  596. jQuery("#client-phone").after("<span class='error'>&nbsp;<br><strong><?php _e("Phone required. <br>Only Numbers 1234567890.", "appointzilla"); ?></strong></span>");
  597. return false;
  598. } else {
  599. var ClientPhoneRes = isNaN(ClientPhone);
  600. if(ClientPhoneRes == true) {
  601. jQuery("#client-phone").after("<span class='error'>&nbsp;<br><strong><?php _e("Invalid phone. <br>Numbers only: 1234567890.", "appointzilla"); ?></strong></span>");
  602. return false;
  603. }
  604. }
  605.  
  606. var PostData1 = "Action=BookAppointment"+ "&ServiceId=" + ServiceId + "&AppDate=" + AppDate + "&StaffId=" + StaffId + "&StartTime=" + StartTime;
  607. <?php if($AllCalendarSettings['apcal_user_registration'] == "yes"){ ?>
  608. var PostData2 = "&UserType=" + UserType + "&ClientUserName="+ ClientUserName + "&ClientPassword=" +ClientPassword + "&ClientEmail=" + ClientEmail;
  609. <?php } else { ?>
  610. var PostData2 = "&UserType=" + UserType + "&ClientEmail=" + ClientEmail;
  611. <?php } ?>
  612. var PostData3 = "&ClientFirstName=" + ClientFirstName + "&ClientLastName=" + ClientLastName + "&ClientPhone=" + ClientPhone + "&ClientNote=" + ClientSi;
  613. var PostData = PostData1 + PostData2 + PostData3;
  614.  
  615. jQuery('#new-user-form-btn-div').hide();
  616. jQuery('#new-user-form-loading-img').show();
  617. }
  618.  
  619. /**
  620. * existing user booking case
  621. */
  622. if(UserType == "ExUser") {
  623.  
  624. var ClientEmail = jQuery("#ex-client-email").val();
  625. var ClientFirstName = jQuery("#ex-client-first-name").val();
  626. var ClientLastName = jQuery("#ex-client-last-name").val();
  627. var ClientPhone = jQuery("#ex-client-phone").val();
  628. var ClientSi = jQuery("#ex-client-si").val();
  629.  
  630. //client email
  631. var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  632. if (ClientEmail == "") {
  633. jQuery("#ex-client-email").after("<span class='error'>&nbsp;<br><strong><?php _e('Email required.', 'appointzilla'); ?></strong></span>");
  634. return false;
  635. } else {
  636. if(regex.test(ClientEmail) == false ) {
  637. jQuery("#ex-client-email").after("<span class='error'>&nbsp;<br><strong><?php _e('Invalid email.', 'appointzilla'); ?></strong></span>");
  638. return false;
  639. }
  640. }
  641.  
  642. //client first name
  643. if (ClientFirstName == "") {
  644. jQuery("#ex-client-first-name").after("<span class='error'>&nbsp;<br><strong><?php _e('First name required.', 'appointzilla'); ?></strong></span>");
  645. return false;
  646. } else {
  647. var Res = isNaN(ClientFirstName);
  648. if(Res == false) {
  649. jQuery("#ex-client-first-name").after("<span class='error'>&nbsp;<br><strong><?php _e('Invalid first name.', 'appointzilla'); ?></strong></span>");
  650. return false;
  651. }
  652.  
  653. }
  654.  
  655. //client last name
  656. if (ClientLastName == "") {
  657. jQuery("#ex-client-last-name").after("<span class='error'>&nbsp;<br><strong><?php _e('Last name required.', 'appointzilla'); ?></strong></span>");
  658. return false;
  659. } else {
  660. var Res = isNaN(ClientLastName);
  661. if(Res == false) {
  662. jQuery("#ex-client-last-name").after("<span class='error'>&nbsp;<br><strong><?php _e('Invalid last name.', 'appointzilla'); ?></strong></span>");
  663. return false;
  664. }
  665.  
  666. }
  667.  
  668. //client phone
  669. if (ClientPhone == "") {
  670. jQuery("#ex-client-phone").after("<span class='error'>&nbsp;<br><strong><?php _e("Phone required. <br>Only Numbers 1234567890.", "appointzilla"); ?></strong></span>");
  671. return false;
  672. } else {
  673. var ClientPhoneRes = isNaN(ClientPhone);
  674. if(ClientPhoneRes == true) {
  675. jQuery("#ex-client-phone").after("<span class='error'>&nbsp;<br><strong><?php _e("Invalid phone. <br>Numbers only: 1234567890.", "appointzilla"); ?></strong></span>");
  676. return false;
  677. }
  678. }
  679.  
  680. var PostData1 = "Action=BookAppointment"+ "&ServiceId=" + ServiceId + "&AppDate=" + AppDate + "&StaffId=" + StaffId + "&StartTime=" + StartTime;
  681. var PostData2 = "&UserType=" + UserType + "&ClientEmail=" + ClientEmail;
  682. var PostData3 = "&ClientFirstName=" + ClientFirstName + "&ClientLastName=" + ClientLastName + "&ClientPhone=" + ClientPhone + "&ClientNote=" + ClientSi;
  683. var PostData = PostData1 + PostData2 + PostData3;
  684.  
  685. jQuery('#ex-user-form-btn-div').hide();
  686. jQuery('#ex-user-form-loading-img').show();
  687. }
  688.  
  689. jQuery.ajax({
  690. dataType : 'html',
  691. type: 'POST',
  692. url : location.href,
  693. cache: false,
  694. data : PostData,
  695. complete : function() { },
  696. success: function(data) {
  697. data = jQuery(data).find('div#AppForthModalData');
  698. jQuery("#new-user-form-loading-img").hide();
  699. jQuery("#check-email-div-form").hide();
  700. jQuery("#AppThirdModal").hide();
  701. jQuery("#AppForthModalFinal").show();
  702. jQuery("#AppForthModalFinal").html(data);
  703. }
  704. });
  705. }
  706.  
  707. //check existing user
  708. function CheckExistingUser() {
  709. jQuery(".error").hide();
  710. var ClientEmail = jQuery("#check-client-email").val();
  711. //client email
  712. var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  713. if (ClientEmail == "") {
  714. jQuery("#check-client-email").after("<span class='error'>&nbsp;<br><strong><?php _e('Email required.', 'appointzilla'); ?></strong></span>");
  715. return false;
  716. } else {
  717. if(regex.test(ClientEmail) == false ) {
  718. jQuery("#check-client-email").after("<span class='error'>&nbsp;<br><strong><?php _e('Invalid email.', 'appointzilla'); ?></strong></span>");
  719. return false;
  720. }
  721. }
  722.  
  723. var PostData = "Action=CheckExistingUser" + "&ClientEmail=" + ClientEmail;
  724. jQuery("#existing-user-form-btn").hide();
  725. jQuery("#existing-user-loading-img").show();
  726. jQuery.ajax({
  727. dataType : 'html',
  728. type: 'POST',
  729. url : location.href,
  730. cache: false,
  731. data : PostData,
  732. complete : function() { },
  733. success: function(Data) {
  734. Data = jQuery(Data).find('div#check-email-result');
  735. jQuery("#existing-user-loading-img").hide();
  736. jQuery("#check-user").hide();
  737. jQuery('#check-email-div-form').hide();
  738. jQuery("#check-email-result-div").show();
  739. jQuery("#check-email-result-div").html(Data);
  740. }
  741. });
  742. }
  743.  
  744. function CloseModelform() {
  745. jQuery("#AppForthModalFinal").hide();
  746. jQuery("#AppSecondModalData").hide();
  747. jQuery("#AppThirdModalData").hide();
  748. jQuery("#ex-pay-canceling-img").show();
  749. location.href = location.href;
  750. }
  751.  
  752. function highlightsradio(timeslotspanid) {
  753. jQuery('span').removeClass('selected');
  754. var spanid = "#" + timeslotspanid;
  755. jQuery(spanid).addClass("selected");
  756. }
  757.  
  758. // failed appointment
  759. function failedappointment() {
  760. var appid = jQuery('#appid').val();
  761. var Datastring = "appstatus=cancel" + "&appid="+ appid;
  762. jQuery.ajax({
  763. dataType : 'html',
  764. type: 'POST',
  765. url : location.href,
  766. cache: false,
  767. data : Datastring,
  768. complete : function() { },
  769. success: function(data) {
  770. jQuery('#AppForthModalFinal').hide();
  771. jQuery('#AppSecondModalData').hide();
  772. jQuery('#AppThirdModalData').hide();
  773. var CurrentUrl = location.href;
  774. CurrentUrl=CurrentUrl.replace('failed=failed&appointId='+appid, '');
  775. location.href = CurrentUrl;
  776. }
  777. });
  778. }
  779.  
  780. //cancel appointment
  781. function CancelAppointment() {
  782. var appid = jQuery('#appid').val();
  783. var DataString = "appstatus=cancel" + "&appid="+ appid;
  784. jQuery("#paybuttondiv").hide();
  785. jQuery("#pay-canceling-img").show();
  786. jQuery.ajax({
  787. dataType : 'html',
  788. type: 'POST',
  789. url : location.href,
  790. cache: false,
  791. data : DataString,
  792. complete : function() { },
  793. success: function() {
  794. jQuery('#AppForthModalFinal').hide();
  795. jQuery('#AppSecondModalData').hide();
  796. jQuery('#AppThirdModalData').hide();
  797. window.location.reload();
  798. }
  799. });
  800. }
  801.  
  802. //apply coupon code
  803. function ApplyCoupon() {
  804. var CouponCode = jQuery("#coupon-code").val();
  805. if(CouponCode == "") {
  806. alert("<?php _e("Enter any coupon code.", "appointzilla"); ?>");
  807. jQuery("#coupon-code").focus();
  808. return false;
  809. } else {
  810. var PostData = "Action=apply-coupon" + "&CouponCode=" + CouponCode;
  811. jQuery("#loading-img").show();
  812. jQuery.ajax({
  813. dataType : 'html',
  814. type: 'POST',
  815. url : location.href,
  816. cache: false,
  817. data : PostData,
  818. complete : function() { },
  819. success: function(ReturnedData) {
  820. ReturnedData = jQuery(ReturnedData).find("div#coupon-result");
  821. jQuery("#loading-img").hide();
  822. jQuery("#apply-coupon-div").hide();
  823. jQuery("#show-coupon-result").html(ReturnedData);
  824. jQuery("#show-coupon-result").show();
  825. var CouponCodeValue = jQuery("#coupon-code-div").text();
  826. var DicountRateValue = jQuery("#discount-rate-div").text();
  827. jQuery("input[name=custom]").val(CouponCodeValue);
  828. jQuery("input[name=discount_rate]").val(DicountRateValue);
  829. }
  830. });
  831. }
  832. }
  833.  
  834. //try another coupon code
  835. function TryAgain() {
  836. jQuery("#apply-coupon-div").show();
  837. jQuery("#show-coupon-result").hide();
  838. }
  839.  
  840. //try again booking
  841. function TryAgainBooking() {
  842. jQuery("#check-email-result-div").hide();
  843. jQuery("#check-user").show();
  844. jQuery('#check-email-div-form').show();
  845. jQuery("#existing-user-form-btn").show();
  846. }
  847.  
  848. //cancel appointment
  849. function Canceling() {
  850. jQuery("#ex-user-form-btn-div").hide();
  851. jQuery("#ex-canceling-img").show();
  852. location.reload();
  853. }
  854.  
  855. // on paypal pay button click
  856. function PayWithPaypal(){
  857. jQuery('#show-redirecting-msg').show();
  858. jQuery('#paybuttondiv').hide();
  859. }
  860. </script>
  861.  
  862. <!---Display Booking Instruction--->
  863. <?php if($AllCalendarSettings['apcal_booking_instructions']) { ?>
  864. <div id="bookinginstructions" align="center">
  865. <?php echo $AllCalendarSettings['apcal_booking_instructions']; ?>
  866. </div>
  867. <?php } ?>
  868.  
  869. <!---Schedule An Appointment Button--->
  870. <div id="bkbtndiv" align="center" style="padding:10px;">
  871. <button name="addappointment" class="apcal_btn apcal_btn-large apcal_btn-primary" type="submit" id="addappointment">
  872. <strong><i class="icon-calendar icon-white"></i> <?php if(isset($AllCalendarSettings['booking_button_text'])) {
  873. echo $AllCalendarSettings['booking_button_text'];
  874. } else {
  875. _e("Schedule New Appointment", 'appointzilla');
  876. } ?>
  877. </strong>
  878. </button>
  879. </button>
  880. </div>
  881.  
  882. <!---Show appointment calendar--->
  883. <div id='calendar'>
  884. <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>
  885. </div>
  886.  
  887. <!---AppFirstModal For Schedule New Appointment--->
  888. <div id="AppFirstModal" style="display:none;">
  889. <div class="apcal_modal" id="myModal" style="z-index:10000;">
  890. <form action="" method="post" name="addnewappointment" id="addnewappointment">
  891. <div class="apcal_modal-info">
  892. <div class="apcal_alert apcal_alert-info">
  893. <a href="#bookinginstructions" style="float:right; margin-right:4px; margin-top:12px;" id="close"><i class="icon-remove"></i></a>
  894. <p><strong><?php _e('Schedule New Appointment', 'appointzilla'); ?></strong></p>
  895. <div><?php _e('Step 1. Select Date & Service', 'appointzilla'); ?></div>
  896. </div>
  897. </div>
  898.  
  899. <div class="apcal_modal-body">
  900. <div id="firdiv" style="float:left; height:210px; width:260px; padding-bottom:30px;">
  901. <!--JS Datepicker -->
  902. <?php if($small_calendar_type == "jquery") { ?>
  903. <div id="datepicker"></div>
  904. <?php } ?>
  905. <!--PHP Datepicker-->
  906. <?php
  907. if($DateFormat == 'd-m-Y') $CalFormat = 'DD-MM-YYYY';
  908. if($DateFormat == 'm-d-Y') $CalFormat = 'MM-DD-YYYY';
  909. if($DateFormat == 'Y-m-d') $CalFormat = 'YYYY-MM-DD'; //coz yy-mm-dd not
  910. if($small_calendar_type == "php") {
  911. $myCalendar->writeScript();
  912. }
  913. ?>
  914. <script>
  915. function myChanged() {
  916. var x = document.getElementById('date1').value;
  917. var x2 = document.getElementById('date1').value;
  918. x = moment(x).format('<?php echo $CalFormat; ?>');
  919. x2 = moment(x2).format('DD-MM-YYYY');
  920. document.getElementById('appdate').value = x;
  921. document.getElementById('appdate2').value = x2;
  922. }
  923. </script>
  924. </div>
  925.  
  926. <div id="secdiv" style="float:right; margin-right:5%; width:40%" >
  927. <strong><?php _e('Your Appointment Date:', 'appointzilla'); ?> </strong><br>
  928. <input name="appdate" id="appdate" type="text" readonly="" style="height:30px; width:100%; padding-left: 15px;" value="<?php echo date($DateFormat, strtotime($StartDate)); ?>" /><br>
  929. <input name="appdate2" id="appdate2" type="hidden" readonly="" style="height:30px; width:100%" value="<?php echo date("Y-m-d", strtotime($StartDate)); ?>" />
  930. <?php global $wpdb;
  931. $CategoryTable = $wpdb->prefix."ap_service_category";
  932. $FindCategorySQL ="SELECT * FROM `$CategoryTable` order by `name` ASC";
  933. $AllCategory = $wpdb->get_results($FindCategorySQL, OBJECT); ?>
  934.  
  935. <style type="text/css"> .mycss { font-weight:bold; } </style>
  936. <strong><?php _e('Select Service:', 'appointzilla'); ?></strong><br>
  937. <select name="servicelist" id="servicelist" style="width:100%">
  938. <option value="0"><?php _e('Select Service', 'appointzilla'); ?></option>
  939. <?php $cal_admin_currency_id = get_option('cal_admin_currency');
  940. if($cal_admin_currency_id) {
  941. $CurrencyTableName = $wpdb->prefix . "ap_currency";
  942. $cal_admin_currency = $wpdb->get_row("SELECT `symbol` FROM `$CurrencyTableName` WHERE `id` = '$cal_admin_currency_id'");
  943. $cal_admin_currency = $cal_admin_currency->symbol;
  944. } else {
  945. $cal_admin_currency = "&#36;";
  946. }
  947.  
  948. if($AllCalendarSettings['show_service_cost'] == 'yes') $ShowCost = 1; else $ShowCost = 0;
  949. if($AllCalendarSettings['show_service_duration'] == 'yes') $ShowDuration = 1; else $ShowDuration = 0;
  950. $ServiceTable = $wpdb->prefix."ap_services";
  951. foreach($AllCategory as $Category) {
  952. echo "<option value='$Category->id' disabled class='mycss'>".ucwords($Category->name)."</option>";
  953. $FindServiceSQL = "SELECT * FROM `$ServiceTable` WHERE `availability` = 'yes' and `category_id` = '$Category->id' order by `name` ASC";
  954. $AllService = $wpdb->get_results($FindServiceSQL, OBJECT);
  955. if(count($AllService)) {
  956. foreach($AllService as $Service) { ?>
  957. <option value="<?php echo $Service->id; ?>">&nbsp;&nbsp;
  958. <?php echo ucwords($Service->name);
  959. if($ShowDuration || $ShowCost) echo " (";
  960. if($ShowDuration) { echo $Service->duration."min"; } if($ShowDuration && $ShowCost) echo "/";
  961. if($ShowCost) { echo $cal_admin_currency. $Service->cost; }
  962. if($ShowDuration || $ShowCost) echo ")"; ?>
  963. </option><?php
  964. }
  965. } else {
  966. echo "<option disabled>&nbsp;&nbsp;&nbsp;".ucwords(__('No service in this category', 'appointzilla'))."</option>";
  967. }
  968. } ?>
  969. </select>
  970. <br>
  971. <script type="text/javascript">
  972. //load staff according to service - start
  973. jQuery('#servicelist').change(function(){
  974.  
  975. var ServiceId = jQuery("select#servicelist").val();
  976. if(ServiceId > 0) {
  977. jQuery('#loading-staff').show();
  978. jQuery('#staff').hide();
  979. var FirstData = "ServiceId=" + ServiceId;
  980. jQuery.ajax({
  981. dataType : 'html',
  982. type: 'GET',
  983. url : location.href,
  984. data : FirstData,
  985. complete : function() { },
  986. success: function(data) {
  987. data=jQuery(data).find('div#stfflistdiv');
  988. jQuery('#staff').show();
  989. jQuery('#loading-staff').hide();
  990. jQuery('#staff').html(data);
  991. }
  992. });
  993. } else {
  994. jQuery('#staff').hide();
  995. }
  996. });
  997. </script>
  998. <div id="loading-staff" style="display:none;"><?php _e('Loading Staff...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" /></div>
  999. <div id="staff"></div>
  1000. </div><!--#secdiv-->
  1001. </div><!--#modal-body-->
  1002. </form>
  1003. </div>
  1004. </div>
  1005. <!---AppSecondModal For Schedule New Appointment--->
  1006.  
  1007. <!---AppSecondModal For Schedule New Appointment--->
  1008. <div id="AppSecondModal" style="display:none;"></div>
  1009. <!---AppSecondModal For Schedule New Appointment End--->
  1010.  
  1011. <!---AppThirdModal For Schedule New Appointment--->
  1012. <div id="AppThirdModal" style="display:none;"></div>
  1013. <!---AppThirdModal For Schedule New Appointment End--->
  1014. <div id="AppForthModalFinal" style="display:none;">
  1015.  
  1016. </div>
  1017. <!---AppThirdModal For Schedule New Appointment End--->
  1018.  
  1019. <!--date-picker js -->
  1020. <script src="<?php echo plugins_url('/menu-pages/datepicker-assets/js/jquery.ui.datepicker.js', __FILE__); ?>" type="text/javascript"></script>
  1021.  
  1022. <!---Loading staff ajax return code--->
  1023. <?php if(isset($_GET['ServiceId'])) { ?>
  1024. <!---load bootstrap css--->
  1025. <link rel='stylesheet' type='text/css' href='<?php echo plugins_url('/bootstrap-assets/css/bootstrap.css', __FILE__); ?>' />
  1026. <div id="stfflistdiv">
  1027. <?php
  1028. $ServiceID = $_GET['ServiceId'];
  1029. if($ServiceID) {
  1030. $ServiceTable = $wpdb->prefix . "ap_services";
  1031. $StaffTable = $wpdb->prefix . "ap_staff";
  1032. $AllStaffIdList = $wpdb->get_row("SELECT `staff_id` FROM `$ServiceTable` WHERE `id` = '$ServiceID'", OBJECT);
  1033. $AllStaffIdList = unserialize($AllStaffIdList->staff_id);
  1034. if(count($AllStaffIdList) > 1) {
  1035. ?>
  1036. <strong><?php _e('Select Staff:', 'appointzilla'); ?></strong><br>
  1037. <select name='stafflist' id='stafflist' style="width:100%">
  1038. <?php //get all staff id list by service id
  1039.  
  1040. if(count($AllStaffIdList)) {
  1041. foreach($AllStaffIdList as $StaffId) {
  1042. $StaffDetails = $wpdb->get_row("SELECT `id`, `name` FROM `$StaffTable` WHERE `id` = '$StaffId'", OBJECT);
  1043. echo "<option value='".$StaffDetails->id."'>&nbsp;&nbsp;".ucwords($StaffDetails->name)."</option>";
  1044. }
  1045. } else {
  1046. echo "<option value='1'>".__("No Staff Assigned")."</option>";
  1047. }
  1048. ?>
  1049. </select>
  1050. <br>
  1051. <?php
  1052. } else { // end of count > 1
  1053. if(count($AllStaffIdList)) {
  1054. foreach($AllStaffIdList as $StaffId) {
  1055. $StaffDetails = $wpdb->get_row("SELECT `id`, `name` FROM `$StaffTable` WHERE `id` = '$StaffId'", OBJECT);
  1056. echo "<input type='hidden' name='stafflist' id='stafflist' value='$StaffDetails->id'>";
  1057. }
  1058. }
  1059. } // end of count > 1 else
  1060. ?>
  1061. <button type="button" class="apcal_btn" id="next1" name="next1" onclick="LoadSecondModal()"><?php _e('Next', 'appointzilla'); ?> <i class="icon-arrow-right"></i></button>
  1062. <div id="loading1" style="display:none;"><?php _e('Loading...', 'appointzilla'); ?><img src="<?php echo plugins_url("images/loading.gif", __FILE__); ?>" /></div>
  1063. <?php } //end of service id if ?>
  1064. </div><?php
  1065. } ?>
  1066.  
  1067.  
  1068. <!---loading second modal form ajax return code--->
  1069. <?php require_once('shortcode-time-slot-calculation.php'); ?>
  1070. <!---loading second modal form ajax return code--->
  1071.  
  1072.  
  1073. <!---loading third modal form ajax return code--->
  1074. <?php
  1075. if( isset($_GET['StartTime']) && isset($_GET['StaffId']) ) { ?>
  1076. <div id="AppThirdModalData">
  1077. <div class="apcal_modal" id="AppThirdModal" style="z-index:10000;">
  1078. <input name="ServiceId" id="ServiceId" type="hidden" value="<?php if(isset($_GET['ServiceId'])) { echo $_GET['ServiceId']; } ?>" />
  1079. <input name="StaffId" id="StaffId" type="hidden" value="<?php if(isset($_GET['StaffId'])) { echo $_GET['StaffId']; } ?>" />
  1080. <input name="AppDate" id="AppDate" type="hidden" value="<?php if(isset($_GET['AppDate'])) { echo $_GET['AppDate']; } ?>" />
  1081. <input name="StartTime" id="StartTime" type="hidden" value="<?php if(isset($_GET['StartTime'])) { echo $_GET['StartTime']; } ?>" />
  1082. <input name="EndTime" id="EndTime" type="hidden" value="<?php if(isset($_GET['EndTime'])) { echo $_GET['EndTime']; } ?>" />
  1083. <input name="RecurringType" id="RecurringType" type="hidden" value="<?php if(isset($_GET['RecurringType'])) { echo $_GET['RecurringType']; } ?>" />
  1084. <input name="RecurringStartDate" id="RecurringStartDate" type="hidden" value="<?php if(isset($_GET['recurring_start_date'])) { echo $_GET['recurring_start_date']; } ?>" />
  1085. <input name="RecurringEndDate" id="RecurringEndDate" type="hidden" value="<?php if(isset($_GET['recurring_end_date'])) { echo $_GET['recurring_end_date']; } ?>" />
  1086.  
  1087. <div class="apcal_modal-info">
  1088. <a href="" onclick="CloseModelform()" style="float:right; margin-right:40px; margin-top:21px;" id="close" ><i class="icon-remove"></i></a>
  1089. <div class="apcal_alert apcal_alert-info">
  1090. <p><strong><?php _e('Schedule New Appointment', 'appointzilla'); ?></strong></p>
  1091. <?php _e('Step 3. Complete Your Booking', 'appointzilla'); ?>
  1092. </div>
  1093. </div>
  1094.  
  1095. <div class="apcal_modal-body">
  1096. <?php if($AllCalendarSettings['apcal_user_registration'] == "yes") { ?>
  1097. <!--check user div-->
  1098. <div id="check-user">
  1099. <table width="100%" class="table">
  1100. <tr>
  1101. <td colspan="3">
  1102. <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>
  1103. <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>
  1104. <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>
  1105. </td>
  1106. </tr>
  1107. </table>
  1108. </div>
  1109.  
  1110. <!--new user div-->
  1111. <div id="new-user-div" style="display: none;">
  1112. <table width="100%" class="table">
  1113. <tr>
  1114. <th scope="row"><?php _e('Username', 'appointzilla'); ?></th>
  1115. <td><strong>:</strong></td>
  1116. <td><input name="client-username" type="text" id="client-username" style="height:30px;" /></td>
  1117. </tr>
  1118. <tr>
  1119. <th scope="row"><?php _e('Password', 'appointzilla'); ?></th>
  1120. <td><strong>:</strong></td>
  1121. <td><input name="client-password" type="password" id="client-password" style="height:30px;" /></td>
  1122. </tr>
  1123. <tr>
  1124. <th scope="row"><?php _e('Confirm Password', 'appointzilla'); ?></th>
  1125. <td><strong>:</strong></td>
  1126. <td><input name="client-confirm-password" type="password" id="client-confirm-password" style="height:30px;" /></td>
  1127. </tr>
  1128. <tr>
  1129. <th scope="row"><?php _e('Email', 'appointzilla'); ?></th>
  1130. <td><strong>:</strong></td>
  1131. <td><input name="client-email" type="text" id="client-email" style="height:30px;" /></td>
  1132. </tr>
  1133. <tr>
  1134. <th scope="row"><?php _e('First Name', 'appointzilla'); ?></th>
  1135. <td><strong>:</strong></td>
  1136. <td><input name="client-first-name" type="text" id="client-first-name" style="height:30px;" /></td>
  1137. </tr>
  1138. <tr>
  1139. <th scope="row"><?php _e('Last Name', 'appointzilla'); ?></th>
  1140. <td><strong>:</strong></td>
  1141. <td><input name="client-last-name" type="text" id="client-last-name" style="height:30px;" /></td>
  1142. </tr>
  1143. <tr>
  1144. <th scope="row"><?php _e('Phone', 'appointzilla'); ?></th>
  1145. <td><strong>:</strong></td>
  1146. <td><input name="client-phone" type="text" id="client-phone" style="height:30px;" maxlength="14"/></td>
  1147. </tr>
  1148. <tr>
  1149. <th scope="row"><?php _e('Special Instruction', 'appointzilla'); ?></th>
  1150. <td><strong>:</strong></td>
  1151. <td><textarea name="client-si" id="client-si"></textarea></td>
  1152. </tr>
  1153. <tr>
  1154. <td>&nbsp;</td>
  1155. <td>&nbsp;</td>
  1156. <td>
  1157. <div id="new-user-form-btn-div">
  1158. <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>
  1159. </div>
  1160. <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>
  1161. </td>
  1162. </tr>
  1163. </table>
  1164. </div>
  1165.  
  1166. <!--existing user div-->
  1167. <div id="existing-user-div" style="display: none;">
  1168.  
  1169. <!--div for display existing user search details-->
  1170. <div id="check-email-div-form" style="display: none;">
  1171. <table width="100%" class="table">
  1172. <tr>
  1173. <th scope="row"><?php _e('Email', 'appointzilla'); ?></th>
  1174. <td><strong>:</strong></td>
  1175. <td><input name="check-client-email" type="text" id="check-client-email" style="height:30px;" /></td>
  1176. </tr>
  1177. <tr>
  1178. <td>&nbsp;</td>
  1179. <td>&nbsp;</td>
  1180. <td>
  1181. <div id="existing-user-form-btn">
  1182. <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>
  1183. </div>
  1184. <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>
  1185. </td>
  1186. </tr>
  1187. </table>
  1188. </div>
  1189.  
  1190. <!--div for display existing user search details-->
  1191. <div id="check-email-result-div" style="display: none;">
  1192.  
  1193. </div>
  1194. </div>
  1195. <?php } else { // end of if registration enable ?>
  1196. <!--user registration not enable-->
  1197. <div id="no-user-registration">
  1198. <table width="100%" class="table">
  1199. <tr>
  1200. <th scope="row"><?php _e('Email', 'appointzilla'); ?></th>
  1201. <td><strong>:</strong></td>
  1202. <td><input name="client-email" type="text" id="client-email" style="height:30px;" /></td>
  1203. </tr>
  1204. <tr>
  1205. <th scope="row"><?php _e('First Name', 'appointzilla'); ?></th>
  1206. <td><strong>:</strong></td>
  1207. <td><input name="client-first-name" type="text" id="client-first-name" style="height:30px;" /></td>
  1208. </tr>
  1209. <tr>
  1210. <th scope="row"><?php _e('Last Name', 'appointzilla'); ?></th>
  1211. <td><strong>:</strong></td>
  1212. <td><input name="client-last-name" type="text" id="client-last-name" style="height:30px;" /></td>
  1213. </tr>
  1214. <tr>
  1215. <th scope="row"><?php _e('Phone', 'appointzilla'); ?></th>
  1216. <td><strong>:</strong></td>
  1217. <td><input name="client-phone" type="text" id="client-phone" style="height:30px;" maxlength="14"/></td>
  1218. </tr>
  1219. <tr>
  1220. <th scope="row"><?php _e('Special Instruction', 'appointzilla'); ?></th>
  1221. <td><strong>:</strong></td>
  1222. <td><textarea name="client-si" id="client-si"></textarea></td>
  1223. </tr>
  1224. <tr>
  1225. <td>&nbsp;</td>
  1226. <td>&nbsp;</td>
  1227. <td>
  1228. <div id="new-user-form-btn-div">
  1229. <button type="button" class="apcal_btn" id="back2" name="back2" onclick="LoadSecondModal2()"><i class="icon-arrow-left"></i> <?php _e('Back', 'appointzilla'); ?></button>
  1230. <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>
  1231. </div>
  1232. <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>
  1233. </td>
  1234. </tr>
  1235. </table>
  1236. </div>
  1237. <?php } ?>
  1238. </div><!--end modal-body-->
  1239. </div>
  1240. </div><?php
  1241. } ?>
  1242.  
  1243. <!---saving appointments--->
  1244. <?php if( isset($_POST['Action'])) {
  1245. $Action = $_POST['Action'];
  1246. $UserType = $_POST['UserType'];
  1247. if($Action == "BookAppointment") {
  1248. //print_r($_POST); die;
  1249. $ServiceId = $_POST['ServiceId'];
  1250. $StaffId = $_POST['StaffId'];
  1251. $AppDateNo = $_POST['AppDate'];
  1252.  
  1253. $ClientEmail = $_POST['ClientEmail'];
  1254. $ClientFirstName = sanitize_text_field($_POST['ClientFirstName']);
  1255. $ClientLastName = sanitize_text_field($_POST['ClientLastName']);
  1256. $ClientName = $ClientFirstName ." ". $ClientLastName;
  1257. $ClientPhone = $_POST['ClientPhone'];
  1258. $ClientNote = $_POST['ClientNote'];
  1259. $AppointmentKey = md5(date("F j, Y, g:i a"));
  1260. $AppDate = date("Y-m-d", strtotime($AppDateNo));
  1261. $StartTime = $_POST['StartTime'];
  1262.  
  1263. //check user registration yes/no
  1264. if($AllCalendarSettings['apcal_user_registration'] == "yes"){
  1265. if($UserType == "NewUser") {
  1266. $ClientUserName = $_POST['ClientUserName'];
  1267. $ClientPassword = $_POST['ClientPassword'];
  1268.  
  1269. //create new user profile as subscriber
  1270. $UserId = username_exists( $ClientUserName );
  1271. if ( !$UserId and email_exists($ClientEmail) == false ) {
  1272. $UserId = wp_create_user( $ClientUserName, $ClientPassword, $ClientEmail );
  1273. if($UserId) {
  1274. update_user_meta( $UserId, 'first_name', $_POST['ClientFirstName']);
  1275. update_user_meta( $UserId, 'last_name', $_POST['ClientLastName']);
  1276. add_user_meta( $UserId, 'client_phone', $ClientPhone);
  1277. add_user_meta( $UserId, 'client_note', $ClientNote);
  1278. }
  1279. } else {
  1280. _e("User already exists", "appointzilla");
  1281. }
  1282. }
  1283.  
  1284. if($UserType == "ExUser") {
  1285. //update existing user profile as subscriber
  1286. $UserId = email_exists($ClientEmail);
  1287. if($UserId) {
  1288. update_user_meta( $UserId, 'first_name', $ClientFirstName);
  1289. update_user_meta( $UserId, 'last_name', $ClientLastName);
  1290. update_user_meta( $UserId, 'client_phone', $ClientPhone);
  1291. update_user_meta( $UserId, 'client_note', $ClientNote);
  1292. } else {
  1293. _e("User already exists", "appointzilla");
  1294. }
  1295. }
  1296. } // end of check user registration
  1297.  
  1298. //fetch service detail calculation EndTime and Service name
  1299. $ServiceTableName = $wpdb->prefix . "ap_services";
  1300. $ServiceName = $wpdb->get_row("SELECT * FROM `$ServiceTableName` WHERE `id` = '$ServiceId' ");
  1301. $ServiceDuration = $ServiceName->duration;
  1302.  
  1303. $StartTimeTimestamp = strtotime($StartTime);
  1304. //calculate end time according to service duration
  1305. $CalculateTime = strtotime("+$ServiceDuration minutes", $StartTimeTimestamp);
  1306. $EndTime = date('h:i A', $CalculateTime );
  1307.  
  1308. if(isset($AllCalendarSettings['apcal_new_appointment_status'])) {
  1309. $Status = $AllCalendarSettings['apcal_new_appointment_status'];
  1310. } else {
  1311. $Status = "pending";
  1312. }
  1313. $AppointmentBy = "user";
  1314. $Recurring = "no";
  1315. $RecurringType = "none";
  1316. $RecurringStartDate = $AppDate;
  1317. $RecurringEndDate = $AppDate;
  1318. $PaymentStatus = "unpaid";
  1319.  
  1320. global $wpdb;
  1321. $AppointmentsTable = $wpdb->prefix ."ap_appointments";
  1322. $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');";
  1323. if($wpdb->query($CreateAppointments)) {
  1324. $LastAppointmentId = $wpdb->insert_id;; ?>
  1325. <div id="AppForthModalData">
  1326. <?php global $wpdb;
  1327. $ClientTable = $wpdb->prefix."ap_clients";
  1328. $ExistClientDetails = $wpdb->get_row("SELECT * FROM `$ClientTable` WHERE `email` = '$ClientEmail' ");
  1329. if(count($ExistClientDetails)) {
  1330. // update exiting client deatils
  1331. $ExistClientId = $ExistClientDetails->id;
  1332. $update_client = "UPDATE `$ClientTable` SET `name` = '$ClientName', `email` = '$ClientEmail', `phone` = '$ClientPhone', `note` = '$ClientNote' WHERE `id` = '$ExistClientId' ;";
  1333. if($wpdb->query($update_client)) {
  1334. $LastClientId = $ExistClientId;
  1335. } else {
  1336. // if now data filed modified then
  1337. $LastClientId = $ExistClientId;
  1338. }
  1339. } else {
  1340. // insert new client deatils
  1341. $InsertClient = "INSERT INTO `$ClientTable` (`id` ,`name` ,`email` ,`phone` ,`note`) VALUES ('NULL', '$ClientName', '$ClientEmail', '$ClientPhone', '$ClientNote');";
  1342. if($wpdb->query($InsertClient)) {
  1343. //$LastClientId = mysql_insert_id();
  1344. $LastClientId = $wpdb->insert_id;
  1345.  
  1346. }
  1347. } ?>
  1348.  
  1349. <div class="apcal_modal" id="AppForthModal" style="z-index:10000;">
  1350. <div class="apcal_modal-info">
  1351. <div style="float:right; margin-top:5px; margin-right:10px;"></div>
  1352. <div class="apcal_alert apcal_alert-info">
  1353. <p><?php _e('Thank You. Your appointment has been scheduled.', 'appointzilla'); ?></p>
  1354. </div><!--end modal-info-->
  1355.  
  1356. <div class="apcal_modal-body">
  1357. <style>
  1358. .table th, .table td {
  1359. padding: 4px;;
  1360. }
  1361. </style>
  1362. <strong><?php _e('Your Appointment Details', 'appointzilla'); ?></strong>
  1363. <input type="hidden" id="appid" name="appid" value="<?php echo $LastAppointmentId; ?>" />
  1364. <table width="100%" class="table">
  1365. <tr>
  1366. <th width="26%" scope="row"><?php _e('Name', 'appointzilla'); ?></th>
  1367. <td width="1%"><strong>:</strong></td>
  1368. <td width="73%"><?php echo ucwords($ClientName); ?></td>
  1369. </tr>
  1370. <tr>
  1371. <th width="26%" scope="row"><?php _e('Email', 'appointzilla'); ?></th>
  1372. <td width="1%"><strong>:</strong></td>
  1373. <td width="73%"><?php echo $ClientEmail; ?></td>
  1374. </tr>
  1375. <tr>
  1376. <th width="26%" scope="row"><?php _e('Phone', 'appointzilla'); ?></th>
  1377. <td width="1%"><strong>:</strong></td>
  1378. <td width="73%"><?php echo $ClientPhone; ?></td>
  1379. </tr>
  1380. <tr>
  1381. <th width="26%" scope="row"><?php _e('Service', 'appointzilla'); ?></th>
  1382. <td width="1%"><strong>:</strong></td>
  1383. <td width="73%"><?php echo ucwords($ServiceName->name); ?></td>
  1384. </tr>
  1385. <tr>
  1386. <th width="26%" scope="row"><?php _e('Staff', 'appointzilla'); ?></th>
  1387. <td width="1%"><strong>:</strong></td>
  1388. <td width="73%">
  1389. <?php $StaffTableName = $wpdb->prefix . "ap_staff";
  1390. $StaffName = $wpdb->get_row("SELECT `name` FROM `$StaffTableName` WHERE `id` = '$StaffId' ");
  1391. echo ucwords($StaffName->name); ?>
  1392. </td>
  1393. </tr>
  1394. <tr>
  1395. <th width="26%" scope="row"><?php _e('Date', 'appointzilla'); ?></th>
  1396. <td width="1%"><strong>:</strong></td>
  1397. <td width="73%"><?php echo date($DateFormat, strtotime($AppDate)); ?></td>
  1398. </tr>
  1399. <tr>
  1400. <?php if($TimeFormat == "h:i") $InfoTimeFormat = "h:i A"; else $InfoTimeFormat = "H:i"; ?>
  1401. <th width="26%" scope="row"><?php _e('Time', 'appointzilla'); ?></th>
  1402. <td width="1%"><strong>:</strong></td>
  1403. <td width="73%"><?php echo date($InfoTimeFormat, strtotime($StartTime))." - ".date($InfoTimeFormat, strtotime($EndTime)); ?></td>
  1404. </tr>
  1405. <tr>
  1406. <th width="26%" scope="row"><?php _e('Status', 'appointzilla'); ?></th>
  1407. <td width="1%"><strong>:</strong></td>
  1408. <td width="73%"><?php echo _e(ucfirst($Status),'appointzilla'); ?></td>
  1409. </tr>
  1410. <?php
  1411. //get service details for payment purpose & also check payment settings
  1412. global $wpdb;
  1413. $ServiceTableName = $wpdb->prefix . 'ap_services';
  1414. $ServiceDetails = $wpdb->get_row("SELECT * FROM `$ServiceTableName` WHERE `id` = '$ServiceId'");
  1415. $AcceptPayment = $ServiceDetails->accept_payment;
  1416. $PaymentType = $ServiceDetails->payment_type;
  1417. $ap_payment_email = get_option('ap_payment_email');
  1418. $ap_payment_gateway_status = get_option('ap_payment_gateway_status');
  1419. if($AcceptPayment == "yes" && $PaymentType == "full" && $ap_payment_email && $ap_payment_gateway_status == "yes") {
  1420. ?>
  1421. <tr>
  1422. <th width="26%" scope="row"><?php _e('Coupon Code', 'appointzilla'); ?></th>
  1423. <td width="1%"><strong>:</strong></td>
  1424. <td width="73%">
  1425. <div id="apply-coupon-div">
  1426. <input type="text" id="coupon-code" name="coupon-code" maxlength="15" style="width: 120px;">
  1427. <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>
  1428. </div>
  1429.  
  1430. <div id="loading-img" style="display:none;"><?php _e('Applying...', 'appointzilla'); ?><img src="<?php echo plugins_url("images/loading.gif", __FILE__); ?>" /></div>
  1431. <div id="show-coupon-result" style="display:none;"></div>
  1432. </td>
  1433. </tr>
  1434. <?php } ?>
  1435. <tr>
  1436. <td colspan="3">
  1437. <?php $Check1 = 0; $Check2 = 0; $Check3 = 0;
  1438. /**
  1439. * Paypal Payment Process
  1440. **/
  1441. //get service details for payment purpose
  1442. global $wpdb;
  1443. $ServiceTableName = $wpdb->prefix . 'ap_services';
  1444. $ServiceDetails = $wpdb->get_row("SELECT * FROM `$ServiceTableName` WHERE `id` = '$ServiceId'");
  1445.  
  1446. //get currency code
  1447. $CurrencyId = get_option('cal_admin_currency');
  1448. if($CurrencyId != '') {
  1449. $CurrencyTableName = $wpdb->prefix."ap_currency";
  1450. $CurrencyDetails = $wpdb->get_row("SELECT `code` FROM `$CurrencyTableName` WHERE `id` = '$CurrencyId'");
  1451. $CurrencyCode = $CurrencyDetails->code;
  1452. } else {
  1453. $CurrencyCode = 'USD';
  1454. }
  1455.  
  1456. $Protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';
  1457. $SuccessCurrentUrl = $Protocol.$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
  1458. $FailedCurrentUrl = $SuccessCurrentUrl."?&failed=failed&appointId=".$LastAppointmentId;
  1459.  
  1460. //check payment is 'yes'
  1461. if($ap_payment_gateway_status == 'yes') {
  1462.  
  1463. //check service is paid
  1464. if($ServiceDetails->accept_payment == 'yes') {
  1465. //check payment type
  1466. if($ServiceDetails->payment_type == 'percentage') {
  1467. $PayCost = $ServiceDetails->cost;
  1468. $percentage = $ServiceDetails->percentage_ammount;
  1469. $PayCost = ($PayCost * $percentage) /100;
  1470. } else {
  1471. $PayCost = $ServiceDetails->cost;
  1472. }
  1473.  
  1474. $ApPaymentEmail = get_option('ap_payment_email');
  1475. if($ApPaymentEmail) {
  1476. // default discount value
  1477. $DiscountRate = 0;
  1478.  
  1479. // Include the paypal library
  1480. require_once ('menu-pages/paypal-api/Scientechpaypal.php');
  1481. $ScientechPaypal = new Scientechpaypal();
  1482. $ScientechPaypal->TakePayment($ApPaymentEmail, $CurrencyCode, $SuccessCurrentUrl, $FailedCurrentUrl, $ServiceDetails->name, $PayCost, $LastAppointmentId, $DiscountRate);
  1483. } else {
  1484. $Check3 = 1;
  1485. }
  1486. } else {
  1487. $Check2 = 1;
  1488. }
  1489. } else {
  1490. $Check1 = 1;
  1491. }
  1492.  
  1493. // send notification if any of check == 1
  1494. if($Check1 || $Check2 || $Check3) { ?>
  1495. <button type="submit" class="apcal_btn apcal_btn" onclick="CloseModelform()" style="margin-left:80%"><i class="icon-ok"></i> <?php _e('Done', 'appointzilla'); ?></button>
  1496. <?php $BlogName = get_bloginfo('name');
  1497. if($LastAppointmentId && $LastClientId) {
  1498. $AppId = $LastAppointmentId;
  1499. $ServiceId = $ServiceId;
  1500. $StaffId = $StaffId;
  1501. $ClientId = $LastClientId;
  1502. //include notification class
  1503. require_once('menu-pages/notification-class.php');
  1504. $Notification = new Notification();
  1505. $Notification->notifyadmin($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
  1506. $Notification->notifyclient($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
  1507. if(get_option('staff_notification_status') == 'on') {
  1508. $Notification->notifystaff($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
  1509. }
  1510. }
  1511. }
  1512.  
  1513. //if status is approved then sync appointment
  1514. if($Status == 'approved') {
  1515.  
  1516. //add service name with event title($name)
  1517. //$ServiceTable = $wpdb->prefix . "ap_services";
  1518. //$ServiceData = $wpdb->get_row("SELECT * FROM `$ServiceTable` WHERE `id` = '$ServiceId'");
  1519. //$name = $name."(".$ServiceData->name.")";
  1520.  
  1521. /***
  1522. * admin appointment sync
  1523. */
  1524. $CalData = get_option('google_caelndar_settings_details');
  1525. if($CalData['google_calendar_client_id'] != '' && $CalData['google_calendar_secret_key'] != '') {
  1526. $StartTime = date("H:i", strtotime($StartTime));
  1527. $EndTime = date("H:i", strtotime($EndTime));
  1528. $AppDate = date("Y-m-d", strtotime($AppDate));
  1529. $ClientNote = strip_tags($ClientNote);
  1530.  
  1531. $ClientId = $CalData['google_calendar_client_id'];
  1532. $ClientSecretId = $CalData['google_calendar_secret_key'];
  1533. $RedirectUri = $CalData['google_calendar_redirect_uri'];
  1534. require_once('menu-pages/google-appointment-sync-class.php');
  1535.  
  1536. //global $wpdb;
  1537. $AppointmentSyncTableName = $wpdb->prefix . "ap_appointment_sync";
  1538. // insert this appointment event on calendar
  1539. $GoogleAppointmentSync = new GoogleAppointmentSync($ClientId, $ClientSecretId, $RedirectUri);
  1540. $tag = "Appointment with: ";
  1541. $OAuth = $GoogleAppointmentSync->NormalSync($ClientName, $AppDate, $StartTime, $EndTime, $ClientNote, $tag);
  1542. //insert appintment sync details
  1543. $OAuth = serialize($OAuth);
  1544. $wpdb->query("INSERT INTO `$AppointmentSyncTableName` ( `id` , `app_id` , `app_sync_details` ) VALUES ( NULL , '$AppId', '$OAuth' )");
  1545. } // end of google calendar setting
  1546.  
  1547. /***
  1548. * staff appointment sync
  1549. */
  1550. $StaffAppointmentSyncSettings = unserialize(get_option("staff_google_calendar_sync_settings_".$StaffId));
  1551. if($StaffAppointmentSyncSettings['StaffGoogleCalendarClientId'] != "" && $StaffAppointmentSyncSettings['StaffGoogleCalendarSecret']) {
  1552. $StaffGoogleEmail = $StaffAppointmentSyncSettings['StaffGoogleEmail'];
  1553. $StaffGoogleCalendarClientId = $StaffAppointmentSyncSettings['StaffGoogleCalendarClientId'];
  1554. $StaffGoogleCalendarSecret = $StaffAppointmentSyncSettings['StaffGoogleCalendarSecret'];
  1555. $StaffGoogleCalendarRedirectUris = $StaffAppointmentSyncSettings['StaffGoogleCalendarRedirectUris'];
  1556. require_once('menu-pages/google-staff-appointment-sync-class.php');
  1557.  
  1558. // add this staff appointment event on his google calendar
  1559. $StaffGoogleAppointmentSync = new StaffGoogleAppointmentSync($StaffGoogleCalendarClientId, $StaffGoogleCalendarSecret, $StaffGoogleCalendarRedirectUris);
  1560. $Tag = __("Appointment with: ", "appointzilla");
  1561. $StaffOAuth = $StaffGoogleAppointmentSync->NormalStaffAppointmentSync($StaffId, $ClientName, $AppDate, $StartTime, $EndTime, $ClientNote, $Tag);
  1562.  
  1563. //insert staff appointment sync details
  1564. global $wpdb;
  1565. $StaffAppointmentSyncTable = $wpdb->prefix . "ap_staff_appointment_sync";
  1566. $StaffOAuth = serialize($StaffOAuth);
  1567. $wpdb->query("INSERT INTO `$StaffAppointmentSyncTable` ( `id` , `app_id` , `staff_sync_details` ) VALUES ( NULL , '$AppId', '$StaffOAuth' )");
  1568. }//end of staff appointment sync
  1569.  
  1570. //unset payment post variables
  1571. //unset($_POST['address_status']); unset($_POST['payer_id']);
  1572.  
  1573. } // end of sync appointment is approved
  1574. ?>
  1575. <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>
  1576. <div id="loading-staff" style="display:none;">
  1577. <?php _e('Loading Staff...', 'appointzilla'); ?><img src="<?php echo plugins_url('images/loading.gif', __FILE__); ?>" />
  1578. </div>
  1579. </td>
  1580. </tr>
  1581. </table>
  1582. </div>
  1583. </div>
  1584. </div>
  1585. <?php
  1586. }//query if
  1587. }
  1588. }// saving appointment if
  1589.  
  1590.  
  1591. // Payment success
  1592. if( isset($_POST['address_status']) && isset($_POST['payer_id']) ) {
  1593. global $wpdb;
  1594. $AppointmentTableName = $wpdb->prefix . "ap_appointments";
  1595. $PaymentTableName = $wpdb->prefix . 'ap_payment_transaction';
  1596. $ClientTableName = $wpdb->prefix . 'ap_clients';
  1597. $CouponsCodesTable = $wpdb->prefix ."apcal_pre_coupons_codes";
  1598. //print_r($_POST);
  1599. $PaymentDetails = serialize($_POST);
  1600. $appId = $_POST['item_number'];
  1601.  
  1602. //get client id by appointment id
  1603. $ClientEmail = $wpdb->get_row("SELECT `email` FROM `$AppointmentTableName` WHERE `id` = '$appId'");
  1604. $FetchClientEmail = $wpdb->get_row("SELECT `id` FROM `$ClientTableName` WHERE `email` = '$ClientEmail->email'");
  1605. $clientId = $FetchClientEmail->id;
  1606.  
  1607. $amount = $_POST['mc_gross'];
  1608. $date = $_POST['payment_date'];
  1609. $status = $_POST['address_status'];
  1610. $txn_id = $_POST['txn_id'];
  1611. $gateway = 'paypal';
  1612.  
  1613. $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');");
  1614. $AppointmentId = $_POST['item_number'];
  1615. $AppointmentRow = $wpdb->get_row("SELECT * FROM `$AppointmentTableName` WHERE `id` = '$AppointmentId'");
  1616. if(count($AppointmentRow)) {
  1617. $name = $AppointmentRow->name;
  1618. $ServiceId = $AppointmentRow->service_id;
  1619. $StaffId = $AppointmentRow->staff_id;
  1620. $StartTime = $AppointmentRow->start_time;
  1621. $EndTime = $AppointmentRow->end_time;
  1622. $Client_name = $AppointmentRow->name;
  1623. $Client_Email = $AppointmentRow->email;
  1624. $Client_Phone = $AppointmentRow->phone;
  1625. $Client_Note = $AppointmentRow->note;
  1626. $AppDate = $AppointmentRow->date;
  1627. $Status = 'approved';
  1628. $AppointmentKey = $AppointmentRow->appointment_key;
  1629.  
  1630. //update appointment status n payment status
  1631. $PaymentStatus = $_POST['payment_status'];
  1632. $AppointmentRow = $wpdb->query("UPDATE `$AppointmentTableName` SET `status` = '$Status', `payment_status` = 'paid' WHERE `id` = '$AppointmentId' ");
  1633.  
  1634. $BlogName = get_bloginfo();
  1635. if($AppointmentId && $clientId) {
  1636. $AppId = $AppointmentId;
  1637. $ServiceId = $ServiceId;
  1638. $StaffId = $StaffId;
  1639. $ClientId = $clientId;
  1640. //include notification class
  1641. require_once('menu-pages/notification-class.php');
  1642. $Notification = new Notification();
  1643. $Notification->notifyadmin($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
  1644. $Notification->notifyclient($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
  1645. if(get_option('staff_notification_status') == "on") {
  1646. $Notification->notifystaff($Status, $AppId, $ServiceId, $StaffId, $ClientId, $BlogName, $DateFormat, $TimeFormat);
  1647. }
  1648. }
  1649.  
  1650. //if status is approved then sync appointment
  1651. if($Status == 'approved') {
  1652.  
  1653. //add service name with event title($name)
  1654. //$ServiceTable = $wpdb->prefix . "ap_services";
  1655. //$ServiceData = $wpdb->get_row("SELECT * FROM `$ServiceTable` WHERE `id` = '$ServiceId'");
  1656. //$name = $name."(".$ServiceData->name.")";
  1657.  
  1658. /**
  1659. * Admin appointment google sync
  1660. */
  1661. $CalData = get_option('google_caelndar_settings_details');
  1662. if($CalData['google_calendar_client_id'] != '' && $CalData['google_calendar_secret_key'] != '') {
  1663. $start_time = date("H:i", strtotime($StartTime));
  1664. $end_time = date("H:i", strtotime($EndTime));
  1665. $appointmentdate = date("Y-m-d", strtotime($AppDate));
  1666. $note = strip_tags($Client_Note);
  1667.  
  1668. $ClientId = $CalData['google_calendar_client_id'];
  1669. $ClientSecretId = $CalData['google_calendar_secret_key'];
  1670. $RedirectUri = $CalData['google_calendar_redirect_uri'];
  1671. require_once('menu-pages/google-appointment-sync-class.php');
  1672.  
  1673. //global $wpdb;
  1674. $AppointmentSyncTableName = $wpdb->prefix . "ap_appointment_sync";
  1675. // insert this appointment event on calendar
  1676. $GoogleAppointmentSync = new GoogleAppointmentSync($ClientId, $ClientSecretId, $RedirectUri);
  1677. $tag = "Appointment with: ";
  1678. $OAuth = $GoogleAppointmentSync->NormalSync($name, $appointmentdate, $start_time, $end_time, $note, $tag);
  1679. //insert appintment sync details
  1680. $OAuth = serialize($OAuth);
  1681. $wpdb->query("INSERT INTO `$AppointmentSyncTableName` ( `id` , `app_id` , `app_sync_details` )
  1682. VALUES ( NULL , '$AppointmentId', '$OAuth' );");
  1683. } // end of google calendar setting
  1684.  
  1685. /**
  1686. * Staff appointment google sync
  1687. */
  1688. $StaffAppointmentSyncSettings = unserialize(get_option("staff_google_calendar_sync_settings_".$StaffId));
  1689. if($StaffAppointmentSyncSettings['StaffGoogleCalendarClientId'] != "" && $StaffAppointmentSyncSettings['StaffGoogleCalendarSecret']) {
  1690. $StaffGoogleEmail = $StaffAppointmentSyncSettings['StaffGoogleEmail'];
  1691. $StaffGoogleCalendarClientId = $StaffAppointmentSyncSettings['StaffGoogleCalendarClientId'];
  1692. $StaffGoogleCalendarSecret = $StaffAppointmentSyncSettings['StaffGoogleCalendarSecret'];
  1693. $StaffGoogleCalendarRedirectUris = $StaffAppointmentSyncSettings['StaffGoogleCalendarRedirectUris'];
  1694. require_once('menu-pages/google-staff-appointment-sync-class.php');
  1695.  
  1696. $start_time = date("H:i", strtotime($StartTime));
  1697. $end_time = date("H:i", strtotime($EndTime));
  1698. $appointmentdate = date("Y-m-d", strtotime($AppDate));
  1699. $note = strip_tags($Client_Note);
  1700. // add this staff appointment event on his google calendar
  1701. $StaffGoogleAppointmentSync = new StaffGoogleAppointmentSync($StaffGoogleCalendarClientId, $StaffGoogleCalendarSecret, $StaffGoogleCalendarRedirectUris);
  1702. $Tag = __("Appointment with: ", "appointzilla");
  1703. $StaffOAuth = $StaffGoogleAppointmentSync->NormalStaffAppointmentSync($StaffId, $name, $appointmentdate, $start_time, $end_time, $note, $Tag);
  1704.  
  1705. //insert staff appointment sync details
  1706. global $wpdb;
  1707. $StaffAppointmentSyncTable = $wpdb->prefix . "ap_staff_appointment_sync";
  1708. $StaffOAuth = serialize($StaffOAuth);
  1709. $wpdb->query("INSERT INTO `$StaffAppointmentSyncTable` ( `id` , `app_id` , `staff_sync_details` ) VALUES ( NULL , '$AppId', '$StaffOAuth' )");
  1710. }//end of staff appointment sync
  1711.  
  1712. //unset payment post variables
  1713. unset($_POST['address_status']); unset($_POST['payer_id']);
  1714.  
  1715. } // end of sync appointment is approved ?>
  1716. <div class="apcal_modal" id="AppForthModal" style="z-index:10000;">
  1717. <div class="apcal_modal-info">
  1718. <div style="float:right; margin-top:5px; margin-right:10px;">
  1719. <div align="center"><a href="" onclick="CloseModelform()" id="close" ><i class="icon-remove"></i></a></div>
  1720. </div>
  1721. <div class="apcal_alert apcal_alert-info">
  1722. <h4 ><?php _e('Payment Successfully Processed', 'appointzilla'); ?></h4>
  1723. </div>
  1724. <div class="apcal_modal-body">
  1725. <div class="apcal_alert apcal_alert-success">
  1726. <strong><?php _e('Payment received and your appointment has been confirmed.', 'appointzilla'); ?></strong><br />
  1727. <strong><?php _e('Thank you for scheduling appointment with us.', 'appointzilla'); ?></strong>
  1728. <?php
  1729. //if payment confirmed(done) then increment coupon used count value
  1730. if($status == "confirmed") {
  1731. $PaymentDetails = unserialize($PaymentDetails);
  1732. if(isset($PaymentDetails['custom'])) {
  1733. $CouponCode = $PaymentDetails['custom'];
  1734. //check coupon exist or not
  1735. $CouponsData = $wpdb->get_row("SELECT * FROM `$CouponsCodesTable` WHERE `coupon_code` LIKE '$CouponCode'");
  1736. if(count($CouponsData)) {
  1737. //increment total used count
  1738. $CouponId = $CouponsData->id;
  1739. $UsedCount = $CouponsData->used_count + 1;
  1740. $wpdb->query("UPDATE `$CouponsCodesTable` SET `used_count` = '$UsedCount' WHERE `id` = '$CouponId' ");
  1741. }
  1742. }
  1743. }
  1744. ?>
  1745. </div>
  1746. <button type='button' onclick='CloseModelform()' name='close' id='close' value='Done' class='apcal_btn'><i class="icon-ok"></i> <?php _e('Done', 'appointzilla'); ?></button>
  1747. </div>
  1748. <div>
  1749. </div>
  1750. </div>
  1751. <?php
  1752. } // end of AppointmentRow
  1753. } // end of Payment success
  1754.  
  1755. // Payment process failed
  1756. if( isset($_GET['failed']) && isset($_GET['appointId'])) { ?>
  1757. <div class="apcal_modal" id="AppForthModal" style="z-index:10000;">
  1758. <div class="apcal_modal-info" style="padding-bottom:20px;">
  1759. <div style="float:right; margin-top:5px; margin-right:10px;">
  1760. <a href="#" onclick="CloseModelformfailed()" id="close" ><i class="icon-remove"></i></a>
  1761. </div>
  1762. <input type="hidden" name="appid" id="appid" value="<?php echo $_GET['appointId']; ?>" />
  1763. <div class="apcal_alert apcal_alert-info">
  1764. <h4><?php _e('Payment Failed', 'appointzilla'); ?></h4>
  1765. </div>
  1766. <div style=" margin-left:20px; padding-right:20px;">
  1767. <div class="apcal_alert apcal_alert-error">
  1768. <?php _e('Sorry! Appointment booking was not successful.', 'appointzilla'); ?>
  1769. </div>
  1770. <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>
  1771. </div>
  1772. </div>
  1773. </div><?php
  1774. }
  1775.  
  1776. // cancel appointment
  1777. if(isset($_POST['appid']) && isset($_POST['appstatus']) ) {
  1778. $appid = $_POST['appid'];
  1779. global $wpdb;
  1780. $apptabname = $wpdb->prefix."ap_appointments";
  1781. $wpdb->query("UPDATE `$apptabname` SET `status` = 'cancelled' WHERE `id` = '$appid' ;");
  1782. }
  1783.  
  1784. //applying coupon code
  1785. if(isset($_POST['Action'])) {
  1786. $Action = $_POST['Action'];
  1787. if($Action == "apply-coupon") {
  1788. if(isset($_POST['CouponCode'])) {
  1789. $CouponCode = strtolower($_POST['CouponCode']);
  1790. } else {
  1791. $CouponCode = "";
  1792. }
  1793. if($CouponCode){
  1794. global $wpdb;
  1795. $Discount = 0;
  1796. $CouponsCodesTable = $wpdb->prefix . "apcal_pre_coupons_codes";
  1797. //Search Coupon
  1798. $CouponDetails = $wpdb->get_row("SELECT * FROM `$CouponsCodesTable` WHERE `coupon_code` LIKE '$CouponCode'");
  1799. if(count($CouponDetails)) {
  1800. //check coupon expire
  1801. $DateTodayTs = strtotime(date("Y-m-d"));
  1802. $ExpireDateTs = strtotime(date("Y-m-d", strtotime($CouponDetails->expire)));
  1803. $TotalUses = $CouponDetails->total_uses;
  1804. $UsedCount = $CouponDetails->used_count;
  1805. $Discount = $CouponDetails->discount;
  1806. if($DateTodayTs > $ExpireDateTs) {
  1807. //coupon expired
  1808. ?><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
  1809. } else if($UsedCount >= $TotalUses) {
  1810. //ckeck used count
  1811. ?><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
  1812. } else {
  1813. //coupon valid and appied
  1814. ?><div id="coupon-result">
  1815. <div id="coupon-code-div" style="display: none;"><?php echo $CouponCode; ?></div>
  1816. <div id="discount-rate-div" style="display: none;"><?php echo $Discount; ?></div>
  1817. <?php echo strtoupper("<strong>$CouponCode</strong> "); _e("coupon code applied.", "appointzilla"); ?> <a id="try-another" onclick="return TryAgain();"><?php _e("Change", "appointzilla"); ?></a>
  1818. </div><?php
  1819. }
  1820. } else {
  1821. ?>
  1822. <div id="coupon-result">
  1823. <div id="discount-rate-div" style="display: none;"><?php echo $Discount; ?></div>
  1824. <?php echo strtoupper("<strong>$CouponCode</strong> "); _e("coupon code is invalid.", "appointzilla"); ?>
  1825. <a id="try-another" onclick="return TryAgain();"><?php _e("Try Another", "appointzilla"); ?></a>
  1826. </div>
  1827. <?php
  1828. }
  1829. }
  1830. }//end of if action
  1831. }
  1832.  
  1833. //check existing user
  1834. if(isset($_POST['Action'])) {
  1835. $Action = $_POST['Action'];
  1836. if($Action == "CheckExistingUser") {
  1837. ?><div id="check-email-result"><?php
  1838. $ClientEmail = $_POST['ClientEmail'];
  1839. $ClientId = email_exists( $ClientEmail );
  1840. if( $ClientId = email_exists( $ClientEmail )) {
  1841. //fetch user details
  1842. $ClientDetails = get_userdata( $ClientId );
  1843. //print_r($ClientDetails);
  1844. $FirstName = "";
  1845. $LastName = "";
  1846. $Phone = "";
  1847. $ClientNote = "";
  1848. $UserMetaData = get_user_meta( $ClientId );
  1849. if(count($UserMetaData)) {
  1850. if(isset($UserMetaData['first_name'][0])) {
  1851. $FirstName = ucwords($UserMetaData['first_name'][0]);
  1852. }
  1853. if(isset($UserMetaData['last_name'][0])) {
  1854. $LastName = ucwords($UserMetaData['last_name'][0]);
  1855. }
  1856. if(isset($UserMetaData['client_phone'][0])) {
  1857. $Phone = $UserMetaData['client_phone'][0];
  1858. }
  1859. if(isset($UserMetaData['client_note'][0])) {
  1860. $ClientNote = ucfirst($UserMetaData['client_note'][0]);
  1861. }
  1862. }
  1863. ?>
  1864. <input type="hidden" id="client-id" name="client-id" value="<?php echo $ClientId; ?>">
  1865. <table width="100%" class="table">
  1866. <tr>
  1867. <th scope="row"><?php _e('Email', 'appointzilla'); ?></th>
  1868. <td><strong>:</strong></td>
  1869. <td><input name="ex-client-email" type="text" id="ex-client-email" style="height:30px;" value="<?php echo $ClientEmail; ?>" readonly="" /></td>
  1870. </tr>
  1871. <tr>
  1872. <th scope="row"><?php _e('First Name', 'appointzilla'); ?></th>
  1873. <td><strong>:</strong></td>
  1874. <td><input name="ex-client-first-name" type="text" id="ex-client-first-name" style="height:30px;" value="<?php echo $FirstName; ?>"/></td>
  1875. </tr>
  1876. <tr>
  1877. <th scope="row"><?php _e('Last Name', 'appointzilla'); ?></th>
  1878. <td><strong>:</strong></td>
  1879. <td><input name="ex-client-last-name" type="text" id="ex-client-last-name" style="height:30px;" value="<?php echo $LastName; ?>" /></td>
  1880. </tr>
  1881. <tr>
  1882. <th scope="row"><?php _e('Phone', 'appointzilla'); ?></th>
  1883. <td><strong>:</strong></td>
  1884. <td><input name="ex-client-phone" type="text" id="ex-client-phone" style="height:30px;" value="<?php echo $Phone; ?>" maxlength="14"/></td>
  1885. </tr>
  1886. <tr>
  1887. <th scope="row"><?php _e('Special Instruction', 'appointzilla'); ?></th>
  1888. <td><strong>:</strong></td>
  1889. <td><textarea name="ex-client-si" id="ex-client-si"><?php echo $ClientNote; ?></textarea></td>
  1890. </tr>
  1891. <tr>
  1892. <td>&nbsp;</td>
  1893. <td>&nbsp;</td>
  1894. <td>
  1895. <div id="ex-user-form-btn-div">
  1896. <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>
  1897. <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>
  1898. </div>
  1899. <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>
  1900. <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>
  1901. </td>
  1902. </tr>
  1903. </table>
  1904. <?php
  1905. } else { ?>
  1906. <table width="100%" class="table">
  1907. <tr>
  1908. <td colspan="3">
  1909. <?php _e("Sorry! No record found.","appointzilla"); ?>
  1910. <button type="button" onclick="return TryAgainBooking();" class="apcal_btn apcal_btn-danger"><i class="fa fa-mail-reply"></i> Try Again</button>
  1911. </td>
  1912. </tr>
  1913. </table>
  1914. <?php
  1915. }
  1916. ?></div><?php
  1917. }
  1918. }
  1919. /*$output_string = ob_get_contents();
  1920. ob_end_clean();
  1921. return $output_string;*/
  1922. }//end of short code function
  1923. ?>
Add Comment
Please, Sign In to add comment