setupCustomFields('Users'); $this->emailAddress = new SugarEmailAddress(); } function get_summary_text() { $this->_create_proper_name_field(); return $this->name; } function fill_in_additional_list_fields() { $this->fill_in_additional_detail_fields(); } function fill_in_additional_detail_fields() { global $locale; $query = "SELECT u1.first_name, u1.last_name from users u1, users u2 where u1.id = u2.reports_to_id AND u2.id = '$this->id' and u1.deleted=0"; $result =$this->db->query($query, true, "Error filling in additional detail fields") ; $row = $this->db->fetchByAssoc($result); $GLOBALS['log']->debug("additional detail query results: $row"); if($row != null) { $this->reports_to_name = stripslashes($locale->getLocaleFormattedName($row['first_name'], $row['last_name'])); } else { $this->reports_to_name = ''; } } function retrieve_employee_id($employee_name) { $query = "SELECT id from users where user_name='$user_name' AND deleted=0"; $result = $this->db->query($query, false,"Error retrieving employee ID: "); $row = $this->db->fetchByAssoc($result); return $row['id']; } /** * @return -- returns a list of all employees in the system. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. * All Rights Reserved.. * Contributor(s): ______________________________________.. */ function verify_data() { //none of the checks from the users module are valid here since the user_name and //is_admin_on fields are not editable. return TRUE; } function get_list_view_data(){ global $current_user; $this->_create_proper_name_field(); // create proper NAME (by combining first + last) $user_fields = $this->get_list_view_array(); // Copy over the reports_to_name if ( isset($GLOBALS['app_list_strings']['messenger_type_dom'][$this->messenger_type]) ) $user_fields['MESSENGER_TYPE'] = $GLOBALS['app_list_strings']['messenger_type_dom'][$this->messenger_type]; if ( isset($GLOBALS['app_list_strings']['employee_status_dom'][$this->employee_status]) ) $user_fields['EMPLOYEE_STATUS'] = $GLOBALS['app_list_strings']['employee_status_dom'][$this->employee_status]; $user_fields['REPORTS_TO_NAME'] = $this->reports_to_name; $user_fields['NAME'] = empty($this->name) ? '' : $this->name; $user_fields['EMAIL1'] = $this->emailAddress->getPrimaryAddress($this,$this->id,'Users'); $this->email1 = $user_fields['EMAIL1']; $user_fields['EMAIL1_LINK'] = $current_user->getEmailLink('email1', $this, '', '', 'ListView'); return $user_fields; } function list_view_parse_additional_sections(&$list_form, $xTemplateSection){ return $list_form; } function create_export_query($order_by, $where) { include('modules/Employees/field_arrays.php'); $cols = ''; foreach($fields_array['Employee']['export_fields'] as $field) { $cols .= (empty($cols)) ? '' : ', '; $cols .= $field; } $query = "SELECT {$cols} FROM users "; $where_auto = " users.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 users.user_name"; return $query; } //use parent class /** * Generate the name field from the first_name and last_name fields. */ /* function _create_proper_name_field() { global $locale; $full_name = $locale->getLocaleFormattedName($this->first_name, $this->last_name); $this->name = $full_name; $this->full_name = $full_name; } */ function preprocess_fields_on_save(){ parent::preprocess_fields_on_save(); } /** * create_new_list_query * * Return the list query used by the list views and export button. Next generation of create_new_list_query function. * * We overrode this function in the Employees module to add the additional filter check so that we do not retrieve portal users for the Employees list view queries * * @param string $order_by custom order by clause * @param string $where custom where clause * @param array $filter Optioanal * @param array $params Optional * * @param int $show_deleted Optional, default 0, show deleted records is set to 1. * @param string $join_type * @param boolean $return_array Optional, default false, response as array * @param object $parentbean creating a subquery for this bean. * @param boolean $singleSelect Optional, default false. * @return String select query string, optionally an array value will be returned if $return_array= true. */ function create_new_list_query($order_by, $where, $filter=array(), $params=array(), $show_deleted=0, $join_type='', $return_array=false, $parentbean=null, $singleSelect=false) { //create the filter for portal only users, as they should not be showing up in query results if(empty($where)){ $where = ' users.portal_only = 0 '; }else{ $where .= ' and users.portal_only = 0 '; } //return parent method, specifying for array to be returned return parent::create_new_list_query($order_by, $where, $filter,$params, $show_deleted, $join_type, $return_array, $parentbean, $singleSelect); } } ?>