function edit_display($line, SugarBean $bean = null, $params = array())
    {
        global $app_list_strings;
        $email_templates_arr = get_bean_select_array(true, 'EmailTemplate', 'name');
        if (!in_array($bean->module_dir, getEmailableModules())) {
            unset($app_list_strings['aow_email_type_list']['Record Email']);
        }
        $targetOptions = getRelatedEmailableFields($bean->module_dir);
        if (empty($targetOptions)) {
            unset($app_list_strings['aow_email_type_list']['Related Field']);
        }
        $html = '<input type="hidden" name="aow_email_type_list" id="aow_email_type_list" value="' . get_select_options_with_id($app_list_strings['aow_email_type_list'], '') . '">
				  <input type="hidden" name="aow_email_to_list" id="aow_email_to_list" value="' . get_select_options_with_id($app_list_strings['aow_email_to_list'], '') . '">';
        $checked = '';
        if (isset($params['individual_email']) && $params['individual_email']) {
            $checked = 'CHECKED';
        }
        $html .= "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
        $html .= "<tr>";
        $html .= '<td id="relate_label" scope="row" valign="top">' . translate("LBL_INDIVIDUAL_EMAILS", "AOW_Actions") . ':';
        $html .= '</td>';
        $html .= "<td valign='top' width='37.5%'>";
        $html .= "<input type='hidden' name='aow_actions_param[" . $line . "][individual_email]' value='0' >";
        $html .= "<input type='checkbox' id='aow_actions_param[" . $line . "][individual_email]' name='aow_actions_param[" . $line . "][individual_email]' value='1' {$checked}></td>";
        $html .= '</td>';
        if (!isset($params['email_template'])) {
            $params['email_template'] = '';
        }
        $hidden = "style='visibility: hidden;'";
        if ($params['email_template'] != '') {
            $hidden = "";
        }
        $html .= '<td id="name_label" scope="row" valign="top" width="12.5%">' . translate("LBL_EMAIL_TEMPLATE", "AOW_Actions") . ':<span class="required">*</span></td>';
        $html .= "<td valign='top' width='37.5%'>";
        $html .= "<select name='aow_actions_param[" . $line . "][email_template]' id='aow_actions_param_email_template" . $line . "' onchange='show_edit_template_link(this," . $line . ");' >" . get_select_options_with_id($email_templates_arr, $params['email_template']) . "</select>";
        $html .= "&nbsp;<a href='javascript:open_email_template_form(" . $line . ")' >" . translate('LBL_CREATE_EMAIL_TEMPLATE', 'AOW_Actions') . "</a>";
        $html .= "&nbsp;<span name='edit_template' id='aow_actions_edit_template_link" . $line . "' {$hidden}><a href='javascript:edit_email_template_form(" . $line . ")' >" . translate('LBL_EDIT_EMAIL_TEMPLATE', 'AOW_Actions') . "</a></span>";
        $html .= "</td>";
        $html .= "</tr>";
        $html .= "<tr>";
        $html .= '<td id="name_label" scope="row" valign="top" width="12.5%">' . translate("LBL_EMAIL", "AOW_Actions") . ':<span class="required">*</span></td>';
        $html .= '<td valign="top" scope="row" width="37.5%">';
        $html .= '<button type="button" onclick="add_emailLine(' . $line . ')"><img src="' . SugarThemeRegistry::current()->getImageURL('id-ff-add.png') . '"></button>';
        $html .= '<table id="emailLine' . $line . '_table" width="100%"></table>';
        $html .= '</td>';
        $html .= "</tr>";
        $html .= "</table>";
        $html .= "<script id ='aow_script" . $line . "'>";
        //backward compatible
        if (isset($params['email_target_type']) && !is_array($params['email_target_type'])) {
            $email = '';
            switch ($params['email_target_type']) {
                case 'Email Address':
                    $email = $params['email'];
                    break;
                case 'Specify User':
                    $email = $params['email_user_id'];
                    break;
                case 'Related Field':
                    $email = $params['email_target'];
                    break;
            }
            $html .= "load_emailline('" . $line . "','to','" . $params['email_target_type'] . "','" . $email . "');";
        }
        //end backward compatible
        if (isset($params['email_target_type'])) {
            foreach ($params['email_target_type'] as $key => $field) {
                if (is_array($params['email'][$key])) {
                    $params['email'][$key] = json_encode($params['email'][$key]);
                }
                $html .= "load_emailline('" . $line . "','" . $params['email_to_type'][$key] . "','" . $params['email_target_type'][$key] . "','" . $params['email'][$key] . "');";
            }
        }
        $html .= "</script>";
        return $html;
    }
示例#2
0
function getRelatedEmailableFields($module)
{
    global $beanList, $app_list_strings;
    $relEmailFields = array();
    $checked_link = array();
    $emailableModules = getEmailableModules();
    if ($module != '') {
        if (isset($beanList[$module]) && $beanList[$module]) {
            $mod = new $beanList[$module]();
            foreach ($mod->get_related_fields() as $field) {
                if (isset($field['link'])) {
                    $checked_link[] = $field['link'];
                }
                if (!isset($field['module']) || !in_array($field['module'], $emailableModules) || isset($field['dbType']) && $field['dbType'] == "id") {
                    continue;
                }
                $relEmailFields[$field['name']] = $field['module'] . ": " . trim(translate($field['vname'], $mod->module_name), ":");
            }
            foreach ($mod->get_linked_fields() as $field) {
                if (!in_array($field['name'], $checked_link) && !in_array($field['relationship'], $checked_link)) {
                    if (isset($field['module']) && $field['module'] != '') {
                        $rel_module = $field['module'];
                    } else {
                        if ($mod->load_relationship($field['name'])) {
                            $relField = $field['name'];
                            $rel_module = $mod->{$relField}->getRelatedModuleName();
                        }
                    }
                    if (in_array($rel_module, $emailableModules)) {
                        if (isset($field['vname']) && $field['vname'] != '') {
                            $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module] . ' : ' . translate($field['vname'], $mod->module_dir);
                        } else {
                            $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module] . ' : ' . $field['name'];
                        }
                    }
                }
            }
            array_multisort($relEmailFields, SORT_ASC, $relEmailFields);
        }
    }
    return $relEmailFields;
}
示例#3
0
function getRelatedEmailableFields($module)
{
    global $beanList;
    $relEmailFields = array();
    $emailableModules = getEmailableModules();
    if ($module != '') {
        if (isset($beanList[$module]) && $beanList[$module]) {
            $mod = new $beanList[$module]();
            foreach ($mod->get_related_fields() as $field) {
                if (!isset($field['module']) || !in_array($field['module'], $emailableModules) || isset($field['dbType']) && $field['dbType'] == "id") {
                    continue;
                }
                $relEmailFields[$field['name']] = $field['module'] . ": " . trim(translate($field['vname'], $mod->module_name), ":");
            }
            array_multisort($relEmailFields, SORT_ASC, $relEmailFields);
        }
    }
    return $relEmailFields;
}