]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/EmailMarketing/EditView.php
Release 6.2.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 /*********************************************************************************
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 $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']);
79 }
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));
89
90 if (isset($_REQUEST['return_module'])) {
91         $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
92 } else {
93         $xtpl->assign("RETURN_MODULE", 'Campaigns');
94 }
95 if (isset($_REQUEST['return_action'])) { 
96         $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
97 } else {
98         $xtpl->assign("RETURN_ACTION", 'DetailView');
99 }       
100 if (isset($_REQUEST['return_id'])) {
101         $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
102 } else {
103         if (!empty($focus->campaign_id)) {
104                 $xtpl->assign("RETURN_ID", $focus->campaign_id);
105         }
106 }
107
108 if($focus->campaign_id) {
109         $campaign_id=$focus->campaign_id;
110 }
111 else {
112         $campaign_id=$_REQUEST['campaign_id'];
113 }
114 $xtpl->assign("CAMPAIGN_ID", $campaign_id);
115
116
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().')');
128
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");
134 }
135 else {
136         $xtpl->assign("EMAIL_TEMPLATE_OPTIONS", get_select_options_with_id($email_templates_arr, ""));
137         $xtpl->assign("EDIT_TEMPLATE","visibility:hidden");
138 }
139
140 //include campaign utils..
141 require_once('modules/Campaigns/utils.php');
142 if (empty($_REQUEST['campaign_name'])) {
143         
144         $campaign = new Campaign();
145         $campaign->retrieve($campaign_id);
146         $campaign_name=$campaign->name;
147 } else {
148         $campaign_name=$_REQUEST['campaign_name'];
149 }
150
151 $params = array();
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'];
156 }else{
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'];
159 }
160
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");               
167 }       
168 else {
169         //get select prospect list.
170         if (!empty($focus->id)) {
171                 $focus->load_relationship('prospectlists');
172                 $prospectlists=$focus->prospectlists->get();
173         };
174 }
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));
178
179 $emails=array();
180 $mailboxes=get_campaign_mailboxes($emails);
181 $mailboxes_with_from_name = get_campaign_mailboxes($emails, false);
182
183 //add empty options.
184 $emails['']='nobody@example.com';
185 $mailboxes['']='';
186
187 //inbound_email_id
188 $default_email_address='nobody@example.com';
189 $from_emails = '';
190 foreach ($mailboxes_with_from_name as $id=>$name) {
191         if (!empty($from_emails)) {
192                 $from_emails.=',';
193         }
194         if ($id=='') {
195                 $from_emails.="'EMPTY','$name','$emails[$id]'";
196         } else {
197                 $from_emails.="'$id','$name','$emails[$id]'";
198         }
199         if ($id==$focus->inbound_email_id) {
200                 $default_email_address=$emails[$id];
201         }
202 }
203 $xtpl->assign("FROM_EMAILS",$from_emails);
204 $xtpl->assign("DEFAULT_FROM_EMAIL",$default_email_address);
205
206 if (empty($focus->inbound_email_id)) {
207         $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, ''));
208 } else {
209         $xtpl->assign("MAILBOXES", get_select_options_with_id($mailboxes, $focus->inbound_email_id));   
210 }
211
212 $xtpl->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['email_marketing_status_dom'], $focus->status));
213
214 $xtpl->parse("main");
215 $xtpl->out("main");
216
217
218
219 $javascript = new javascript();
220 $javascript->setFormName('EditView');
221 $javascript->setSugarBean($focus);
222 $javascript->addAllFields('');
223 echo $javascript->getScript();
224 ?>