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 ********************************************************************************/
50 class EmailMarketing extends SugarBean {
58 var $modified_user_id;
69 var $all_prospect_lists;
71 var $inbound_email_id;
73 var $table_name = 'email_marketing';
74 var $object_name = 'EmailMarketing';
75 var $module_dir = 'EmailMarketing';
77 var $new_schema = true;
79 function EmailMarketing()
87 function retrieve($id) {
88 parent::retrieve($id);
91 $date_start_array=explode(" ",trim($this->date_start));
92 if (count($date_start_array)==2) {
93 $this->time_start = $date_start_array[1];
94 $this->date_start = $date_start_array[0];
99 function get_summary_text()
104 function create_export_query($order_by, $where)
106 return $this->create_new_list_query($order_by, $where);
109 function get_list_view_data(){
111 $temp_array = $this->get_list_view_array();
113 $id = $temp_array['ID'];
114 $template_id = $temp_array['TEMPLATE_ID'];
116 //mode is set by schedule.php from campaigns module.
117 if (!isset($this->mode) or empty($this->mode) or $this->mode!='test') {
121 if ($temp_array['ALL_PROSPECT_LISTS']==1) {
122 $query="SELECT name from prospect_lists ";
123 $query.=" INNER JOIN prospect_list_campaigns plc ON plc.prospect_list_id = prospect_lists.id";
124 $query.=" WHERE plc.campaign_id='{$temp_array['CAMPAIGN_ID']}'";
125 $query.=" AND prospect_lists.deleted=0";
126 $query.=" AND plc.deleted=0";
127 if ($this->mode=='test') {
128 $query.=" AND prospect_lists.list_type='test'";
130 $query.=" AND prospect_lists.list_type!='test'";
133 $query="SELECT name from prospect_lists ";
134 $query.=" INNER JOIN email_marketing_prospect_lists empl ON empl.prospect_list_id = prospect_lists.id";
135 $query.=" WHERE empl.email_marketing_id='{$id}'";
136 $query.=" AND prospect_lists.deleted=0";
137 $query.=" AND empl.deleted=0";
138 if ($this->mode=='test') {
139 $query.=" AND prospect_lists.list_type='test'";
141 $query.=" AND prospect_lists.list_type!='test'";
144 $res = $this->db->query($query);
145 while (($row = $this->db->fetchByAssoc($res)) != null) {
146 if (!empty($temp_array['PROSPECT_LIST_NAME'])) {
147 $temp_array['PROSPECT_LIST_NAME'].="<BR>";
149 $temp_array['PROSPECT_LIST_NAME'].=$row['name'];
154 function bean_implements($interface){
156 case 'ACL':return true;
161 function get_all_prospect_lists() {
163 $query="select prospect_lists.* from prospect_lists ";
164 $query.=" left join prospect_list_campaigns on prospect_list_campaigns.prospect_list_id=prospect_lists.id";
165 $query.=" where prospect_list_campaigns.deleted=0";
166 $query.=" and prospect_list_campaigns.campaign_id='$this->campaign_id'";
167 $query.=" and prospect_lists.deleted=0";
168 $query.=" and prospect_lists.list_type not like 'exempt%'";