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-2012 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 ********************************************************************************/
39 class EmailMarketing extends SugarBean
47 var $modified_user_id;
58 var $all_prospect_lists;
60 var $inbound_email_id;
62 var $table_name = 'email_marketing';
63 var $object_name = 'EmailMarketing';
64 var $module_dir = 'EmailMarketing';
66 var $new_schema = true;
68 function EmailMarketing()
76 function retrieve($id, $encode=true, $deleted=true) {
77 parent::retrieve($id,$encode,$deleted);
80 $date_start_array=explode(" ",trim($this->date_start));
81 if (count($date_start_array)==2) {
82 $this->time_start = $date_start_array[1];
83 $this->date_start = $date_start_array[0];
88 function get_summary_text()
93 function create_export_query($order_by, $where)
95 return $this->create_new_list_query($order_by, $where);
98 function get_list_view_data(){
100 $temp_array = $this->get_list_view_array();
102 $id = $temp_array['ID'];
103 $template_id = $temp_array['TEMPLATE_ID'];
105 //mode is set by schedule.php from campaigns module.
106 if (!isset($this->mode) or empty($this->mode) or $this->mode!='test') {
110 if ($temp_array['ALL_PROSPECT_LISTS']==1) {
111 $query="SELECT name from prospect_lists ";
112 $query.=" INNER JOIN prospect_list_campaigns plc ON plc.prospect_list_id = prospect_lists.id";
113 $query.=" WHERE plc.campaign_id='{$temp_array['CAMPAIGN_ID']}'";
114 $query.=" AND prospect_lists.deleted=0";
115 $query.=" AND plc.deleted=0";
116 if ($this->mode=='test') {
117 $query.=" AND prospect_lists.list_type='test'";
119 $query.=" AND prospect_lists.list_type!='test'";
122 $query="SELECT name from prospect_lists ";
123 $query.=" INNER JOIN email_marketing_prospect_lists empl ON empl.prospect_list_id = prospect_lists.id";
124 $query.=" WHERE empl.email_marketing_id='{$id}'";
125 $query.=" AND prospect_lists.deleted=0";
126 $query.=" AND empl.deleted=0";
127 if ($this->mode=='test') {
128 $query.=" AND prospect_lists.list_type='test'";
130 $query.=" AND prospect_lists.list_type!='test'";
133 $res = $this->db->query($query);
134 while (($row = $this->db->fetchByAssoc($res)) != null) {
135 if (!empty($temp_array['PROSPECT_LIST_NAME'])) {
136 $temp_array['PROSPECT_LIST_NAME'].="<BR>";
138 $temp_array['PROSPECT_LIST_NAME'].=$row['name'];
143 function bean_implements($interface){
145 case 'ACL':return true;
150 function get_all_prospect_lists() {
152 $query="select prospect_lists.* from prospect_lists ";
153 $query.=" left join prospect_list_campaigns on prospect_list_campaigns.prospect_list_id=prospect_lists.id";
154 $query.=" where prospect_list_campaigns.deleted=0";
155 $query.=" and prospect_list_campaigns.campaign_id='$this->campaign_id'";
156 $query.=" and prospect_lists.deleted=0";
157 $query.=" and prospect_lists.list_type not like 'exempt%'";