JezK
Edit File: bookAppointment.php
<?php ini_set('memory_limit', '-1'); include('mainHeader.php'); if(!isset($_REQUEST['pid'])) { echo "<script>alert('Invalid details');window.location='index.php'</script>"; } $id=$users->encrypt_decrypt('decrypt',$_REQUEST['pid']); if($id<=0) { echo "<script>alert('Invalid details');window.location='index.php'</script>"; } $bookingDet=''; $rescheduleId=''; $rescheduleparams=''; if(isset($_REQUEST['scheduleby']) && $_REQUEST['scheduleby']!='') { $rescheduleId=$users->encrypt_decrypt('decrypt',$_REQUEST['scheduleby']); $rescheduleparams='&scheduleby='.$_REQUEST['scheduleby']; if($rescheduleId<=0) { echo "<script>alert('Invalid details');window.location='bookAppointment.php?pid=".$_REQUEST['pid']."'</script>"; }else{ $bookingDet=$users->getUserTransactionDet('',$rescheduleId); } } $availableDates=$users->availableDatesTime(date('Y-m-d'), $id); //$todayava=$users->todayAvailabilityDates($id,date('Y-m-d')); $businessAvailability=$users->todayAvailabilityDates(date('Y-m-d'), $id); //print_r($todayava);exit; $getava=$users->getBusiness('id',$id); ///////////////////Already Booked Details//// $bookedSlots=$users->bookedSlotsByDate(date('Y-m-d'), $id); $myBookedTimeSlots=''; $mybookedtime=''; $bs=0; foreach($bookedSlots as $k=>$v) { $bs++; if($bs==1) { $myBookedTimeSlots.=$v['slot_times']; }else{ $myBookedTimeSlots.=','.$v['slot_times']; } } $bookedTimeSlots=explode(',',$myBookedTimeSlots); $getPrice=''; if(count($availableDates)>0) { $getPrice=$users->getBusinessPrice($availableDates['0']['addedby_id']); } $avaDatesPicking=''; foreach($availableDates as $k=>$v) { //$avaDatesPicking.="{ start: new Date(".date('Y',strtotime($v['slot_dates'])).", ".date('m',strtotime($v['slot_dates']))."-1, ".date('d',strtotime($v['slot_dates']))."), text: 'Conference', background: '#f4511e' },"; $avaDatesPicking.="{ name: 'AvailableSlots', date: new Date(".date('Y',strtotime($v['slot_dates'])).", ".date('m',strtotime($v['slot_dates']))."-1, ".date('d',strtotime($v['slot_dates'])).") }, "; } $avaDatesPicking=trim($avaDatesPicking,','); ?> <link rel="stylesheet" type="text/css" href="demo/css/style.css"/> <link rel="stylesheet" type="text/css" href="demo/css/ui.css"/> <!-- <link rel="stylesheet" href="dist/css/pignose.calendar.css"> --> <link rel="stylesheet" href="dist/css/pignose.calendar.min.css"> <style> .nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link{ background: #b8d2de !important; border-radius:0; padding:5px 15px; border:unset !important; } .nav-tabs .nav-link{ padding:5px 15px; } .nav-link{ color:black; } .event a { background-color: #42B373 !important; background-image :none !important; color: #ffffff !important; } .mbsc-ios .mbsc-cal-cell,.mbsc-ios.mbsc-fr-inline .mbsc-fr-c,.mbsc-ios.mbsc-fr-inline .mbsc-fr-w{ border:unset !important; } .mbsc-col-sm-12 .mbsc-col-md-4{ height: 300px !important; } .pignose-calendar { font-size: 13px !important; } .pignose-calendar-week{ font-size:12px !important; } .pignose-calendar-unit.calender_availableslot a { background: #2dc732db !important; } /* */ .pignose-calendar-unit.calender_availableslot.pignose-calendar-unit-active a { background: #009fe3 !important; } .pignose-calendar-unit-active.selected_slot a{ background:#009fe3 !important; } </style> <section class="mt-5 pt-4 mx-5"> <div class="container-fluid bg-white text-dark pb-4 px-4 mb-4"> <?php $businesspic='img/dummybusinesspic.png'; if($getava['0']['business_pic']!='' && file_exists('uploads/'.$getava['0']['business_pic'])) { $businesspic='uploads/'.$getava['0']['business_pic']; } $countryName = $users->getCountry($getava['0']['country']); ?> <form method="post" id="bookappiontmentsubmit" action="confirmAppointment.php?pid=<?php echo $_REQUEST['pid'].$rescheduleparams;?>" class=""> <div class="row" > <div class="col-xl-1 col-sm-6 col-md-4 mbrPadding text-center"> <div> <img width="90px" height="90px" src="<?php echo $businesspic;?>"> </div> </div> <div class="col-xl-11 col-sm-6 col-md-8 videoConf"> <div class="row mt-4 pt-2"> <div class="col-xl-9 col-sm-6 col-md-8 mbrMargin"> <p class="mb-1 text-dark"><?php echo (isset($getava['0']['business_name']) && $getava['0']['business_name']!='')?$getava['0']['business_name']:$getava['0']['professional_name'];?></p> <p class="mb-1"><img src="img/verified.png"> Verified</p> </div> <div id="printpricedate"> <?php if(isset($getPrice['call_cost']) && $getPrice['call_cost']>0 && is_array($businessAvailability) && count($businessAvailability)>0){ ?> <div class="col-xl-12 col-sm-6 col-md-8 mbrMargin text-right mb-2"> <p class="mb-1 text-dark consultation-rate">Consultation <?php echo $getPrice['call_cost'];?><?php echo $recentPractCountry=="India"?"Rs.":($recentPractCountry=="United States"?"$":"");?>/ <?php echo $getPrice['call_to_minutes'];?>Min.</p> <button class="btn btn-primary b-appointment" onclick="return bookAppiontment();">Confirm Appointment</button> <input type="hidden" name="callcost" value="<?php echo $getPrice['call_cost'];?>"> </div> <?php } ?> </div> </div> </div> </div> <div class="row border-right border-bottom border-primaryTop mx-0 mb-3"> <div class="col-12 col-sm-4 col-xl-3 col-md-5 px-0 border-left border-right"> <div class="calendar"></div> <!-- <div class="mbsc-col-sm-12 mbsc-col-md-4"> <div class="mbsc-form-group"> <div id="demo-colored"></div> </div> </div> --> <!-- <div id="calendar2" class="border-right border-left"></div> --> </div> <div class="col-12 col-sm-8 col-xl-9 col-md-7 mt-3" id="replaceWithAjaxRec"> <h3><?php echo date('d M, Y')?></h3> <?php //if($availableDates['0']['available_from']<='12 AM'){ $mycount=0; $morningslots=''; $afternoonslots=''; $eveningslots=''; if(is_array($businessAvailability) && count($businessAvailability)>0) { $k=0; foreach($businessAvailability as $key=>$todayava) { $date1 = strtotime(date('Y-m-d '.$todayava['available_from'])); $date2 = strtotime(date('Y-m-d '.$todayava['available_to'])); $mins = ($date2 - $date1) / 60; $numofslots=ceil($mins/$getPrice['call_to_minutes']); $availablefrom=strtotime(date('Y-m-d 12:00')); $afternoonfrom=strtotime(date('Y-m-d 12:00')); $afternoonto=strtotime(date('Y-m-d 15:00')); $from_presenttime=$date1; $to_presenttime=$date1; for($i=1;$i<=$numofslots;$i++) { $k++; if($date1<=$availablefrom && $to_presenttime<=$availablefrom) { $to_presenttime=$to_presenttime + ($getPrice['call_to_minutes'] * 60); $mybookedtime=date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime); if(in_array($mybookedtime,$bookedTimeSlots)) { if($i==$numofslots){ $to_presenttime=$date2; } $morningslots.= '<td> <div id="slot-a'.$k.'" class="p-1 slotFull text-white text-nowrap fs-14 ava-slot"> <label for="check'.$k.'">'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'</label> <!--<input type="hidden" name="slotbooking[]" id="check'.$k.'" class="hidden" onclick="available('.$k.')" value ="'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'">--> </div> </td>'; }else{ if($i==$numofslots){ $to_presenttime=$date2; } $morningslots.= '<td> <div id="slot-a'.$k.'" class="p-1 slotAvailable text-white text-nowrap fs-14 ava-slot"> <label for="check'.$k.'">'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'</label> <input type="checkbox" name="slotbooking[]" id="check'.$k.'" class="hidden" onclick="available('.$k.')" value ="'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'"> </div> </td>'; } $from_presenttime=$from_presenttime + ($getPrice['call_to_minutes'] * 60); }else if($afternoonfrom<=$to_presenttime && $afternoonto>=$to_presenttime){ $to_presenttime=$to_presenttime + ($getPrice['call_to_minutes'] * 60); $mybookedtime=date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime); if(in_array($mybookedtime,$bookedTimeSlots)) { if($i==$numofslots){ $to_presenttime=$date2; } $afternoonslots.='<td> <div id="slot-a'.$k.'" class="p-1 slotFull text-white text-nowrap fs-14 ava-slot"> <label for="check'.$k.'">'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'</label> <!--<input type="hidden" name="slotbooking[]" id="check'.$k.'" class="hidden" onclick="available('.$k.')" value ="'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'">--> </div> </td>'; }else{ if($i==$numofslots){ $to_presenttime=$date2; } $afternoonslots.='<td> <div id="slot-a'.$k.'" class="p-1 slotAvailable text-white text-nowrap fs-14 ava-slot"> <label for="check'.$k.'">'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'</label> <input type="checkbox" name="slotbooking[]" id="check'.$k.'" class="hidden" onclick="available('.$k.')" value ="'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'"> </div> </td>'; } $from_presenttime=$from_presenttime + ($getPrice['call_to_minutes'] * 60); } else if($afternoonto<$to_presenttime){ $to_presenttime=$to_presenttime + ($getPrice['call_to_minutes'] * 60); $mybookedtime=date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime); if(in_array($mybookedtime,$bookedTimeSlots)) { if($i==$numofslots){ $to_presenttime=$date2; } $eveningslots.='<td> <div id="slot-a'.$k.'" class="p-1 slotFull text-white text-nowrap fs-14 ava-slot"> <label for="check'.$k.'">'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'</label> <!--<input type="hidden" name="slotbooking[]" id="check'.$k.'" class="hidden" onclick="available('.$k.')" value ="'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'">--> </div> </td>'; }else{ if($i==$numofslots){ $to_presenttime=$date2; } $eveningslots.='<td> <div id="slot-a'.$k.'" class="p-1 slotAvailable text-white text-nowrap fs-14 ava-slot"> <label for="check'.$k.'">'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'</label> <input type="checkbox" name="slotbooking[]" id="check'.$k.'" class="hidden" onclick="available('.$k.')" value ="'.date('H:i',$from_presenttime).'-'.date('H:i',$to_presenttime).'"> </div> </td>'; } $from_presenttime=$from_presenttime + ($getPrice['call_to_minutes'] * 60); } } }////////Foreach ended Here/////////// ?> <div class="row mx-0"> <p class="fs-14">Morning</p> <div class="table-responsive"> <table class="slot-book" cellspacing="0"> <tbody> <tr> <?php echo $morningslots;?> </tr> </tbody> </table> </div> </div> <div class="row mx-0 mt-4"> <p class="fs-14">Afternoon</p> <div class="table-responsive"> <table class="slot-book" cellspacing="0"> <tbody> <tr> <?php echo $afternoonslots;?> </tr> </tbody> </table> </div> </div> <div class="row mx-0 mt-4"> <p class="fs-14">Evening</p> <div class="table-responsive"> <table class="slot-book" cellspacing="0"> <tbody> <tr> <?php echo $eveningslots;?> </tr> </tbody> </table> </div> </div> <div class="row mx-0 mt-4"> <div class="col-12 col-lg-2 col-sm-3 col-md-3 p-0"> <span class="s-available"></span ><span class="span-text1">Available</span> </div> <div class="col-12 col-lg-2 col-sm-3 col-md-3 p-0"> <span class="s-full"></span><span class="span-text2">Selected Slot</span> </div> <div class="col-12 col-lg-3 col-sm-3 col-md-3 p-0"> <span class="s-n-available"></span><span class="span-text4">Slots Filled</span> </div> <div class="col-12 col-lg-4 col-sm-3 col-md-3 p-0"> <!-- <span class="s-n-released"></span><span class="span-text3">Slot Not Released</span> --> </div> </div> <?php }else{ ?> <h1 style="color:red;text-align:center;">No Slots Available</h1> <?php } ?> <input type="hidden" id="slotbooking_date" name="slotbooking_date" value="<?php echo date('Y-m-d');?>"> </div> </div> <input type="hidden" name="businessid" value="<?php echo $id;?>"> <input type="hidden" name="rescheduleId" value="<?php echo $rescheduleId;?>"> <input type="hidden" name="rescheduleSlotscnt" id="rescheduleSlotscnt" value="<?php echo (isset($bookingDet['slot_times']) && $bookingDet['slot_times']!='')?count(explode(',',$bookingDet['slot_times'])):0;?>"> </form> <div class="border mx-0"> <ul class="nav nav-tabs border-0" role="tablist"> <li class="nav-item"> <a class="nav-link active top-tabs" data-toggle="tab" href="#ongoing">Overview</a> </li> </ul> <div class="tab-content"> <div id="ongoing" class="container tab-pane active UserFont"><br> <h6>About</h6> <p class="paraColor mb-4"><?php echo $getava['0']['about'];?></p> <div class="row"> <div class="col-xl-4 col-sm-6 col-md-4 UserFont"> <p class="paraColor"><img src="img/address.png"> Address</p> <p class="mb-1"><?php echo $getava['0']['location'];?></p> </div> </div> </div> </div> </div> </section> <?php include('mainFooter.php')?> <script src="dist/js/pignose.calendar.js"></script> <script> //todayAppointmentList(); function available(id) { var aestTime = new Date().toLocaleString("en-US", { <?php if($recentPractCountry == 'United States'){ ?> timeZone: "America/Chicago" <?php }else{ ?> timeZone: "Asia/Calcutta" <?php } ?> }); var todayMyDate = new Date(aestTime); //var MyDate = new Date(); var MyDate = todayMyDate var MyDateString; MyDate.setDate(MyDate.getDate()); MyDateString = MyDate.getFullYear() + '-' + ('0' + (MyDate.getMonth()+1)).slice(-2) + '-' + ('0' + MyDate.getDate()).slice(-2); var time = ('0' + (MyDate.getHours())).slice(-2) + ":" + ('0' + (MyDate.getMinutes())).slice(-2); //console.log(time); ////////Get Checked time// var checktime=($('#check'+id).val()).split('-'); /*console.log(checktime['0']); console.log(MyDateString); console.log($('#slotbooking_date').val());*/ if(MyDateString==$('#slotbooking_date').val() && checktime['0']<=time ) { //$('#check'+id).attr('checked', false); // Unchecks it $('#check'+id).prop('checked', false); alert("Sorry, the time slot you selected can not be choosen as its over."); return false; } /*var hasClass = element.classList.contains(''); if(hasClass === true){ $(".pignose-calendar-unit a").addClass("background"); }*/ var checkBox = document.getElementById("check"+id); var text = document.getElementById("slot-a"+id); if (checkBox.checked == true){ text.style.background = "#06b3f9"; } else { text.style.background = "#2dc732db"; } } $(document).ready(function(){ var selcDate = new Date(); selcDate.setDate(selcDate.getDate() -1); $('.calendar').pignoseCalendar({ theme: 'blue',// light, dark, blue minDate: selcDate, schedules: [<?php echo $avaDatesPicking;?>], scheduleOptions: { colors: { AvailableSlots: '#ff0000', } }, select: function(date, context) { var selectedDate=convert(date[0]); if(selectedDate!='' && selectedDate!=undefined) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var data=this.responseText; var mydata=data.split('###########'); document.getElementById("printpricedate").innerHTML=mydata['0']; document.getElementById("replaceWithAjaxRec").innerHTML =mydata['1']; } }; xhttp.open("GET", "ajax.php?action=getusertimedet&seldate="+selectedDate+"&pid=<?php echo $_REQUEST['pid'];?>", true); xhttp.send(); } // multiple: true // selectOver: true } }); // colors for calender if ($(".pignose-calendar-unit").hasClass("pignose-calendar-unit-date")) { $(".pignose-calendar-unit").addClass("calender_availableslot"); // for disable $(".pignose-calendar-unit-disabled").removeClass("calender_availableslot"); }; if ($(".pignose-calendar-unit-active").hasClass("pignose-calendar-unit-date")) { $(".pignose-calendar-unit-active").addClass("selected_slot"); $(".pignose-calendar-unit-active").removeClass("calender_availableslot"); }; // }); function todayAppointmentList(){ var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var data=this.responseText; var mydata=data.split('###########'); document.getElementById("printpricedate").innerHTML=mydata['0']; document.getElementById("replaceWithAjaxRec").innerHTML =mydata['1']; } }; xhttp.open("GET", "ajax.php?action=getusertimedet&seldate="+new Date().toISOString().slice(0, 10)+"&pid=<?php echo $_REQUEST['pid'];?>", true); xhttp.send(); } function convert(str) { var date = new Date(str), mnth = ("0" + (date.getMonth() + 1)).slice(-2), day = ("0" + date.getDate()).slice(-2); return [date.getFullYear(), mnth, day].join("-"); } function bookAppiontment() { var i=0; var chkblkentry='No'; var slots=[]; $.each($("input[name='slotbooking[]']:checked"), function(){ i++; chkblkentry=='Yes'; slots.push($(this).val()); }); if($('#rescheduleSlotscnt').val()>1) { if(slots.length>$('#rescheduleSlotscnt').val()) { alert("Please select "+$('#rescheduleSlotscnt').val()+" slots only");return false; } } if(chkblkentry=='Yes' && i!=0){ /*if($('#rescheduleSlotscnt').val()>0) { if(confirm("You are eligible to select "+$('#rescheduleSlotscnt').val()+" slots.Are you sure wants to submit")) }*/ document.getElementById('bookappiontmentsubmit').submit(); }else if(chkblkentry=='No' && i==0){ alert("Please select atleast one time slot to Appointment");return false; } } /*document .getElementById('demo-colored') .addEventListener('click', function (e) { var selectedVal = e.target $('.mbsc-selected').each(function(){ if($(this).attr('data-full')!=undefined) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var data=this.responseText; var mydata=data.split('###########'); document.getElementById("printpricedate").innerHTML=mydata['0']; document.getElementById("replaceWithAjaxRec").innerHTML =mydata['1']; } }; xhttp.open("GET", "ajax.php?action=getusertimedet&seldate="+$(this).attr('data-full')+"&pid=<?php echo $_REQUEST['pid'];?>", true); xhttp.send(); } }) }, false); */ </script>