]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/EmailMarketing/EditView.php
Release 6.1.4
[Github/sugarcrm.git] / modules / EmailMarketing / EditView.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM 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 /*********************************************************************************
39
40  * Description:  TODO: To be written.
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42  * All Rights Reserved.
43  * Contributor(s): ______________________________________..
44  ********************************************************************************/
45
46
47
48 require_once('modules/EmailMarketing/Forms.php');
49
50
51 global $timedate;
52 global $app_strings;
53 global $app_list_strings;
54 global $mod_strings;
55 global $current_user;
56
57 // Unimplemented until jscalendar language files are fixed
58 // global $current_language;
59 // global $default_language;
60 // global $cal_codes;
61
62 $focus = new EmailMarketing();
63 if(isset($_REQUEST['record'])) {
64     $focus->retrieve($_REQUEST['record']);
65 }
66
67 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
68         $focus->id = "";
69 }
70 global $theme;
71
72
73
74 $GLOBALS['log']->info("EmailMarketing Edit View");
75 //echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'].": ".$focus->name, true);
76 $xtpl=new XTemplate ('modules/EmailMarketing/EditView.html');
77 if(!ACLController::checkAccess('EmailTemplates', 'edit', true)){
78         unset($mod_strings['LBL_CREATE_EMAIL_TEMPLATE']);
79         unset($mod_strings['LBL_EDIT_EMAIL_TEMPLATE']);
80 }
81 $xtpl->assign("MOD", $mod_strings);
82 $xtpl->assign("APP", $app_strings);
83 $xtpl->assign("THEME", SugarThemeRegistry::current()->__toString());
84 // Unimplemented until jscalendar language files are fixed
85 // $xtpl->assign("CALENDAR_LANG", ((empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]));
86 $xtpl->assign("CALENDAR_LANG", "en");
87 $xtpl->assign("USER_DATEFORMAT", '('. $timedate->get_user_date_format().')');
88 $xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
89 $xtpl->assign("TIME_MERIDIEM", $timedate->AMPMMenu('', $focus->time_start));
90
91 if (isset($_REQUEST['return_module'])) {
92         $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
93 } else {
94         $xtpl->assign("RETURN_MODULE", 'Campaigns');
95 }
96 if (isset($_REQUEST['return_action'])) { 
97         $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
98 } else {
99         $xtpl->assign("RETURN_ACTION", 'DetailView');
100 }       
101 if (isset($_REQUEST['return_id'])) {
102         $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
103 } else {
104         if (!empty($focus->campaign_id)) {
105                 $xtpl->assign("RETURN_ID", $focus->campaign_id);
106         }
107 }
108
109 if($focus->campaign_id) {
110         $campaign_id=$focus->campaign_id;
111 }
112 else {
113         $campaign_id=$_REQUEST['campaign_id'];
114 }
115 $xtpl->assign("CAMPAIGN_ID", $campaign_id);
116
117
118 $xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
119 $xtpl->assign("JAVASCRIPT", get_set_focus_js().get_validate_record_js());
120 $xtpl->assign("DATE_ENTERED", $focus->date_entered);
121 $xtpl->assign("DATE_MODIFIED", $focus->date_modified);
122 $xtpl->assign("ID", $focus->id);
123 $xtpl->assign("NAME", $focus->name);
124 $xtpl->assign("FROM_NAME", $focus->from_name);
125 $xtpl->assign("FROM_ADDR", $focus->from_addr);
126 $xtpl->assign("DATE_START", $focus->date_start);
127 $xtpl->assign("TIME_START", $focus->time_start);
128 $xtpl->assign("TIME_FORMAT", '('. $timedate->get_user_time_format().')');
129
130 $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name','','name');
131 if($focus->template_id) {
132         $xtpl->assign("TEMPLATE_ID", $focus->template_id);
133         $xtpl->assign("EMAIL_TEMPLATE_OPTIONS", get_select_options_with_id($email_templates_arr, $focus->template_id));
134         $xtpl->assign("EDIT_TEMPLATE","visibility:inline");
135 }
136 else {
137         $xtpl->assign("EMAIL_TEMPLATE_OPTIONS", get_select_options_with_id($email_templates_arr, ""));
138         $xtpl->assign("EDIT_TEMPLATE","visibility:hidden");
139 }
140
141 //include campaign utils..
142 require_once('modules/Campaigns/utils.php');
143 if (empty($_REQUEST['campaign_name'])) {
144         
145         $campaign = new Campaign();
146         $campaign->retrieve($campaign_id);
147         $campaign_name=$campaign->name;
148 } else {
149         $campaign_name=$_REQUEST['campaign_name'];
150 }
151
152 $params = array();
153 $params[] = "<a href='index.php?module=Campaigns&action=index'>{$mod_strings['LNK_CAMPAIGN_LIST']}</a>";
154 $params[] = "<a href='index.php?module=Campaigns&action=DetailView&record={$campaign_id}'>{$campaign_name}</a>";
155 if(empty($focus->id)){
156         $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']." ".$mod_strings['LBL_MODULE_NAME'];
157 }else{
158         $params[] = "<a href='index.php?module={$focus->module_dir}&action=DetailView&record={$focus->id}'>{$focus->name}</a>";
159         $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
160 }
161
162 echo getClassicModuleTitle($focus->module_dir, $params, true);
163 $scope_options=get_message_scope_dom($campaign_id,$campaign_name,$focus->db);
164 $prospectlists=array();
165 if (isset($focus->all_prospect_lists) && $focus->all_prospect_lists==1) {
166         $xtpl->assign("ALL_PROSPECT_LISTS_CHECKED","checked");
167         $xtpl->assign("MESSAGE_FOR_DISABLED","disabled");               
168 }       
169 else {
170         //get select prospect list.
171         if (!empty($focus->id)) {
172                 $focus->load_relationship('prospectlists');
173                 $prospectlists=$focus->prospectlists->get();
174         };
175 }
176 if (empty($prospectlists)) $prospectlists=array();
177 if (empty($scope_options)) $scope_options=array();
178 $xtpl->assign("SCOPE_OPTIONS", get_select_options_with_id($scope_options, $prospectlists));
179
180 $emails=array();
181 $mailboxes=get_campaign_mailboxes($emails);
182 $mailboxes_with_from_name = get_campaign_mailboxes($emails, false);
183
184 //add empty options.
185 $emails['']='nobody@example.com';
186 $mailboxes['']='';
187
188 //inbound_email_id
189 $default_email_address='nobody@example.com';
190 $from_emails = '';
191 foreach ($mailboxes_with_from_name as $id=>$name) {
192         if (!empty($from_emails)) {
193                 $from_emails.=',';
194         }
195         if ($id=='') {
196                 $from_emails.="'EMPTY','$name','$emails[$id]'";
197         } else {
198                 $from_emails.="'$id','$name','$emails[$id]'";
199         }
200         if ($id==$focus->inbound_email_id) {
201                 $default_email_address=$emails[$id];
202         }
203 }
204 $xtpl->assign("FROM_EMAILS",$from_emails);
205 $xtpl->assign("DEFAULT_FROM_EMAIL",$default_email_address);
206
207 if (empty($focus->inbound_email_id)) {
208         $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, ''));
209 } else {
210         $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, $focus->inbound_email_id));   
211 }
212
213 $xtpl->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['email_marketing_status_dom'], $focus->status));
214
215 $xtpl->parse("main");
216 $xtpl->out("main");
217
218
219
220 $javascript = new javascript();
221 $javascript->setFormName('EditView');
222 $javascript->setSugarBean($focus);
223 $javascript->addAllFields('');
224 echo $javascript->getScript();
225 ?>