2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
42 * Created on Oct 4, 2005
44 * To change the template for this generated file go to
45 * Window - Preferences - PHPeclipse - PHP - Code Templates
50 //require_once('include/utils.php');
51 require_once('include/json_config.php');
52 $json_config = new json_config();
55 global $app_list_strings;
59 global $sugar_version, $sugar_config;
63 $xtpl = new XTemplate('modules/MailMerge/Step2.html');
64 $xtpl->assign("MOD", $mod_strings);
65 $xtpl->assign("APP", $app_strings);
66 $xtpl->assign('JSON_CONFIG_JAVASCRIPT', $json_config->get_static_json_server(false, true));
68 if(isset($_POST['mailmerge_module']))
70 $_SESSION['MAILMERGE_MODULE'] = $_POST['mailmerge_module'];
71 if($_SESSION['MAILMERGE_MODULE'] == 'Campaigns'){
72 $_SESSION['MAILMERGE_MODULE'] = 'CampaignProspects';
74 if($_SESSION['MAILMERGE_MODULE'] == 'Contacts' || $_SESSION['MAILMERGE_MODULE'] == 'Leads'|| $_SESSION['MAILMERGE_MODULE'] == 'CampaignProspects')
77 $_SESSION['MAILMERGE_SKIP_REL'] = true;
81 $step_txt = "Step 2: ";
82 if(!empty($_SESSION['SELECTED_OBJECTS_DEF'])){
83 $selObjs = $_SESSION['SELECTED_OBJECTS_DEF'];
85 parse_str($selObjs,$sel_obj);
87 $_SESSION['MAILMERGE_WHERE'] = "";
88 foreach($sel_obj as $key => $value){
89 $value = str_replace("##", "&", $value);
90 $idArray[$key] = $value;
91 if($_SESSION['MAILMERGE_MODULE'] == 'CampaignProspects'){
92 if(isset($_POST['mailmerge_module']) && $_POST['mailmerge_module'] == 'Campaigns'){
93 $where = "campaigns.id = '$key'";
94 $_SESSION['MAILMERGE_WHERE'] = $where;
95 $_SESSION['MAILMERGE_CAMPAIGN_ID'] = $key;
102 $xtpl->assign("MAILMERGE_WHERE", $_SESSION['MAILMERGE_WHERE']);
103 $xtpl->assign("MAILMERGE_PRESELECTED_OBJECTS", get_select_options_with_id($idArray, '0'));
104 $step_txt .= "Refine list of ".$_SESSION['MAILMERGE_MODULE']." to merge.";
105 $xtpl->assign("MAILMERGE_GET_OBJECTS", 0);
109 $step_txt .= "Select list of ".$_SESSION['MAILMERGE_MODULE']." to merge.";
110 $xtpl->assign("MAILMERGE_GET_OBJECTS", 1);
113 if(isset($_SESSION['MAILMERGE_SKIP_REL']) && $_SESSION['MAILMERGE_SKIP_REL'])
115 $xtpl->assign("STEP", "4");
122 if(isset($_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO']) && $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO']){
123 $selected = $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'];
125 $xtpl->assign("STEP", "3");
126 //$xtpl->assign("MAIL_MERGE_CONTAINS_CONTACT_INFO", '<table><tr><td><input id="contains_contact_info" name="contains_contact_info" class="checkbox" type="checkbox" '.$checked.'/></td><td>'.$mod_strings['LBL_CONTAINS_CONTACT_INFO'].'</td></tr></table>');
127 $rel_options = array(""=>"--None--");
128 $seed = loadBean($_SESSION['MAILMERGE_MODULE']);
129 if($seed->load_relationship('contacts')){
130 $rel_options["Contacts"] = "Contacts";
132 if($_SESSION['MAILMERGE_MODULE'] == "Accounts"){
133 $rel_options["Opportunities"] = "Opportunities";
135 elseif($_SESSION['MAILMERGE_MODULE'] == "Opportunities"){
136 $rel_options["Accounts"] = "Accounts";
138 $xtpl->assign("MAIL_MERGE_CONTAINS_CONTACT_INFO", '<table><tr><td>'.$mod_strings['LBL_CONTAINS_CONTACT_INFO'].'</td><td><select id="contains_contact_info" name="contains_contact_info">'.get_select_options_with_id($rel_options, $selected).'</select></td></tr></table>');
141 $xtpl->assign("MAILMERGE_MODULE", $_SESSION['MAILMERGE_MODULE']);
142 $xtpl->assign("MAILMERGE_PREV", SugarThemeRegistry::current()->getImage('previous','border="0" style="margin-left: 1px;" id="prevItems" onClick="decreaseOffset();getObjects();"',null,null,'.gif',$mod_strings['LBL_BACK']));
143 $xtpl->assign("MAILMERGE_NEXT", SugarThemeRegistry::current()->getImage('next','border="0" style="margin-left: 1px;" alt="Next" id="nextItems" onClick="increaseOffset();getObjects();"',null,null,'.gif',$mod_strings['LBL_NEXT']));
144 $xtpl->assign("MAILMERGE_RIGHT_TO_LEFT", SugarThemeRegistry::current()->getImage('leftarrow_big','border="0" style="margin-left: 1px;" onClick="moveLeft();"',null,null,'.gif',$mod_strings['LBL_REMOVE']));
145 $xtpl->assign("MAILMERGE_LEFT_TO_RIGHT", SugarThemeRegistry::current()->getImage('rightarrow_big','border="0" style="margin-left: 1px;" onClick="moveRight();"',null,null,'.gif',$mod_strings['LBL_ADD']));
146 $xtpl->assign("MAIL_MERGE_HEADER_STEP_2", $step_txt);
147 if($_SESSION['MAILMERGE_MODULE'] == 'CampaignProspects'){
148 $rel_options = array("Contacts"=>"Contacts", "Leads" => "Leads", "Prospects" => "Prospects", "Users"=>"Users");
149 $xtpl->assign("MAIL_MERGE_CAMPAIGN_PROSPECT_SELECTOR", '<select id="campaign_prospect_type" name="campaign_prospect_type">'.get_select_options_with_id($rel_options, 'Prospects').'</select>');
153 if(!empty($_POST['document_id']))
155 $_SESSION['MAILMERGE_DOCUMENT_ID'] = $_POST['document_id'];
159 $xtpl->parse("main");
162 function displaySelectionBox($objectList)
164 $html = '<select id="display_objs" name="display_objs[]" size="10" multiple="multiple" size="10" >';
165 foreach($objectList as $key=>$value)
167 $html .= '<option value="'.$key.'">'.$value.'</option>';
169 $html .= '</select>';