Hello everyone,
I want to generate a custom PDF in record view. And want to add button for pdf in Edit button dropdown as par below image.
Want to show record view data in PDF as table format.
Hello everyone,
I want to generate a custom PDF in record view. And want to add button for pdf in Edit button dropdown as par below image.
Want to show record view data in PDF as table format.
Did you try the pdf generator in admin section?
Harald Kuske
Principal Solution Architect – Professional Services, EMEA
hkuske@sugarcrm.com
SugarCRM Deutschland GmbH
Hello Harald Kuske,
But I want to know about if we need to customize through code then how we can do this means need to apply some other field in pdf
laxmichand
laxmichand
PDF Manager handles adding the item in the menu when there is a published PDF for that module.
As for adding data from related records you will need to do some customizations.
See Cédric Mourizard's post
sugarclub.sugarcrm.com/.../how-to-customize-the-sugar-pdf-manager
Thanks Francesca Shiekh
I will try this.
laxmichand
Hello Francesca Shiekh,
I have tried it but getting the error:
TCPDF ERROR: The class SugarpdfSmarty has to be extended and you have to set a location for the Smarty template.
My code is:
<?php
require_once 'include/Sugarpdf/sugarpdf/sugarpdf.pdfmanager.php';
class PO_Purchase_OrderSugarpdfPdfmanager extends SugarpdfPdfmanager
{
public function preDisplay()
{
$GLOBALS['log']->fatal("pdf bean->name ".$this->bean->name);
parent::preDisplay();
$previewMode = false;
if (!empty($_REQUEST['pdf_preview']) && $_REQUEST['pdf_preview'] == 1) {
$previewMode = true;
}
if ($previewMode === false) {
// Select links to add
$linksToLoad = array('po_purchase_order_ori_order_request_item_1', 'po_purchase_order_poi_purchase_order_item_1');
foreach ($linksToLoad as $linkName) {
// @var PO_Purchase_Order $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);
}
}
}
}
laxmichand
Hello Francesca Shiekh,
I have applied it according to https://sugarclub.sugarcrm.com/dev-club/b/dev-blog/posts/how-to-customize-the-sugar-pdf-manager but if I add assigned variable in PDF Manager then getting 500 internal error. Let me know if there are any issue in my code.
My code in PDF Manager:
{if isset($po_purchase_order_ori_order_request_item_1item) and $po_purchase_order_ori_order_request_item_1item|@count gt 0}
<table style="width: 100%;" border="0">
<tbody>
<tr>
<td><strong>Name</strong></td>
<td>Email</td>
<td>Phone</td>
</tr>
{foreach from=$po_purchase_order_ori_order_request_item_1 item="contact"}
<tr>
<td>{$contact.name}</td>
<td>Email {$contact.email1}</td>
<td>{$contact.status}</td>
</tr>
{/foreach} </tbody>
</table>
{/if}
Thanks
Laxmichand saini
laxmichand
You have a couple of mistakes in your smarty:
first the foreach statements need to be inside html comments
<!-- {foreach from=$po_purchase_order_ori_order_request_item_1 item="contact"} -->
and
<!-- {/foreach} -->
Second, it looks like you are pulling items from a PO so they are probably not "contacts"
which means that these fields are probably incorrect:
<td>{$contact.name}</td>
<td>Email {$contact.email1}</td>
<td>{$contact.status}</td>
Your code will most likely look more something like:
<!-- {foreach from=$po_purchase_order_ori_order_request_item_1 item="item"} -->
<tr>
<td>{$item.name}</td>
...some other fields here like quantity, etc.
</tr>
<!-- {/foreach} --> </tbody>
Thanks Francesca Shiekh for your suggestion I will try according this.
laxmichand
Hello Francesca Shiekh,
One more question for that how to apply pdf manager according conditionally.
1. I want show download button only if Category = Vet Check and Category = Test.
2. I want to print different pdf if Category = Vet Check and Category = Test.
Please let me know how to manage.
Thanks,
Laxmichand saini
laxmichand