$class_name = $beanList[$relModule]; require_once $beanFiles[$class_name]; $seed = new $class_name(); if (isset($_SESSION['MAILMERGE_SKIP_REL']) && $_SESSION['MAILMERGE_SKIP_REL']) { $disabled = 'disabled'; } else { $disabled = ''; } $oddRow = true; foreach ($sel_obj as $key => $value) { $value = str_replace("##", "&", $value); $value = stripslashes($value); $code = md5($key); $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'rel_id_' . $code, 'name' => 'rel_name_' . $code)); $encoded_popup_request_data = urlencode($json->encode($popup_request_data)); $fullQuery = get_merge_query($seed, $_SESSION['MAILMERGE_MODULE'], $key); $result = $seed->db->limitQuery($fullQuery, 0, 1, true, "Error performing limit query"); $full_name = ''; $contact_id = ''; if ($row = $seed->db->fetchByAssoc($result, 0)) { if ($relModule == "Contacts") { $full_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']); } else { $full_name = $row['name']; } $contact_id = $row['id']; } $umodule = urlencode($_SESSION['MAILMERGE_MODULE']); $ukey = urlencode($key); $change_parent_button = "<input title='{$app_strings['LBL_SELECT_BUTTON_TITLE']}' tabindex='2' type='button' class='button' value='{$app_strings['LBL_SELECT_BUTTON_LABEL']}'\n\t\tname='button' onclick='open_popup(document.EditView.rel_type_{$code}.value, 600, 400,\n\t\t\t\"&html=mail_merge&rel_module={$umodule}&id={$ukey}&request_data={$encoded_popup_request_data}\", true, false, {});' {$disabled}/>"; $items = array('ID' => $key, 'NAME' => $value, 'CODE' => $code, 'TYPE_OPTIONS' => get_select_options_with_id($modules, '0'), 'CHANGE_RELATIONSHIP' => $change_parent_button, 'CONTACT_ID' => $contact_id, 'CONTACT_NAME' => $full_name, 'REL_MODULE' => $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO']);
function process_page_for_merge() { global $theme; global $mod_strings; global $app_strings; global $currentModule; global $sugar_version, $sugar_config; $output_html = ''; $where = ''; $where = $this->_get_where_clause(); $first_name = empty($_REQUEST['first_name']) ? '' : $_REQUEST['first_name']; $last_name = empty($_REQUEST['last_name']) ? '' : $_REQUEST['last_name']; $account_name = empty($_REQUEST['account_name']) ? '' : $_REQUEST['account_name']; $hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true; $button = "<form action='index.php' method='post' name='form' id='form'>\n"; //START:FOR MULTI-SELECT $multi_select = false; if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') { $multi_select = true; $button .= "<input type='button' name='button' class='button' onclick=\"send_back_selected('Contacts',document.MassUpdate,'mass[]','" . $app_strings['ERR_NOTHING_SELECTED'] . "');\" title='" . $app_strings['LBL_SELECT_BUTTON_TITLE'] . "' accesskey='" . $app_strings['LBL_SELECT_BUTTON_KEY'] . "' value=' " . $app_strings['LBL_SELECT_BUTTON_LABEL'] . " ' />\n"; } //END:FOR MULTI-SELECT if (!$hide_clear_button) { $button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='" . $app_strings['LBL_CLEAR_BUTTON_TITLE'] . "' value=' " . $app_strings['LBL_CLEAR_BUTTON_LABEL'] . " ' />\n"; } $button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='" . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . "' accesskey='" . $app_strings['LBL_CANCEL_BUTTON_KEY'] . "' value=' " . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . " ' />\n"; $button .= "</form>\n"; $form = new XTemplate('modules/Contacts/MailMergePicker.html'); $form->assign('MOD', $mod_strings); $form->assign('APP', $app_strings); $form->assign('THEME', $theme); $form->assign('MODULE_NAME', $currentModule); $form->assign('FIRST_NAME', $first_name); $form->assign('LAST_NAME', $last_name); $form->assign('ACCOUNT_NAME', $account_name); $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data']; $form->assign('request_data', $request_data); ob_start(); insert_popup_header($theme); $output_html .= ob_get_contents(); ob_end_clean(); $output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false); $form->parse('main.SearchHeader'); $output_html .= $form->text('main.SearchHeader'); // Reset the sections that are already in the page so that they do not print again later. $form->reset('main.SearchHeader'); // create the listview $seed_bean = new Contact(); $ListView = new ListView(); $ListView->display_header_and_footer = false; $ListView->show_export_button = false; $ListView->process_for_popups = true; $ListView->setXTemplate($form); $ListView->multi_select_popup = $multi_select; if ($multi_select) { $ListView->xTemplate->assign("TAG_TYPE", "SPAN"); } else { $ListView->xTemplate->assign("TAG_TYPE", "A"); } $ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']); $ListView->setQuery($where, '', 'contacts.last_name, contacts.first_name', 'CONTACT'); $ListView->setModStrings($mod_strings); ob_start(); $output_html .= get_form_header($mod_strings['LBL_LIST_FORM_TITLE'], $button, false); //BEGIN ATHENA CUSTOMIZATION - rsmith require_once 'modules/MailMerge/merge_query.php'; $rel_module = empty($_REQUEST['rel_module']) ? '' : $_REQUEST['rel_module']; $id = empty($_REQUEST['id']) ? '' : $_REQUEST['id']; $query = get_merge_query($seed_bean, $rel_module, $id); $result = $seed_bean->db->query($query, true, "Error retrieving {$seed_bean->object_name} list: "); $list = array(); while (($row = $seed_bean->db->fetchByAssoc($result)) != null) { $seed_bean = new Contact(); foreach ($seed_bean->field_defs as $field => $value) { if (isset($row[$field])) { $seed_bean->{$field} = $row[$field]; } else { if (isset($row[$seed_bean->table_name . '.' . $field])) { $seed_bean->{$field} = $row[$seed_bean->table_name . '.' . $field]; } else { $seed_bean->{$field} = ""; } } } $seed_bean->fill_in_additional_list_fields(); $list[] = $seed_bean; } $ListView->processListViewTwo($list, 'main', 'CONTACT'); //END ATHENA CUSTOMIZATION - rsmith $output_html .= ob_get_contents(); ob_end_clean(); $output_html .= insert_popup_footer(); return $output_html; }