Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9691 - Add PDF template functionality to more modules automatically #9692

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/DetailView/DetailView2.php
Expand Up @@ -96,6 +96,11 @@ public function setup(
}
if (!empty($this->metadataFile) && file_exists($this->metadataFile)) {
require($this->metadataFile);
if (!in_array($this->module, AOS_PDF_Templates::$excludedModulesToAddButtons)){
$viewdefs[$this->module][$this->view]['templateMeta']['form']['buttons']['AOS_GENLET'] = array ('customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="{$APP.LBL_PRINT_AS_PDF}">');
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::DVPopupHtml($this->module);
}
} else {
//If file doesn't exist we create a best guess
if (!file_exists("modules/$this->module/metadata/$metadataFileName.php") &&
Expand Down
10 changes: 10 additions & 0 deletions include/ListView/ListViewDisplay.php
Expand Up @@ -380,6 +380,9 @@ protected function buildActionsLink($id = 'actions_link', $location = 'top')
&& $this->export
) {
$menuItems[] = $this->buildExportLink($location);
if (!in_array($this->seed->module_dir, AOS_PDF_Templates::$excludedModulesToAddButtons)){
$menuItems[] = $this->buildPDFLinkAndPopupHtml();
}
}

foreach ($this->actionsMenuExtraItems as $item) {
Expand Down Expand Up @@ -416,6 +419,13 @@ protected function buildExportLink($loc = 'top')
return "<a href='javascript:void(0)' class=\"parent-dropdown-action-handler\" id=\"export_listview_". $loc ." \" onclick=\"return sListView.send_form(true, '{$this->seed->module_dir}', 'index.php?entryPoint=export','{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_EXPORT']}</a>";
}

protected function buildPDFLinkAndPopupHtml()
{
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::LVPopupHtml($this->seed->module_name);
return formLetter::LVSmarty();
}

/**
* Builds the massupdate link
*
Expand Down
Expand Up @@ -47,6 +47,13 @@
$viewdefs[$module_name]['DetailView'] = array(
'templateMeta' => array(
'maxColumns' => '2',
'form' => array(
'buttons' => array(
'EDIT',
'DUPLICATE',
'DELETE',
)
),
'form' => array(),
'widths' => array(
array('label' => '10', 'field' => '30'),
Expand Down
6 changes: 0 additions & 6 deletions include/language/en_us.lang.php
Expand Up @@ -3129,12 +3129,6 @@
$app_list_strings['product_quote_parent_type_dom']['AOS_Quotes'] = 'Quotes';
$app_list_strings['product_quote_parent_type_dom']['AOS_Invoices'] = 'Invoices';
$app_list_strings['product_quote_parent_type_dom']['AOS_Contracts'] = 'Contracts';
$app_list_strings['pdf_template_type_dom']['AOS_Quotes'] = 'Quotes';
$app_list_strings['pdf_template_type_dom']['AOS_Invoices'] = 'Invoices';
$app_list_strings['pdf_template_type_dom']['AOS_Contracts'] = 'Contracts';
$app_list_strings['pdf_template_type_dom']['Accounts'] = 'Accounts';
$app_list_strings['pdf_template_type_dom']['Contacts'] = 'Contacts';
$app_list_strings['pdf_template_type_dom']['Leads'] = 'Leads';
$app_list_strings['pdf_template_sample_dom'][''] = '';
$app_list_strings['contract_status_list']['Not Started'] = 'Not Started';
$app_list_strings['contract_status_list']['In Progress'] = 'In Progress';
Expand Down
32 changes: 32 additions & 0 deletions modules/AOS_PDF_Templates/AOS_PDF_Templates.php
Expand Up @@ -30,10 +30,42 @@
require_once('modules/AOS_PDF_Templates/AOS_PDF_Templates_sugar.php');
class AOS_PDF_Templates extends AOS_PDF_Templates_sugar
{
public static $excludedModulesForCreateTemplates = ['Home', 'Calendar'];
public static $excludedModulesToAddButtons = [
'Home',
'Calendar',
'Users',
'SecurityGroups',
'OAuth2Clients',
'OAuthKeys',
'Schedulers',
'AOS_Contracts', // The Contracts, Quotes and Invoices modules
'AOS_Quotes', // add their own custom buttons
'AOS_Invoices' // and therefore they are excluded.
];

public function __construct()
{
parent::__construct();
global $app_list_strings;
$app_list_strings['pdf_template_type_dom'] = $this->loadTabModules();
}

public static function loadTabModules()
{
global $app_list_strings;
include_once 'modules/MySettings/TabController.php';
$controller = new TabController();
$currentTabs = $controller->get_system_tabs();

$modules = array();
foreach($currentTabs as $key => $mod){
if (!in_array($mod, self::$excludedModulesForCreateTemplates)) {
$modules[$key] = (isset($app_list_strings['moduleList'][$key])) ? $app_list_strings['moduleList'][$key] : $key;
}
}

asort($modules);
return $modules;
}
}
2 changes: 1 addition & 1 deletion modules/Accounts/AccountsListViewSmarty.php
Expand Up @@ -151,6 +151,6 @@ public function buildExportLink($id = 'export_link')
"'index.php?entryPoint=jjwg_Maps&display_module={$_REQUEST['module']}', " .
"'{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_MAP']}</a>";

return formLetter::LVSmarty().$script;
return $script;
}
}
3 changes: 0 additions & 3 deletions modules/Accounts/views/view.detail.php
Expand Up @@ -64,9 +64,6 @@ public function display()
sugar_die($app_strings['ERROR_NO_RECORD']);
}

require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::DVPopupHtml('Accounts');

$this->dv->process();

if (ACLController::checkAccess('Contacts', 'edit', true)) {
Expand Down
2 changes: 0 additions & 2 deletions modules/Accounts/views/view.list.php
Expand Up @@ -9,8 +9,6 @@ class AccountsViewList extends ViewList
*/
public function preDisplay()
{
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::LVPopupHtml('Accounts');
parent::preDisplay();

$this->lv = new AccountsListViewSmarty();
Expand Down
2 changes: 1 addition & 1 deletion modules/Contacts/ContactsListViewSmarty.php
Expand Up @@ -54,6 +54,6 @@ public function buildExportLink($id = 'export_link')
"'index.php?entryPoint=jjwg_Maps&display_module={$_REQUEST['module']}', " .
"'{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_MAP']}</a>";

return formLetter::LVSmarty().$script;
return $script;
}
}
3 changes: 0 additions & 3 deletions modules/Contacts/views/view.detail.php
Expand Up @@ -60,9 +60,6 @@ public function display()

$this->ss->assign("AOP_PORTAL_ENABLED", $aop_portal_enabled);

require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::DVPopupHtml('Contacts');

$admin = BeanFactory::newBean('Administration');
$admin->retrieveSettings();
if (isset($admin->settings['portal_on']) && $admin->settings['portal_on']) {
Expand Down
2 changes: 0 additions & 2 deletions modules/Contacts/views/view.list.php
Expand Up @@ -9,8 +9,6 @@ class ContactsViewList extends ViewList
*/
public function preDisplay()
{
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::LVPopupHtml('Contacts');
parent::preDisplay();

$this->lv = new ContactsListViewSmarty();
Expand Down
2 changes: 1 addition & 1 deletion modules/Leads/LeadsListViewSmarty.php
Expand Up @@ -53,6 +53,6 @@ public function buildExportLink($id = 'export_link')
"'index.php?entryPoint=jjwg_Maps&display_module={$_REQUEST['module']}', " .
"'{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_MAP']}</a>";

return formLetter::LVSmarty().$script;
return $script;
}
}
3 changes: 0 additions & 3 deletions modules/Leads/views/view.detail.php
Expand Up @@ -48,9 +48,6 @@ public function display()
{
global $sugar_config;

require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::DVPopupHtml('Leads');

//If the convert lead action has been disabled for already converted leads, disable the action link.
$disableConvert = ($this->bean->status == 'Converted' && !empty($sugar_config['disable_convert_lead'])) ? true : false;
$this->ss->assign("DISABLE_CONVERT_ACTION", $disableConvert);
Expand Down
2 changes: 0 additions & 2 deletions modules/Leads/views/view.list.php
Expand Up @@ -9,8 +9,6 @@ class LeadsViewList extends ViewList
*/
public function preDisplay()
{
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::LVPopupHtml('Leads');
parent::preDisplay();

$this->lv = new LeadsListViewSmarty();
Expand Down
9 changes: 9 additions & 0 deletions modules/Notes/metadata/detailviewdefs.php
Expand Up @@ -45,6 +45,15 @@
'templateMeta' =>
array(
'maxColumns' => '2',
'form' =>
array(
'buttons' =>
array(
0 => 'EDIT',
1 => 'DUPLICATE',
2 => 'DELETE',
),
),
'widths' =>
array(
0 =>
Expand Down