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.
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 get_module_title('Campaigns', $current_module_strings['LBL_MODULE_SEND_TEST'], false);
78 echo get_module_title('Campaigns', $current_module_strings['LBL_MODULE_SEND_EMAILS'], false);
81 $focus = new EmailMarketing();
82 if(isset($_REQUEST['record']))
85 if (isset($_REQUEST['record'])) $campaign_id = $_REQUEST['record'];
87 $where_clauses = Array();
89 if(isset($campaign_id) && !empty($campaign_id)) array_push($where_clauses, "campaign_id = '".$GLOBALS['db']->quote($campaign_id)."'");
92 foreach($where_clauses as $clause)
99 $GLOBALS['log']->info("Here is the where clause for the list view: $where");
102 $ListView = new ListView();
103 $ListView->initNewXTemplate('modules/Campaigns/Schedule.html',$current_module_strings);
106 $ListView->xTemplateAssign("SCHEDULE_MESSAGE_HEADER",$current_module_strings['LBL_SCHEDULE_MESSAGE_TEST']);
108 $ListView->xTemplateAssign("SCHEDULE_MESSAGE_HEADER",$current_module_strings['LBL_SCHEDULE_MESSAGE_EMAILS']);
111 //force multi-select popup
112 $ListView->process_for_popups=true;
113 $ListView->multi_select_popup=true;
115 $ListView->mergeduplicates = false;
116 $ListView->show_export_button = false;
117 $ListView->show_select_menu = false;
118 $ListView->show_delete_button = false;
119 $ListView->setDisplayHeaderAndFooter(false);
120 $ListView->xTemplateAssign("RETURN_MODULE",$_POST['return_module']);
121 $ListView->xTemplateAssign("RETURN_ACTION",$_POST['return_action']);
122 $ListView->xTemplateAssign("RETURN_ID",$_POST['record']);
123 $ListView->setHeaderTitle($current_module_strings['LBL_LIST_FORM_TITLE']);
124 $ListView->setQuery($where, "", "name", "EMAILMARKETING");
127 $ListView->xTemplateAssign("MODE",$_POST['mode']);
128 //finds all marketing messages that have an association with prospect list of the test.
129 //this query can be siplified using sub-selects.
130 $query="select distinct email_marketing.id email_marketing_id from email_marketing ";
131 $query.=" inner join email_marketing_prospect_lists empl on empl.email_marketing_id = email_marketing.id ";
132 $query.=" inner join prospect_lists on prospect_lists.id = empl.prospect_list_id ";
133 $query.=" inner join prospect_list_campaigns plc on plc.prospect_list_id = empl.prospect_list_id ";
134 $query.=" where empl.deleted=0 ";
135 $query.=" and prospect_lists.deleted=0 ";
136 $query.=" and prospect_lists.list_type='test' ";
137 $query.=" and plc.deleted=0 ";
138 $query.=" and plc.campaign_id='$campaign_id'";
139 $query.=" and email_marketing.campaign_id='$campaign_id'";
140 $query.=" and email_marketing.deleted=0 ";
141 $query.=" and email_marketing.all_prospect_lists=0 ";
145 $result=$focus->db->query($query);
146 while(($row=$focus->db->fetchByAssoc($result)) != null) {
148 $bean = new EmailMarketing();
149 $bean->retrieve($row['email_marketing_id']);
153 $query=" select email_marketing.id email_marketing_id from email_marketing ";
154 $query.=" WHERE email_marketing.campaign_id='$campaign_id'";
155 $query.=" and email_marketing.deleted=0 ";
156 $query.=" and email_marketing.all_prospect_lists=1 ";
158 $result=$focus->db->query($query);
159 while(($row=$focus->db->fetchByAssoc($result)) != null) {
161 $bean = new EmailMarketing();
162 $bean->retrieve($row['email_marketing_id']);
167 $ListView->processListView($seed, "main", "EMAILMARKETING");
169 $ListView->processListView($focus, "main", "EMAILMARKETING");