'opportunities', 'bug_id' => 'bugs', 'case_id'=>'cases', 'contact_id'=>'contacts', 'task_id'=>'tasks', 'note_id'=>'notes', 'meeting_id'=>'meetings', 'call_id'=>'calls', 'email_id'=>'emails','member_id'=>'members', 'project_id'=>'project', ); //Meta-Data Framework fields var $push_billing; var $push_shipping; function Account() { parent::Company(); $this->setupCustomFields('Accounts'); foreach ($this->field_defs as $field) { if(isset($field['name'])) { $this->field_name_map[$field['name']] = $field; } } //Combine the email logic original here with bug #26450. if( (!empty($_REQUEST['parent_id']) && !empty($_REQUEST['parent_type']) && $_REQUEST['parent_type'] == 'Emails' && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Emails' ) || (!empty($_REQUEST['parent_type']) && $_REQUEST['parent_type'] != 'Accounts' && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] != 'Accounts') ){ $_REQUEST['parent_name'] = ''; $_REQUEST['parent_id'] = ''; } } function get_summary_text() { return $this->name; } function get_contacts() { return $this->get_linked_beans('contacts','Contact'); } function clear_account_case_relationship($account_id='', $case_id='') { if (empty($case_id)) $where = ''; else $where = " and id = '$case_id'"; $query = "UPDATE cases SET account_name = '', account_id = '' WHERE account_id = '$account_id' AND deleted = 0 " . $where; $this->db->query($query,true,"Error clearing account to case relationship: "); } /** * This method is used to provide backward compatibility with old data that was prefixed with http:// * We now automatically prefix http:// * @deprecated. */ function remove_redundant_http() { /* if(preg_match("@http://@", $this->website)) { $this->website = substr($this->website, 7); } */ } function fill_in_additional_list_fields() { parent::fill_in_additional_list_fields(); // Fill in the assigned_user_name // $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id); } function fill_in_additional_detail_fields() { parent::fill_in_additional_detail_fields(); //rrs bug: 28184 - instead of removing this code altogether just adding this check to ensure that if the parent_name //is empty then go ahead and fill it. if(empty($this->parent_name) && !empty($this->id)){ $query = "SELECT a1.name from accounts a1, accounts a2 where a1.id = a2.parent_id and a2.id = '$this->id' and a1.deleted=0"; $result = $this->db->query($query,true," Error filling in additional detail fields: "); // Get the id and the name. $row = $this->db->fetchByAssoc($result); if($row != null) { $this->parent_name = $row['name']; } else { $this->parent_name = ''; } } // Set campaign name if there is a campaign id if( !empty($this->campaign_id)){ $camp = new Campaign(); $where = "campaigns.id='{$this->campaign_id}'"; $campaign_list = $camp->get_full_list("campaigns.name", $where, true); $this->campaign_name = $campaign_list[0]->name; } } function get_list_view_data(){ global $system_config,$current_user; $temp_array = $this->get_list_view_array(); $temp_array["ENCODED_NAME"]=$this->name; // $temp_array["ENCODED_NAME"]=htmlspecialchars($this->name, ENT_QUOTES); if(!empty($this->billing_address_state)) { $temp_array["CITY"] = $this->billing_address_city . ', '. $this->billing_address_state; } else { $temp_array["CITY"] = $this->billing_address_city; } $temp_array["BILLING_ADDRESS_STREET"] = $this->billing_address_street; $temp_array["SHIPPING_ADDRESS_STREET"] = $this->shipping_address_street; if(isset($system_config->settings['system_skypeout_on']) && $system_config->settings['system_skypeout_on'] == 1){ if(!empty($temp_array['PHONE_OFFICE']) && skype_formatted($temp_array['PHONE_OFFICE'])){ $temp_array['PHONE_OFFICE'] = ''.$temp_array['PHONE_OFFICE']. '' ; }} $temp_array["EMAIL1"] = $this->emailAddress->getPrimaryAddress($this); $this->email1 = $temp_array['EMAIL1']; $temp_array["EMAIL1_LINK"] = $current_user->getEmailLink('email1', $this, '', '', 'ListView'); 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, "accounts.name like '$the_query_string%'"); if (is_numeric($the_query_string)) { array_push($where_clauses, "accounts.phone_alternate like '%$the_query_string%'"); array_push($where_clauses, "accounts.phone_fax like '%$the_query_string%'"); array_push($where_clauses, "accounts.phone_office like '%$the_query_string%'"); } $the_where = ""; foreach($where_clauses as $clause) { if(!empty($the_where)) $the_where .= " or "; $the_where .= $clause; } return $the_where; } 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 accounts.*,email_addresses.email_address email_address, accounts.name as account_name, users.user_name as assigned_user_name "; if($custom_join){ $query .= $custom_join['select']; } $query .= " FROM accounts "; $query .= "LEFT JOIN users ON accounts.assigned_user_id=users.id "; //join email address table too. $query .= ' LEFT JOIN email_addr_bean_rel on accounts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module=\'Accounts\' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 '; $query .= ' LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id ' ; if($custom_join){ $query .= $custom_join['join']; } $where_auto = "( accounts.deleted IS NULL OR accounts.deleted=0 )"; if($where != "") $query .= "where ($where) AND ".$where_auto; else $query .= "where ".$where_auto; if(!empty($order_by)) $query .= " ORDER BY ". $this->process_order_by($order_by, null); return $query; } function set_notification_body($xtpl, $account) { $xtpl->assign("ACCOUNT_NAME", $account->name); $xtpl->assign("ACCOUNT_TYPE", $account->account_type); $xtpl->assign("ACCOUNT_DESCRIPTION", $account->description); return $xtpl; } function bean_implements($interface){ switch($interface){ case 'ACL':return true; } return false; } function get_unlinked_email_query($type=array()) { return get_unlinked_email_query($type, $this); } }