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 ********************************************************************************/
38 /*********************************************************************************
40 * Description: TODO: To be written.
41 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42 * All Rights Reserved.
43 * Contributor(s): ______________________________________..
44 ********************************************************************************/
48 require_once('modules/EmailMarketing/Forms.php');
53 global $app_list_strings;
57 // Unimplemented until jscalendar language files are fixed
58 // global $current_language;
59 // global $default_language;
62 $focus = new EmailMarketing();
63 if(isset($_REQUEST['record'])) {
64 $focus->retrieve($_REQUEST['record']);
67 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
74 $GLOBALS['log']->info("EmailMarketing Edit View");
75 $xtpl=new XTemplate ('modules/EmailMarketing/EditView.html');
76 if(!ACLController::checkAccess('EmailTemplates', 'edit', true)){
77 unset($mod_strings['LBL_CREATE_EMAIL_TEMPLATE']);
78 unset($mod_strings['LBL_EDIT_EMAIL_TEMPLATE']);
80 $xtpl->assign("MOD", $mod_strings);
81 $xtpl->assign("APP", $app_strings);
82 $xtpl->assign("THEME", SugarThemeRegistry::current()->__toString());
83 // Unimplemented until jscalendar language files are fixed
84 // $xtpl->assign("CALENDAR_LANG", ((empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]));
85 $xtpl->assign("CALENDAR_LANG", "en");
86 $xtpl->assign("USER_DATEFORMAT", '('. $timedate->get_user_date_format().')');
87 $xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
88 $xtpl->assign("TIME_MERIDIEM", $timedate->AMPMMenu('', $focus->time_start));
90 if (isset($_REQUEST['return_module'])) {
91 $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
93 $xtpl->assign("RETURN_MODULE", 'Campaigns');
95 if (isset($_REQUEST['return_action'])) {
96 $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
98 $xtpl->assign("RETURN_ACTION", 'DetailView');
100 if (isset($_REQUEST['return_id'])) {
101 $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
103 if (!empty($focus->campaign_id)) {
104 $xtpl->assign("RETURN_ID", $focus->campaign_id);
108 if($focus->campaign_id) {
109 $campaign_id=$focus->campaign_id;
112 $campaign_id=$_REQUEST['campaign_id'];
114 $xtpl->assign("CAMPAIGN_ID", $campaign_id);
117 $xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
118 $xtpl->assign("JAVASCRIPT", get_set_focus_js().get_validate_record_js());
119 $xtpl->assign("DATE_ENTERED", $focus->date_entered);
120 $xtpl->assign("DATE_MODIFIED", $focus->date_modified);
121 $xtpl->assign("ID", $focus->id);
122 $xtpl->assign("NAME", $focus->name);
123 $xtpl->assign("FROM_NAME", $focus->from_name);
124 $xtpl->assign("FROM_ADDR", $focus->from_addr);
125 $xtpl->assign("DATE_START", $focus->date_start);
126 $xtpl->assign("TIME_START", $focus->time_start);
127 $xtpl->assign("TIME_FORMAT", '('. $timedate->get_user_time_format().')');
129 $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name','','name');
130 if($focus->template_id) {
131 $xtpl->assign("TEMPLATE_ID", $focus->template_id);
132 $xtpl->assign("EMAIL_TEMPLATE_OPTIONS", get_select_options_with_id($email_templates_arr, $focus->template_id));
133 $xtpl->assign("EDIT_TEMPLATE","visibility:inline");
136 $xtpl->assign("EMAIL_TEMPLATE_OPTIONS", get_select_options_with_id($email_templates_arr, ""));
137 $xtpl->assign("EDIT_TEMPLATE","visibility:hidden");
140 //include campaign utils..
141 require_once('modules/Campaigns/utils.php');
142 if (empty($_REQUEST['campaign_name'])) {
144 $campaign = new Campaign();
145 $campaign->retrieve($campaign_id);
146 $campaign_name=$campaign->name;
148 $campaign_name=$_REQUEST['campaign_name'];
152 $params[] = "<a href='index.php?module=Campaigns&action=index'>{$mod_strings['LNK_CAMPAIGN_LIST']}</a>";
153 $params[] = "<a href='index.php?module=Campaigns&action=DetailView&record={$campaign_id}'>{$campaign_name}</a>";
154 if(empty($focus->id)){
155 $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']." ".$mod_strings['LBL_MODULE_NAME'];
157 $params[] = "<a href='index.php?module={$focus->module_dir}&action=DetailView&record={$focus->id}'>{$focus->name}</a>";
158 $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
161 echo getClassicModuleTitle($focus->module_dir, $params, true);
162 $scope_options=get_message_scope_dom($campaign_id,$campaign_name,$focus->db);
163 $prospectlists=array();
164 if (isset($focus->all_prospect_lists) && $focus->all_prospect_lists==1) {
165 $xtpl->assign("ALL_PROSPECT_LISTS_CHECKED","checked");
166 $xtpl->assign("MESSAGE_FOR_DISABLED","disabled");
169 //get select prospect list.
170 if (!empty($focus->id)) {
171 $focus->load_relationship('prospectlists');
172 $prospectlists=$focus->prospectlists->get();
175 if (empty($prospectlists)) $prospectlists=array();
176 if (empty($scope_options)) $scope_options=array();
177 $xtpl->assign("SCOPE_OPTIONS", get_select_options_with_id($scope_options, $prospectlists));
180 $mailboxes=get_campaign_mailboxes($emails);
181 $mailboxes_with_from_name = get_campaign_mailboxes($emails, false);
184 $emails['']='nobody@example.com';
188 $default_email_address='nobody@example.com';
190 foreach ($mailboxes_with_from_name as $id=>$name) {
191 if (!empty($from_emails)) {
195 $from_emails.="'EMPTY','$name','$emails[$id]'";
197 $from_emails.="'$id','$name','$emails[$id]'";
199 if ($id==$focus->inbound_email_id) {
200 $default_email_address=$emails[$id];
203 $xtpl->assign("FROM_EMAILS",$from_emails);
204 $xtpl->assign("DEFAULT_FROM_EMAIL",$default_email_address);
206 if (empty($focus->inbound_email_id)) {
207 $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, ''));
209 $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, $focus->inbound_email_id));
212 $xtpl->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['email_marketing_status_dom'], $focus->status));
214 $xtpl->parse("main");
219 $javascript = new javascript();
220 $javascript->setFormName('EditView');
221 $javascript->setSugarBean($focus);
222 $javascript->addAllFields('');
223 echo $javascript->getScript();