2. About the Speaker
Asa
Kusuma
• Intern at Milsoft Utility Solutions
• Sophomore at Abilene Christian University
• Twitter: asakusuma
• www.asakusuma.com
10. About Milsoft
• We make software for
utility companies
• Headquarters in
Abilene, TX
• Over 1,000 customers,
US + International
photo by philipbouchard
11. Our needs at Milsoft
• Send geographic-sensitive data to customers
• Marketing
• Workshops
• Inform decision makers
• Streamline meetings
• Do it all in SugarCRM
14. The Old Way
1. Export SugarCRM data
2. Cleanup data
3. Import data into 3rd party software
4. Filter data or generate visual
5. Cross fingers
6. Import data back into SugarCRM
15. The New Way
1. Filter data or create visual in SugarCRM
2. Laugh at people doing it the old way
16. Steps to Success
1. Extend your data
• Add coordinates to Accounts
2. Create data filtering capabilities
• Add geographic filters for Reports
3. Create visuals
• Link your Accounts with Google Maps
• Link your Reports with Google Maps
20. Guidelines
• Permanent, scalable solutions, not hacks
• If it’s not simple, it won’t be used
• Insert new features into existing workflow
• Complement and extend existing features
22. Step 1:
Add Geographic Data
• Get a Google Maps API Key
• Create custom fields
• Create script
• Connect to database
• Add coordinates to each account
• Run script (takes a long time)
23. Create Custom Fields
Admin > Studio > Accounts > Fields > Add Field
• Add fields to store latitude & longitude
• Datatype: Decimal
• Uncheck “Required Field”
• Check “Reportable”
• Populate fields using address + Google Maps
24.
25. Create Script
• Connect to SugarCRM database
• Invoke config.php (don’t hardcode)
• Retrieve and loop through Accounts
• Send address to Google Maps
• Receive Latitude and Longitude
• Record coordinates
27. Now What?
• Accounts with an address have coordinates
• Do stuff with the coordinates
• Filter Accounts with Reports
• Put your Accounts on a map
• Put your filtered Accounts on a map
28. Filtering in Reports
• Select Accounts within a certain distance of
a postal code
• Add functionality to Reports
29. Code the Filter
1. Create the label string
2. Associate the label string with a function
3. Create the function
4. Add the extra text inputs
5. Force a JOIN with accounts_cstm
31. Associate Label with Function
modules/Reports/templates/
templates_modules_defs_js.php
32. Create the Function
Get postal code coordinates
Filter query
include/generic/SugarWidgets/SugarWidgetReportField.php
(queryFilterWithin_Radius())
33. Add Extra Text Inputs
Add inputs
include/javascript/reports.js
34. Add Extra Text Inputs (cont.)
2 new arguments
Set default input size
Add label
include/javascript/reports.js (addFilterInputText())
35. Force the JOIN
Link to accounts_cstm
• Custom fields are stored in accounts_cstm
• JOIN combines accounts and accounts_cstm
modules/Reports/Reports.php (create_from())
36. Radius
Distance Radius Center
(Postal Code)
The Result
43. Data Path
Report ID
Report Map
Report Data
ID Points
Query
Database
44. Create Query Retrieval Function
Check for
Lat & Long columns
Add Lat & Long columns
Build Query
Return Query
modules/Reports/Reports.php (execute_query())
45. Link From Report to Map
Create link
modules/Reports/Reports.php (execute_query())
46. Prepare the Data for the Map
Receive Report ID
Create a Report
Produce MySQL query
modules/Reports/map.php
47. Display the Map
Package account
as a point
Initialize Map
Plot data
on Map
modules/Reports/map.php
50. Try This At Home
• Protect your data
• Work out the kinks
• Issues with editing Reports
• Issues with multi-module Reports
• Code Snippets at:
http://www.asakusuma.com/sugarcon
• Be the envy of your next meeting