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-2013 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 /*********************************************************************************
41 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42 * All Rights Reserved.
43 * Contributor(s): ______________________________________..
44 ********************************************************************************/
53 //account for case when called from marketing wizard
54 if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] == 'WizardMarketing'){
55 $_POST['return_module'] = $_REQUEST['return_module'];
56 $_POST['return_action'] = 'TrackDetailView';
57 $_POST['record'] = $_REQUEST['record'];
61 if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'test') {
63 $_POST['mode'] = 'test';
68 global $app_list_strings;
69 global $current_language;
72 global $currentModule;
74 $current_module_strings = return_module_language($current_language, 'EmailMarketing');
76 echo getClassicModuleTitle('Campaigns', array($current_module_strings['LBL_MODULE_SEND_TEST']), false);
78 echo getClassicModuleTitle('Campaigns', array($current_module_strings['LBL_MODULE_SEND_EMAILS']), false);
81 $campaign_id = isset($_REQUEST['record']) ? $_REQUEST['record'] : false;
83 if (!empty($campaign_id)) {
84 $campaign = new Campaign();
85 $campaign->retrieve($campaign_id);
88 if ($campaign_id && isset($campaign) && $campaign->status == 'Inactive') {
89 $ss = new Sugar_Smarty();
90 $ss->assign('campaignName', $campaign->name);
91 $ss->display('modules/Campaigns/tpls/campaign-inactive.tpl');
93 $focus = new EmailMarketing();
96 $where_clauses = Array();
98 if(!empty($campaign_id)) array_push($where_clauses, "campaign_id = '".$GLOBALS['db']->quote($campaign_id)."'");
101 foreach($where_clauses as $clause)
108 $GLOBALS['log']->info("Here is the where clause for the list view: $where");
111 $ListView = new ListView();
112 $ListView->initNewXTemplate('modules/Campaigns/Schedule.html',$current_module_strings);
115 $ListView->xTemplateAssign("SCHEDULE_MESSAGE_HEADER",$current_module_strings['LBL_SCHEDULE_MESSAGE_TEST']);
117 $ListView->xTemplateAssign("SCHEDULE_MESSAGE_HEADER",$current_module_strings['LBL_SCHEDULE_MESSAGE_EMAILS']);
120 //force multi-select popup
121 $ListView->process_for_popups=true;
122 $ListView->multi_select_popup=true;
124 $ListView->mergeduplicates = false;
125 $ListView->show_export_button = false;
126 $ListView->show_select_menu = false;
127 $ListView->show_delete_button = false;
128 $ListView->setDisplayHeaderAndFooter(false);
129 $ListView->xTemplateAssign("RETURN_MODULE",$_POST['return_module']);
130 $ListView->xTemplateAssign("RETURN_ACTION",$_POST['return_action']);
131 $ListView->xTemplateAssign("RETURN_ID",$_POST['record']);
132 $ListView->setHeaderTitle($current_module_strings['LBL_LIST_FORM_TITLE']);
133 $ListView->setQuery($where, "", "name", "EMAILMARKETING");
136 $ListView->xTemplateAssign("MODE",$_POST['mode']);
137 //finds all marketing messages that have an association with prospect list of the test.
138 //this query can be siplified using sub-selects.
139 $query="select distinct email_marketing.id email_marketing_id from email_marketing ";
140 $query.=" inner join email_marketing_prospect_lists empl on empl.email_marketing_id = email_marketing.id ";
141 $query.=" inner join prospect_lists on prospect_lists.id = empl.prospect_list_id ";
142 $query.=" inner join prospect_list_campaigns plc on plc.prospect_list_id = empl.prospect_list_id ";
143 $query.=" where empl.deleted=0 ";
144 $query.=" and prospect_lists.deleted=0 ";
145 $query.=" and prospect_lists.list_type='test' ";
146 $query.=" and plc.deleted=0 ";
147 $query.=" and plc.campaign_id='$campaign_id'";
148 $query.=" and email_marketing.campaign_id='$campaign_id'";
149 $query.=" and email_marketing.deleted=0 ";
150 $query.=" and email_marketing.all_prospect_lists=0 ";
154 $result=$focus->db->query($query);
155 while(($row=$focus->db->fetchByAssoc($result)) != null) {
157 $bean = new EmailMarketing();
158 $bean->retrieve($row['email_marketing_id']);
162 $query=" select email_marketing.id email_marketing_id from email_marketing ";
163 $query.=" WHERE email_marketing.campaign_id='$campaign_id'";
164 $query.=" and email_marketing.deleted=0 ";
165 $query.=" and email_marketing.all_prospect_lists=1 ";
167 $result=$focus->db->query($query);
168 while(($row=$focus->db->fetchByAssoc($result)) != null) {
170 $bean = new EmailMarketing();
171 $bean->retrieve($row['email_marketing_id']);
176 $ListView->processListView($seed, "main", "EMAILMARKETING");
178 $ListView->processListView($focus, "main", "EMAILMARKETING");