Skip navigation
All Places > Developer > Blog > 2016 > April
2016
Here is another guest post from Cédric Mourizard from the Elite SugarCRM Partner Synolia.  Cedric is a well recognized expert on the Sugar PDF Manager.

 

In regard to some recent questions from Sugar Community stalwart, Francesca Shiekh, we will address some questions about how to deal with the PDF Manager that was originally introduced in Sugar 6.

 

A Common Use Case

 

In this article we want to resolve this common use case for customizing the PDF manager. When following up on a meeting, you want to be able to generate an attractive summary document that lists all the meeting details included lists of those who were invited or attended.

 

We will customize the PDF manager so that we can print a meeting summary for any Meeting record that will have all contacts and invited users listed.

 

Understanding PDF Manager and extending it

 

Sugar uses two important 3rd party libraries as part of the PDF Manager implementation. Note that Sugar 7.6.2.1 uses TinyMCE 3.5.8 and TCPdf 4.6.013.  These are not the latest available versions of these libraries.

 

The architecture of the SugarPDF API is described in the Developer Guide.  It can be customized in the usual way by creating your custom code at a special location under Sugar's custom directory. We need to create a file at custom/modules/Meetings/sugarpdf/sugarpdf.pdfmanager.php where we can implement our logic to add related record information for the meeting:

 

 

 

<?php

 

require_once 'include/Sugarpdf/sugarpdf/sugarpdf.pdfmanager.php';

 

class MeetingsSugarpdfPdfmanager extends SugarpdfPdfmanager

 

{

 

    public function preDisplay()

 

    {

 

        parent::preDisplay();

 

        $previewMode = false;

 

        if (!empty($_REQUEST['pdf_preview']) && $_REQUEST['pdf_preview'] == 1) {

 

            $previewMode = true;

 

        }

 

        if ($previewMode === false) {

 

            // Select links to add

 

            $linksToLoad = array('contacts', 'users');

 

            foreach ($linksToLoad as $linkName) {

 

                /** @var Meeting $this->bean */

 

                $this->bean->load_relationship($linkName);

 

                $linkedBeans = $this->bean->$linkName->getBeans();

 

                // Prepare data

 

                $linkedData = array();

 

                foreach ($linkedBeans as $linkedBean) {

 

                    $linkedData[] = PdfManagerHelper::parseBeanFields($linkedBean, true);

 

                }

 

                // Assign data to template

 

                $this->ss->assign($linkName, $linkedData);

 

            }

 

        }

 

    }

 

}

 

 

 

Now we can create our PDF template based on the Meeting module with the PDF Manager which can be found in the Administration panel:

 

 

 

<h1>Meeting Summary</h1>

 

Topic: {$fields.name}

 

Description: {$fields.description}

 

{if isset($contacts) and $contacts|@count gt 0}

 

<h2>Contact Guests</h2>

 

<table style="width: 100%;" border="0">

 

<tbody>

 

<tr>

 

<td><strong>Name</strong></td>

 

<td>Email</td>

 

<td>Phone</td>

 

</tr>

 

<!-- {foreach from=$contacts item="contact"} -->

 

<tr>

 

<td>{$contact.full_name}</td>

 

<td>Email {$contact.email1}</td>

 

<td>{$contact.phone_work}</td>

 

</tr>

 

<!--  {/foreach} --></tbody>

 

</table>

 

{/if} {if isset($users) and $users|@count gt 0}

 

<h2>User Guests</h2>

 

<table style="width: 100%;" border="0">

 

<tbody>

 

<tr>

 

<td><strong>Name</strong></td>

 

<td>Email</td>

 

<td>Title</td>

 

</tr>

 

<!-- {foreach from=$users item="user"} -->

 

<tr>

 

<td>{$user.full_name}</td>

 

<td>{$user.email1}</td>

 

<td>{$user.title}</td>

 

</tr>

 

<!-- {/foreach} --></tbody>

 

</table>

 

{/if}

 

 

Hey! When I copy and paste this code into the WYSIWYG editor it doesn't appear the same! What is going on here?

 

You are right! By default TinyMCE will add an HTML p tag on every line. To avoid that you can adapt the configuration by creating a file at custom/include/tinyMCEDefaultConfig.php

 

 

 

<?php

 

$defaultConfig = array(

 

    'forced_root_block' => '',

 

);

 

 

 

Want to learn more about TinyMCE configuration in Sugar? Do not hesitate to read the world famous Sugar Developer Guide section on Modifying TinyMCE Editor!

 

Tips for your own Templates

 

You can follow some of these tips when you are thinking about creating a new template:

  • Use HTML comment tag to add Smarty operators where you want
  • Use inline styles instead of a CSS declaration
  • Remember that PDF generation is performed using the language selected by the current user

 

Do not forget to perform a Quick Repair and Rebuild to make your customizations available for the application.

 

Enjoy your new PDF summary for your meetings!

Welcome to the 2016 App Throwdown!



Submissions are now open for the 2016 App Throwdown! Our annual showcase of technology for the Sugar platform is always a crowd favorite. The App Throwdown is where customers, partners, and prospects get to see some of the coolest, most useful, and innovative extensions that drive business transformation, save costs, and close deals faster. Check out this overview document, then head on over to the How to Submit Your App to the App Throwdown! document to learn how to get started in the 2016 App Throwdown!

 

Don't forget, you must be registered in the community to participate and submit an entry. No worries though! Registration is super easy--just fill out this form and validate your email. Also, there's no cost to be a member of the community or participate in the App Throwdown.

 

Best in Class & Best in Show

 

This year's categories will help align with the overall themes of SugarCon. From the submissions in each category your SugarCon team will select three finalists. These finalists will be reviewed by SugarCRM's executive team, who will choose one entry from each category as "Best in Class."  Each category winner will be invited to present on the main stage in front of the entire SugarCon audience to compete for the "Best in Show" award!

 

Power to the People!



For the first time ever the community also gets a voice for who will compete for the  "Best in Show" award!    Each submission will use a blog post in Welcome to the App Throwdown! space . This will give you, all of your colleagues, facebook friends, and twitter followers, the opportunity to "Like" your entry. When submissions close, the entry with the most "Likes," will be designated "Community Favorite" and will be invited to show their stuff under the bright lights on SugarCon's main stage! So go vote today!

 

Don't wait to submit your application! This year's deadline for all submissions is May 13!  Remember, the earlier you submit, the more time you have to get support and "Likes" on your entry.

 

The 2016 App Throwdown Categories

CategoryDescription
Mobile CRM and the Internet of ThingsAre you helping design "wearable" CRM? Building a mobile cool app or a connector to help track and manage smart device data in Sugar? Then we want your submission! This category is all about innovative applications that take a unique approach to mobility and the Internet of Things.
Customer InsightWe are looking for the latest and greatest in Sugar extensions and integrations that focus on everything from understanding the customer journey, to the 360 degree view of the customer, and predictive analytics. If you're merging next-generation Business Intelligence with Sugar, this is your category!
Customer EngagementThe way we connect, engage and solve customer issues is changing in an increasingly customer-controlled world. Are you extending Sugar's engagement, service and support capabilities? Then submit your cool extensions here!
User ProductivityThe impact of digital, mobile, and cloud technologies is driving new interpretations of the modern workforce. If you have a connector or extension app that helps make CRM users more productive than or simply changes the way we can do business individual-to-individual in the modern age, then this is your category!

 

Submissions are open to... EVERYONE!

 

Like last year, submissions are open to EVERYONE! That’s right – anyone who wants to submit an extension, connector, custom app integration, or any other cool use of the Sugar platform, is eligible for consideration.

 

So what are you waiting for?

Want to throw it down with a submission?Get started now!Want to vote on submissions?

 

Learn more about the voting process and then go vote for your favorite app!

 

At SugarCRM Engineering, open source is part of our DNA.

 

We build Sugar on open source technology and open standards. We host and run our software on open source platforms in Sugar On-Demand. And all of our developers use open source tools for developing Sugar and implementing CRM projects for our customers.

 

As much as we benefit from open source software, we are obliged to give back. We host a number of open source projects in our SugarCRM Github organization that are actively maintained by SugarCRM employees. We encourage everyone in the Sugar Developer community to collaborate with us on these projects!

 

Read more to find out about some brand spanking new SugarCRM open source projects.

 

Sucrose Charts

 

SugarCRM Engineering has built a custom D3.js based chart library that we use to build charts used in Sugar 7.  We are refactoring this code into a dedicated library used by Sugar product. This allows us to launch a new open source project for the benefit of anyone needing a localized, responsive, and easy to use HTML5 chart library.

 

Head over to Sucrose.io to see some live and interactive examples of Sucrose Charts in action!

 



 

We will explore how to leverage Sucrose Charts within Sugar code and in web application or framework in an upcoming post!  Stay tuned!

 

The Sugar REST Harness

 

SugarCRM Professional Services has created a REST API test automation framework that they use to test their Enterprise CRM projects.  We are now providing this code as a framework for any Sugar Developers out there looking for an easy and repeatable way to automate functional tests for Sugar REST APIs including custom or extended APIs.

 

This is going to be a great tool for any Sugar Developers looking to build a better automated test practice.  It also supports a variety of output formats which makes it an ideal Sugar REST API test tool to integrate with your DevOps or continuous integration process.

 

Check out the project README for usage instructions.

 

Updated Tidbit documentation

 

Tidbit is a great open source tool used widely by our Sugar Developer community to generate pseudo-random data in the Sugar database for testing purposes. Our Performance team has been enhancing this tool and put together some new and improved usage documentation.

 

This new Tidbit documentation is posted on the project's Github wiki page.

Planning for this year's UnCon is just beginning and we need your help!

 

What is UnCon?

 

Hosted by SugarCRM Engineering, UnCon is the developer conference within SugarCon. UnCon is your opportunity to learn, rub shoulders, and hack with the top developers and architects at SugarCRM. Whether you are a Sugar Developer ace trying to get answers to your deepest technical questions or a Sugar newbie trying to learn what the Sugar platform is all about, this where you can get the answers straight from the source.

 

This year it is again being held on June 14th and June 15th at the Hilton Union Square in San Francisco.

 

UnCon is your conference!

 

The Sugar Developer community (You!) helps plan this event each year. That is why we are using a new space in the Sugar Community as the place for us to engage with each other.Participation in the UnCon community is free and open to anyone who has a SugarCRM.com account.  All you need to do is Log In or Register first if you do not have an account.

 

Let's make this the best UnCon ever!

 

Calls to Action

 

Create new Ideas

Create new UnCon Ideas on how we can make this year's UnCon awesome. You can vote on existing ideas too such as video recordings.

 

Vote in the Topic Survey

Vote on the topics you want to see presented or discussed at UnCon in the Topic Survey! Leave comments or create ideas if you do not see something you want to learn about listed.

 

 

Ask Questions

 

Is there something you still want to know? Get answers to those burning UnCon Questions too.

 

RSVP for UnCon

 

Finally, if you are coming then please RSVP for the UnCon Events to let others know too! This way, your colleagues in the Sugar Developer community will see who else is going.

 

We hope to see all of you there!

This post is a follow up on a question we posed on the Sugar Developer Community.
The "Rebuild Minified JS Files" action is used to rebuild the contents of the jssource directory.

 

We are considering removing this particular action from the UI because, generally, rebuilding the minfied JS files is not something we would expect most users to need to do.  While customizing jssource files is not upgrade safe, we recognize some folks in Sugar Developer community may be using this action for one reason or another.

 

Where is JavaScript stored in Sugar?

 

As of Sugar 7.7, the application stores JavaScript in multiple locations on the filesystem.

 

Core JavaScript files are stored in many places: under the include directory, the vendor directory, under many modules subdirectories, etc.  We also separately store Sidecar framework JavaScript files under the sidecar directory.

 

Copies of unminified core JavaScript source files have traditionally been placed under the jssource directory.

 

At runtime, core JavaScript files are minified and concatenated into groupings stored under the cache directory.  The contents of the JavaScript cache are regenerated as needed at runtime.

 

The Sugar application generally only uses the JavaScript stored in the cache directory at runtime. For example, a browser page running Sugar does not refer to any files under the jssource path.

 

In reality, there is no compelling need to store JavaScript files in three different locations. We need only one copy of unminified sources and one copy of minified sources located under the cache directory.

 

Keeping copies of unminified source files in a separate location under jssource is superfluous and increases confusion about how JavaScript files are handled.

 

Changes for Sugar 7.7 release

 

The following actions have been removed from the Sugar Administration user interface in Sugar 7.7.  They are available under the Repair panel.

  • Rebuild JS Compressed Files
  • Rebuild Minified JS Files
  • Repair JS Files

 

These three actions all rebuild core JavaScript files based upon contents of jssource directory.  This is not necessary when the JavaScript in the cache directory gets rebuilt during a Quick Repair or at runtime as needed.

 

While they have been removed from the UI, these actions still exist and have just been deprecated. You can still manually run these JavaScript actions if needed.

 

Manually running these actions

 

As an example, you can navigate to the following URL to run the Repair JS Files action from your browser.

http(s)://path_to_sugar/index.php?module=Administration&action=RepairJSFile&type=replace&run_deprecated_feature=1

 

You may need to update your config_override.php file to include additional http_referer configuration if you encounter a Cross Site Request Forgery (XSRF) warning.  Directions are included on that warning page if you encounter it.

 

For example, here is a config that will allow localhost to run the Repair JS Files action.config_override.php

<?php

 

$sugar_config['http_referer']['list'][] = 'localhost';$sugar_config['http_referer']['actions'] =array( 'index', 'ListView', 'DetailView', 'EditView', 'oauth', 'authorize', 'Authenticate', 'Login', 'SupportPortal', 'LogView', 'SugarpdfSettings', 'saveftsmodules', 'SaveSequence', 'PasswordManager', 'LicenseSettings', 'Updater', 'Backups', 'Languages', 'Locale', 'Upgrade', 'repair', 'GlobalSearchSettings', 'Diagnostic', 'EnableWirelessModules', 'ConfigureTabs', 'UpgradeWizard', 'ConfigureShortcutBar', 'wizard', 'historyContactsEmails', 'GoogleOauth2Redirect', 'RepairJSFile' );

 

If the action was run successfully, you should see the expected message.

 



 

 

 

Changes in upcoming Sugar releases

 

The jssource directory will be remove completely.  Unminified sources will still be available outside of the cache directory.  We also will then remove the code related to the deprecated JavaScript repair actions because at that time they would have use.