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 ********************************************************************************/
38 require_once('modules/EmailMarketing/Forms.php');
42 global $app_list_strings;
46 // Unimplemented until jscalendar language files are fixed
47 // global $current_language;
48 // global $default_language;
51 $focus = new EmailMarketing();
52 if(isset($_REQUEST['record'])) {
53 $focus->retrieve($_REQUEST['record']);
56 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
63 $GLOBALS['log']->info("EmailMarketing Edit View");
64 $xtpl=new XTemplate ('modules/EmailMarketing/EditView.html');
65 if(!ACLController::checkAccess('EmailTemplates', 'edit', true)){
66 unset($mod_strings['LBL_CREATE_EMAIL_TEMPLATE']);
67 unset($mod_strings['LBL_EDIT_EMAIL_TEMPLATE']);
69 $xtpl->assign("MOD", $mod_strings);
70 $xtpl->assign("APP", $app_strings);
71 $xtpl->assign("THEME", SugarThemeRegistry::current()->__toString());
72 // Unimplemented until jscalendar language files are fixed
73 // $xtpl->assign("CALENDAR_LANG", ((empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]));
74 $xtpl->assign("CALENDAR_LANG", "en");
75 $xtpl->assign("USER_DATEFORMAT", '('. $timedate->get_user_date_format().')');
76 $xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
77 $time_ampm = $timedate->AMPMMenu('', $focus->time_start);
78 $xtpl->assign("TIME_MERIDIEM", $time_ampm);
80 if (isset($_REQUEST['return_module'])) {
81 $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
83 $xtpl->assign("RETURN_MODULE", 'Campaigns');
85 if (isset($_REQUEST['return_action'])) {
86 $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
88 $xtpl->assign("RETURN_ACTION", 'DetailView');
90 if (isset($_REQUEST['return_id'])) {
91 $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
93 if (!empty($focus->campaign_id)) {
94 $xtpl->assign("RETURN_ID", $focus->campaign_id);
98 if($focus->campaign_id) {
99 $campaign_id=$focus->campaign_id;
101 $campaign_id=$_REQUEST['campaign_id'];
103 $xtpl->assign("CAMPAIGN_ID", $campaign_id);
105 if(empty($time_ampm) || empty($focus->time_start)) {
106 $time_start = $focus->time_start;
108 $split = $timedate->splitTime($focus->time_start, $timedate->get_time_format());
109 $time_start = $split['h'].$timedate->timeSeparator().$split['m'];
111 $xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
112 $xtpl->assign("JAVASCRIPT", get_set_focus_js().get_validate_record_js());
113 $xtpl->assign("DATE_ENTERED", $focus->date_entered);
114 $xtpl->assign("DATE_MODIFIED", $focus->date_modified);
115 $xtpl->assign("ID", $focus->id);
116 $xtpl->assign("NAME", $focus->name);
117 $xtpl->assign("FROM_NAME", $focus->from_name);
118 $xtpl->assign("FROM_ADDR", $focus->from_addr);
119 $xtpl->assign("REPLY_NAME", $focus->reply_to_name);
120 $xtpl->assign("REPLY_ADDR", $focus->reply_to_addr);
121 $xtpl->assign("DATE_START", $focus->date_start);
122 $xtpl->assign("TIME_START", $time_start);
123 $xtpl->assign("TIME_FORMAT", '('. $timedate->get_user_time_format().')');
125 $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name',"(type IS NULL OR type='' OR type='campaign')",'name');
126 if($focus->template_id) {
127 $xtpl->assign("TEMPLATE_ID", $focus->template_id);
128 $xtpl->assign("EMAIL_TEMPLATE_OPTIONS", get_select_options_with_id($email_templates_arr, $focus->template_id));
129 $xtpl->assign("EDIT_TEMPLATE","visibility:inline");
132 $xtpl->assign("EMAIL_TEMPLATE_OPTIONS", get_select_options_with_id($email_templates_arr, ""));
133 $xtpl->assign("EDIT_TEMPLATE","visibility:hidden");
136 //include campaign utils..
137 require_once('modules/Campaigns/utils.php');
138 if (empty($_REQUEST['campaign_name'])) {
140 $campaign = new Campaign();
141 $campaign->retrieve($campaign_id);
142 $campaign_name=$campaign->name;
144 $campaign_name=$_REQUEST['campaign_name'];
148 $params[] = "<a href='index.php?module=Campaigns&action=index'>{$mod_strings['LNK_CAMPAIGN_LIST']}</a>";
149 $params[] = "<a href='index.php?module=Campaigns&action=DetailView&record={$campaign_id}'>{$campaign_name}</a>";
150 if(empty($focus->id)){
151 $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']." ".$mod_strings['LBL_MODULE_NAME'];
153 $params[] = "<a href='index.php?module={$focus->module_dir}&action=DetailView&record={$focus->id}'>{$focus->name}</a>";
154 $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
157 echo getClassicModuleTitle($focus->module_dir, $params, true);
158 $scope_options=get_message_scope_dom($campaign_id,$campaign_name,$focus->db);
159 $prospectlists=array();
160 if (isset($focus->all_prospect_lists) && $focus->all_prospect_lists==1) {
161 $xtpl->assign("ALL_PROSPECT_LISTS_CHECKED","checked");
162 $xtpl->assign("MESSAGE_FOR_DISABLED","disabled");
165 //get select prospect list.
166 if (!empty($focus->id)) {
167 $focus->load_relationship('prospectlists');
168 $prospectlists=$focus->prospectlists->get();
171 if (empty($prospectlists)) $prospectlists=array();
172 if (empty($scope_options)) $scope_options=array();
173 $xtpl->assign("SCOPE_OPTIONS", get_select_options_with_id($scope_options, $prospectlists));
176 $mailboxes=get_campaign_mailboxes($emails);
177 $mailboxes_with_from_name = get_campaign_mailboxes($emails, false);
180 $emails['']='nobody@example.com';
184 $default_email_address='nobody@example.com';
186 foreach ($mailboxes_with_from_name as $id=>$name) {
187 if (!empty($from_emails)) {
191 $from_emails.="'EMPTY','$name','$emails[$id]'";
193 $from_emails.="'$id','$name','$emails[$id]'";
195 if ($id==$focus->inbound_email_id) {
196 $default_email_address=$emails[$id];
199 $xtpl->assign("FROM_EMAILS",$from_emails);
200 $xtpl->assign("DEFAULT_FROM_EMAIL",$default_email_address);
202 if (empty($focus->inbound_email_id)) {
203 $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, ''));
205 $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, $focus->inbound_email_id));
208 $xtpl->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['email_marketing_status_dom'], $focus->status));
210 //pass in info to populate from/reply address info
211 require_once('modules/Campaigns/utils.php');
212 $json = getJSONobj();
213 $IEStoredOptions = get_campaign_mailboxes_with_stored_options();
214 $IEStoredOptionsJSON = (!empty($IEStoredOptions)) ? $json->encode($IEStoredOptions, false) : 'new Object()';
215 $xtpl->assign("IEStoredOptions", $IEStoredOptionsJSON);
218 $xtpl->parse("main");
223 $javascript = new javascript();
224 $javascript->setFormName('EditView');
225 $javascript->setSugarBean($focus);
226 $javascript->addAllFields('');
227 echo $javascript->getScript();