Calendar'; $menu.='
  • List of Appoinments
  • '; $menu.='
  • Add Appointment
  • '; //menu.='
  • Setting
  • '; //$menu.='
  • Templates
  • '; return $menu; } public function status() { return array('Pending','Approved','Rejected','Completed'); } public function check_page() { if(isset($_REQUEST['page']) && $_REQUEST['page'] == "Test-class" && $_REQUEST['new']=="") { require_once dirname(__FILE__).'/admin/calendar.php'; } if(isset($_REQUEST['page']) && $_REQUEST['page'] == "Test-class" && $_REQUEST['new']=="calendar.php") { require_once dirname(__FILE__).'/admin/calendar.php'; } if(isset($_REQUEST['page']) && $_REQUEST['page'] == "Test-class" && $_REQUEST['new']=="list_appointments.php") { require_once dirname(__FILE__).'/admin/list_appointments.php'; //unset($_REQUEST['google']); } if(isset($_REQUEST['page']) && $_REQUEST['page'] == "Test-class" && $_REQUEST['new']=="appointment.php") { require_once dirname(__FILE__).'/admin/appointment.php'; } /*if(isset($_REQUEST['page']) && $_REQUEST['page'] == "Test-class" && $_REQUEST['new']=="approval.php") { require_once dirname(__FILE__).'/admin/approval.php'; } if(isset($_REQUEST['page']) && $_REQUEST['page'] == "Test-class" && $_REQUEST['new']=="rejection.php") { require_once dirname(__FILE__).'/admin/rejection.php'; }*/ /*if(isset($_REQUEST['page']) && $_REQUEST['page'] == "Test-class" && $_REQUEST['new']=="setting.php") { require_once dirname(dirname(__FILE__)).'/setting.php'; }*/ /*if(isset($_REQUEST['page']) && $_REQUEST['page'] == "Test-class" && $_REQUEST['new']=="email-template.php") { require_once dirname(__FILE__).'/admin/email-template.php'; }*/ } public function wpb_recently_registered_users() { //phpinfo(); global $wpdb; /*$user_meta = get_user_meta(53); var_dump($user_meta);*/ $blogusers = get_users( 'blog_id=1&orderby=ID&role=subscriber' ); // Array of WP_User objects. //$recentusers = 'style="float: left;width: 100%;height: auto; ">'; $recentusers .= ''; $recentusers .= 'User_IDProfile imageNameE-mailRoleAction'; foreach ( $blogusers as $user ) { $user_info = get_userdata($user->ID); //echo 'User roles: ' . implode(', ', $user_info->roles) . "\n"; $recentusers .= ''; $recentusers .= ''; $recentusers .= esc_html( $user->ID ).''; $recentusers .= ''.get_avatar($user->user_email, 45).''; $recentusers .= ''.esc_html( $user->display_name ).''; $recentusers .= ''.esc_html( $user->user_email ).''; $recentusers .= ''.esc_html( implode(', ', $user_info->roles) ).''; //$recentusers .= ''.esc_html( $user->display_name ); $recentusers .= 'Remove'; $recentusers .= ''; $recentusers .= ''; //$recentusers .= '
  • ' .get_avatar($user->user_email, 45) .esc_html( $user->display_name ).' Remove
  • '; } $recentusers .= ''; //$recentusers .= ''; if($blogusers==NULL){ _e('*No users registered!','appointments'); } return $recentusers; } public function remove_logged_in_user() { if(isset($_REQUEST['id'])) { global $wpdb; $link=explode("&",$_SERVER['REQUEST_URI']); $id=$_REQUEST['id']; $table = $wpdb->prefix."users"; $r = $wpdb->delete( $table, array( 'ID' => $id ), array( '%d') ); //wp_redirect(admin_url().'admin.php?page=usermanage-page'); echo ''; } } /*public function manage_appointments(){ global $wpdb; $html; $table_name = $wpdb->prefix . 'Appointments'; $user=get_userdata(1); $id=$user->ID; if(is_admin()){ $data=$wpdb->get_results($wpdb->prepare("SELECT * from $table_name where status=%d",0)); $rows=count($data); if($rows>0) { $html.=''; $html.=''; foreach($data as $key => $val){ $st=$val->status; $html.=''; } } else { echo "* No records not found..."; } } $html.='
    ID Name of Appointments Date of Appointments Email Userid Options
    '.$val->appointment_id.' '.$val->appointment_name.' '.$val->date_of_apointment.' '.$val->email_id.' '.$val->user_id.' Approve Reject
    '; return $html; }*/ /*public function approval_request() { extract($_REQUEST); global $wpdb; $tablename=$wpdb->prefix. 'Appointments'; $tb=$wpdb->prefix.'events'; $query=$wpdb->query("Update $tablename SET `status`='1' where appointment_id='".$apid."'"); $qr=$wpdb->query("Update $tb SET `status`='1' where appointment_id='".$apid."'"); if($query==true && $qr==true){ require_once dirname(__FILE__).'/templates/appointment_approval(admin).php'; echo ''; } else{ echo "error"; exit(); } }*/ /*public function rejection_request() { extract($_REQUEST); global $wpdb; $tablename=$wpdb->prefix. 'Appointments'; $tb=$wpdb->prefix.'events'; $query=$wpdb->query("Update $tablename SET `status`='2' where appointment_id='".$apid."'"); $qr=$wpdb->query("Update $tb SET `status`='2' where appointment_id='".$apid."'"); if($query==true && $qr==true){ require_once dirname(__FILE__).'/templates/appointment_delete(admin).php'; echo ''; } else{ echo "error"; exit(); } }*/ public function calendar_events() { global $wpdb; $userid=get_current_user_id(); // Current user id //$tb= $wpdb->prefix.'events'; $table= $wpdb->prefix.'Appointments'; // Execute the query $resultat = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table WHERE status not in('%s')",'Rejected')); // sending the encoded result to success page $data=json_encode($resultat); return $data; } public function frontcal_events() { global $wpdb; $tb= $wpdb->prefix.'events'; $table= $wpdb->prefix.'Appointments'; $userid=get_current_user_id(); // Current user id // Execute the query $resultat = $wpdb->get_results($wpdb->prepare("SELECT start,title from $table where status not in('%s') and user_id ='%d'",'Rejected',$userid)); // sending the encoded result to success page $data=json_encode($resultat); return $data; } public function cal_event() { global $wpdb; $admin_email = get_option( 'email_address' ); // Get admin email address $table_name = $wpdb->prefix.'Appointments'; // $tb= $wpdb->prefix.'events'; $total=$this->options['booking_perday']; $url=admin_url().'admin.php?page=Test-class'; //$id=get_current_user_id(); /* Get current user id*/ extract($_POST); // Convert html input name as a variable //$dat=date('Y-m-d',strtotime($start)); if ( current_user_can( 'administrator' ) ) { $id=get_current_user_id(); /* Get current user id*/ $abc=$wpdb->get_var("SELECT count(start) from $table_name WHERE start='".$start."'"); if($abc>=$total){ echo "* You can book only {$total} events on particular date!"; exit(); } else{ $wpdb->query($wpdb->prepare( "INSERT INTO $table_name(title,start,email,phone,user_id,status) VALUES (%s,%s,%s,%s,%d,%s) ", $title,$start,$admin_email,NULL,$id,'Approved' )); $lastid=$wpdb->insert_id; // Get last insert id $URL=$url."&new=list_appointments.php&app_id=".$lastid."&userid=".$id; $status=$wpdb->update($table_name,array('url'=>$URL), array('app_id'=>$lastid), array('%s'), array('%d') ); if($status) { echo "* New appointment added! "; } else { echo "* Something going wrong! "; exit(); } die(); } } } public function appointments_list() { //$admin=get_super_admins()); global $wpdb,$html; $table_name = $wpdb->prefix . 'Appointments'; //$tb=$wpdb->prefix.'events'; if(is_admin()){ //$userid=get_current_user_id(); $data=$wpdb->get_results($wpdb->prepare("Select * from $table_name",NULL)); $rows=count($data); if($rows>0) { $html.='
    '; $html.=''; foreach($data as $key => $val){ $data = get_userdata($val->user_id); $email = $data->user_email; $st=$val->status; //die("hello"); if(isset($_REQUEST['app_id']) && $_REQUEST['app_id']==$val->app_id) { $html.=''; $html.=''; $html.=''; $html.=''; } else{ $html.=''; $html.=''; } } } else { $html.=""; } $html.='
    ID Name of Appointments Date of Appointments Email Userid Phone Status Options
    '.$_REQUEST['app_id'].' '.$val->user_id.' '.$val->phone.'
    '.$val->app_id.' '.$val->title.' '.$val->start.' '.$email.' '.$val->user_id.' '.$val->phone.''; if($st == "Pending"){$html.='';} if($st == "Approved"){$html.='';} if($st == "Rejected"){$html.='';} if($st == "Completed"){$html.='';} $html.=''; $html.="app_id."&userid=".$val->user_id." class='button-primary'>Edit"; '
    '; $html.='
    '; } return $html; } public function action() { global $wpdb; $table_name = $wpdb->prefix . 'Appointments'; //$tb=$wpdb->prefix.'events'; $a=$_SERVER['REQUEST_URI']; $sb= explode("&", $a); //die("hello"); extract($_REQUEST); $total=$this->options['booking_perday']; // Total no of events perday booked if(isset($ebtnup)) { //die("hhh"); $e_id=$_REQUEST['app_id']; $name=trim($_REQUEST['txteappname']); $dt=date('Y-m-d',strtotime(trim($_REQUEST['txtedate']))); $em=trim($_REQUEST['txteemail']); // die($dt); $ph=trim($_REQUEST['txtephone']); $uid=trim($_REQUEST['txtuid']); $status = $_REQUEST['estatus']; if($dt* Date must be today or grater than today date!

    "; exit(); } if(!preg_match("/^[a-zA-Z -]+$/", $name)){ /* match only string not numeric value */ echo "

    * Number not alowed!

    "; exit(); } $abc=$wpdb->get_var("SELECT count(start) from $table_name WHERE start='".$dt."'"); if($abc>=$total){ echo "

    * You can book only {$total} events on particular date!

    "; exit(); } else { //die("come"); $query=$wpdb->update($table_name,array('title'=>trim($name),'start'=>$dt,'email'=>$em,'status'=>$status), array('app_id'=>$e_id,'user_id'=>$uid), array('%s','%s','%s','%s'), array('%d','%d') ); if($query==true) { if($status=='Approved') { require_once dirname(__FILE__).'/templates/appointment_approval(user).php'; require_once dirname(__FILE__).'/templates/appointment_approval(admin).php'; } if($status == "Rejected") { require_once dirname(__FILE__).'/templates/appointment_delete(admin).php'; } require_once dirname(__FILE__).'/templates/appointment_update(admin).php'; print ""; print ''; // wp_redirect(admin_url().'admin.php?page=Test-class&new=list_appointments.php'); } else{ print ''; } } } if(isset($ebtncan)) { print ''; exit(); } } public function frontappointments_list() { global $wpdb,$html; $table_name = $wpdb->prefix . 'Appointments'; // $tb=$wpdb->prefix.'events'; // $userid=get_current_user_id(); $url=$_SERVER['REDIRECT_URL']; $a=explode("/", $url); // print_r($_SERVER); if(is_user_logged_in()) { $userid=get_current_user_id(); $userdata = get_userdata($userid); $email = $userdata->user_email; $data=$wpdb->get_results($wpdb->prepare("SELECT * from $table_name where user_id=%d",$userid)); $rows=count($data); if($rows>0) { //echo "
    ";
    	      //print_r($_SERVER);
    	  $html.='
    '; $html.=''; foreach($data as $key => $val){ $st=$val->status; if(isset($_REQUEST['appid']) && $_REQUEST['appid']==$val->app_id) { $id=$_REQUEST['appid']; $html.=''; $html.=''; } else{ $html.=''; $html.=''; $html.=''; } } } else { echo "* No records found!"; exit(); } } $html.='
    ID Name of Appointments Date of Appointments Email Phone Status Options
    '.$val->app_id.' '; if($st=='Pending'){$html.='Pending';} if($st=='Approved'){$html.='Approved';} if($st=='Rejected'){$html.='Rejected';} if($st=='Completed'){$html.='Completed';} $html.='
    '.$val->app_id.' '.$val->title.' '.$val->start.' '.$email.' '.$val->phone.''; if($st=='Pending'){$html.='Pending';} elseif($st=='Approved'){$html.='Approved';} elseif($st=='Rejected'){$html.='Rejected';} elseif($st=='Completed'){$html.='Completed';} $html.=''; if($st!='Rejected') { $html.='Edit |'; $html.='Delete'; } $html.='
    '; $html.='
    '; return $html; } public function manage_front_action() { global $wpdb; $table_name = $wpdb->prefix . 'Appointments'; //$tb=$wpdb->prefix.'events'; $a=$_SERVER['REQUEST_URI']; // die($a); $sb= explode("?", $a); if(is_user_logged_in()){ if(isset($_REQUEST['apid'])){ //require_once dirname(__FILE__).'/templates/appointment_delete(user).php'; $id=$_REQUEST['apid']; $userid=get_current_user_id(); $url=$_SERVER['REQUEST_URI']; $arr=explode("&", $url); $res=$wpdb->update($table_name,array('status'=>'Rejected'), array('app_id'=>$id,'user_id'=>$userid), array('%s'), array('%d','%d') ); if($res==true){ require_once dirname(__FILE__).'/templates/appointment_delete(user).php'; echo ''; } } if(isset($_REQUEST['btnup'])){ $userid=get_current_user_id(); $total=$this->options['booking_perday']; // Total no of events perday booked $e_id=$_REQUEST['txtid']; $name=trim($_REQUEST['txteappname']); $dt=date('Y-m-d',strtotime(trim($_REQUEST['txtedate']))); // die($dt); $em=trim($_REQUEST['txteemail']); $ph=trim($_REQUEST['txtephone']); // die($e_id); if($dt* Date must be today or grater than today date!

    "; exit(); } if(!preg_match("/^[a-zA-Z -]+$/", $name)){ /* match only string not numeric value */ echo "

    * Number not alowed!

    "; exit(); } $abc=$wpdb->get_var("SELECT count(start) from $table_name WHERE start='".$dt."' and user_id='$userid'"); if($abc>=$total){ echo "

    * You can book only {$total} events on particular date!

    "; exit(); } else { $udata = wp_update_user( array( 'ID' => $userid, 'user_email' => $em ) ); $query=$wpdb->update($table_name,array('title'=>trim($name),'start'=>$dt,'email'=>sanitize_email($em),'phone'=>trim($ph)), array('app_id'=>$e_id,'user_id'=>$userid), array('%s','%s','%s','%s'), array('%d','%d') ); if($query==true && $udata==true){ require_once dirname(__FILE__).'/templates/appointment_update(user).php'; print ""; print ''; } else{ print ''; } } } if(isset($_REQUEST['btncan'])) // Redirect to page { print ''; exit(); } } } public function user_validation($username, $password, $email, $first_name, $last_name, $nickname, $bio) { global $reg_errors,$html; extract($_POST); $reg_errors = new WP_Error; if ( isset($register) ) { if ( empty( $username ) || empty( $password ) || empty( $email ) ) { $reg_errors->add('field', 'Required form field is missing'); } if ( 4 > strlen( $username ) ) { $reg_errors->add( 'username_length', 'Username too short. At least 4 characters is required' ); } if ( username_exists( $username ) ){ $reg_errors->add('user_name', 'Sorry, that username already exists!'); } if ( ! validate_username( $username ) ) { $reg_errors->add( 'username_invalid', 'Sorry, the username you entered is not valid' ); } if ( 5 > strlen( $password ) ) { $reg_errors->add( 'password', 'Password length must be greater than 5' ); } if ( !is_email( $email ) ) { $reg_errors->add( 'email_invalid', 'Email is not valid' ); } if ( email_exists( $email ) ) { $reg_errors->add( 'email', 'Email Already in use' ); } if ( is_wp_error( $reg_errors ) ) { foreach ( $reg_errors->get_error_messages() as $error ) { echo '
    '; echo 'ERROR:'; echo $error . '
    '; echo '
    '; } } } } public function confirm_mail($email,$admin_email,$userid) { $img = $this->options['upload_image']; $data = get_userdata($userid); $username = $data->user_firstname; //echo "user = ".$username; $to = $email; $from = $admin_email; $subject = "Confirmation mail"; $content = '