grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026'emails','call_id'=>'calls','meeting_id'=>'meetings','task_id'=>'tasks',); public function __construct() { parent::__construct(); } /** * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead */ public function Lead() { $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; if (isset($GLOBALS['log'])) { $GLOBALS['log']->deprecated($deprecatedMessage); } else { trigger_error($deprecatedMessage, E_USER_DEPRECATED); } self::__construct(); } public function get_account() { if (isset($this->account_id) && !empty($this->account_id)) { $query = "SELECT name , assigned_user_id account_name_owner FROM accounts WHERE id='{$this->account_id}'"; //requireSingleResult has beeen deprecated. //$result = $this->db->requireSingleResult($query); $result = $this->db->limitQuery($query, 0, 1, true, "Want only a single row"); if (!empty($result)) { $row = $this->db->fetchByAssoc($result); $this->account_name = $row['name']; $this->account_name_owner = $row['account_name_owner']; $this->account_name_mod = 'Accounts'; } } } public function get_opportunity() { if (isset($this->opportunity_id) && !empty($this->opportunity_id)) { $query = "SELECT name, assigned_user_id opportunity_name_owner FROM opportunities WHERE id='{$this->opportunity_id}'"; //requireSingleResult has beeen deprecated. //$result = $this->db->requireSingleResult($query); $result = $this->db->limitQuery($query, 0, 1, true, "Want only a single row"); if (!empty($result)) { $row = $this->db->fetchByAssoc($result); $this->opportunity_name = $row['name']; $this->opportunity_name_owner = $row['opportunity_name_owner']; $this->opportunity_name_mod = 'Opportunities'; } } } public function get_contact() { global $locale; if (isset($this->contact_id) && !empty($this->contact_id)) { $query = "SELECT first_name, last_name, assigned_user_id contact_name_owner FROM contacts WHERE id='{$this->contact_id}'"; //requireSingleResult has beeen deprecated. //$result = $this->db->requireSingleResult($query); $result = $this->db->limitQuery($query, 0, 1, true, "Want only a single row"); if (!empty($result)) { $row= $this->db->fetchByAssoc($result); $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']); $this->contact_name_owner = $row['contact_name_owner']; $this->contact_name_mod = 'Contacts'; } } } public function create_list_query($order_by, $where, $show_deleted=0) { $custom_join = $this->getCustomJoin(); $query = "SELECT "; $query .= "$this->table_name.*, users.user_name assigned_user_name"; $query .= $custom_join['select']; $query .= " FROM leads "; $query .= " LEFT JOIN users ON leads.assigned_user_id=users.id "; $query .= "LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = leads.id AND eabl.bean_module = 'Leads' and eabl.primary_address = 1 and eabl.deleted=0 "; $query .= "LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) "; $query .= $custom_join['join']; $where_auto = '1=1'; if ($show_deleted == 0) { $where_auto = " leads.deleted=0 "; } elseif ($show_deleted == 1) { $where_auto = " leads.deleted=1 "; } if ($where != "") { $query .= "where ($where) AND ".$where_auto; } else { $query .= "where ".$where_auto; } //."and (leads.converted='0')"; if (!empty($order_by)) { $query .= " ORDER BY $order_by"; } return $query; } public function create_new_list_query($order_by, $where, $filter=array(), $params=array(), $show_deleted = 0, $join_type='', $return_array = false, $parentbean=null, $singleSelect = false, $ifListForExport = false) { $ret_array = parent::create_new_list_query($order_by, $where, $filter, $params, $show_deleted, $join_type, true, $parentbean, $singleSelect, $ifListForExport); if (strpos($ret_array['select'], "leads.account_name") == false && strpos($ret_array['select'], "leads.*") == false) { $ret_array['select'] .= " ,leads.account_name"; } if (!$return_array) { return $ret_array['select'] . $ret_array['from'] . $ret_array['where']. $ret_array['order_by']; } return $ret_array; } public function converted_lead($leadid, $contactid, $accountid, $opportunityid) { $query = "UPDATE leads set converted='1', contact_id=$contactid, account_id=$accountid, opportunity_id=$opportunityid where id=$leadid and deleted=0"; $this->db->query($query, true, "Error converting lead: "); //we must move the status out here in order to be able to capture workflow conditions $leadid = str_replace("'", "", $leadid); $lead = new Lead(); $lead->retrieve($leadid); $lead->status='Converted'; $lead->save(); } public function fill_in_additional_list_fields() { parent::fill_in_additional_list_fields(); $this->_create_proper_name_field(); $this->get_account(); } public function fill_in_additional_detail_fields() { //Fill in the assigned_user_name //if(!empty($this->status)) //$this->status = translate('lead_status_dom', '', $this->status); parent::fill_in_additional_detail_fields(); $this->_create_proper_name_field(); $this->get_contact(); $this->get_opportunity(); $this->get_account(); if (!empty($this->campaign_id)) { $camp = new Campaign(); $where = "campaigns.id='$this->campaign_id'"; $campaign_list = $camp->get_full_list("campaigns.name", $where, true); if (!empty($campaign_list)) { $this->campaign_name = $campaign_list[0]->name; } } } public function get_list_view_data() { $temp_array = parent::get_list_view_data(); if (!isset($temp_array['ACCOUNT_NAME'])) { LoggerManager::getLogger()->warn('Leads get list view data error: account name is not defined in list view data.'); $tempArrayAccountName = null; } else { $tempArrayAccountName = $temp_array['ACCOUNT_NAME']; } $temp_array['ACC_NAME_FROM_ACCOUNTS'] = empty($temp_array['ACC_NAME_FROM_ACCOUNTS']) ? ($tempArrayAccountName) : ($temp_array['ACC_NAME_FROM_ACCOUNTS']); return $temp_array; } /** * Returns an array of fields that are of type link. * * @return array List of fields. * * Internal function, do not override. */ //fix for bug 27339 Shine public function get_linked_fields() { $linked_fields=array(); $fieldDefs = $this->getFieldDefinitions(); //find all definitions of type link. if (!empty($fieldDefs)) { foreach ($fieldDefs as $name=>$properties) { if ($name == 'oldmeetings' || $name == 'oldcalls') { continue; } elseif (array_search('link', $properties) === 'type') { $linked_fields[$name]=$properties; } } } return $linked_fields; } /** 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 */ public function build_generic_where_clause($the_query_string) { $where_clauses = array(); $the_query_string = DBManagerFactory::getInstance()->quote($the_query_string); array_push($where_clauses, "leads.last_name like '$the_query_string%'"); array_push($where_clauses, "leads.account_name like '$the_query_string%'"); array_push($where_clauses, "leads.first_name like '$the_query_string%'"); array_push($where_clauses, "ea.email_address like '$the_query_string%'"); if (is_numeric($the_query_string)) { array_push($where_clauses, "leads.phone_home like '%$the_query_string%'"); array_push($where_clauses, "leads.phone_mobile like '%$the_query_string%'"); array_push($where_clauses, "leads.phone_work like '%$the_query_string%'"); array_push($where_clauses, "leads.phone_other like '%$the_query_string%'"); array_push($where_clauses, "leads.phone_fax like '%$the_query_string%'"); } $the_where = ""; foreach ($where_clauses as $clause) { if ($the_where != "") { $the_where .= " or "; } $the_where .= $clause; } return $the_where; } public function set_notification_body($xtpl, $lead) { global $app_list_strings; global $locale; $xtpl->assign("LEAD_NAME", $locale->getLocaleFormattedName($lead->first_name, $lead->last_name, $lead->salutation)); $xtpl->assign("LEAD_SOURCE", (isset($lead->lead_source) ? $app_list_strings['lead_source_dom'][$lead->lead_source] : "")); $xtpl->assign("LEAD_STATUS", (isset($lead->status)? $app_list_strings['lead_status_dom'][$lead->status]:"")); $xtpl->assign("LEAD_DESCRIPTION", $lead->description); return $xtpl; } public function bean_implements($interface) { switch ($interface) { case 'ACL':return true; } return false; } public function listviewACLHelper() { $array_assign = parent::listviewACLHelper(); $is_owner = false; $in_group = false; //SECURITY GROUPS if (!empty($this->account_name)) { if (!empty($this->account_name_owner)) { global $current_user; $is_owner = $current_user->id == $this->account_name_owner; } /* BEGIN - SECURITY GROUPS */ else { global $current_user; $parent_bean = BeanFactory::getBean('Accounts', $this->account_id); if ($parent_bean !== false) { $is_owner = $current_user->id == $parent_bean->assigned_user_id; } } require_once("modules/SecurityGroups/SecurityGroup.php"); $in_group = SecurityGroup::groupHasAccess('Accounts', $this->account_id, 'view'); /* END - SECURITY GROUPS */ } /* BEGIN - SECURITY GROUPS */ /** if( ACLController::checkAccess('Accounts', 'view', $is_owner)){ */ if (ACLController::checkAccess('Accounts', 'view', $is_owner, 'module', $in_group)) { /* END - SECURITY GROUPS */ $array_assign['ACCOUNT'] = 'a'; } else { $array_assign['ACCOUNT'] = 'span'; } $is_owner = false; $in_group = false; //SECURITY GROUPS if (!empty($this->opportunity_name)) { if (!empty($this->opportunity_name_owner)) { global $current_user; $is_owner = $current_user->id == $this->opportunity_name_owner; } /* BEGIN - SECURITY GROUPS */ else { global $current_user; $parent_bean = BeanFactory::getBean('Opportunities', $this->opportunity_id); if ($parent_bean !== false) { $is_owner = $current_user->id == $parent_bean->assigned_user_id; } } require_once("modules/SecurityGroups/SecurityGroup.php"); $in_group = SecurityGroup::groupHasAccess('Opportunities', $this->opportunity_id, 'view'); /* END - SECURITY GROUPS */ } /* BEGIN - SECURITY GROUPS */ /** if( ACLController::checkAccess('Opportunities', 'view', $is_owner)){ */ if (ACLController::checkAccess('Opportunities', 'view', $is_owner, 'module', $in_group)) { /* END - SECURITY GROUPS */ $array_assign['OPPORTUNITY'] = 'a'; } else { $array_assign['OPPORTUNITY'] = 'span'; } $is_owner = false; $in_group = false; //SECURITY GROUPS if (!empty($this->contact_name)) { if (!empty($this->contact_name_owner)) { global $current_user; $is_owner = $current_user->id == $this->contact_name_owner; } /* BEGIN - SECURITY GROUPS */ //contact_name_owner not being set for whatever reason so we need to figure this out else { global $current_user; $parent_bean = BeanFactory::getBean('Contacts', $this->contact_id); if ($parent_bean !== false) { $is_owner = $current_user->id == $parent_bean->assigned_user_id; } } require_once("modules/SecurityGroups/SecurityGroup.php"); $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view'); /* END - SECURITY GROUPS */ } /* BEGIN - SECURITY GROUPS */ /** if( ACLController::checkAccess('Contacts', 'view', $is_owner)){ */ if (ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)) { /* END - SECURITY GROUPS */ $array_assign['CONTACT'] = 'a'; } else { $array_assign['CONTACT'] = 'span'; } return $array_assign; } //carrys forward custom lead fields to contacts, accounts, opportunities during Lead Conversion public function convertCustomFieldsForm(&$form, &$tempBean, &$prefix) { global $mod_strings, $app_list_strings, $app_strings, $lbl_required_symbol; foreach ($this->field_defs as $field => $value) { if (!empty($value['source']) && $value['source'] == 'custom_fields') { if (!empty($tempBean->field_defs[$field]) and isset($tempBean->field_defs[$field])) { $form .= "