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-2012 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 ********************************************************************************/
39 * Created on Oct 4, 2005
41 * To change the template for this generated file go to
42 * Window - Preferences - PHPeclipse - PHP - Code Templates
53 global $app_list_strings;
58 $xtpl = new XTemplate('modules/MailMerge/Step4.html');
59 $xtpl->assign("MOD", $mod_strings);
60 $xtpl->assign("APP", $app_strings);
62 if(!empty($_POST['document_id']))
64 $_SESSION['MAILMERGE_DOCUMENT_ID'] = $_POST['document_id'];
66 $document_id = $_SESSION['MAILMERGE_DOCUMENT_ID'];
67 $revision = new DocumentRevision();
68 $revision->retrieve($document_id);
69 //$document = new Document();
70 //$document->retrieve($document_id);
72 if(!empty($_POST['selected_objects']))
74 $selObjs = urldecode($_POST['selected_objects']);
75 $_SESSION['SELECTED_OBJECTS_DEF'] = $selObjs;
77 $selObjs = $_SESSION['SELECTED_OBJECTS_DEF'];
80 parse_str(stripslashes(html_entity_decode($selObjs, ENT_QUOTES)),$sel_obj);
81 foreach($sel_obj as $key=>$value)
83 $sel_obj[$key] = stripslashes($value);
86 //build relationship array
87 foreach($sel_obj as $key=>$value)
89 $id = 'rel_id_'.str_replace('-', '', $key);
90 if(isset($_POST[$id]) && !empty($_POST[$id]))
92 $relArray[$key] = $_POST[$id];
97 $builtArray = array();
98 if(count($relArray) > 0)
100 $_SESSION['MAILMERGE_RELATED_CONTACTS'] = $relArray;
102 $relModule = $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'];
103 global $beanList, $beanFiles;
104 $class_name = $beanList[$relModule ];
105 require_once($beanFiles[$class_name]);
107 $seed = new $class_name();
108 foreach($sel_obj as $key=>$value)
110 $builtArray[$key] = $value;
111 if(isset($relArray[$key]))
113 $seed->retrieve($relArray[$key]);
115 if($relModule == "Contacts"){
116 $name = $locale->getLocaleFormattedName($seed->first_name,$seed->last_name);
121 $builtArray[$key] = str_replace('##', '&', $value)." (".$name.")";
128 $builtArray = $sel_obj;
131 $xtpl->assign("MAILMERGE_MODULE", $_SESSION['MAILMERGE_MODULE']);
132 $xtpl->assign("MAILMERGE_DOCUMENT_ID", $document_id);
133 $xtpl->assign("MAILMERGE_TEMPLATE", $revision->filename." (rev. ".$revision->revision.")");
134 $xtpl->assign("MAILMERGE_SELECTED_OBJECTS", get_select_options_with_id($builtArray,'0'));
135 $xtpl->assign("MAILMERGE_SELECTED_OBJECTS_DEF", urlencode($selObjs));
138 if(isset($_SESSION['MAILMERGE_SKIP_REL']) && $_SESSION['MAILMERGE_SKIP_REL'] || !isset($_SESSION['MAILMERGE_RELATED_CONTACTS']) || empty($_SESSION['MAILMERGE_RELATED_CONTACTS']))
140 $xtpl->assign("PREV_STEP", "2");
145 $xtpl->assign("PREV_STEP", "3");
148 $xtpl->assign("STEP_NUM", "Step ".$step_num.":");
150 $xtpl->parse("main");