• Resolved jiggaman

    (@jiggaman)


    This was previously working 4 versions ago, did the upgrade and found I can no longer view the staff members.

    Upon reviewing the file: admin/scripts/admin.js, found the function:

    function bup_load_staff_details

    Is referring to:

    “action”: “bup_get_staff_details_admin”,

    but the function bup_get_staff_details_admin is nowhere to be found…reviewing your old code you named it: ubp_get_staff_details_admin

    So thats worth testing…

    Me fixing that still doesnt fix the issue. I am getting an error in the function:

    function bup_load_staff_member
    in the line
    jQuery.post(ajaxurl, {

    its showing an error in my browser inspector.
    not sure why…..are you seeing this?

    https://www.ads-software.com/plugins/booking-ultra-pro/

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter jiggaman

    (@jiggaman)

    So fixing your function: function bup_load_staff_details

    jQuery.ajax({
                    type: 'POST',
                    url: ajaxurl,
                    data: {
                            "action": "udp_get_staff_details_ajax",
                            "staff_id": staff_id
                    },
                    success: function(response){
                            alert(response);
                            jQuery("#bup-staff-details" ).html( response );
                            bup_rebuild_dom_date_picker();
                            jQuery("#bup-spinner").hide();
                    }
            });

    Gets rid of the error…but this isn’t returning any data other than 0 in the response…so…something is wrong here as well.

    Thread Starter jiggaman

    (@jiggaman)

    Actually never mind, i misspelled the function in the action, once i fixed the function same issue.

    Using ngnix, u seeing the error too?

    Please open a ticket here https://bookingultrapro.com/contact.php

    We will be glad to troubleshot it.

    BTW: bup_get_staff_details_admin is an AJAX reference, not a function.

    We look forward to hearing from you.

    Cheers

    Thread Starter jiggaman

    (@jiggaman)

    I don’t think you read emails. Now realizing you haven’t fixed the bugs i had previously emailed you back on version 1.0.18 for the booking pro compliment…fudge man.

    test this scenario: a person using your plugin WITHOUT google calendar and having the compliment plugin…errors.

    you need to make tests for that.

    example of a fix, in your compliment plugin, the function “public function get_auth_url()”

    you have:
    if (file_exists( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php'))

    However this needs to be checked something like this:

    $client_id = $bookingultrapro->get_option('google_calendar_client_id');
    $client_secret = $bookingultrapro->get_option('google_calendar_client_secret');
    if (file_exists( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php') && $client_id && $client_secret)

    So…lets get things locked down please.

    Thanks!

    Thread Starter jiggaman

    (@jiggaman)

    (note that is not the only fix necessary to make the check)

    Thread Starter jiggaman

    (@jiggaman)

    (sorry to have sounds harsh, i do appreciate the work you have done)

    Thread Starter jiggaman

    (@jiggaman)

    fixes I have made for you in the compliment plugin, please review where the word “ben” is, hope that helps get things fixed up more rapidly, thank you.

    in the file: classes/bup.complement.googlecalendar.class.php

    <?php
    class BupComplementGoogleCalendar
    {
    
    	public function __construct()
    	{
    
    		// Load Stripe library
    		$this->load_library();
    
        }
    
    	public function load_library()
    	{
    
    		//require_once( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php' );
    
    	}
    
    	public function get_auth_url()
    	{
    		global $bookingultrapro;
    
    		$client_id = $bookingultrapro->get_option('google_calendar_client_id'); // ben
    		$client_secret = $bookingultrapro->get_option('google_calendar_client_secret');// ben
    
    		if (file_exists( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php') && $client_id && $client_secret)// ben //if (file_exists( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php'))
    		{
    			require_once( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php' );	
    
    			$redirect_url = get_admin_url().'admin.php?page=bookingultra&tab=users';
    
    			// ben // $client_id = $bookingultrapro->get_option('google_calendar_client_id');
    			// ben // $client_secret = $bookingultrapro->get_option('google_calendar_client_secret');
    
    			$client = new Google_Client();
    			$client->setApplicationName("Google Calendar Application");
    			$client->setClientId($client_id);
    			$client->setClientSecret($client_secret);
    			$client->setRedirectUri($redirect_url);
    			$client->setAccessType('offline');
    			$client->setApprovalPrompt('force');
    			$client->setScopes(array('https://www.googleapis.com/auth/calendar'));
    			//$cal = new Google_CalendarService($client);
    			$authUrl = $client->createAuthUrl();
    
    		}	
    
    		return $authUrl;
    
    	}
    
    	public function auth_client_with_code($code, $current_staff_id=NULL)
    	{
    		global $bookingultrapro;
    
    		if (file_exists( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php'))
    		{
    			require_once( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php' );	
    
    			$redirect_url = get_admin_url().'admin.php?page=bookingultra&tab=users';
    
    			$client_id = $bookingultrapro->get_option('google_calendar_client_id');
    			$client_secret = $bookingultrapro->get_option('google_calendar_client_secret');
    
    			$client = new Google_Client();
    			$client->setApplicationName("Google Calendar Application");
    			$client->setClientId($client_id);
    			$client->setClientSecret($client_secret);
    			$client->setRedirectUri($redirect_url);
    			$client->setAccessType('offline');
    			$client->setApprovalPrompt('force');
    			$client->setScopes(array('https://www.googleapis.com/auth/calendar'));
    			$credentials = $client->authenticate($code); 
    
    			$access_token = $client->getAccessToken();
    
    		  	// Refresh the token if it's expired.
    		    if ($client->isAccessTokenExpired())
    		    {
    			 // $client->refreshToken($client->getRefreshToken());
    
    		    }
    			//echo "access token :" . $access_token;
    
    			update_user_meta ($current_staff_id, 'google_cal_access_token', $access_token);	
    
    		}	
    
    		return $client;
    
    	}
    
    	public function create_event($booking_id,$order_data)
    	{
    		global $bookingultrapro;
    
    		extract($order_data);
    
    		$time_from = $day.' '.$time_from.':00';
    		$time_to = $day.' '.$time_to.':00';
    
    		if (file_exists( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php'))
    		{
    			require_once( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php' );	
    
    			$redirect_url = get_admin_url().'admin.php?page=bookingultra&tab=users';
    
    			$client_id = $bookingultrapro->get_option('google_calendar_client_id');
    			$client_secret = $bookingultrapro->get_option('google_calendar_client_secret');
    
    			$client = new Google_Client();
    			$client->setApplicationName("Google Calendar Application");
    			$client->setClientId($client_id);
    			$client->setClientSecret($client_secret);
    			$client->setRedirectUri($redirect_url);
    			$client->setAccessType('offline');
    			$client->setApprovalPrompt('force');
    			$client->setScopes(array('https://www.googleapis.com/auth/calendar'));
    
    			//get client access token
    			$accessToken = $bookingultrapro->bup_get_user_meta($staff_id, 'google_cal_access_token');			
    
    			if($accessToken!='') //get auth url
    			{
    
    				$client->setAccessToken($accessToken);
    
    				// Refresh the token if it's expired.
    				if ($client->isAccessTokenExpired())
    				{
    					$client->refreshToken($client->getRefreshToken());
    					update_user_meta ($staff_id, 'google_cal_access_token', $client->getAccessToken());
    				 }
    
    				 //let's create the event.
    				 $service = new Google_Service_Calendar($client);
    
    				 $calendar_id = 'primary';
    				 $time_zone_string = get_option('timezone_string');	
    
    				 $sumary = 	$this->get_google_cal_sumary($service_id, $staff_id , $user_id);
    				 $description = 	$this->get_google_cal_description($service_id, $staff_id , $user_id, $booking_id, $time_from); 
    
    				 $event_data = array(
    							  'summary' => $sumary,
    							  'description' => $description,
    							  'start' => array(
    								'dateTime' => $this->get_google_cal_date_format($time_from),
    								'timeZone' => $time_zone_string,
    							  ),
    							  'end' => array(
    								'dateTime' => $this->get_google_cal_date_format($time_to),
    								'timeZone' => $time_zone_string,
    							  ));
    
    				 $event = new Google_Service_Calendar_Event($event_data);				 
    
    				 try {
    
    					$new_event = $service->events->insert($calendar_id, $event);
    					$new_event_id= $new_event->getId();
    					$bookingultrapro->appointment->update_booking_meta($booking_id, 'google_event_id', $new_event_id);
    
    					//if($bookingultrapro->get_option('google_calendar_debug') == 'yes'){
    
    					//	print_r($new_event);
    						//exit();
    
    					 //}
    
    				 } catch (Google_Service_Exception $e) {
    
    					$err_message = $e->getMessage();
    
    					if($bookingultrapro->get_option('google_calendar_debug') == 'yes'){
    
    						print_r($err_message);
    						exit();
    
    					 }
    				 }
    
    			} //end if user access token
    
    		}	
    
    		return $err_message;
    
    	}
    
    	public function get_google_cal_date_format($date)
    	{
    		global $bookingultrapro;
    
    		//2015-05-28T17:00:00-07:00
    		$d_date = date('Y-m-d', strtotime($date));
    		$d_time = date('H:i:s', strtotime($date));
    
    		return $d_date.'T'.$d_time ;
    
    	}
    
    	public function get_google_cal_description($service_id, $staff_id , $user_id, $booking_id, $date_from)
    	{
    		global $bookingultrapro;
    
    		$service = $bookingultrapro->service->get_one_service($service_id);
    		$staff_member = get_user_by( 'id', $staff_id );
    		$client = get_user_by( 'id', $user_id );
    
    		$time_format = $bookingultrapro->service->get_time_format();		
    
    		$from_at = date($time_format, strtotime($date_from));
    		$from_date = $bookingultrapro->commmonmethods->formatDate($date_from);
    
    		$html = $service->service_title.  __(' by ', 'bookingup').$staff_member->display_name.  __(' at ', 'bookingup'). $from_at. __(' on ', 'bookingup') . $from_date;
    
    		return $html ;
    
    	}
    
    	public function get_google_cal_sumary($service_id, $staff_id , $user_id)
    	{
    		global $bookingultrapro;
    
    		$template = $bookingultrapro->get_option('google_calendar_template');
    
    		$html ='';
    
    		if($template=='service_name' || $template=='')
    		{
    			$service = $bookingultrapro->service->get_one_service($service_id);
    			$html = $service->service_title;
    
    		}elseif($template=='staff_name'){
    
    			$staff_member = get_user_by( 'id', $staff_id );
    			$html = $staff_member->display_name;
    
    		}elseif($template=='client_name'){
    
    			$client = get_user_by( 'id', $user_id );
    			$html = $client->display_name;
    
    		}
    
    		return $html ;
    
    	}
    
    	public function get_user_auth_status($staff_id)
    	{
    		global $bookingultrapro;
    
    		$html = '';
    
    		//get client access token
    		$accessToken = $bookingultrapro->bup_get_user_meta($staff_id, 'google_cal_access_token');
    
    		$client_id = $bookingultrapro->get_option('google_calendar_client_id'); // ben
    		$client_secret = $bookingultrapro->get_option('google_calendar_client_secret');// ben
    		if(!$client_id && !$client_secret) { // ben
    			$html = Null; // ben
    		} else	// ben
    		if($accessToken=='') //get auth url
    		{
    
    			$auth_url = $this->get_auth_url();
    			$html = "<p><a href='$auth_url'>".__('Connect Me!','bookingup')."</a></p>";		
    
    		}else{
    
    			$html = "<p>".__('Already Connected!','bookingup')."</p>";
    
    		}
    
    		return $html;
    
    	}
    
    }
    $key = "googlecalendar";
    $this->{$key} = new BupComplementGoogleCalendar();
    ?>

    @jiggaman,

    Thanks for your post.

    I highly appreciate your suggestions. This topic contains different issues. if yo have a suggestion about a feature that belongs o the pro version this is not the place to take care of it. WordPress allows us to offer support for the free version only.

    As for this:

    I don’t think you read emails. Now realizing you haven’t fixed the bugs i had previously emailed you back on version 1.0.18 for the booking pro compliment…fudge man.

    Well, we reply to all emails and we’re sorry if you didn’t see implemented the bugs you’re reported.

    Where you able to resolve the issue “Can’t display staff members on admin page anymore”, this version has been online for about 3 weeks and we didn’t get a report about it.

    Admin members are loaded by using AJAX, perhaps, there is a JS error in your admin triggered by a third-party plugin.

    I will reply separately for the suggestion you’ve posted for the Google Calendar.

    Cheers

    @jiggaman,,

    Once again, thanks for the suggestion for the Google Calendar Implementation.

    Actually, that’s already handled on bookingultra.register.php.

    The “create_event” function is called only when a booking is submitted. This happens only on register class.

    We’re using the following code:

    $google_client_id = $bookingultrapro->get_option(‘google_calendar_client_id’);
    $google_client_secret = $bookingultrapro->get_option(‘google_calendar_client_secret’);

    //google calendar
    if(isset($bupcomplement) && $google_client_id!=” && $google_client_secret!=” )
    {

    $bupcomplement->googlecalendar->create_event($booking_id,$order_data);

    }

    There is no need to double check for google credentials. Actually, what you’re kindly suggesting is double query the database, every time you use the get_option function, this is a SQL query which overloads the MySQL server.

    In few words, the suggestions you’re mentioning are already controlled in the core plugin, which is the free version, there is where we control for client ID and client Secret. So.. this is not a bug.

    Once again, i would like to thank you for the time you’ve spent to post your suggestion on this forum. We listen to all our users and you can rest assured, everything is already controlled on the core plugin.

    I look forward to hearing from you about the issue you’re mentioning on the subject of this post.

    Have a great start of week.

    Cheers

    Thread Starter jiggaman

    (@jiggaman)

    Just to be clear…are u testing this in the scenario where the user has not entered google cal credentials.

    In addition what if another plugin is also making use of the google cal library?

    Here is the scenario I am seeing play out when attempting to load a staff member’s admin data to be edited for hour and availability:
    the function:
    public function get_user_auth_status($staff_id)
    is called. Since the user has no credentials, $accessToken will be null.
    Which then calls the function:
    get_auth_url()
    Then inside get_auth_url()

    you only check for:

    if (file_exists( bookingup_comp_path . 'libs/google-api-php-client/src/Google/autoload.php')

    Then you proceed to do the $client = new Google_Client(); and all the other google stuff when there is no client_id ect etc causing an error….are you not seeing this…?

    Thread Starter jiggaman

    (@jiggaman)

    If you don’t believe this code is running, in the function:
    public function get_user_auth_status($staff_id)

    Add the following line of code:
    echo "<script>console.log('poop');</script>";

    You will indeed see this message in the console every time you select a staff user.

    @plugins Area with regards too
    “Where you able to resolve the issue “Can’t display staff members on admin page anymore”, this version has been online for about 3 weeks and we didn’t get a report about it.”

    I have too had this problem of not being able to display staff. I was not sure what caused it and as I was only just starting to play around with the plugin There probably an easier way to fix it but i just uninstalled wordpress and reinstalled wordpress from scratch and added the plugin. It was a pain going through and adding all of the staff and services again but it was a testing installation so there was no real loss except for time.

    @plugins Area with regards too
    “WordPress allows us to offer support for the free version only.”
    can you setup a forum on your site for the paid version so users can contribute/seek help from other users.

    Thread Starter jiggaman

    (@jiggaman)

    @cobolt78 my modifications address some of the issue, so try that out and tell me what happens.

    @jiggaman,

    Thanks for your post and suggestions.

    You are right, we’re implementing the improvements you’ve suggested.

    Once again, thanks for your cooperation.

    Cheers

    The new version is up an ready to download.

    Thanks for all your cooperation.

    Cheers

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘BUG: Can't display staff members on admin page anymore’ is closed to new replies.