JezK
Edit File: appointment.php
<?php include("header.php"); $active1 = "active"; $active2 = ""; $active3 = ""; $tab = 1; if(isset($_REQUEST['tab'])&& $_REQUEST['tab']==2) { $active2 = "active"; $active1 = ""; $tab =2; } if(isset($_REQUEST['tab'])&& $_REQUEST['tab']==3) { $active3 = "active"; $active1 = ""; $tab =3; } $fromdate = isset($_REQUEST['fromdate'])?$_REQUEST['fromdate']:''; $todate = isset($_REQUEST['todate'])?$_REQUEST['todate']:''; $appointments = $videocon->getUserAppiontments('','',$tab,'',$fromdate,$todate); // echo "<pre>";print_r($appointments);exit; if((isset($_REQUEST['did']) && $_REQUEST['did']!='') || (isset($_POST['action']) && ($_POST['action']='deleteUpcoming' || $_POST['action']='deleteCompleted' || $_POST['action']='deleteCancelled' ))) { if(!isset($_POST['action'])) { $bid=$videocon->encrypt_decrypt('decrypt',$_REQUEST['did']); } else { $bid=implode(',',$_POST['delAppointment']); // echo $bid;exit; } $deleteBusness=$videocon->deleteAppointment($bid); if($deleteBusness) { echo "<script>alert('Deleted Successfully');window.location='appointment.php?tab=$tab';</script>"; }else{ echo "<script>alert('Deletion Failed');window.location='appointment.php';</script>"; } } ?> <style> div.dataTables_wrapper div.dataTables_filter { position: absolute; top: 154px; } </style> <section class="section-padding"> <div class="container"> <!-- Nav tabs --> <ul class="nav nav-tabs border-0" role="tablist"> <li class="nav-item"> <a class="nav-link <?php echo $active1;?> anc-Color" href="?tab=1">UPCOMING</a> </li> <li class="nav-item"> <a class="nav-link anc-Color <?php echo $active2;?>" href="?tab=2">COMPLETED</a> </li> <li class="nav-item"> <a class="nav-link anc-Color <?php echo $active3;?>" href="?tab=3">CANCELLED</a> </li> </ul> <!-- Tab panes --> <div class="tab-content bg-white m-3"><br> <div class="container"> <div class="container px-1"> <form action ='' method='GET' id="appointments"> <div class="calender-Right mb-2"> <label class="fieldName mt-2 mr-2">Select Date Range</label> <div id="reportrange<?php echo $tab?>" class="col-xl-5 col-md-6 col-lg-8 formField-control" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;"> <i class=" float-right "><img src="img/calenderdark.png"></i> <span></span> <input type="hidden" class="hidden fromdate" name="fromdate" value=""> <input type="hidden" class="hidden todate" name="todate" value=""> <input type="hidden" class="hidden " name="tab" value="<?php echo $tab?>"> </div> </div> </form> </div> </div> <div id="ongoing" class="container tab-pane <?php echo $active1;?>"> <!--start calender --> <!--ENd calender --> <!-- <span class=""> <a class="selectAll buttonStyle">Select All</a> <a class="unSelectAll buttonStyle">Unselect All</a> <a class="deleteAll buttonStyle" onclick="return deleteall('deleteUpcoming');">Delete All</a> </span> --> <div class="table-responsive"> <form name="deleteUpcoming" id="deleteUpcoming" action="" method="post"> <table id="dataTable" class="table table-striped table-borderless " style="width:100%"> <thead class="tableBackground"> <tr> <!-- <th></th> --> <th>S.No</th> <th>BUSINESS NAME</th> <th>USER NAME</th> <th>APPOINTMENT DATE</th> <th>APPOINTMENT TIME </th> <th>CALL FEE</th> <th>BOOKING STATUS</th> <th>ACTION</th> </tr> </thead> <tbody> <?php $i=0; foreach($appointments as $k=>$v){ $i++; $getava=$videocon->getBusiness('id',$v['business_id']); if(!empty($getava)) { $val = (isset($getava['0']['business_name']) && $getava['0']['business_name']!='')?$getava['0']['business_name']:$getava['0']['professional_name']; ?> <tr> <!-- <td> <label class="container1"> <input type="checkbox" name="delAppointment[]" class="checkmark" value="<?php echo $v['id']; ?>"> <span class="checkmark1"></span> </label> </td> --> <td><?php echo $i;?>.</td> <td><?php echo $val;?></td> <td><?php echo $v['client_name'];?></td> <td><?php echo date("F, d, Y" ,strtotime($v['slot_date']));?> </td> <td><?php echo $v['slot_times'];?></td> <td><?php echo ($v['currency']=='INR'?"Rs.":"$").$v['amount'];?></td> <td><?php echo $v['booking_status']==4?"Accepted":"Upcoming";?></td> <td><a href="appointmentDetails.php?bid=<?php echo $videocon->encrypt_decrypt('encrypt',$v['id']);?>" class="viewStyles">View</a> <a href="javascript:void(0)" class="viewStyles" onclick="return cancelconfirmed('<?php echo $videocon->encrypt_decrypt('encrypt',$v['id']);?>' )" />Cancel</a></td> </tr> <?php } }?> </tbody> </table> <input type="hidden" class="hidden " name="tab" value="<?php echo $tab?>"> <input type="hidden" name="action" value="deleteUpcoming"> </form> </div> </div> <div id="upcoming" class="container tab-pane <?php echo $active2;?>"> <!-- <div class="container px-1"> <form action ='' method='GET' id="appointments"> <div class="calender-Right mb-2"> <label class="fieldName mt-2 mr-2">Select Date Range</label> <div id="reportrange<?php echo $tab?>" class="col-xl-5 col-md-6 col-lg-8 formField-control" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;"> <i class="fa fa-calendar float-right pt-1"></i> <span></span> <input type="hidden" class="hidden fromdate" name="fromdate" value=""> <input type="hidden" class="hidden todate" name="todate" value=""> </div> </div> </form> </div> --> <!--ENd calender --> <!-- <span class=""> <a class="selectAll buttonStyle">Select All</a> <a class="unSelectAll buttonStyle">Unselect All</a> <a class="deleteAll buttonStyle" onclick="return deleteall('deleteCompleted');">Delete All</a> </span> --> <div class="table-responsive"> <form name="deleteCompleted" id="deleteCompleted" action="" method="post"> <table id="dataTable1" class="table table-striped table-borderless" style="width:100%"> <thead class="tableBackground"> <tr> <!-- <th></th> --> <th>S.No</th> <th>BUSINESS NAME</th> <th>USER NAME</th> <th>APPOINTMENT DATE </th> <th>APPOINTMENT TIME </th> <th>SESSION STATUS </th> <th>CALL FEE</th> <th>ACTION</th> </tr> </thead> <tbody> <?php $i=0; foreach($appointments as $k=>$v){ $sessionStatus =''; if($v['booking_status']==2 || $v['completed_timeslots']!=''){ $sessionStatus ='Completed'; }else if($v['booking_status']==1 || $v['booking_status']==4){ $sessionStatus ='Time Expired'; } $i++; $getava=$videocon->getBusiness('id',$v['business_id']); if(!empty($getava)) { $val = (isset($getava['0']['business_name']) && $getava['0']['business_name']!='')?$getava['0']['business_name']:$getava['0']['professional_name']; ?> <tr> <!-- <td> <label class="container1"> <input type="checkbox" name="delAppointment[]" class="checkmark" value="<?php echo $v['id']; ?>"> <span class="checkmark1"></span> </label> </td> --> <td><?php echo $i;?>.</td> <td><?php echo $val;?></td> <td><?php echo $v['client_name'];?></td> <td><?php echo date("F, d, Y" ,strtotime($v['slot_date']));?> </td> <td><?php echo $v['slot_times'];?></td> <td><?php echo $sessionStatus;?></td> <td><?php echo ($v['currency']=='INR'?"Rs.":"$").$v['amount'];?></td> <td><a href="appointmentDetails.php?bid=<?php echo $videocon->encrypt_decrypt('encrypt',$v['id']);?>" class="viewStyles">View</a></td> </tr> <?php } }?> </tbody> </table> <input type="hidden" class="hidden " name="tab" value="<?php echo $tab?>"> <input type="hidden" name="action" value="deleteCompleted"> </form> </div> </div> <div id="completed" class="container tab-pane <?php echo $active3;?>"> <!-- <div class="container px-1"> <form action ='' method='GET' id="appointments"> <div class="calender-Right mb-2"> <label class="fieldName mt-2 mr-2">Select Date Range</label> <div id="reportrange<?php echo $tab?>" class="col-xl-5 col-md-6 col-lg-8 formField-control" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;"> <i class="fa fa-calendar float-right pt-1"></i> <span></span> <input type="hidden" class="hidden fromdate" name="fromdate" value=""> <input type="hidden" class="hidden todate" name="todate" value=""> </div> </div> </form> </div> --> <!--ENd calender --> <!-- <span class=""> <a class="selectAll buttonStyle">Select All</a> <a class="unSelectAll buttonStyle">Unselect All</a> <a class="deleteAll buttonStyle" onclick="return deleteall('deleteCancelled');">Delete All</a> </span> --> <div class="table-responsive"> <form name="deleteCancelled" id="deleteCancelled" action="" method="post"> <table id="dataTable2" class="table table-striped table-borderless" style="width:100%"> <thead class="tableBackground"> <tr> <!-- <th></th> --> <th>S.No</th> <th>BUSINESS NAME</th> <th>USER NAME</th> <th>APPOINTMENT DATE </th> <th>APPOINTMENT TIME </th> <th>CALL FEE</th> <th>ACTION</th> </tr> </thead> <tbody> <?php $i=0; foreach($appointments as $k=>$v){ $i++; $getava=$videocon->getBusiness('id',$v['business_id']); if(!empty($getava)) { $val = (isset($getava['0']['business_name']) && $getava['0']['business_name']!='')?$getava['0']['business_name']:$getava['0']['professional_name']; ?> <tr> <!-- <td> <label class="container1"> <input type="checkbox" name="delAppointment[]" class="checkmark" value="<?php echo $v['id']; ?>"> <span class="checkmark1"></span> </label> </td> --> <td><?php echo $i;?>.</td> <td><?php echo $val;?></td> <td><?php echo $v['client_name'];?></td> <td><?php echo date("F, d, Y" ,strtotime($v['slot_date']));?> </td> <td><?php echo $v['slot_times'];?></td> <td><?php echo ($v['currency']=='INR'?"Rs.":"$").$v['amount'];?></td> <td><a href="appointmentDetails.php?bid=<?php echo $videocon->encrypt_decrypt('encrypt',$v['id']);?>" class="viewStyles">View</a></td> </tr> <?php } }?> </tbody> </table> <input type="hidden" class="hidden " name="tab" value="<?php echo $tab?>"> <input type="hidden" name="action" value="deleteCancelled"> </form> </div> </div> </div> </div> </section> <?php include("footer.php");?> <script> $(function() { var start = moment().subtract(1, 'days'); var end = moment(); function cb(start, end) { $('.fromdate').val(start.format('YYYY-MM-DD')); $('.todate').val(end.format('YYYY-MM-DD')); $('#reportrange<?php echo $tab?> span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY')); } $('#reportrange<?php echo $tab?>').daterangepicker({ startDate: start, endDate: end, ranges: { 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] } }, cb); cb(start, end); }); $(document).ready(function() { var url = window.location.href; function getParameterByName( name,href ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( href ); return decodeURIComponent(results[1].replace(/\+/g, " ")); } var from = getParameterByName("fromdate",url); var to = getParameterByName("todate",url); var x1 = moment(from).format('DD MMMM, YYYY '); var y1 = moment(to).format('DD MMMM, YYYY'); // alert(x1); $('#reportrange<?php echo $tab?> span').html(x1 + ' - ' + y1); }); $('#reportrange<?php echo $tab?>').on('apply.daterangepicker', function(ev, picker) { //alert(picker.startDate.format('DD-MM-YYYY')+' To '+picker.endDate.format('DD-MM-YYYY')); var fromdate = picker.startDate.format('YYYY-MM-DD'); var todate =picker.endDate.format('YYYY-MM-DD'); // alert('hai'); $('#appointments').submit(); }); function cancelconfirmed(id) { if(confirm('Are you sure wants to cancel this booking')) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var data=this.responseText; if(data==1) { alert("Your booking slot is cancelled"); window.location='appointment.php'; }else{ alert("Booking cancel was failed"); $('#cancelAppointment').modal(hide); } } }; xhttp.open("GET", "ajax.php?action=cancelappointment&bid="+id, true); xhttp.send(); }else{ return false; } } </script>