'prospect_lists'); var $new_schema = true; function list_view_parse_additional_sections(&$listTmpl) { global $locale; // take $assigned_user_id and get the Username value to assign $assId = $this->getFieldValue('assigned_user_id'); $query = "SELECT first_name, last_name FROM users WHERE id = '".$assId."'"; $result = $this->db->query($query); $user = $this->db->fetchByAssoc($result); //_ppd($user); if(!empty($user)) { $fullName = $locale->getLocaleFormattedName($user->first_name, $user->last_name); $listTmpl->assign('ASSIGNED_USER_NAME', $fullName); } } function get_summary_text() { return $this->name; } function create_export_query(&$order_by, &$where, $relate_link_join='') { $custom_join = $this->custom_fields->getJOIN(true, true,$where); if($custom_join) $custom_join['join'] .= $relate_link_join; $query = "SELECT campaigns.*, users.user_name as assigned_user_name "; if($custom_join){ $query .= $custom_join['select']; } $query .= " FROM campaigns "; $query .= "LEFT JOIN users ON campaigns.assigned_user_id=users.id"; if($custom_join){ $query .= $custom_join['join']; } $where_auto = " campaigns.deleted=0"; if($where != "") $query .= " where $where AND ".$where_auto; else $query .= " where ".$where_auto; if($order_by != "") $query .= " ORDER BY $order_by"; else $query .= " ORDER BY campaigns.name"; return $query; } function clear_campaign_prospect_list_relationship($campaign_id, $prospect_list_id='') { if(!empty($prospect_list_id)) $prospect_clause = " and prospect_list_id = '$prospect_list_id' "; else $prospect_clause = ''; $query = "DELETE FROM $this->rel_prospect_list_table WHERE campaign_id='$campaign_id' AND deleted = '0' " . $prospect_clause; $this->db->query($query, true, "Error clearing campaign to prospect_list relationship: "); } function mark_relationships_deleted($id) { $this->clear_campaign_prospect_list_relationship($id); } function fill_in_additional_list_fields() { parent::fill_in_additional_list_fields(); } function fill_in_additional_detail_fields() { parent::fill_in_additional_detail_fields(); //format numbers. //don't need additional formatting here. //$this->budget=format_number($this->budget); //$this->expected_cost=format_number($this->expected_cost); //$this->actual_cost=format_number($this->actual_cost); //$this->expected_revenue=format_number($this->expected_revenue); } function update_currency_id($fromid, $toid){ } function get_list_view_data(){ $temp_array = $this->get_list_view_array(); if ($this->campaign_type != 'Email') { $temp_array['OPTIONAL_LINK']="display:none"; } $temp_array['TRACK_CAMPAIGN_TITLE'] = translate("LBL_TRACK_BUTTON_TITLE",'Campaigns'); $temp_array['TRACK_CAMPAIGN_IMAGE'] = SugarThemeRegistry::current()->getImageURL('view_status.gif'); $temp_array['LAUNCH_WIZARD_TITLE'] = translate("LBL_TO_WIZARD_TITLE",'Campaigns'); $temp_array['LAUNCH_WIZARD_IMAGE'] = SugarThemeRegistry::current()->getImageURL('edit_wizard.gif'); $temp_array['TRACK_VIEW_ALT_TEXT'] = translate("LBL_TRACK_BUTTON_TITLE",'Campaigns'); $temp_array['LAUNCH_WIZ_ALT_TEXT'] = translate("LBL_TO_WIZARD_TITLE",'Campaigns'); return $temp_array; } /** builds a generic search based on the query string using or do not include any $this-> because this is called on without having the class instantiated */ function build_generic_where_clause ($the_query_string) { $where_clauses = Array(); $the_query_string = $this->db->quote($the_query_string); array_push($where_clauses, "campaigns.name like '$the_query_string%'"); $the_where = ""; foreach($where_clauses as $clause) { if($the_where != "") $the_where .= " or "; $the_where .= $clause; } return $the_where; } function save($check_notify = FALSE) { //US DOLLAR if(isset($this->amount) && !empty($this->amount)){ $currency = new Currency(); $currency->retrieve($this->currency_id); $this->amount_usdollar = $currency->convertToDollar($this->amount); } $this->unformat_all_fields(); return parent::save($check_notify); } function mark_deleted($id){ $query = "update contacts set campaign_id = null where campaign_id = '{$id}' "; $this->db->query($query); $query = "update accounts set campaign_id = null where campaign_id = '{$id}' "; $this->db->query($query); return parent::mark_deleted($id); } function set_notification_body($xtpl, $camp) { $xtpl->assign("CAMPAIGN_NAME", $camp->name); $xtpl->assign("CAMPAIGN_AMOUNT", $camp->budget); $xtpl->assign("CAMPAIGN_CLOSEDATE", $camp->end_date); $xtpl->assign("CAMPAIGN_STATUS", $camp->status); $xtpl->assign("CAMPAIGN_DESCRIPTION", $camp->content); return $xtpl; } function track_log_entries($type=array()) { //get arguments being passed in $args = func_get_args(); $mkt_id =''; $this->load_relationship('log_entries'); $query_array = $this->log_entries->getQuery(true); //if one of the arguments is marketing ID, then we need to filter by it foreach($args as $arg){ if(isset($arg['EMAIL_MARKETING_ID_VALUE'])){ $mkt_id = $arg['EMAIL_MARKETING_ID_VALUE']; } if(isset($arg['group_by'])) { $query_array['group_by'] = $arg['group_by']; } } if (empty($type)) $type[0]='targeted'; $query_array['select'] ="SELECT campaign_log.* "; $query_array['where'] = $query_array['where']. " AND activity_type='{$type[0]}' AND archived=0"; //add filtering by marketing id, if it exists if (!empty($mkt_id)) $query_array['where'] = $query_array['where']. " AND marketing_id ='$mkt_id' "; //B.F. #37943 if( isset($query_array['group_by'])) { //perform the inner join with the group by if a marketing id is defined, which means we need to filter out duplicates. //if no marketing id is specified then we are displaying results from multiple marketing emails and it is understood there might be duplicate target entries if (!empty($mkt_id)){ $group_by = str_replace("campaign_log", "cl", $query_array['group_by']); $join_where = str_replace("campaign_log", "cl", $query_array['where']); $query_array['from'] .= " INNER JOIN (select min(id) as id from campaign_log cl $join_where GROUP BY $group_by ) secondary on campaign_log.id = secondary.id "; } unset($query_array['group_by']); } else if(isset($query_array['group_by'])) { $query_array['where'] = $query_array['where'] . ' GROUP BY ' . $query_array['group_by']; unset($query_array['group_by']); } $query = (implode(" ",$query_array)); return $query; } function get_queue_items() { //get arguments being passed in $args = func_get_args(); $mkt_id =''; $this->load_relationship('queueitems'); $query_array = $this->queueitems->getQuery(true); //if one of the arguments is marketing ID, then we need to filter by it foreach($args as $arg){ if(isset($arg['EMAIL_MARKETING_ID_VALUE'])){ $mkt_id = $arg['EMAIL_MARKETING_ID_VALUE']; } if(isset($arg['group_by'])) { $query_array['group_by'] = $arg['group_by']; } } //add filtering by marketing id, if it exists, and if where key is not empty if (!empty($mkt_id) && !empty($query_array['where'])){ $query_array['where'] = $query_array['where']. " AND marketing_id ='$mkt_id' "; } //get select query from email man $man = new EmailMan(); $listquery= $man->create_queue_items_query('',str_replace(array("WHERE","where"),"",$query_array['where']),null,$query_array); return $listquery; } // function get_prospect_list_entries() { // $this->load_relationship('prospectlists'); // $query_array = $this->prospectlists->getQuery(true); // // $query=<<