Esempio n. 1
0
 public function display()
 {
     // Disable VCR Control
     $this->ev->showVCRControl = false;
     // Default Team as Global
     if (empty($this->bean->id) && !$this->ev->isDuplicate) {
         $this->bean->team_id = 1;
         $this->bean->team_set_id = 1;
     }
     // Load TinyMCE
     require_once 'include/SugarTinyMCE.php';
     $tiny = new SugarTinyMCE();
     $tiny->defaultConfig['apply_source_formatting'] = true;
     $tiny->defaultConfig['cleanup_on_startup'] = true;
     $tiny->defaultConfig['relative_urls'] = false;
     $tiny->defaultConfig['convert_urls'] = false;
     $ed = $tiny->getInstance('body_html');
     $this->ss->assign('tiny_script', $ed);
     // Load Fields for main module
     if (empty($this->bean->base_module)) {
         $modulesList = PdfManagerHelper::getAvailableModules();
         $this->bean->base_module = key($modulesList);
     }
     $fieldsForSelectedModule = PdfManagerHelper::getFields($this->bean->base_module, true);
     $this->ss->assign('fieldsForSelectedModule', $fieldsForSelectedModule);
     parent::display();
 }
Esempio n. 2
0
 public function display()
 {
     $fieldsForSelectedModule = PdfManagerHelper::getFields($this->baseModule, true);
     $selectedField = $fieldsForSelectedModule;
     $fieldsForSubModule = array();
     if (!empty($this->baseLink) && strpos($this->baseLink, 'pdfManagerRelateLink_') === 0) {
         $selectedField = $this->baseLink;
         $linkName = substr($this->baseLink, strlen('pdfManagerRelateLink_'));
         $focus = BeanFactory::newBean($this->baseModule);
         $focus->id = create_guid();
         $linksForSelectedModule = PdfManagerHelper::getLinksForModule($this->baseModule);
         if (isset($linksForSelectedModule[$linkName]) && $focus->load_relationship($linkName)) {
             $fieldsForSubModule = PdfManagerHelper::getFields($focus->{$linkName}->getRelatedModuleName());
         }
     }
     $this->ss->assign('fieldsForSelectedModule', $fieldsForSelectedModule);
     $this->ss->assign('selectedField', $selectedField);
     $this->ss->assign('fieldsForSubModule', $fieldsForSubModule);
     $this->ss->display('modules/PdfManager/tpls/getFields.tpl');
 }
    die('Not A Valid Entry Point');
}
/*
 * Your installation or use of this SugarCRM file is subject to the applicable
 * terms available at
 * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/.
 * If you do not agree to all of the applicable terms or do not have the
 * authority to bind the entity as an authorized representative, then do not
 * install or use this SugarCRM file.
 *
 * Copyright (C) SugarCRM Inc. All rights reserved.
 */
require_once 'include/Sugarpdf/sugarpdf_config.php';
global $mod_strings, $installer_mod_strings;
include_once 'modules/PdfManager/PdfManagerHelper.php';
$templatesArray = PdfManagerHelper::getPublishedTemplatesForModule('Quotes');
if (empty($templatesArray)) {
    $modStringSrc = return_module_language($GLOBALS['current_language'], 'PdfManager');
    $logoUrl = './themes/default/images/pdf_logo.jpg';
    if (defined('PDF_HEADER_LOGO')) {
        $logoUrl = K_PATH_CUSTOM_IMAGES . PDF_HEADER_LOGO;
        $imsize = @getimagesize($logoUrl);
        if ($imsize === FALSE) {
            // encode spaces on filename
            $logoUrl = str_replace(' ', '%20', $logoUrl);
            $imsize = @getimagesize($logoUrl);
            if ($imsize === FALSE) {
                $logoUrl = K_PATH_IMAGES . PDF_HEADER_LOGO;
            }
        }
        $logoUrl = './' . $logoUrl;
/**
 * smarty_function_sugar_button
 * This is the constructor for the Smarty plugin.
 *
 * @param $params The runtime Smarty key/value arguments
 * @param $smarty The reference to the Smarty object used in this invocation
 */
function smarty_function_sugar_button($params, $smarty)
{
    if (empty($params['module'])) {
        $smarty->trigger_error("sugar_button: missing required param (module)");
    } else {
        if (empty($params['id'])) {
            $smarty->trigger_error("sugar_button: missing required param (id)");
        } else {
            if (empty($params['view'])) {
                $smarty->trigger_error("sugar_button: missing required param (view)");
            }
        }
    }
    $js_form = empty($params['form_id']) ? "var _form = (this.form) ? this.form : document.forms[0];" : "var _form = document.getElementById('{$params['form_id']}');";
    $type = $params['id'];
    $location = empty($params['location']) ? "" : "_" . $params['location'];
    if (isset($GLOBALS['sugar_config']['enable_action_menu']) && $GLOBALS['sugar_config']['enable_action_menu'] === false) {
        $enable_action_menu = false;
    } else {
        $enable_action_menu = true;
    }
    if (!is_array($type)) {
        $module = $params['module'];
        $view = $params['view'];
        switch (strtoupper($type)) {
            case "SEARCH":
                $output = '<input tabindex="2" title="{$APP.LBL_SEARCH_BUTTON_TITLE}" onclick="SUGAR.savedViews.setChooser();" class="button" type="submit" name="button" value="{$APP.LBL_SEARCH_BUTTON_LABEL}" id="search_form_submit"/>&nbsp;';
                break;
            case "CANCEL":
                $cancelButton = '{capture name="cancelReturnUrl" assign="cancelReturnUrl"}';
                $cancelButton .= '{if !empty($smarty.request.return_action) && $smarty.request.return_action == "DetailView" && !empty($fields.id.value) && empty($smarty.request.return_id)}';
                $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$fields.id.value|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')';
                $cancelButton .= '{elseif !empty($smarty.request.return_module) || !empty($smarty.request.return_action) || !empty($smarty.request.return_id)}';
                $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$smarty.request.return_id|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')';
                $cancelButton .= '{else}';
                $cancelButton .= "parent.SUGAR.App.router.buildRoute('{$module}')";
                $cancelButton .= '{/if}';
                $cancelButton .= '{/capture}';
                $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="parent.SUGAR.App.bwc.revertAttributes();parent.SUGAR.App.router.navigate({$cancelReturnUrl}, {literal}{trigger: true}{/literal}); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> ';
                $output = $cancelButton;
                break;
            case "DELETE":
                $output = '{if $bean->aclAccess("delete")}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'ListView\'; _form.action.value=\'Delete\'; if(confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\')) SUGAR.ajaxUI.submitForm(_form);" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}" id="delete_button">{/if} ';
                break;
            case "DUPLICATE":
                $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.isDuplicate.value=true; _form.action.value=\'' . $view . '\'; _form.return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if} ';
                break;
            case "EDIT":
                $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'EditView\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if} ';
                break;
            case "FIND_DUPLICATES":
                $output = '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<input title="{$APP.LBL_DUP_MERGE}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'Step1\'; _form.module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Merge" value="{$APP.LBL_DUP_MERGE}" id="merge_duplicate_button">{/if} ';
                break;
            case "SAVE":
                $view = $_REQUEST['action'] == 'EditView' ? 'EditView' : ($view == 'EditView' ? 'EditView' : $view);
                $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' {if $isDuplicate}_form.return_id.value=\'\'; {/if}_form.action.value=\'Save\'; if(check_form(\'' . $view . '\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="' . $type . $location . '">{/if} ';
                break;
            case "SUBPANELSAVE":
                if ($view == 'QuickCreate' || isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate') {
                    $view = "form_SubpanelQuickCreate_{$module}";
                }
                $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}"  class="button" onclick="' . $js_form . ' _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return SUGAR.subpanelUtils.inlineSave(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} ';
                break;
            case "SUBPANELCANCEL":
                $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate($(this).attr(\'id\'));return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> ';
                break;
            case "SUBPANELFULLFORM":
                $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" class="button" onclick="' . $js_form . ' _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> ';
                $output .= '<input type="hidden" name="full_form" value="full_form">';
                break;
            case "DCMENUCANCEL":
                $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="javascript:lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" type="submit" name="' . $params['module'] . '_dcmenu_cancel_button" id="' . $params['module'] . '_dcmenu_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> ';
                break;
            case "DCMENUSAVE":
                if ($view == 'QuickCreate') {
                    $view = "form_DCQuickCreate_{$module}";
                } else {
                    if ($view == 'EditView') {
                        $view = "form_DCEditView_{$module}";
                    }
                }
                $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return DCMenu.save(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_dcmenu_save_button" id="' . $params['module'] . '_dcmenu_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} ';
                break;
            case "DCMENUFULLFORM":
                $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; _form.return_module.value=\'' . $params['module'] . '\';_form.return_id.value=_form.record.value;if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';SUGAR.ajaxUI.submitForm(_form,null,true);DCMenu.closeOverlay();" type="button" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> ';
                $output .= '<input type="hidden" name="full_form" value="full_form">';
                $output .= '<input type="hidden" name="is_admin" value="">';
                break;
            case "POPUPSAVE":
                $view = $view == 'QuickCreate' ? "form_QuickCreate_{$module}" : $view;
                $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" ' . 'class="button primary" onclick="' . $js_form . ' _form.action.value=\'Popup\';' . 'return check_form(\'' . $view . '\')" type="submit" name="' . $params['module'] . '_popupcreate_save_button" id="' . $params['module'] . '_popupcreate_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} ';
                break;
            case "POPUPCANCEL":
                $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" ' . 'class="button" onclick="toggleDisplay(\'addform\');return false;" ' . 'name="' . $params['module'] . '_popup_cancel_button" type="submit"' . 'id="' . $params['module'] . '_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> ';
                break;
            case "AUDIT":
                $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array());
                $json = getJSONobj();
                require_once 'include/SugarFields/Parsers/MetaParser.php';
                $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data));
                $audit_link = '<input id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" class="button" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\' type="button" value="{$APP.LNK_VIEW_CHANGE_LOG}">';
                $output = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}' . $audit_link . '{/if}{/if}';
                break;
                //Button for the Connector intergration wizard
            //Button for the Connector intergration wizard
            case "CONNECTOR":
                require_once 'include/connectors/utils/ConnectorUtils.php';
                require_once 'include/connectors/sources/SourceFactory.php';
                $modules_sources = ConnectorUtils::getDisplayConfig();
                if (!is_null($modules_sources) && !empty($modules_sources)) {
                    foreach ($modules_sources as $mod => $entry) {
                        if ($mod == $module && !empty($entry)) {
                            foreach ($entry as $source_id) {
                                $source = SourceFactory::getSource($source_id);
                                if ($source->isEnabledInWizard()) {
                                    $output = '<input title="{$APP.LBL_MERGE_CONNECTORS}" type="button" class="button" onClick="document.location=\'index.php?module=Connectors&action=Step1&record={$fields.id.value}&merge_module={$module}\'" name="merge_connector" value="{$APP.LBL_MERGE_CONNECTORS}">';
                                    if (isset($params['appendTo'])) {
                                        $smarty->append($params['appendTo'], $output);
                                        return;
                                    }
                                    return $output;
                                }
                            }
                        }
                    }
                }
                return '';
            case "PDFVIEW":
                $output = '{sugar_button module="$module" id="REALPDFVIEW" view="$view" form_id="formDetailView" record=$fields.id.value}';
                break;
            case "REALPDFVIEW":
                if (empty($params['record'])) {
                    $smarty->trigger_error("sugar_button: missing required param (record)");
                }
                $record = $params['record'];
                require_once 'modules/PdfManager/PdfManagerHelper.php';
                $pdfManagerList = PdfManagerHelper::getPublishedTemplatesForModule($module);
                //quote legacy templates
                if ($module == "Quotes") {
                    require_once 'modules/Quotes/Layouts.php';
                    $tplLayouts = get_layouts();
                }
                $output = '';
                if (!empty($pdfManagerList) || !empty($tplLayouts)) {
                    if (SugarThemeRegistry::current()->name != "Classic") {
                        if ($enable_action_menu) {
                            $output = '
                            <input id="pdfview_button" value="' . translate('LBL_PDF_VIEW') . '" type="button" class="button"  />';
                        }
                        $pdfItems = array();
                        if (!empty($pdfManagerList)) {
                            foreach ($pdfManagerList as $pdfTemplate) {
                                if (!$enable_action_menu) {
                                    $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'name' => $pdfTemplate->name);
                                } else {
                                    $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id);
                                    $pdfItems[] = array('html' => '<a id="' . $pdfTemplate->name . '_pdfview" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>', 'items' => array());
                                }
                            }
                        }
                        //quote legacy templates
                        if ($module == "Quotes") {
                            foreach ($tplLayouts as $sugarpdf => $path) {
                                if (!$enable_action_menu) {
                                    $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => '', 'name' => $path);
                                } else {
                                    $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => '');
                                    $pdfItems[] = array('html' => '<a href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $path . '</a>', 'items' => array());
                                }
                            }
                        }
                        sort($pdfItems);
                        if (!$enable_action_menu) {
                            if (!empty($urlParams)) {
                                $output .= '<ul class="clickMenu fancymenu">';
                                $output .= '<li class="sugar_action_button">';
                                $output .= '<a>' . translate('LBL_PDF_VIEW') . '</a>';
                                $output .= '<ul class="subnav" style="display: none;">';
                                foreach ($urlParams as $tplButton) {
                                    if (isset($tplButton['pdf_template_id'])) {
                                        $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&pdf_template_id=' . $tplButton['pdf_template_id'];
                                        $output .= '<li><a id="' . $tplButton['name'] . '_pdfview" ' . 'href="' . $parentLocation . '">' . $tplButton['name'] . '</a></li>';
                                    } else {
                                        // legacy templates
                                        $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&email_action=' . $tplButton['email_action'];
                                        $output .= '<li><a id="' . $tplButton['name'] . '_pdfview" ' . 'href="' . $parentLocation . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $tplButton['name'] . '</a></li>';
                                    }
                                }
                                $output .= '</ul><span class="ab"></span></li></ul>';
                            }
                        } else {
                            require_once 'include/SugarSmarty/plugins/function.sugar_menu.php';
                            $output .= smarty_function_sugar_menu(array('id' => "pdfview_action_menu", 'items' => $pdfItems, 'htmlOptions' => array('class' => 'subnav-sub'), 'itemOptions' => array(), 'submenuHtmlOptions' => array()), $smarty);
                        }
                    } else {
                        $output = '
                            <script type="text/javascript">
                                function display_pdf_list(el) {
                                    var menu = \'';
                        if (!empty($pdfManagerList)) {
                            foreach ($pdfManagerList as $pdfTemplate) {
                                $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id);
                                $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>';
                            }
                        }
                        //quote legacy templates
                        if ($module == "Quotes") {
                            require_once 'modules/Quotes/Layouts.php';
                            $tplLayouts = get_layouts();
                            foreach ($tplLayouts as $sugarpdf => $path) {
                                $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => '');
                                $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $path . '</a>';
                            }
                        }
                        $output .= '\';
                                SUGAR.util.showHelpTips(el,menu);
                                }
                            </script>
                            <a onclick="display_pdf_list(this);" />' . translate('LBL_PDF_VIEW') . '</a>
                          ';
                    }
                }
                break;
            case "PDFEMAIL":
                $output = '{sugar_button module="$module" id="REALPDFEMAIL" view="$view" form_id="formDetailView" record=$fields.id.value}';
                break;
            case "REALPDFEMAIL":
                $output = '';
                global $current_user, $sugar_config;
                $userPref = $current_user->getPreference('email_link_type');
                $defaultPref = $sugar_config['email_default_client'];
                if ($userPref != '') {
                    $client = $userPref;
                } else {
                    $client = $defaultPref;
                }
                if ($client == 'sugar') {
                    if (empty($params['record'])) {
                        $smarty->trigger_error("sugar_button: missing required param (record)");
                    }
                    $record = $params['record'];
                    require_once 'modules/PdfManager/PdfManagerHelper.php';
                    $pdfManagerList = PdfManagerHelper::getPublishedTemplatesForModule($module);
                    //quote legacy templates
                    if ($module == "Quotes") {
                        require_once 'modules/Quotes/Layouts.php';
                        $tplLayouts = get_layouts();
                    }
                    if (!empty($pdfManagerList) || !empty($tplLayouts)) {
                        if (SugarThemeRegistry::current()->name != "Classic") {
                            if ($enable_action_menu) {
                                $output = '
                            <input id="pdfemail_button" value="' . translate('LBL_PDF_EMAIL') . '" type="button" class="button"  />';
                            }
                            $pdfItems = array();
                            if (!empty($pdfManagerList)) {
                                foreach ($pdfManagerList as $pdfTemplate) {
                                    if (!$enable_action_menu) {
                                        $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1", 'name' => $pdfTemplate->name);
                                    } else {
                                        $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1");
                                        $pdfItems[] = array('html' => '<a id="' . $pdfTemplate->name . '_pdfemail" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>', 'items' => array());
                                    }
                                }
                            }
                            //quote legacy templates
                            if ($module == "Quotes") {
                                foreach ($tplLayouts as $sugarpdf => $path) {
                                    if (!$enable_action_menu) {
                                        $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout', 'name' => $path);
                                    } else {
                                        $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout');
                                        $pdfItems[] = array('html' => '<a href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $path . '</a>', 'items' => array());
                                    }
                                }
                            }
                            sort($pdfItems);
                            if (!$enable_action_menu) {
                                if (!empty($urlParams)) {
                                    $output .= '<ul class="clickMenu fancymenu">';
                                    $output .= '<li class="sugar_action_button">';
                                    $output .= '<a>' . translate('LBL_PDF_EMAIL') . '</a>';
                                    $output .= '<ul class="subnav" style="display: none;">';
                                    foreach ($urlParams as $tplButton) {
                                        if (isset($tplButton['pdf_template_id'])) {
                                            $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&pdf_template_id=' . $tplButton['pdf_template_id'] . '&to_email=' . $tplButton['to_email'];
                                            $output .= '<li><a id="' . $tplButton['name'] . '_pdfemail" ' . 'href="' . $parentLocation . '">' . $tplButton['name'] . '</a></li>';
                                        } else {
                                            // legacy templates
                                            $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&email_action=' . $tplButton['email_action'];
                                            $output .= '<li><a id="' . $tplButton['name'] . '_pdfemail" ' . 'href="' . $parentLocation . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $tplButton['name'] . '</a></li>';
                                        }
                                    }
                                    $output .= '</ul><span class="ab"></span></li></ul>';
                                }
                            } else {
                                require_once 'include/SugarSmarty/plugins/function.sugar_menu.php';
                                $output .= smarty_function_sugar_menu(array('id' => "pdfview_action_menu", 'items' => $pdfItems, 'htmlOptions' => array('class' => 'subnav-sub'), 'itemOptions' => array(), 'submenuHtmlOptions' => array()), $smarty);
                            }
                        } else {
                            $output = '
                            <script language="javascript">
                                function display_pdf_email_list(el) {
                                    var menu = \'';
                            if (!empty($pdfManagerList)) {
                                foreach ($pdfManagerList as $pdfTemplate) {
                                    $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1");
                                    $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>';
                                }
                            }
                            //quote legacy templates
                            if ($module == "Quotes") {
                                require_once 'modules/Quotes/Layouts.php';
                                $tplLayouts = get_layouts();
                                foreach ($tplLayouts as $sugarpdf => $path) {
                                    $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout');
                                    $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $sugarpdf . '</a>';
                                }
                            }
                            $output .= '\';
                                SUGAR.util.showHelpTips(el,menu);
                                }
                            </script>
                                <a onclick="display_pdf_email_list(this);" />' . translate('LBL_PDF_EMAIL') . '</a>
                          ';
                        }
                    }
                }
                break;
            case 'SHARE':
                // TODO we shouldn't rely on the name field only, but we don't
                // have this information anywhere and this is BWC code...
                $shareButton = <<<ENDB
<form>
<input type="hidden" id="share_button_name" value="{\$fields.name.value}">
<input title="{\$APP.LBL_SHARE_BUTTON_TITLE}" accessKey="{\$APP.LBL_SHARE_BUTTON_KEY}"
  class="button" onclick="parent.SUGAR.App.bwc.shareRecord('{$params['module']}', '{\$fields.id.value}', this.form.share_button_name.value)" type="button" name="button" value="{\$APP.LBL_SHARE_BUTTON_LABEL}">
</form>
ENDB;
                $output = $shareButton;
                break;
        }
        //switch
        if (isset($params['appendTo'])) {
            $smarty->append($params['appendTo'], $output);
            return;
        }
        return $output;
    } else {
        if (is_array($type) && isset($type['sugar_html'])) {
            require_once 'include/SugarHtml/SugarHtml.php';
            $dom_tree = SugarHtml::parseSugarHtml($type['sugar_html']);
            replaceFormClick($dom_tree, $js_form);
            $output = SugarHtml::createHtml($dom_tree);
            if (isset($params['appendTo'])) {
                $smarty->append($params['appendTo'], $output);
                return;
            }
            return $output;
        } else {
            if (is_array($type) && isset($type['customCode'])) {
                require_once 'include/SugarHtml/SugarHtml.php';
                $dom_tree = SugarHtml::parseHtmlTag($type['customCode']);
                $hidden_exists = false;
                replaceFormClick($dom_tree, $js_form, $hidden_exists);
                if ($hidden_exists) {
                    //If the customCode contains hidden fields, the extracted hidden fields need to append in the original form
                    $form = $smarty->get_template_vars('form');
                    $hidden_fields = $dom_tree;
                    extractHiddenInputs($hidden_fields);
                    if (!isset($form)) {
                        $form = array();
                    }
                    if (!isset($form['hidden'])) {
                        $form['hidden'] = array();
                    }
                    $form['hidden'][] = SugarHtml::createHtml($hidden_fields);
                    $smarty->assign('form', $form);
                }
                $output = SugarHtml::createHtml($dom_tree);
                if (isset($params['appendTo'])) {
                    $smarty->append($params['appendTo'], $output);
                    return;
                }
                return $output;
            }
        }
    }
}
Esempio n. 5
0
 public function get_list_view_data()
 {
     $the_array = parent::get_list_view_data();
     $the_array['BASE_MODULE'] = PdfManagerHelper::getModuleName($this->base_module);
     return $the_array;
 }
Esempio n. 6
0
 /**
  * Takes an array of field defs and returns a formated list of fields that are valid for use in select list.
  *
  * @param  array $fieldDef
  * @return array
  */
 public static function cleanFields($fieldDef, $moduleName = '', $includeLinks = true, $forRelatedField = false, $returnKeys = false)
 {
     $bannedFieldsAndLinks = PdfManagerHelper::getBannnedFieldsAndLinks();
     $fieldArray = array();
     foreach ($fieldDef as $fieldName => $def) {
         if (!is_array($def) || $fieldName == 'deleted' || empty($def['type'])) {
             continue;
         }
         if (isset($bannedFieldsAndLinks[$moduleName]) && isset($bannedFieldsAndLinks[$moduleName]['fields']) && in_array($fieldName, $bannedFieldsAndLinks[$moduleName]['fields'])) {
             continue;
         }
         //Check the studio property of the field def.
         if (isset($def['studio']) && (self::isFalse($def['studio']) || is_array($def['studio']) && (isset($def['studio']['formula']) && self::isFalse($def['studio']['formula']) || $forRelatedField && isset($def['studio']['related']) && self::isFalse($def['studio']['related'])))) {
             continue;
         }
         switch ($def['type']) {
             case "int":
             case "float":
             case "decimal":
             case "currency":
                 $fieldArray[$fieldName] = array($fieldName, 'number');
                 break;
             case "bool":
                 $fieldArray[$fieldName] = array($fieldName, 'boolean');
                 break;
             case "varchar":
             case "name":
             case "user_name":
             case "phone":
             case "text":
             case "url":
             case "encrypt":
             case "enum":
             case "radio":
             case "radioenum":
             case "multienum":
                 $fieldArray[$fieldName] = array($fieldName, 'string');
                 break;
             case "relate":
                 if (!empty($def['ext2'])) {
                     $fieldArray[$fieldName] = array($fieldName, 'string');
                 }
                 break;
             case "date":
             case "datetime":
             case "datetimecombo":
                 $fieldArray[$fieldName] = array($fieldName, 'date');
                 break;
             case "link":
                 if ($includeLinks) {
                     $fieldArray[$fieldName] = array($fieldName, 'relate');
                 }
                 break;
             default:
                 //Do Nothing
                 break;
         }
     }
     if ($returnKeys) {
         return $fieldArray;
     }
     return array_values($fieldArray);
 }
 public function preDisplay()
 {
     parent::preDisplay();
     // settings for disable smarty php tags
     $this->ss->security_settings['PHP_TAGS'] = false;
     $this->ss->security = true;
     if (defined('SUGAR_SHADOW_PATH')) {
         $this->ss->secure_dir[] = SUGAR_SHADOW_PATH;
     }
     // header/footer settings
     $this->setPrintHeader(false);
     $this->setPrintFooter(true);
     // always print page number at least
     if (!empty($_REQUEST['pdf_template_id'])) {
         $pdfTemplate = BeanFactory::newBean('PdfManager');
         if ($pdfTemplate->retrieve($_REQUEST['pdf_template_id'], false) !== null) {
             $previewMode = FALSE;
             if (!empty($_REQUEST['pdf_preview']) && $_REQUEST['pdf_preview'] == 1) {
                 $previewMode = true;
                 $this->bean = BeanFactory::newBean($pdfTemplate->base_module);
             }
             $this->SetCreator(PDF_CREATOR);
             $this->SetAuthor($pdfTemplate->author);
             $this->SetTitle($pdfTemplate->title);
             $this->SetSubject($pdfTemplate->subject);
             $this->SetKeywords($pdfTemplate->keywords);
             $this->templateLocation = $this->buildTemplateFile($pdfTemplate, $previewMode);
             $headerLogo = '';
             if (!empty($pdfTemplate->header_logo)) {
                 // Create a temporary copy of the header logo
                 // and append the original filename, so TCPDF can figure the extension
                 $headerLogo = 'upload/' . $pdfTemplate->id . $pdfTemplate->header_logo;
                 copy('upload/' . $pdfTemplate->id, $headerLogo);
             }
             if (!empty($pdfTemplate->header_logo) || !empty($pdfTemplate->header_title) || !empty($pdfTemplate->header_text)) {
                 $this->setHeaderData($headerLogo, PDF_HEADER_LOGO_WIDTH, $pdfTemplate->header_title, $pdfTemplate->header_text);
                 $this->setPrintHeader(true);
             }
             if (!empty($pdfTemplate->footer_text)) {
                 $this->footerText = $pdfTemplate->footer_text;
             }
             $filenameParts = array();
             if (!empty($this->bean) && !empty($this->bean->name)) {
                 $filenameParts[] = $this->bean->name;
             }
             if (!empty($pdfTemplate->name)) {
                 $filenameParts[] = $pdfTemplate->name;
             }
             $cr = array(' ', "\r", "\n", "/");
             $this->pdfFilename = str_replace($cr, '_', implode("_", $filenameParts) . ".pdf");
         }
     }
     if ($previewMode === FALSE) {
         require_once 'modules/PdfManager/PdfManagerHelper.php';
         $fields = PdfManagerHelper::parseBeanFields($this->bean, true);
     } else {
         $fields = array();
     }
     if ($this->module == 'Quotes' && $previewMode === FALSE) {
         global $locale;
         require_once 'modules/Quotes/Quote.php';
         require_once 'modules/Quotes/config.php';
         require_once 'modules/Currencies/Currency.php';
         $currency = BeanFactory::getBean('Currencies');
         $format_number_array = array('currency_symbol' => true, 'type' => 'sugarpdf', 'currency_id' => $this->bean->currency_id, 'charset_convert' => true);
         $currency->retrieve($this->bean->currency_id);
         $fields['currency_iso'] = $currency->iso4217;
         // Adding Tax Rate Field
         $fields['taxrate_value'] = format_number_sugarpdf($this->bean->taxrate_value, $locale->getPrecision(), $locale->getPrecision(), array('percentage' => true));
         $this->bean->load_relationship('product_bundles');
         $product_bundle_list = $this->bean->product_bundles->getBeans();
         usort($product_bundle_list, array('ProductBundle', 'compareProductBundlesByIndex'));
         $bundles = array();
         $count = 0;
         foreach ($product_bundle_list as $ordered_bundle) {
             $bundleFields = PdfManagerHelper::parseBeanFields($ordered_bundle, true);
             $bundleFields['products'] = array();
             $product_bundle_line_items = $ordered_bundle->get_product_bundle_line_items();
             foreach ($product_bundle_line_items as $product_bundle_line_item) {
                 $bundleFields['products'][$count] = PdfManagerHelper::parseBeanFields($product_bundle_line_item, true);
                 if ($product_bundle_line_item->object_name == "ProductBundleNote") {
                     $bundleFields['products'][$count]['name'] = $bundleFields['products'][$count]['description'];
                 } else {
                     // Special case about discount amount
                     if ($product_bundle_line_item->discount_select) {
                         $bundleFields['products'][$count]['discount_amount'] = format_number($product_bundle_line_item->discount_amount, $locale->getPrecision(), $locale->getPrecision()) . '%';
                     }
                     // Special case about ext price
                     $bundleFields['products'][$count]['ext_price'] = format_number_sugarpdf($product_bundle_line_item->discount_price * $product_bundle_line_item->quantity, $locale->getPrecision(), $locale->getPrecision(), $format_number_array);
                 }
                 $count++;
             }
             $bundles[] = $bundleFields;
         }
         $this->ss->assign('product_bundles', $bundles);
     }
     $this->ss->assign('fields', $fields);
 }