Difference between revisions of "Module Google"

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
Tag: 2017 source edit
(94 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
<!-- BEGIN origin interlang links -->
 +
<!-- You can edit this section but do NOT remove these comments
 +
    Links below will be automatically replicated on translated pages by PolyglotBot -->
 +
[[fr:Module_Google FR]]
 +
[[es:Módulo_Google]]
 +
<!-- END interlang links -->
 +
 
[[Category:Complementary modules]]
 
[[Category:Complementary modules]]
 
[[Category:Google]]
 
[[Category:Google]]
 +
[[Category:NLTechno]]
 
{{TemplateDocDevEn}}
 
{{TemplateDocDevEn}}
 
{{TemplateDocUser}}
 
{{TemplateDocUser}}
<keywords content="Google, Dolibarr, synchro, synchronize, interface, calendar, contacts, address, map, maps, event, addresses, link" />
+
<seo metak="Google, Dolibarr, synchro, synchronize, interface, calendar, contacts, address, map, maps, event, addresses, link" />
= Informations =
+
=Informations=
 
{{TemplateModuleInfo
 
{{TemplateModuleInfo
 
|modulename=Google
 
|modulename=Google
Line 12: Line 20:
 
|status=stable
 
|status=stable
 
|prerequisites=
 
|prerequisites=
|minversion=3.4.1+
+
|minversion=3.9+
 +
- Your instance must be on a secured URL (it must start with https:// and not with http://)
 +
 
 
- Having module openssl extension enabled into your PHP. To check this, go into module Home - Setup - PHP infos and make a search into page of "openssl". If you don't find, openssl module is not installed.
 
- Having module openssl extension enabled into your PHP. To check this, go into module Home - Setup - PHP infos and make a search into page of "openssl". If you don't find, openssl module is not installed.
  
Line 18: Line 28:
  
 
- Having module curl extension enabled into your PHP. To check this, go into module Home - Setup - PHP infos and make a search into page of "curl". If you don't find, curl module is not installed.
 
- Having module curl extension enabled into your PHP. To check this, go into module Home - Setup - PHP infos and make a search into page of "curl". If you don't find, curl module is not installed.
 +
 +
- To use the Maps and geocoding service, you must enable the billing on your Google account. Price is 0.005 € per address.
 
|note=
 
|note=
 
}}
 
}}
  
= Features =
+
=Features=
 
This module provides some Google integration into Dolibarr:
 
This module provides some Google integration into Dolibarr:
* Synchronize your third parties/contacts or members into Google Contacts.
 
* Add into menu a new entry called "Google Agenda" to show contents of your Google Agendas.
 
* Synchronize any event created or modified into Dolibarr agenda to Google Agenda.
 
* Add a pictogram near all addresses. A click on it show address inside a Google Maps.
 
* Add a view of location of all your customers/members into Google Maps.
 
* Can add a Google Adsense tag into logon page.
 
* Can add a Google Analytics tag into any software pages.
 
  
* Compatible with all standard Google Gmail account and with Google Apps Gmail account (from version 3.4.5 of module)
+
*Synchronize your third parties/contacts or members into Google Contacts.
 +
*Add into menu a new entry called "Google Agenda" to show contents of your Google Agendas.
 +
*Synchronize any event created or modified into Dolibarr agenda to Google Agenda.
 +
*Add a pictogram near all addresses. A click on it show address inside a Google Maps.
 +
*Add a view of location of all your customers/members into Google Maps.
 +
*Can add a Google Adsense tag into logon page.
 +
*Can add a Google Analytics tag into any software pages.
 +
 
 +
*Compatible with all standard Google Gmail account and with Google Apps Gmail account (from version 3.4.5 of module)
  
= Install =
+
=Install=
 
{{InstallModuleEn}}
 
{{InstallModuleEn}}
  
= Setup =
+
=Setup=
 
{{ActivationModuleEn}}
 
{{ActivationModuleEn}}
  
== Setup of Google Calendar/agenda features ==
+
==Setup of Google Calendar/agenda features==
 
This module provide 2 different features:
 
This module provide 2 different features:
  
=== Showing Google calendar tab into Agenda view ===
+
===Showing Google calendar tab into Agenda view===
First feature is to show the Google calendar view into a tab into Agenda view. This feature does not provide any synchronisation (see next feature for this) but only a visibility of Google native calendar into a Dolibarr tab.  
+
First feature is to show the Google calendar view into a tab into Agenda view. This feature does not provide any synchronization (see next feature for this) but only a visibility of Google native calendar into a Dolibarr tab. This list of agenda will be the same for every users so this feature is not usefull if you have different agenda that need different visibility according to users (The next feature may be more interesting if you are in this case).
To see the Google calendar into your Dolibarr, go onto Google module setup page, tab "View Google calendar" and:
+
 
 +
To define list of Google calendar to see into your Dolibarr, go onto Google module setup page, tab "View Google calendar" and:
  
 
Choose "Activate this tool" to Yes.
 
Choose "Activate this tool" to Yes.
  
 
Then for each Google agenda you want to show in menus, you must enter:
 
Then for each Google agenda you want to show in menus, you must enter:
* A label for this Agenda.
+
 
* A color for this Agenda.
+
*A label for this Agenda.
* Google ID of Agenda. It can be found on the Google parameters pages for the agendas like this:
+
*A color for this Agenda.
# Log to http://calendar.google.com
+
*Google ID of Agenda. It can be found on the Google parameters pages for the agendas like this:
# Click on the "Parameters" link
+
 
# Click on the name of Agenda to show the Details of agenda.
+
#Log to http://calendar.google.com
# Search line "URL Address", you will see a text "Agenda ID : theagendaid@gmail.com"
+
#Click on the "Parameters" link in the wheels
[[File:Find google agenda id.jpg|200px]]
+
#Click on the name of Agenda to show the Details of agenda.
 +
#Search line "URL Address", you will see a text "Calendar ID: theagendaid@gmail.com" like into the following screenshot (click twice on image to have it enlarged)
 +
 
 +
[[File:Find your Google Calendar or Agenda ID.png|400px]]
  
 
The Agenda ID is value that looks like an email. If you have only one Agenda, it might simply
 
The Agenda ID is value that looks like an email. If you have only one Agenda, it might simply
Line 63: Line 80:
 
The last section of configuration (Google Client ID and Google Client secret) is only needed if you want the authentication request to Google is integrated into Dolibarr screens.
 
The last section of configuration (Google Client ID and Google Client secret) is only needed if you want the authentication request to Google is integrated into Dolibarr screens.
  
=== Synchronize events from Dolibarr to Google Agenda ===
+
===Synchronize events from Dolibarr to Google Agenda===
 
The other feature is to write/update an event into Google Calendar, each time an event is added/updated into Dolibarr.
 
The other feature is to write/update an event into Google Calendar, each time an event is added/updated into Dolibarr.
 +
The event is pushed to a unique Agenda, or if you choose to use one agenda per user, to the agenda of the owner of the event.
  
For this, go onto module setup page, tab "Sync to Google Agenda", and set "Create a Google event into Google Calendar when creating a Dolibarr event" to "Yes".
+
To setup this synchronization, go onto module setup page, tab "Sync to Google Agenda", and set "Create a Google event into Google Calendar when creating a Dolibarr event" to "Yes".
  
Then, you must setup and enter the API keys provided by Google. This is dones in several step.
+
Then, you must setup and enter the API keys provided by Google. This is done in several step.
  
1) Find the Google Agenda ID or your calendar.
 
Go into your Google Calendar, then "Parameters" in the wheels, then tab "Agenda", or try this link https://www.google.com/calendar/render#i and then click on name or your Agenda. You Agenda ID is an ID that looks like an email.
 
  
Fille this ID found into field "ID Agenda".
+
1) You must also enable the API for your Google account. For this go on page {{ModuleGoogleUrlToCreateApiAccount}}, menu "API & Authentication" -> "Enable API". Click to enable API for "Calendar API".
  
2) You must create a service account user/email from page https://code.google.com/apis/console/, menu "API & Authentication" -> "Credentials" . Click on "Create a client ID" and choose "Service Account" then "Create". You will get a new service account with a Service account client ID and a Service account EMail. You need here to enter the Service account EMail.
 
  
Note: A popup to download a file (used by next step)
+
2) Find the Google Agenda ID or your calendar.
 +
For this,
  
3) Once you have you created your service account user/email (see note on previous fields), you must download your security p12 file (or use the one downloaded at previous step). Return on https://code.google.com/apis/console/ and select "API & Authentication" -> "Credentials". Then Click on "Generate a p12 key" to download the file on your desktop. Then submit it using this form.
+
#Log to http://calendar.google.com
 +
#Click on the "Parameters" link in the wheels
 +
#Click on the name of Agenda to show the Details of agenda.
 +
#Search line "URL Address", you will see a text "Calendar ID: theagendaid@gmail.com" like into the following screenshot (click twice on image to have it enlarged)
  
4) You must also enable the API for your Google account. For this go on page https://code.google.com/apis/console/, menu "API & Authentication" -> "API". Click to enable API for "Calendar API".
+
[[File:Find your Google Calendar or Agenda ID.png|400px]]
  
5) You must also share the agenda (all permissions) with the service account user/email (created at step 2): For this, go into Google calendar, choose "Parameters" then tab "Agendas" (direct access with this link https://www.google.com/calendar/render?tab=mc#i). Click on link "Share parameters" at end of line of the Agenda to synchronize (It must be same Agenda than the one choosed on parameter "ID Agenda" at step 1). Then add the service account user into the email field, choose permission "Edit events" and validate by clicking "Add user".  
+
Fill this found ID into the Dolibarr setup field "ID Agenda". It means all events will be synchronized toward this agenda.
  
With Google Apps for work (not required for standard gmail account), permissions may be forced to "Ready only" instead of "Edit". To solve this, go onto https://admin.google.com/AdminHome#AppDetails:service=Calendar&flyout=sharing and check that sharing option of Agenda application allows sharing with external service account. [[File:Warning.png]] A 24h delay may be required to be able to return and finish step 5.
+
Note: you can keep this field empty and fill instead the "ID Agenda" at the user card level (into tab "Google" on '''each user card'''). Each user can have its own calendar. In such a case, it is the owner of the event (visible on Dolibarr event card) that will be used by Dolibarr to know which Agenda ID to target for synchronization. It means each event into Dolibarr can be pushed only toward one and only one agenda (if there is several users assigned to event, it is the owner of event that will be targeted). Note also that in such a case, step 5 must also be done for each Google account.
  
 +
 +
3) You must create a service account user/email from page {{ModuleGoogleUrlToCreateApiAccount}}, menu "Credentials" . Click on "Create a client ID" and choose "Service Account" then choose "type of file P12" then "Create". You will get:
 +
 +
*A new service account with a Service account client ID and a Service account EMail. You need here to enter the Service account EMail.
 +
*A .p12 file was also downloaded.
 +
 +
If you choose to synchronize to only 1 unique Google agenda target or to one different agenda for each user, you have only to create 1 service account. However, you may need to give permissions to all google account if you set 1 different agenda for each user (see step 5).
 +
 +
You can also create a service account from page {{ModuleGoogleUrlToCreateApiAccountBis}}.
 +
 +
 +
4) Submit the information received and the downloaded file on the Dolibarr setup page, tab "Sync to Google Agenda".
 +
 +
 +
5) You must also share the agenda (all permissions) with the service account user/email (created at step 2): For this, go into Google calendar, choose "'''Settings and Sharing'''" from the combo list on the right of your Agenda on the area "'''My Calendars'''" (It must be same Agenda than the one chosen on parameter "ID Agenda" at step 1). Click on link "Share with Specific people". Then add the service account user into the email field, choose permission "'''Make changes to events'''" and validate.
 +
 +
With Google G Suite (not required for standard gmail account), permissions may be forced to "Ready only" instead of "Edit". To solve this, go onto
 +
{{GoogleURLToSetupCalendarAppSharing}}
 +
and check that sharing option of Agenda application ("External sharing options for primary calendars") to value allows sharing with external service account (Must be at least on value "Share all information, and outsiders can change calendars"). [[File:Warning.png]] A 24h delay may be required to be able to return and finish step 5.
  
 
Once all steps are done, you can use the button to make a synchronization test. Click on it to make a test.
 
Once all steps are done, you can use the button to make a synchronization test. Click on it to make a test.
Line 93: Line 131:
 
'''TroubleShooting'''
 
'''TroubleShooting'''
  
* If you receive error "ERROR Error calling POST https://www.googleapis.com/calendar/v3/calendars/yourcalendarid/events: (404) Not Found": Check the step 5 was done.
+
*If you receive error "ERROR Error calling POST https://www.googleapis.com/calendar/v3/calendars/yourcalendarid/events: (404) Not Found": Check the step 5 was done.
 +
 
 +
*If you receive error "ERROR Error calling POST https://www.googleapis.com/calendar/v3/calendars/yourcalendarid/events: (403) Forbidden": Check the step 5 was done and that permission granted was read and write and not read only.
  
* If you receive error "ERROR Error calling POST https://www.googleapis.com/calendar/v3/calendars/yourcalendarid/events: (403) Forbidden": Check the step 5 was done and that permission granted was read and write and not read only.
+
*If you receive error "ERROR Error calling POST https://www.googleapis.com/calendar/v3/calendars/yourcalendarid/events: (403) Service accounts cannot invite attendees without Domain-Wide Delegation of Authority": Check the step 5 was done and that you allo external acounts (so your service account) to edit calendar.
 +
 
 +
*[[File:Warning.png]] Note: A possible error is that Google denies access, even if your setup is correct, just because the server that host Dolibarr is located into another country or region than the one using google apps usually.
  
* [[File:Warning.png]] Note: A possible error is that Google denies access, even if login and password are correct, but just because the server that host Dolibarr is located into another country or region than the one using google apps usually.
 
 
To check Google has locked your access for this reason, go onto page https://security.google.com/settings/security/activity?hl=fr after failure.
 
To check Google has locked your access for this reason, go onto page https://security.google.com/settings/security/activity?hl=fr after failure.
  
 
If it appears Google has blocked access attempts from an unusual location, accept this attempt. Then, you must wait 24 hours to try again.
 
If it appears Google has blocked access attempts from an unusual location, accept this attempt. Then, you must wait 24 hours to try again.
  
* [[File: Warning.png]] Note: Another possible error is that Google denies access even if your login and password are correct, because you turn on Google option 2-step validation. To check if you have actually enabled this option, go to the page: https://security.google.com/settings/security?pli=1
+
*[[File: Warning.png]] Note: Another possible error is that Google denies access even if your setup is correct, because you turn on Google option 2-step validation. To check if you have actually enabled this option, go to the page: {{GoogleURLToSetup2StepValidation}}
 +
 
 +
If in the "Validation in two stages," you have "On", try to disable it. Module should works even with the two step validation on, but errors are easier to diagnose if this option if off.
 +
 
 +
*[[File: Warning.png]] Note: Another possible error is that Google denies access even if your setup is correct, because the server Dolibarr runs on or your local computer is not on time. Check that date and hour of your computer and server are correct.
 +
 
 +
==Setup of Google Contact==
 +
This module allows you to synchronize Dolibarr with your Google contact annuary. The object you can synchronize are:
 +
 
 +
* Third Parties
 +
* Addresses
 +
* Members of the module Association / Foundation
 +
 
 +
Synchronisation can be done toward only 1 Google account. However, using the Google sharing features (delegate contacts), several Google users with different accounts could see them.
 +
 
  
If in the "Validation in two stages," you have "On", the problem is found. You do not have to disable it. You can solve the problem as follows:
+
1) You must first enable the API for your Google account. For this go on page {{ModuleGoogleUrlToCreateApiAccount}}, menu "API & Authentication" -> "Enable API". Click to enable API for "Contact API".
Click "Edit" next to the title of the "Validation in two steps."
+
 
Click the link "Manage passwords specific to applications". Enter a name, for example "Google Access for Dolibarr" and confirm. A password will be provided.
+
 
Return to the configuration page of Google Dolibarr module and enter this password in the configuration page of the module, instead of your regular password, then click '''Save'''.
+
2) Then go on the setup page of Google module in Dolibarr, choose all Dolibarr elements you want to synchronize among (You can choose several choices):
Retry the test synchronization.
 
  
== Setup of Google Contact ==
+
* Third parties (if module Third party is enabled)
This module allows you to synchronize Dolibarr with your Google contact annuary.
+
* Contacts/addresses of thirdparties (if module Third party is enabed)
First, choose all Dolibarr elements you want to synchronize ampong (You can choose several choices):
 
* Thirdparties (if module Thirdparty is enabled)
 
* Contacts/addresses of thirdparties (if module Thirdparty is enabed)
 
 
* Members (if module foundation members is enabled)
 
* Members (if module foundation members is enabled)
  
Then enter your Google login and password and Save.
+
For each type of synchronization activated, enter a label of the Google Group of your choice. This is the group visible into Google to group all records together. Group will be created into Google Contact if not exists. You can also use a label of one of any predefined Google system group like: '''"System Group: My Contacts", "System Group: Friend", "System Group: CoWorker", "System Group: Family"'''
 +
 
 +
Note also that only the predefined system group '''"System Group: My Contacts"''' is shared by the "Delegate contacts" Google feature of Google contact (Google Apps for Work). So if you want to share your Google contact annuary, that contains Dolibarr records, to have other users seeing it, you must put your Dolibarr records into this group. They can't be put into another group if you plan such a share (only one account can be used).
 +
 
 +
Then enter the following information:
 +
 
 +
#The Google login account (example myaccount@gmail.com or myname@mycompany.com)
 +
#The Google Client ID and the Google Client Secret. You can create your Google Client ID and Secret from page {{ModuleGoogleUrlToCreateApiAccount}}, menu "API & Authentication" -> "Credentials". Click on "Create a client ID" and choose "Web Application", set "Allowed Javascript origin" to empty and set "Redirect URI" to the value provided into the "Note" on the setup page. It should be something like http://mycompanydomain/.../google/oauth2callback.php
 +
#Then click on button "Create". You will get a new '''Client ID''' and a '''Secret code'''. Save the Google setup page after filling Client ID and Secret Code.
 +
#A warning should say you don't have yet any Google token saved into your Dolibarr database. Click on the link to authenticate, enter your Google credential if requested (same account than the account entered at step 2 and accept any confirmation. You should go back on the Dolibarr setup page, but a value for the token, saved into your Dolibarr database should appears.
  
 
Buttons to make synchronization tests should be available. Click on them to make tests.
 
Buttons to make synchronization tests should be available. Click on them to make tests.
 +
  
 
'''TroubleShooting'''
 
'''TroubleShooting'''
  
* [[File:Warning.png]] Note: A possible error is that Google denies access, even if login and password are correct, but just because the server that host Dolibarr is located into another country than country uou are using google apps usually.
+
*[[File:Warning.png]] Note: A possible error is that Google denies access, even if your setup is correct, just because the server that host Dolibarr is located into another country than country uou are using google apps usually.
 +
 
 
To check Google has locked your access for this reason, go onto page https://security.google.com/settings/security/activity?hl=fr after failure.
 
To check Google has locked your access for this reason, go onto page https://security.google.com/settings/security/activity?hl=fr after failure.
  
 
If it appears Google has blocked access attempts from an unusual location, accept this attempt. Then, you must wait 24 hours to try again.
 
If it appears Google has blocked access attempts from an unusual location, accept this attempt. Then, you must wait 24 hours to try again.
  
* [[File: Warning.png]] Note: Another possible error is that Google denies access even if your login and password are correct, because you turn on Google option 2-step validation. To check if you have actually enabled this option, go to the page: https://security.google.com/settings/security?pli=1
+
*[[File: Warning.png]] Note: Another possible error is that Google denies access even if your setup is correct, because you turned on Google option 2-step validation. To check if you have actually enabled this option, go to the page: {{GoogleURLToSetup2StepValidation}}
  
 
If in the "Validation in two stages," you have "On", the problem is found. You do not have to disable it. You can solve the problem as follows:  
 
If in the "Validation in two stages," you have "On", the problem is found. You do not have to disable it. You can solve the problem as follows:  
Line 136: Line 198:
 
Retry the test synchronization.
 
Retry the test synchronization.
  
== Setup of GMaps features ==
+
*[[File: Warning.png]] Note: Another possible error is that Google denies access even if your setup is correct, because the server Dolibarr runs on or your local computer is not on time. Check that date and hour of your computer and server are correct.
 +
 
 +
==Setup of GMaps features==
 +
 
 +
1) You must first enable the API for your Google account. For this go on page {{ModuleGoogleUrlToCreateApiAccount}}, menu "API & Service" -> "Enable API & Services". Click to enable API for "Google Maps Geocoding API" and "Google Maps JavaScript API".
  
=== Link to localize a specific address ===
+
2) Create an API key of type "Server". You must check that the value for
 +
'''Restrictions relative to applications''' is on '''None'''
 +
'''Restrictions relative to API''' is on '''No restriction''' or, for a more secured usage, set to Restricted to the 2 APIs '''GeoCoding API''' and '''Maps Javascript API'''.
 +
Then save the API key on the setup page of module Google in Dolibarr, tab GMaps.
 +
 
 +
3) You must enable the "billing" of APIs on your Google account (price is 0.005 € per geo-encoded address)
 +
 
 +
===Link to localize a specific address===
 
Choose elements on which you want to see a GMaps picto after addresses, among (you can choose several choices):
 
Choose elements on which you want to see a GMaps picto after addresses, among (you can choose several choices):
* Thirdparties (if module Thirdparty is enabled)
 
* Contacts/addresses of thirdparties (if module Thirdparty is enabed)
 
* Members (if module foundation members is enabled)
 
Then define the zoom level to define scale used by defaut when a map will be output (value from 1 to 10, 10 is the more accurate zoom level). 7 is a recommanded value.
 
  
=== Links to global maps ===
+
*Third parties (if module Third party is enabled)
The other feature provided by module, is to show a global map with all your thirdparties, contact/addresses or members. To see link to thoose maps, go into menu Home -Setup - Boxes.
+
*Contacts/addresses of third parties (if module Third party is enabled)
 +
*Members (if module foundation members is enabled)
 +
 
 +
Then define the zoom level to define scale used by default when a map will be output (value from 1 to 10, 10 is the more accurate zoom level). 7 is a recommended value.
 +
 
 +
===Links to global maps===
 +
The other feature provided by module, is to show a global map with all your third parties, contact/addresses or members. To see link to those maps, go into menu Home -Setup - Boxes/Widgets.
 
Check that the box "Links to Google Maps" is activated. Return to Dolibarr home page. If boxes does not appears, choose it into the combo list on the left, to add it definitely on you screen.
 
Check that the box "Links to Google Maps" is activated. Return to Dolibarr home page. If boxes does not appears, choose it into the combo list on the left, to add it definitely on you screen.
  
== Setup of Adsense==
+
==Setup of Adsense==
 
If you want to enable adsense feature, on Adsense tab, enter:
 
If you want to enable adsense feature, on Adsense tab, enter:
* Your adsense customer id (ca-pub-xxxxxx)
+
 
 +
*Your adsense customer id (ca-pub-xxxxxx)
 +
 
 
Id specific to ad shown (you can find this id into Google adsenses dashboard adsense.google.com)
 
Id specific to ad shown (you can find this id into Google adsenses dashboard adsense.google.com)
 
An advert will be added onto demo and logon page.
 
An advert will be added onto demo and logon page.
  
== Setup of Google analytics ==
+
==Setup of Google analytics==
 
If you want to enable analytics feature, on Analytics tab, enter:
 
If you want to enable analytics feature, on Analytics tab, enter:
* Your Google analytics id (something like UA-xxxxxxx-y). You can find this id on Google analytics dashboard.
+
 
 +
*Your Google analytics id (something like UA-xxxxxxx-y). You can find this id on Google analytics dashboard.
 +
 
 
The Google Analytics tag will be then output onto all Dolibarr pages.
 
The Google Analytics tag will be then output onto all Dolibarr pages.
  
= Usage =
+
=Usage=
 +
 
 +
==Usage of Google Agendas features==
 +
 
 +
===If you activate synchronization===
 +
 
 +
*Dolibarr -> Google: Just go onto Google calendar, after creating or editing a Dolibarr event. You should see it into Google calendar (for example on calendar of your Android smartphone).
 +
 
 +
*Google -> Dolibarr: If you need to synchronize changes done on Google side, go onto the agenda view. You should see a link to force synchronization from Google to Dolibarr. See example here. Link is sentence "'''Click to resfresh agenda database with ...'''"
 +
 
 +
<div class="divforimgcentpercent">
 +
[[File:Link for sync from google.png|border]]
 +
</div>
  
== Usage of Google Agendas features ==
+
===If you enabled feature to show Google agenda===
=== If you enabled feature to show Google agenda ===
 
 
Choose menu Agenda Google, the agenda will be shown.
 
Choose menu Agenda Google, the agenda will be shown.
 
If you have defined several agendas, you can limit view for only one of them using the left menu.
 
If you have defined several agendas, you can limit view for only one of them using the left menu.
Line 169: Line 259:
 
To add event into it, you must click on link "+ Google calendar" at bottom of agenda (this is a Google limit).
 
To add event into it, you must click on link "+ Google calendar" at bottom of agenda (this is a Google limit).
  
[[File:Google module add.jpg|200px]].
+
<div class="divforimgcentpercent">
 +
[[File:screen_shot_google_view_agenda.png|border]]
 +
</div>
  
 
For security reasons imposed by Google, the Google calendar view will display correctly only if you are logged in to Google.
 
For security reasons imposed by Google, the Google calendar view will display correctly only if you are logged in to Google.
 
To facilitate this, it is possible to configure a key to allow the application to offer the Google Logon if you are not connected (See setup of module Google, tab Agenda setup, last section).
 
To facilitate this, it is possible to configure a key to allow the application to offer the Google Logon if you are not connected (See setup of module Google, tab Agenda setup, last section).
  
=== If you activate synchronization ===
+
==Usage of Google Contact feature==
Just go onto Google calendar after creating a Dolibarr event. You should see it into Google.
 
  
 +
*Dolibarr -> Google: Create or edit a thirdparty, contact or memeber (depending on which sync you enabled). Then go to Google contact. You should see the card created into Google.
 +
*Google -> Dolibarr: Change on this direction is not supported.
  
== Usage of GMaps feature ==
+
==Usage of GMaps feature==
 
Depending on the choice made ​​in configuration, a small pictogram appears on the third page, Contacts / Addresses or members after the address. By clicking above, you will see a map with the address positioned above. It is possible for you to navigate the map without leaving Dolibarr.
 
Depending on the choice made ​​in configuration, a small pictogram appears on the third page, Contacts / Addresses or members after the address. By clicking above, you will see a map with the address positioned above. It is possible for you to navigate the map without leaving Dolibarr.
  
[[File:Screen shot google 2.png|200px]]
+
<div class="divforimgcentpercent">
 +
[[File:screen_shot_google_address.png|border]]
 +
</div>
 +
 
 +
 
 +
In addition, you also have access to a box on the home page with a link to see all of your third party or members on the same map.
 +
 
 +
<div class="divforimgcentpercent">
 +
[[File:screen_shot_google_box.png|border]]
 +
</div>
 +
 
  
In addition, from version 3.4, you also have access to a box on the home page with a link to see all of your third party or members on the same map.
+
This is an example when you click on link on home page to see "Map of customers".
 +
Note that you can filter on sale representative, or any customer or supplier tag.
  
[[File:Screen shot google 3.png|200px]]
+
<div class="divforimgcentpercent">
 +
[[File:screen_shot_google_map.png|border]]
 +
</div>
  
== Usage of Adsense feature ==
+
==Usage of Adsense feature==
  
 
There is no particular things to do. Once setup is done (see previous chapter), a Google Adsense advert will appear on login page.
 
There is no particular things to do. Once setup is done (see previous chapter), a Google Adsense advert will appear on login page.
Line 193: Line 299:
 
Note: When Dolibarr is used with the [[Application Android - DoliDroid]], advert will not be active.
 
Note: When Dolibarr is used with the [[Application Android - DoliDroid]], advert will not be active.
  
== Usage of Google Analytics ==
+
==Usage of Google Analytics==
  
 
There is no particular things to do. Once setup is done (see previous chapter), a Google Analytics tag is added onto each Dolibarr page. By using the Google Analytic interface, you can have statistics on your Dolibarr usage, as if it was a public web site.
 
There is no particular things to do. Once setup is done (see previous chapter), a Google Analytics tag is added onto each Dolibarr page. By using the Google Analytic interface, you can have statistics on your Dolibarr usage, as if it was a public web site.
Line 199: Line 305:
 
Note: When Dolibarr is used with the [[Application Android - DoliDroid]], tag will not be active.
 
Note: When Dolibarr is used with the [[Application Android - DoliDroid]], tag will not be active.
  
= Development =
+
=Development=
 
{{TemplateModNLTechnoEn}}
 
{{TemplateModNLTechnoEn}}

Revision as of 10:55, 29 May 2020

Informations

Module name Google
Editor / Editeur NLTechno - www.nltechno.com
Download or buy page / Page achat ou téléchargement www.dolistore.com
Status / Statut / Estado Stable
Prerequisites / Prérequis Dolibarr min version 3.9+

- Your instance must be on a secured URL (it must start with https:// and not with http://)

- Having module openssl extension enabled into your PHP. To check this, go into module Home - Setup - PHP infos and make a search into page of "openssl". If you don't find, openssl module is not installed.

- Having module xml extension enabled into your PHP. To check this, go into module Home - Setup - PHP infos and make a search into page of "xml". If you don't find, xml module is not installed.

- Having module curl extension enabled into your PHP. To check this, go into module Home - Setup - PHP infos and make a search into page of "curl". If you don't find, curl module is not installed.

- To use the Maps and geocoding service, you must enable the billing on your Google account. Price is 0.005 € per address.   

Last update date / Date mise à jour fiche / Fecha última actualización 2020-05-29
Note / Nota

Features

This module provides some Google integration into Dolibarr:

  • Synchronize your third parties/contacts or members into Google Contacts.
  • Add into menu a new entry called "Google Agenda" to show contents of your Google Agendas.
  • Synchronize any event created or modified into Dolibarr agenda to Google Agenda.
  • Add a pictogram near all addresses. A click on it show address inside a Google Maps.
  • Add a view of location of all your customers/members into Google Maps.
  • Can add a Google Adsense tag into logon page.
  • Can add a Google Analytics tag into any software pages.
  • Compatible with all standard Google Gmail account and with Google Apps Gmail account (from version 3.4.5 of module)

Install

  • Download the archive file of module (.zip file)
  • Put the file into the root directory of Dolibarr.
  • Uncompress the archive file, for example with command
unzip modulefile.zip
  • Module is then visible into list of available modules (Home->Setup->Modules) and can be activated.

Setup

To use this module, you must first enable it using an administrator account, via the menu option "Home - Setup - Modules".

Choose the tab where the module is listed. Then click on "Activate".

The module is now activated.

If an icon appears at end of the line for the module, click on it to access the setup page specific to the module.

Setup of Google Calendar/agenda features

This module provide 2 different features:

Showing Google calendar tab into Agenda view

First feature is to show the Google calendar view into a tab into Agenda view. This feature does not provide any synchronization (see next feature for this) but only a visibility of Google native calendar into a Dolibarr tab. This list of agenda will be the same for every users so this feature is not usefull if you have different agenda that need different visibility according to users (The next feature may be more interesting if you are in this case).

To define list of Google calendar to see into your Dolibarr, go onto Google module setup page, tab "View Google calendar" and:

Choose "Activate this tool" to Yes.

Then for each Google agenda you want to show in menus, you must enter:

  • A label for this Agenda.
  • A color for this Agenda.
  • Google ID of Agenda. It can be found on the Google parameters pages for the agendas like this:
  1. Log to http://calendar.google.com
  2. Click on the "Parameters" link in the wheels
  3. Click on the name of Agenda to show the Details of agenda.
  4. Search line "URL Address", you will see a text "Calendar ID: theagendaid@gmail.com" like into the following screenshot (click twice on image to have it enlarged)

Find your Google Calendar or Agenda ID.png

The Agenda ID is value that looks like an email. If you have only one Agenda, it might simply be your Google login.

The last section of configuration (Google Client ID and Google Client secret) is only needed if you want the authentication request to Google is integrated into Dolibarr screens.

Synchronize events from Dolibarr to Google Agenda

The other feature is to write/update an event into Google Calendar, each time an event is added/updated into Dolibarr. The event is pushed to a unique Agenda, or if you choose to use one agenda per user, to the agenda of the owner of the event.

To setup this synchronization, go onto module setup page, tab "Sync to Google Agenda", and set "Create a Google event into Google Calendar when creating a Dolibarr event" to "Yes".

Then, you must setup and enter the API keys provided by Google. This is done in several step.


1) You must also enable the API for your Google account. For this go on page https://console.developers.google.com/apis/credentials, menu "API & Authentication" -> "Enable API". Click to enable API for "Calendar API".


2) Find the Google Agenda ID or your calendar. For this,

  1. Log to http://calendar.google.com
  2. Click on the "Parameters" link in the wheels
  3. Click on the name of Agenda to show the Details of agenda.
  4. Search line "URL Address", you will see a text "Calendar ID: theagendaid@gmail.com" like into the following screenshot (click twice on image to have it enlarged)

Find your Google Calendar or Agenda ID.png

Fill this found ID into the Dolibarr setup field "ID Agenda". It means all events will be synchronized toward this agenda.

Note: you can keep this field empty and fill instead the "ID Agenda" at the user card level (into tab "Google" on each user card). Each user can have its own calendar. In such a case, it is the owner of the event (visible on Dolibarr event card) that will be used by Dolibarr to know which Agenda ID to target for synchronization. It means each event into Dolibarr can be pushed only toward one and only one agenda (if there is several users assigned to event, it is the owner of event that will be targeted). Note also that in such a case, step 5 must also be done for each Google account.


3) You must create a service account user/email from page https://console.developers.google.com/apis/credentials, menu "Credentials" . Click on "Create a client ID" and choose "Service Account" then choose "type of file P12" then "Create". You will get:

  • A new service account with a Service account client ID and a Service account EMail. You need here to enter the Service account EMail.
  • A .p12 file was also downloaded.

If you choose to synchronize to only 1 unique Google agenda target or to one different agenda for each user, you have only to create 1 service account. However, you may need to give permissions to all google account if you set 1 different agenda for each user (see step 5).

You can also create a service account from page https://console.developers.google.com/iam-admin/serviceaccounts.


4) Submit the information received and the downloaded file on the Dolibarr setup page, tab "Sync to Google Agenda".


5) You must also share the agenda (all permissions) with the service account user/email (created at step 2): For this, go into Google calendar, choose "Settings and Sharing" from the combo list on the right of your Agenda on the area "My Calendars" (It must be same Agenda than the one chosen on parameter "ID Agenda" at step 1). Click on link "Share with Specific people". Then add the service account user into the email field, choose permission "Make changes to events" and validate.

With Google G Suite (not required for standard gmail account), permissions may be forced to "Ready only" instead of "Edit". To solve this, go onto https://admin.google.com/ac/appslist/core - Google Agenda - General parameters and check that sharing option of Agenda application ("External sharing options for primary calendars") to value allows sharing with external service account (Must be at least on value "Share all information, and outsiders can change calendars"). Warning.png A 24h delay may be required to be able to return and finish step 5.

Once all steps are done, you can use the button to make a synchronization test. Click on it to make a test.


TroubleShooting

  • Warning.png Note: A possible error is that Google denies access, even if your setup is correct, just because the server that host Dolibarr is located into another country or region than the one using google apps usually.

To check Google has locked your access for this reason, go onto page https://security.google.com/settings/security/activity?hl=fr after failure.

If it appears Google has blocked access attempts from an unusual location, accept this attempt. Then, you must wait 24 hours to try again.

  • Warning.png Note: Another possible error is that Google denies access even if your setup is correct, because you turn on Google option 2-step validation. To check if you have actually enabled this option, go to the page: https://myaccount.google.com/security

If in the "Validation in two stages," you have "On", try to disable it. Module should works even with the two step validation on, but errors are easier to diagnose if this option if off.

  • Warning.png Note: Another possible error is that Google denies access even if your setup is correct, because the server Dolibarr runs on or your local computer is not on time. Check that date and hour of your computer and server are correct.

Setup of Google Contact

This module allows you to synchronize Dolibarr with your Google contact annuary. The object you can synchronize are:

  • Third Parties
  • Addresses
  • Members of the module Association / Foundation

Synchronisation can be done toward only 1 Google account. However, using the Google sharing features (delegate contacts), several Google users with different accounts could see them.


1) You must first enable the API for your Google account. For this go on page https://console.developers.google.com/apis/credentials, menu "API & Authentication" -> "Enable API". Click to enable API for "Contact API".


2) Then go on the setup page of Google module in Dolibarr, choose all Dolibarr elements you want to synchronize among (You can choose several choices):

  • Third parties (if module Third party is enabled)
  • Contacts/addresses of thirdparties (if module Third party is enabed)
  • Members (if module foundation members is enabled)

For each type of synchronization activated, enter a label of the Google Group of your choice. This is the group visible into Google to group all records together. Group will be created into Google Contact if not exists. You can also use a label of one of any predefined Google system group like: "System Group: My Contacts", "System Group: Friend", "System Group: CoWorker", "System Group: Family"

Note also that only the predefined system group "System Group: My Contacts" is shared by the "Delegate contacts" Google feature of Google contact (Google Apps for Work). So if you want to share your Google contact annuary, that contains Dolibarr records, to have other users seeing it, you must put your Dolibarr records into this group. They can't be put into another group if you plan such a share (only one account can be used).

Then enter the following information:

  1. The Google login account (example myaccount@gmail.com or myname@mycompany.com)
  2. The Google Client ID and the Google Client Secret. You can create your Google Client ID and Secret from page https://console.developers.google.com/apis/credentials, menu "API & Authentication" -> "Credentials". Click on "Create a client ID" and choose "Web Application", set "Allowed Javascript origin" to empty and set "Redirect URI" to the value provided into the "Note" on the setup page. It should be something like http://mycompanydomain/.../google/oauth2callback.php
  3. Then click on button "Create". You will get a new Client ID and a Secret code. Save the Google setup page after filling Client ID and Secret Code.
  4. A warning should say you don't have yet any Google token saved into your Dolibarr database. Click on the link to authenticate, enter your Google credential if requested (same account than the account entered at step 2 and accept any confirmation. You should go back on the Dolibarr setup page, but a value for the token, saved into your Dolibarr database should appears.

Buttons to make synchronization tests should be available. Click on them to make tests.


TroubleShooting

  • Warning.png Note: A possible error is that Google denies access, even if your setup is correct, just because the server that host Dolibarr is located into another country than country uou are using google apps usually.

To check Google has locked your access for this reason, go onto page https://security.google.com/settings/security/activity?hl=fr after failure.

If it appears Google has blocked access attempts from an unusual location, accept this attempt. Then, you must wait 24 hours to try again.

  • Warning.png Note: Another possible error is that Google denies access even if your setup is correct, because you turned on Google option 2-step validation. To check if you have actually enabled this option, go to the page: https://myaccount.google.com/security

If in the "Validation in two stages," you have "On", the problem is found. You do not have to disable it. You can solve the problem as follows: Click "Edit" next to the title of the "Validation in two steps." Click the link "Manage passwords specific to applications". Enter a name, for example "Google Access for Dolibarr" and confirm. A password will be provided. Return to the configuration page of Google Dolibarr module and enter this password in the configuration page of the module, instead of your regular password, then click Save. Retry the test synchronization.

  • Warning.png Note: Another possible error is that Google denies access even if your setup is correct, because the server Dolibarr runs on or your local computer is not on time. Check that date and hour of your computer and server are correct.

Setup of GMaps features

1) You must first enable the API for your Google account. For this go on page https://console.developers.google.com/apis/credentials, menu "API & Service" -> "Enable API & Services". Click to enable API for "Google Maps Geocoding API" and "Google Maps JavaScript API".

2) Create an API key of type "Server". You must check that the value for

Restrictions relative to applications is on None
Restrictions relative to API is on No restriction or, for a more secured usage, set to Restricted to the 2 APIs GeoCoding API and Maps Javascript API. 

Then save the API key on the setup page of module Google in Dolibarr, tab GMaps.

3) You must enable the "billing" of APIs on your Google account (price is 0.005 € per geo-encoded address)

Link to localize a specific address

Choose elements on which you want to see a GMaps picto after addresses, among (you can choose several choices):

  • Third parties (if module Third party is enabled)
  • Contacts/addresses of third parties (if module Third party is enabled)
  • Members (if module foundation members is enabled)

Then define the zoom level to define scale used by default when a map will be output (value from 1 to 10, 10 is the more accurate zoom level). 7 is a recommended value.

Links to global maps

The other feature provided by module, is to show a global map with all your third parties, contact/addresses or members. To see link to those maps, go into menu Home -Setup - Boxes/Widgets. Check that the box "Links to Google Maps" is activated. Return to Dolibarr home page. If boxes does not appears, choose it into the combo list on the left, to add it definitely on you screen.

Setup of Adsense

If you want to enable adsense feature, on Adsense tab, enter:

  • Your adsense customer id (ca-pub-xxxxxx)

Id specific to ad shown (you can find this id into Google adsenses dashboard adsense.google.com) An advert will be added onto demo and logon page.

Setup of Google analytics

If you want to enable analytics feature, on Analytics tab, enter:

  • Your Google analytics id (something like UA-xxxxxxx-y). You can find this id on Google analytics dashboard.

The Google Analytics tag will be then output onto all Dolibarr pages.

Usage

Usage of Google Agendas features

If you activate synchronization

  • Dolibarr -> Google: Just go onto Google calendar, after creating or editing a Dolibarr event. You should see it into Google calendar (for example on calendar of your Android smartphone).
  • Google -> Dolibarr: If you need to synchronize changes done on Google side, go onto the agenda view. You should see a link to force synchronization from Google to Dolibarr. See example here. Link is sentence "Click to resfresh agenda database with ..."

Link for sync from google.png

If you enabled feature to show Google agenda

Choose menu Agenda Google, the agenda will be shown. If you have defined several agendas, you can limit view for only one of them using the left menu. The Google agenda is shown in read only mode. To add event into it, you must click on link "+ Google calendar" at bottom of agenda (this is a Google limit).

Screen shot google view agenda.png

For security reasons imposed by Google, the Google calendar view will display correctly only if you are logged in to Google. To facilitate this, it is possible to configure a key to allow the application to offer the Google Logon if you are not connected (See setup of module Google, tab Agenda setup, last section).

Usage of Google Contact feature

  • Dolibarr -> Google: Create or edit a thirdparty, contact or memeber (depending on which sync you enabled). Then go to Google contact. You should see the card created into Google.
  • Google -> Dolibarr: Change on this direction is not supported.

Usage of GMaps feature

Depending on the choice made ​​in configuration, a small pictogram appears on the third page, Contacts / Addresses or members after the address. By clicking above, you will see a map with the address positioned above. It is possible for you to navigate the map without leaving Dolibarr.

Screen shot google address.png


In addition, you also have access to a box on the home page with a link to see all of your third party or members on the same map.

Screen shot google box.png


This is an example when you click on link on home page to see "Map of customers". Note that you can filter on sale representative, or any customer or supplier tag.

Screen shot google map.png

Usage of Adsense feature

There is no particular things to do. Once setup is done (see previous chapter), a Google Adsense advert will appear on login page.

Note: When Dolibarr is used with the Application Android - DoliDroid, advert will not be active.

Usage of Google Analytics

There is no particular things to do. Once setup is done (see previous chapter), a Google Analytics tag is added onto each Dolibarr page. By using the Google Analytic interface, you can have statistics on your Dolibarr usage, as if it was a public web site.

Note: When Dolibarr is used with the Application Android - DoliDroid, tag will not be active.

Development

Development of this module is not included inside the standard GIT repository of Dolibarr but inside a repository dedicated to modules not supported by the Dolibarr development team but supported by NLTechno on platform Git by Framasoft:

Note this is a private repository, so to contribute and/or get sources, you must create an account on https://git.framasoft.org web site.