]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/EmailMarketing/EditView.php
Release 6.4.0
[Github/sugarcrm.git] / modules / EmailMarketing / EditView.php
1 <?php
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.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38 require_once('modules/EmailMarketing/Forms.php');
39
40 global $timedate;
41 global $app_strings;
42 global $app_list_strings;
43 global $mod_strings;
44 global $current_user;
45
46 // Unimplemented until jscalendar language files are fixed
47 // global $current_language;
48 // global $default_language;
49 // global $cal_codes;
50
51 $focus = new EmailMarketing();
52 if(isset($_REQUEST['record'])) {
53     $focus->retrieve($_REQUEST['record']);
54 }
55
56 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
57         $focus->id = "";
58 }
59 global $theme;
60
61
62
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']);
68 }
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);
79
80 if (isset($_REQUEST['return_module'])) {
81         $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
82 } else {
83         $xtpl->assign("RETURN_MODULE", 'Campaigns');
84 }
85 if (isset($_REQUEST['return_action'])) {
86         $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
87 } else {
88         $xtpl->assign("RETURN_ACTION", 'DetailView');
89 }
90 if (isset($_REQUEST['return_id'])) {
91         $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
92 } else {
93         if (!empty($focus->campaign_id)) {
94                 $xtpl->assign("RETURN_ID", $focus->campaign_id);
95         }
96 }
97
98 if($focus->campaign_id) {
99         $campaign_id=$focus->campaign_id;
100 } else {
101         $campaign_id=$_REQUEST['campaign_id'];
102 }
103 $xtpl->assign("CAMPAIGN_ID", $campaign_id);
104
105 if(empty($time_ampm) || empty($focus->time_start)) {
106     $time_start = $focus->time_start;
107 } else {
108     $split = $timedate->splitTime($focus->time_start, $timedate->get_time_format());
109     $time_start = $split['h'].$timedate->timeSeparator().$split['m'];
110 }
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("DATE_START", $focus->date_start);
120 $xtpl->assign("TIME_START", $time_start);
121 $xtpl->assign("TIME_FORMAT", '('. $timedate->get_user_time_format().')');
122
123 $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name','','name');
124 if($focus->template_id) {
125         $xtpl->assign("TEMPLATE_ID", $focus->template_id);
126         $xtpl->assign("EMAIL_TEMPLATE_OPTIONS", get_select_options_with_id($email_templates_arr, $focus->template_id));
127         $xtpl->assign("EDIT_TEMPLATE","visibility:inline");
128 }
129 else {
130         $xtpl->assign("EMAIL_TEMPLATE_OPTIONS", get_select_options_with_id($email_templates_arr, ""));
131         $xtpl->assign("EDIT_TEMPLATE","visibility:hidden");
132 }
133
134 //include campaign utils..
135 require_once('modules/Campaigns/utils.php');
136 if (empty($_REQUEST['campaign_name'])) {
137
138         $campaign = new Campaign();
139         $campaign->retrieve($campaign_id);
140         $campaign_name=$campaign->name;
141 } else {
142         $campaign_name=$_REQUEST['campaign_name'];
143 }
144
145 $params = array();
146 $params[] = "<a href='index.php?module=Campaigns&action=index'>{$mod_strings['LNK_CAMPAIGN_LIST']}</a>";
147 $params[] = "<a href='index.php?module=Campaigns&action=DetailView&record={$campaign_id}'>{$campaign_name}</a>";
148 if(empty($focus->id)){
149         $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']." ".$mod_strings['LBL_MODULE_NAME'];
150 }else{
151         $params[] = "<a href='index.php?module={$focus->module_dir}&action=DetailView&record={$focus->id}'>{$focus->name}</a>";
152         $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
153 }
154
155 echo getClassicModuleTitle($focus->module_dir, $params, true);
156 $scope_options=get_message_scope_dom($campaign_id,$campaign_name,$focus->db);
157 $prospectlists=array();
158 if (isset($focus->all_prospect_lists) && $focus->all_prospect_lists==1) {
159         $xtpl->assign("ALL_PROSPECT_LISTS_CHECKED","checked");
160         $xtpl->assign("MESSAGE_FOR_DISABLED","disabled");
161 }
162 else {
163         //get select prospect list.
164         if (!empty($focus->id)) {
165                 $focus->load_relationship('prospectlists');
166                 $prospectlists=$focus->prospectlists->get();
167         };
168 }
169 if (empty($prospectlists)) $prospectlists=array();
170 if (empty($scope_options)) $scope_options=array();
171 $xtpl->assign("SCOPE_OPTIONS", get_select_options_with_id($scope_options, $prospectlists));
172
173 $emails=array();
174 $mailboxes=get_campaign_mailboxes($emails);
175 $mailboxes_with_from_name = get_campaign_mailboxes($emails, false);
176
177 //add empty options.
178 $emails['']='nobody@example.com';
179 $mailboxes['']='';
180
181 //inbound_email_id
182 $default_email_address='nobody@example.com';
183 $from_emails = '';
184 foreach ($mailboxes_with_from_name as $id=>$name) {
185         if (!empty($from_emails)) {
186                 $from_emails.=',';
187         }
188         if ($id=='') {
189                 $from_emails.="'EMPTY','$name','$emails[$id]'";
190         } else {
191                 $from_emails.="'$id','$name','$emails[$id]'";
192         }
193         if ($id==$focus->inbound_email_id) {
194                 $default_email_address=$emails[$id];
195         }
196 }
197 $xtpl->assign("FROM_EMAILS",$from_emails);
198 $xtpl->assign("DEFAULT_FROM_EMAIL",$default_email_address);
199
200 if (empty($focus->inbound_email_id)) {
201         $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, ''));
202 } else {
203         $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, $focus->inbound_email_id));
204 }
205
206 $xtpl->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['email_marketing_status_dom'], $focus->status));
207
208 $xtpl->parse("main");
209 $xtpl->out("main");
210
211
212
213 $javascript = new javascript();
214 $javascript->setFormName('EditView');
215 $javascript->setSugarBean($focus);
216 $javascript->addAllFields('');
217 echo $javascript->getScript();
218 ?>