JezK
Edit File: ajax.php
<?php // ini_set('display_errors', 1); // ini_set('display_startup_errors', 1); // error_reporting(E_ALL); include('classes/class_professional_videoconsultation.php'); $videocon=new professional_videoconsultation(); $recentPractCountry = $videocon->practManCountry; $recentPractCountryID = $videocon->practManCountryID; if(isset($_REQUEST['action']) && $_REQUEST['action']=="forgetpwd") { $forgetpwd=$videocon->forgetPassword($_REQUEST); } if(isset($_REQUEST['action']) && $_REQUEST['action']=='resendotp'){ // $bid=$_REQUEST['bid']; // $mobile=$_REQUEST['mobilenum']; $id=$videocon->encrypt_decrypt('decrypt',$_REQUEST['mid']); $businessDet = $videocon->getBusinessDetails($id); $sentotp=$videocon->sendOtp($businessDet['mobile'],$businessDet['country_code'],$businessDet['id']); if($sentotp>0){ echo "1"; }else{ echo "2"; } } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='checkcurrentpassword') { $checkcurpwd=$videocon->checkCurrentPassword($_SESSION['pid'],$_REQUEST); echo $checkcurpwd; } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='sendotp') { $mobile = $_REQUEST['mobile']; $checkMobile = $videocon->checkMobileNumber($mobile); // echo $checkMobile ;exit; if($checkMobile>0) { $businessDet = $videocon->getBusinessDet($mobile); if($businessDet['signup_type'] == 2){ $ProfessionalDet = $videocon->getBusinessDetails($businessDet['parent_id']); if($ProfessionalDet["delete_status"] == 0) { //account deleted by admin echo -7;exit; } if($ProfessionalDet["status"] == 0){ echo -2;exit; } } if($businessDet["delete_status"] == 0) { //account deleted by admin echo -7;exit; } else if($businessDet["status"] == 0){ echo -2;exit; } else if($recentPractCountryID != $businessDet["country"]) { echo -9;exit; } else{ $sendOtp = $videocon->sendOtp($mobile,$businessDet['country_code'],$businessDet['id']); if($sendOtp ==1) { echo $videocon->encrypt_decrypt('encrypt',$businessDet['id']); } else{ echo 0; } } } else{ echo -1; } }else if(isset($_REQUEST['action']) && $_REQUEST['action'] =='verifyotp') { // echo $_REQUEST['mobile']." ".$_REQUEST['otp'] ;exit; $id=$videocon->encrypt_decrypt('decrypt',$_REQUEST['mid']); $businessDet = $videocon->getBusinessDetails($id); if($businessDet>0) { $otpVerified = $videocon->otpverification($id,$_REQUEST['mobile'],$_REQUEST['otp']); echo $otpVerified; }else{ echo -3; } } else if(isset($_REQUEST['mode']) && $_REQUEST['mode']=='country') { $countryID = $_REQUEST['countryID']; $state = $videocon->getStates($countryID); $stateid=''; if(isset($_REQUEST['stateID']) && $_REQUEST['stateID']!=''){ $stateid=$_REQUEST['stateID']; } $stavalues ='<option value="">Select State</option>'; foreach($state as $k=>$v) { $selected=""; if($v['id']==$stateid){ $selected="Selected"; } $stavalues.="<option value='".$v['id']."' ".$selected.">".$v['name']."</option>"; } echo $stavalues; } else if(isset($_REQUEST['mode']) && $_REQUEST['mode']=='state') { $cityid=''; if(isset($_REQUEST['cityID']) && $_REQUEST['cityID']!=''){ $cityid=$_REQUEST['cityID']; } $countryID = $_REQUEST['stateID']; $cities = $videocon->getCities($countryID); $cityValues="<option value=''>Select City</option>"; foreach($cities as $k=>$v) { $selected=""; if($v['id']==$cityid){ $selected="Selected"; } $cityValues.="<option value='".$v['id']."' ".$selected.">".$v['name']."</option>"; } echo $cityValues; } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='appointments') { $data=''; if(isset($_REQUEST['type'])) { $minValue = isset($_REQUEST["min"])?$_REQUEST["min"]:0; $maxValue = 10; $getappiontments=$videocon->getUserAppiontments($minValue,$maxValue,$_REQUEST['type'],$_REQUEST['fromdate'],$_REQUEST['todate'],$_REQUEST['seltype']); //print_r($getappiontments); if(count($getappiontments)>0) { foreach ($getappiontments as $k => $v) { $d1=date('jS',strtotime($v['slot_date'])); $d2=date('M',strtotime($v['slot_date'])); $d3=date('Y',strtotime($v['slot_date'])); $busDetails = $videocon->getBusinessDetails($v['business_id']); $userDet=$videocon->getUsers('id',$v['user_id']); $val = (isset($getava['0']['fullname']) && $getava['0']['fullname']!='')?$getava['0']['business_name']:''; if($_REQUEST['type']==1) { $data.='<div class="container pb-1 pt-3"> <div class="row border-bottom my-0"> <div class="col-12 col-sm-12 col-md-6 col-lg-6"> <figure class="d-flex"> <small class="bg-secondary px-4 py-2 mr-3">'.$d1.' <br /> '.$d2.' <br /> '.$d3.'</small> <figcaption> <h6 class="user-name text-muted">'.$userDet['0']['fullname'].'</h6> <h6 class="user-name">'.date('M d, l',strtotime($v['slot_date'])).'</h6> <h6 class="user-name"><span class="text-muted">Slots Time:</span> '.$v['slot_times'].'</h6> <h6 class="user-name"><span class="text-muted">Profession:</span> '.$busDetails['profession'].'</h6> <h6 class="user-name"><span class="text-muted">Professional Name:</span> '.$busDetails['professional_name'].'</h6> </figcaption> </figure> </div>'; /*$explodetimes=explode(",",$v['slot_times']); $joinAppointment=False; for($g=0;$g<count($explodetimes);$g++) { $expTimes=explode("-",$explodetimes[$g]); if(date('H:i')>=$expTimes['0'] && $expTimes['1']>=date('H:i')) { $joinAppointment=TRUE; } }*/ //if($v['slot_date']==date('Y-m-d') && $v['booking_status']==4 && $joinAppointment) //else if($v['slot_date']==date('Y-m-d') && $v['booking_status']==4 && !$joinAppointment) if($v['slot_date']==date('Y-m-d') && $v['booking_status']==4) { //$data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"><button class="btn btn-primary appointment-btns w-50 p-1"><a href="../opentok_archive/web/index.php?joincall&id='.$videocon->encrypt_decrypt('encrypt',$_SESSION['id']).'" >Join Call</a></button></div> '; if($_SESSION['pid']==$v['business_id']) { $data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"> <button class="btn btn-sm btn-primary w-50"> <a href="javascript:void(0)" onclick="informToSubscriber(\''.$videocon->encrypt_decrypt('encrypt',$v['id']).'\',\''.$videocon->encrypt_decrypt('encrypt',$v['user_id']).'\', \''.$v['token'].'\',\''.$v['channel_name'].'\');" >Join Call</a> </button> <button class="btn btn-danger w-50 mt-3"> <a href="javascript:void(0)" onclick="return cancelconfirmed(\''.$videocon->encrypt_decrypt('encrypt',$v['id']).'\')" >Cancel</a> </button> </div> '; }else{ $data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"><button class="btn btn-sm btn-primary w-50"><a href="javascript:void(0)" onclick="return unauthorizedUser();">Join Call</a></button></div> '; } // btn btn-primary appointment-btns w-50 p-1 /* $data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"><a href="javascript:void(0);" class="btn btn-primary w-20">Join Call</a></div> '; */ } else if($v['slot_date']!=date('Y-m-d') && $v['slot_date']<date('Y-m-d') && $v['booking_status']==4) { $data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"><a href="javascript:void(0);" class="btn btn-primary w-20">Call Time Is Over</a></div> '; } else{ if($v['booking_status']==4){ $data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"> <button type="button" class="btn btn-sm btn-primary w-50">Accepted</button> <button class="btn btn-danger w-50 mt-3"> <a href="javascript:void(0)" onclick="return cancelconfirmed(\''.$videocon->encrypt_decrypt('encrypt',$v['id']).'\')" >Cancel</a> </button> </div>'; // appointment-btns } else { $data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"> <button type="button" class="btn bg-transparent btn-sm"><img class="img" src="img/accept.png" onclick="return bookingAccept(\''.$videocon->encrypt_decrypt('encrypt',$v['id']).'\')"/></button> <button type="button" class="btn bg-transparent btn-sm w-50 "><img class="img" src="img/cancel.png" onclick="return cancelconfirmed(\''.$videocon->encrypt_decrypt('encrypt',$v['id']).'\')" /></button> </div>'; // appointment-btns } } $data.='</div> </div>'; } else if($_REQUEST['type']==2) { $data.='<div class="container pb-1 pt-3"> <div class="row border-bottom my-0"> <div class="col-12 col-sm-12 col-md-6 col-lg-6"> <figure class="d-flex"> <small class="bg-secondary px-4 py-2 mr-3">'.$d1.' <br /> '.$d2.' <br /> '.$d3.'</small> <figcaption> <h6 class="user-name text-muted">'.$userDet['0']['fullname'].'</h6> <h6 class="user-name">'.date('M d, l',strtotime($v['slot_date'])).'</h6> <h6 class="user-name"><span class="text-muted">Slots Time:</span> '.trim($v['slot_times'],",").'</h6> </figcaption> </figure> </div>'; if($v['booking_status'] == 1 || $v['booking_status'] == 4) { $data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"> <button type="button" class="btn bg-transparent btn-sm"><img class="img" src="img/accept.png" />Time Expired</button> </div>'; } $data.=' <!--<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"> <button type="button" class="btn bg-transparent btn-sm"><img class="img" src="img/accept.png" /></button> <button type="button" class="btn bg-transparent btn-sm"><img class="img" src="img/cancel.png" /></button> <button type="button" class="btn bg-transparent btn-sm "><img class="img" src="img/reapply.png" /></button> </div>--> </div> </div>'; } else if($_REQUEST['type']==3) { $data.='<div class="container pb-1 pt-3"> <div class="row border-bottom my-0"> <div class="col-12 col-sm-12 col-md-6 col-lg-6"> <figure class="d-flex"> <small class="bg-secondary px-4 py-2 mr-3">'.$d1.' <br /> '.$d2.' <br /> '.$d3.'</small> <figcaption> <h6 class="user-name text-muted">'.$userDet['0']['fullname'].'</h6> <h6 class="user-name">'.date('M d, l',strtotime($v['slot_date'])).'</h6> <h6 class="user-name"><span class="text-muted">Slots Time:</span> '.$v['slot_times'].'</h6> </figcaption> </figure> </div>'; if($v['reschedule_booking_id']>0){ $data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"> <button class="btn btn-sm btn-primary w-50">Cancelled And Rescheduled</button> </div>'; // appointment-btns }else{ $data.='<div class="col-12 col-sm-12 col-md-6 col-lg-6 text-right py-4"> <button class="btn btn-sm btn-primary w-50">Cancelled</button> </div>'; // appointment-btns } $data.='</div> </div>'; } } } } echo $data; } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='bookingAccept') { $id=$videocon->encrypt_decrypt('decrypt',$_REQUEST['bid']); $token=$_REQUEST['agoratoken']; $name=$_REQUEST['channelName']; echo $acceptbybusiness=$videocon->acceptBooking($id, $token, $name); } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='cancelappointment') { $id=$videocon->encrypt_decrypt('decrypt',$_REQUEST['bid']); $cancelAppoint=$videocon->cancelAppointment($id); echo $cancelAppoint; } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='dashboard') { $fromdate = $_REQUEST['fromdate']; $todate = $_REQUEST['todate']; // echo $fromdate."<br>".$todate; $upcomingcnt = $videocon->upcomingCnt($fromdate,$todate); $completdCancelledCnt= $videocon->completdCancelledCnt($fromdate,$todate); // print_r($completdCancelledCnt);exit; $upcomingAmt=isset($upcomingcnt['totalamt'])?$upcomingcnt['totalamt']:0; $completedAmt=isset($completdCancelledCnt[2]['totalamt'])?$completdCancelledCnt[2]['totalamt']:0; $cancelledAmt=isset($completdCancelledCnt[3]['totalamt'])?$completdCancelledCnt[3]['totalamt']:0; $totalAmount = $upcomingAmt + $completedAmt + $cancelledAmt; $countUpcoming = $upcomingcnt['cnt']!=""?$upcomingcnt['cnt']:"0"; $completdCancelled2 = isset($completdCancelledCnt[2]['cnt'])?$completdCancelledCnt[2]['cnt']:"0"; $completdCancelledCnt3 = isset($completdCancelledCnt[3]['cnt'])?$completdCancelledCnt[3]['cnt']:"0"; $data='<div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title d-flex blue-Block pt-2 px-1"> <div class="icon"><img class="img dashboard-img1" src="img/users.png" /></div> <div class="name pt-2"> <h1 class="text-white stats-title">'.$countUpcoming.'</h1> <h6 class="text-white stats-subtitle pl-2">Upcoming</h6> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title d-flex pink-Block pt-2 px-1"> <div class="icon"><img class="img dashboard-img2" src="img/completed.png" /></div> <div class="name pt-2"> <h1 class="text-white stats-title">'.$completdCancelled2.'</h1> <h6 class="text-white stats-subtitle pl-2">Completed Appointments</h6> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title orange-Block d-flex pt-2 px-1"> <div class="icon"><img class="img dashboard-img3" src="img/cancelled.png" /></div> <div class="name pt-2"> <h1 class="text-white stats-title">'.$completdCancelledCnt3.'</h1> <h6 class="text-white stats-subtitle">Cancelled Appointments</h6> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title green-Block d-flex pt-2 px-1"> <div class="icon"><img class="img dashboard-img4" src="img/totalincome.png" /></div> <div class="name pt-2"> <!-- <h1 class="text-white stats-title">$25K</h1> --> <h1 class="text-white stats-title">'.$totalAmount.'</h1> <h6 class="text-white stats-subtitle">Total Income</h6> </div> </div> </div>'; echo $data; } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='joncalltonotify') { $bid=$videocon->encrypt_decrypt('decrypt',$_REQUEST['bid']); $uid=$videocon->encrypt_decrypt('decrypt',$_REQUEST['uid']); $bookingDet=$videocon->getUserTransactionDet('',$bid); $userDet = $videocon->getUsers('id',$bookingDet['user_id']); if($userDet[0]['status'] == 0 || $userDet[0]['delete_status'] == 0 ){ echo 2;exit; } $exptime=explode(",",$bookingDet['slot_times']); $existstatus=False; for($i=0;$i<count($exptime);$i++) { $spttime=explode('-',$exptime[$i]); if(date('H:i')>=$spttime[0] && $spttime[1]>=date('H:i')){ $existstatus=TRUE; break; } } if($existstatus) { $getUserProfConnection =$videocon->getUserProfConnection($bid,$uid); if(is_array($getUserProfConnection) && count($getUserProfConnection)>0 && $getUserProfConnection['redirect_url']!='') { echo $getUserProfConnection['redirect_url']; }else{ echo 1; } }else{ echo $existstatus; } //echo $saveNotify=$videocon->saveNotification($bid,$uid); //$notifyToUser=$videocon->notifyToSubscriber() } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='getnotifications') { $array=array(); $rows=array(); $notifList = $videocon->listNotificationUser($_SESSION['pid'],'','PushPrompt'); $record = 0; foreach ($notifList as $key){ if($key['redirect_url'] == '' || $key['redirect_url'] == NULL || $key['redirect_url'] == null ) { $key['redirect_url']='professional/appointment.php'; } $data['title'] = $key['title']; $data['msg'] = $key['message']; $data['icon'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?"https" : "http") . "://" . $_SERVER['HTTP_HOST'] .'/videoconsultation_web/img/logo1.png'; $data['url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?"https" : "http") . "://" . $_SERVER['HTTP_HOST'] .'/videoconsultation_web/'.str_replace("../","",$key['redirect_url']); $data['id'] = $key['id']; $rows[] = $data; } $array['notif'] = $rows; $array['result'] = true; // $users->updateNotificationUser($_SESSION['id']); echo json_encode($array); } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='updatenotificationid1') { echo $notifList = $videocon->UpdatePushPrompt1($_REQUEST['notifyid']); } /*else if(isset($_REQUEST['action']) && $_REQUEST['action']=='updatenotificationid') { echo $notifList = $users->UpdatePushPrompt($_REQUEST['notifyid']); }*/ else if(isset($_REQUEST['action']) && $_REQUEST['action']=="usernotifications") { $minValue = isset($_REQUEST["min"])?$_REQUEST["min"]:0; $maxValue = 10; $notifications=$videocon->listNotificationUser($_SESSION['pid'],'read','',$minValue,$maxValue); $data=''; $i=0; foreach($notifications as $k=>$v){ $minValue++; $slotID=''; if($v['notification_type'] ==2 || $v['notification_type'] ==4) { $slotID ='?slotid=3'; } if($v['redirect_url'] == '') { $v['redirect_url']='/professional/appointment.php'; } $url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?"https" : "http") . "://" . $_SERVER['HTTP_HOST'] .'/videoconsultation_web'.$v['redirect_url'].$slotID; $data.='<div class="row flex-nowrap m-0" > <span> '.$minValue.'.</span> <span><a href=" '.$url.'" class="text-primary d-flex"><p class="pl-3"> '.$v['message'].'</a></p></span> </div>'; } echo $data; } else if(isset($_REQUEST['action']) && $_REQUEST['action']=="unreadnotifications") { $notifications = $videocon->listNotificationUser($_SESSION['pid']); $count = count($notifications); $data1=''; $data2=''; $data1=$count; foreach($notifications as $k=>$v){ if($v['redirect_url'] == '') { $v['redirect_url']='/professional/appointment.php'; } $url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?"https" : "http") . "://" . $_SERVER['HTTP_HOST'] .'/videoconsultation_web'.$v['redirect_url']; $data2.='<li> <a rel="nofollow" href='.$url.' class="dropdown-item"> <div class="notification d-flex justify-content-between"> <div class="notification-content"><i class="fa fa-envelope"></i>'.$v['message'].'</div> <div class="notification-time"><small>'.$v['time'].'</small></div> </div> </a> </li>'; } $data2.='<li> <a rel="nofollow" href="userNotifications.php" class="dropdown-item all-notifications text-center"> <strong> <i class="fa fa-bell"></i>view all notifications </strong></a> </li>'; echo $data1."#####".$data2; } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='blkunblkBusiness') { $statusUpdate=$videocon->businessUpdateStatus($_REQUEST['bid'],$_REQUEST['status']); echo $statusUpdate; } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='bookingCompleted'){ $bookingUpdate=$videocon->bookingCompleted($_REQUEST['bid']); echo $bookingUpdate; } else if(isset($_REQUEST['action']) && $_REQUEST['action']=='updateAvailability'){ $updateAvailability=$videocon->updateProfessionalAvailability($_REQUEST['pid'],$_REQUEST['availability']); echo $updateAvailability; } ?>