Professional Documents
Culture Documents
Abstract
This lab uses a basic sample to demonstrate how to use Microsoft SQL Server Reporting Services to add reporting features to the SugarCRM Community Edition application. The lab covers the initial steps to achieve such integration leveraging the SQL Server Reporting Services Software Development Kit (SDK) for PHP. Note that this lab is for educational purpose about the potential possibilities and does not demonstrate a final solution that is ready for production use.
Table of Contents
Introduction.................................................................................................................................................. 3 Lab Overview .............................................................................................................................................. 4 Lab Products and Solutions ...................................................................................................................... 5 SugarCRM Community Edition ............................................................................................................. 5 Microsoft SQL Server Reporting Services (SRSS)............................................................................ 5 SQL Server Reporting Services SDK for PHP ................................................................................... 6 Lab Execution ............................................................................................................................................. 7 Step 1: Designing Reports for SugarCRM Community Edition ....................................................... 8 Getting Ready ...................................................................................................................................... 8 Creating a Linked Server against MySQL SugarCRM Database ................................................ 9 Deploying a Sample SugarCRM Report Solution......................................................................... 17 Viewing the Deployed SugarCRM Reports in Report Viewer ..................................................... 19 Step 2: Installing SQL Services Reporting Module in SugarCRM................................................. 21 Adding the Reports Module in SugarCRM .................................................................................... 21 Step 3: End User Experiences ............................................................................................................ 27 Creating a New Report in Report Designer ................................................................................... 27 Viewing the New Report in Reports Viewer .................................................................................. 43 Viewing the New Report in SugarCRM .......................................................................................... 44 The Interop Vendor Alliance ................................................................................................................... 47
Introduction
There are many web applications built with PHP that need to include Business Intelligence and Reporting features. Such features can be built from scratch or leverage external components providing out of the box features. This lab uses a basic sample to demonstrate how to use Microsoft SQL Server Reporting Services to add reporting features to existing PHP applications. The lab covers the initial steps to achieve such integration leveraging the SQL Server Reporting Services Software Development Kit (SDK) for PHP. In this particular scenario, this lab uses the popular SugarCRM Community Edition, a web based Customer Relationship Management system, to demonstrate how to combine SQL Server Reporting Services with third party software. These scenarios teach how to build additional reporting capabilities inside the SurgarCRM Community Edition while offering the end-users more business intelligence tools right inside the SugarCRM Community Edition dashboard.
Note that this lab is for educational purpose about the potential possibilities and does not demonstrate a final solution that is ready for production use.
Lab Overview
This lab demonstrates how to use Microsoft SQL Server Reporting Services (SSRS) to add reporting features to the SugarCRM Community Edition and explains the initial steps to achieve such integration. The lab explores major steps on how to use the SQL Server Reporting Services Software Development Kit (SDK) for PHP to generate and display reports in PHP applications like SugarCRM Community Edition. The use case scenario implemented in the lab is the following: Step 1: The user logs-on to the SugarCRM application and navigates to the report module dashboard. Step 2: The SugarCRM module calls the corresponding SSRS SDK for PHP API to load and render the report from the report server. Step 3 and 4: The Reporting Service connects to the SugarCRM database through SQL Server Express using the configured Linked Server and runs the report. Step 5: The Reporting Server returns the processed report in the desired format. Step 6: The SugarCRM module displays the report.
The key benefits of using SSRS SDK for PHP are: The SDK offers a simple interoperability bridge between PHP and Microsoft SQL Server Reporting Services The SDK is independent of the host operating system. The SDK allows developers to control and display reports in any PHP application.
The open source architecture of SugarCRM allows other software vendors to build various enhancements and modules and then integrate them with SugarCRM. SugarCRM also offers Professional and Enterprise editions. More information at: http://www.sugarcrm.com
The API is built on top of the SQL Server Reporting Services Web Service API using SOAP as the underlying communication mechanism. PHP applications can then manage reports, parameters, credentials, and output formats with SQL Server 2008 Reporting Services. The design of the report is created with Business Intelligence Development Studio which comes with SQL Server 2008 Express with Advanced Services. Developers can alter the style of the output formats to fit their needs. The following code snippet shows how to use SSRS SDK for PHP APIs to connect to report server, load a report, and run and display the report.
/* connect to the Report Service */ $rs = new SSRSReport(new Credentials(UID, PASWD),REPORT_SERVICE_URL); /* Load a report */ $executionInfo = $rs->LoadReport2(REPORT, NULL); /* Define the report parameters */ $parameters = array(); $parameters[0] = new ParameterValue(); $parameters[0]->Name = "ProductCategory"; $parameters[0]->Value = "1"; $parameters[1] = new ParameterValue(); $parameters[1]->Name = "StartDate"; $parameters[1]->Value = "1/1/2003"; /* Set the report parameters */ $rs->SetExecutionParameters2($parameters); /* Define the expected report format as HTML */ $renderAsHTML = new RenderAsHTML(); /* Run and get the report in html format */ $result_html = $rs->Render2($renderAsHTML, PageCountModeEnum::$Actual, $Extension, $MimeType, $Encoding, $Warnings, $StreamIds); /* Display the report */ echo $result_html;
More information on the SDK is available the on Interoperability Bridges website: http://www.interoperabilitybridges.com/projects/sql-server-reporting-services-sdk-for-php
Lab Execution
The use case scenario implemented in the lab is the following: Step 1: The user logs-on to the SugarCRM application and navigates to the report module dashboard. Step 2: The SugarCRM module calls the corresponding SSRS SDK for PHP API to load and render the report from the report server. Step 3 and 4: The Reporting Service connects to the SugarCRM database through SQL Server Express using the configured Linked Server and runs the report. Step 5: The Reporting Server returns the processed report in the desired format. Step 6: The SugarCRM module displays the report.
Heres the detailed architecture of the solution deployed during this lab:
The following sections explain how to configure the different pieces of software in order to have them to work together. The lab execution includes three steps: Step 1: Designing Reports for SugarCRM Step 2: Installing SQL Services Reporting Module in SugarCRM Step 3: End User Experiences
The Report Designer is hosted within the Microsoft Visual Studio environment and is used to design the report. The report designer provides a collection of design and graphical query tools that are used to design the report. The Report Designer used SQL Server Express Linked Server to connect to the SugarCRM MySQL database. This lab scenario assumes the following: SugarCRM is installed. SugarCRM database is setup with the test data if required. SQL Express 2008 with Advanced Services is installed. SQL Server Reporting Services (included in SQL Express 2008 with Advanced Services) is installed. Microsoft BI Studio Report Designer is installed (Report Designer is hosted in the Business
Intelligence Development Studio, which is fully integrated with the Microsoft Visual Studio 2008 development environment. If you do not have Visual Studio 2008 installed, SQL Server Setup installs the shell so that you can run Report Designer)
Linked Server is configured on the local SQL Server Express instance against MySQL SugarCRM database.
The configuration of the Linked Server consists of the following steps: 1. Installing MySQL ODBC Driver. 2. Configuring MySQL DSN. 3. Configuring Microsoft OLEDB Provider for ODBC Drivers (MSDASQL) to use the MySQL Connector/ODBC DSN. 4. Creating a Linked Server against MySQL SugarCRM database.
2. In System DSN tab, click Add to create the MySQL System DSN.
3. Select MySQL ODBC 5.1 Driver and click Finish. 4. Click Finish. The Operating System displays the MySQL Connector/ODBC 3.51 Data Source Configuration window. You can specify all the connection setting parameters for connecting SQL Server to MySQL in this window.
10
5. After you have entered all the required parameters, click Test to ensure that a connection can be made to the MySQL server.
6. Click Details to view the section where you can specify optional parameters to MySQL Connector/ODBC Driver. You can set some additional options to optimize the connection between the servers.
11
7. Select the optional parameters in Flag1, Flag2, and Flag3 tabs as specified in the following table: Tab F Flag 1 Flag 2 Option to Check Allow Big Results Use Compression Dont Cache Result of forward- only cursors Force Use Of Forwardonly cursors Purpose Do not set any packet limit for results and bind parameters. Use the compressed client/server protocol. Do not cache the results locally in the driver, instead read from server. This works only for forward-only cursors This flag needs to be set for non-cache result sets.
Configuring MySQL
To configure MySQL, perform the following steps:
12
1. Start the application SQL Server Management Studio to view the properties window of Microsoft OLEDB Provider for ODBC Drivers.
13
2. Type cd C:\Program Files\Microsoft SQL Server\100\Tools\Binn in the command window and press ENTER to change the current working directory to the location of sqlcmd.exe.
14
3. Use the sqlcmd utility to run the script file (.\..\Samples\SugarCRM\sugarcrm_linkedserver.sql) to create a linked server. sqlcmd S ./SQLEXPRESS i [file_path]\sugarcrm_linkedserver.sql If you are using any SQL instance other than SQL Express (ex: SQL Server), then you need to change the instance name accordingly. For example: sqlcmd S . i [file_path]\sugarcrm_linkedserver.sql Execution of this script creates the linked server (with name LS_SUGARCRM_MYSQL), a database (with name SugarcrmMySQL), and creates views in this database that map to the corresponding tables in MySQL sugarcrm Database. 4. Open and verify SQL Express Management Studio to make sure that the linked server and the SugarCRM database has been successfully created. 5. In the SugarCRM configuration, specify a username/password to connect to SSRS Server. The same users must have DataRead permission on the new DB (SugarcrmMySQL).
15
16
4. In the ReportData Pane, double-click on the DataSource1 data source node. The application displays the Data Source Properties Window.
17
The value of connection string is Data Source=.\SQLEXPRESS;initial Catalog=SugarcrmMySQL. Note: If you are using any SQL instance other than SQL Express (for example: SQL Server), then change the value of DataSource in the connection string accordingly. For example: Data Source=.;initial Catalog=sugarcrmMySQL 5. In the Solution Explorer, right-click on sugarcrm, and select Properties to open the Solution Properties window.
18
Ensure that the value of TargetServiceURL contains the URL that points to the report server and click OK. The SugarCRM reports are now deployed.
19
2. Click on the required report name to view the corresponding details of the report. The browser displays the details of the report.
20
The SSRSReport package is a sample package which includes a module to list and render SugarCRM reports. You can import this module into the SugarCRM application. To import the module into the SugarCRM application, perform the following: 1. Login to the SugarCRM as admin.
21
3. Select the zip file \samples\ SugarCRM\project_Reports2009_10_31_074917.zip using the Browse button and click Upload. project_Reports2009_10_31_074917.zip is a sample SSRS module which shows how SSRS reports can be used within the SugarCRM. The module connects to SSRS server and displays the reports available in the SugarCRM dashboard.
4. Go to Admin -> Module Loader and click the Install button to install the module listed.
5. Go to Admin -> Module Builder -> Reports Package in the left pane and select Deploy.
22
The application displays a new link SSRS Reports under the tab Reports.
If the SSRS Reports link appears under Other tab as shown in the below diagram, then you can move it under the Reports tab by configuring in the Configure Tabs Group section.
To move the SSRS Reports link under the Reports tab, go to Admin -> Developer Tools Section > Configure Tabs Group. Drag the SSRS Reports under Others group and drop it into the Reports group. Click Save and Deploy.
23
6. Copy and paste the provided \samples\ SugarCRM\index.php and config.ini file to [sugarcrm_installation_path]\sugarcrm\modules\SSRS_Reports folder.
7. Create a folder images under [sugarcrm_installation_path]\ modules\SSRS_Reports with write permissions and copy the file .\..\samples\ SugarCRM\web.config into this folder.
24
8. Type the username, password and service URL in the config.php file. These details are required to access the reporting server. 9. Click Reports->SSRS Reports to see the list of reports.
10. Click on any report link shown in the dashboard to view the details of the corresponding report. The SugarCRM application displays the selected report within the dashboard
25
26
27
4. In the Solution Explorer pane, right-click on Shared Data Source and click Add New Data Source to add a new shared data source.
28
The application displays the Shared Data Source Properties dialog box.
5. In the Name text box, type the name of the data source. 6. Click Edit to set the connection properties for the new data source. The Connection Properties dialog box appears.
29
7. In the Server name box, type the name of the server. 8. Select the option Use Windows Authentication. 9. Select the option Select or enter a database name. 10. Select the database SugarcrmMySQL from the drop down list.
30
You can view the following dialog box if the database connection is successful.
12. Click OK in the Connection Properties dialog box. The Shared Data Source Properties dialog box appears.
13. Click OK in the Shared Data Source Properties dialog box. The new data source appears under the Shared Data Sources in the Solution Explorer pane.
31
32
2. Click Next. 3. Select the option Shared Data Source. 4. Select the data source name that you gave while creating the data source.
5. Click Next. The Report Wizard dialog box refreshes to show the Query Builder button.
33
6. Click Query Builder to build the query. The Query Designer dialog box appears.
7. In the Query Designer dialog box, right-click on the white space and select Add Table.
34
8. In the Views tab, select the required view and click Add. A dialog box appears which shows the fields of the selected view.
35
9. In the Query Designer dialog box, select the required fields and click OK. The Report Wizard dialog box appears.
11. Click Tabular. 12. Click Next. The Report Wizard allows you to design the report.
36
13. Click Next. 14. Select the type of layout you require for the table.
37
15. Click Next. 16. Select the type of layout you require for the table.
38
18. Type the name of the table in the Report name text box.
19. Click Finish. You can now view the new report in the Solution Explorer pane of Visual Studio Report Designer.
20. In the Solution Explorer pane, right-click the new report you created and click Build.
39
21. In the Solution Explorer pane, right-click the new report you have created and click Deploy.
40
22. In the Solution Explorer pane, right-click the new report you created and click Run.
41
Visual Studio Report Designer runs the report and displays the report in a new window.
42
The browser displays a list of SugarCRM reports. You can see that the Browser Report Manager displays the name of the new report.
2. Click on the new report you created to view the corresponding details of the report. The browser displays the details of the report.
43
44
2. Click on the new report link that you created to view the details of the corresponding report. The SugarCRM application displays the details of the selected report within the dashboard.
45
46
47
This document is provided as-is. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes. You may modify this document for your internal, reference purposes. Distributed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0
48