Skip to content

Instantly share code, notes, and snippets.

@cmourizard
Created March 13, 2016 10:42
Show Gist options
  • Save cmourizard/288411475064a7bd6f16 to your computer and use it in GitHub Desktop.
Save cmourizard/288411475064a7bd6f16 to your computer and use it in GitHub Desktop.
Dealing with PDF Manager
<?php
$defaultConfig = array(
'forced_root_block' => '',
);
<?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);
}
}
}
}
<h1>Meeting Summary</h1>
Topic:&nbsp;{$fields.name}<br />
Description:&nbsp;{$fields.description}<br />
{if isset($contacts) and $contacts|@count gt 0}
<br />
<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}
<br />
<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}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment