Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appointment creation in Google calendar #1399

Open
JiroMusik opened this issue Aug 17, 2023 · 11 comments
Open

Appointment creation in Google calendar #1399

JiroMusik opened this issue Aug 17, 2023 · 11 comments

Comments

@JiroMusik
Copy link

Hi guys,

is there any way to integrate the sync with Events created in Google Calendar?
So when I create an event that does not match all required fields, the sync will not finish and shows an error message.
Is there any way to set default options for all required fields?

Thanks
jiromusik

@alextselegidis
Copy link
Owner

Hello!

There is currently already two way sync support with Google Calendar.

Which error are you getting during syncing?

Alex Tselegidis, Easy!Appointments Creator
Need a customization? Get a free quote!

@JiroMusik
Copy link
Author

JiroMusik commented Aug 24, 2023

Only when there are new events created through Google Calendar there is following message:
Client error: POST https://oauth2.googleapis.com/token/ resulted in a 400 Bad Request
response: {"error":"invalid_grant","error_description":"Token has been expired or revoked"}

I have set following permission in OAuth:
grafik

When I remove the event again, Sync from App to Google works again.

After reconnecting the Sync I now get following error:
Not all required fields are provided: Array ( [start_datetime] => 2023-07-27 18:00:00 [end_datetime] => 2023-07-27 22:00:00 [is_unavailability] => 1 [location] => Heartbeat Studio [notes] => Long Single Session 4h [id_users_provider] => 4 [id_google_calendar] => apbogpf3m68p27q3hnc2lgadsc [id_users_customer] => [id_services] => )

@brackenhill-mob
Copy link

brackenhill-mob commented Aug 25, 2023

I've hit this issue as well.

In the WordPress plugin I used before (Webba), I could enter appointments directly in my Google Calendar and they would be picked up by Webba during the sync so that the slot I'd just booked out could not be selected by someone else. Now, i have to use the EA backend to do this which is really inconvenient if I'm in a meeting and need to block out my time, when all I have is my phone.

Would it be possible for EA to populate the necessary "missing" fields with default values when syncing an appointment that is created in Google Calendar so that this scenario, and the error detailed above by @JiroMusik, can be catered for?

@JiroMusik
Copy link
Author

JiroMusik commented Sep 19, 2023

Hey sorry for asking again but how is the two-way sync supposed to work? I would love to integrate but what field in Google Calendar app needs to be populated?

Everything created in EA is synced to google but not the other way round

Edit: Changes to existing entries, created in EA are synchronized to EA. But not even a duplicated google calendar event is added.

@Forsskieken
Copy link

Forsskieken commented Sep 29, 2023

I think I found the culprit:

In a file on your server...
I did..

nano application/controllers/Google.php

In this Google.php file look for the entry below.

// Record doesn't exist in the Easy!Appointments, so add the event now.
               $appointment = [
                   'start_datetime' => $event_start->format('Y-m-d H:i:s'),
                   'end_datetime' => $event_end->format('Y-m-d H:i:s'),
                   'is_unavailability' => TRUE,
                   'location' => $google_event->getLocation(),
                   'notes' => $google_event->getSummary() . ' ' . $google_event->getDescription(),
                   'id_users_provider' => $provider_id,
                   'id_google_calendar' => $google_event->getId(),
                   'id_users_customer' => NULL,
                   'id_services' => NULL,
               ];

change to thenumber that belongs to the provider that is connected to the email account NOT THE ADMIN
drawback is that this will probably work for only 1 provider.
The id_services can be whatever of course you'll see that service. Maybe create a custom services for this and use that id
I found these values with phpmyadmin and for me it became

                   'id_users_customer' => 5,
                   'id_services' =>5,

If you book:
Easy!appointments --> Google Calendar you'll see that booking almost instantly reflected to the Google calendar.
Google --> Easy!appointments you'll need a cron job that checks every 10 minutes or so. Or push the button on the main calendar view

@alextselegidis
Copy link
Owner

@JiroMusik Could you please download and try the latest 1.5 dev package and see if you can reproduce the problem there? The google sync was updated to fix minor issues.

@Forsskieken Thanks for providing your solution here, but this will probably won't fix the problem

@JiroMusik
Copy link
Author

JiroMusik commented Oct 9, 2023

About is showing 1.5.0-dev.4
Is there a newer package?

@antsfiles
Copy link

As i put also here, to be able to get the address when booked in Google calendar, I would also add address, city and zipcode to the location field, when the client books:

booking.php:

            if (empty($appointment['location']) && !empty($service['location'])) {
                $appointment['location'] = $service['location'];
            }
            // if not location: use the full address given when booked
            if (empty($appointment['location'])) {
                $appointment['location'] = $customer['address'] . ' ' . $customer['zip_code'] . ' ' . $customer['city'];
            }

@alextselegidis
Copy link
Owner

@JiroMusik

There is no newer package out so far.

Hmm I'm using Google Sync for quite some time and the token would not get expired.

Could it be that the sync process was not executed for some time?

Are you using a cron job for syncing?

@iriikoad

Please create a new ticket for this

Alex Tselegidis, Easy!Appointments Creator
Need a customization? Get a free quote!

@Grekkor
Copy link

Grekkor commented Feb 8, 2024

I digged into this because this is not an issue in 1.4.3

@alextselegidis I do not understand how you cannot be affected by this issue (unless you have a local version that is different than the 1.5.0-dev4 release).

application/models/Appointments_model.php has a new code snipped for the validation function (see picture)

I uncommented the two lines that cause this issue and now it works again.

2024-02-08_12-46-49

Either this validation is unnecessary and can be removed or in application/models/Google.php in the sync function 'id_users_customer' and 'id_services' should not be set to NULL.

image

@JiroMusik
Copy link
Author

JiroMusik commented Feb 8, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants