function getTemplateFileName() { $profID = CRM_Utils_Request::retrieve('gid', 'String', $this); $this->_params['contact_type'] = 'Individual'; $selector = new CRM_Profile_Selector_Listings($this->_params, $this->_customFields, $profID, $this->_map, FALSE, 0); $extraWhereClause = NULL; $grpParams = array('name' => 'HRJobContract_Summary'); CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomGroup', $grpParams, $cGrp); $fdParams = array('name' => 'Final_Termination_Date', 'custom_group_id' => $cGrp['id']); CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $fdParams, $fdField); $idParams = array('name' => 'Initial_Join_Date', 'custom_group_id' => $cGrp['id']); CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $idParams, $idField); $extraWhereClause = " (({$cGrp['table_name']}.{$fdField['column_name']} >= CURDATE() OR {$cGrp['table_name']}.{$fdField['column_name']} IS NULL) AND\n ({$cGrp['table_name']}.{$idField['column_name']} IS NOT NULL AND {$cGrp['table_name']}.{$idField['column_name']} <= CURDATE()))"; $column = $columnHeaders = $selector->getColumnHeaders(); $rows = $selector->getRows(4, 0, 0, NULL, NULL, $extraWhereClause); CRM_Utils_Hook::searchColumns('profile', $columnHeaders, $rows, $this); $this->assign('aaData', json_encode($rows)); /* to bring column names in [ { "sTitle": "Engine" }, { "sTitle": "Browser" },] format*/ $colunmH = "["; foreach ($column as $k => $v) { if (!empty($v['name'])) { $name = '{"sTitle":"' . $v['name'] . '"}'; } else { $name = '{"bSortable": false}'; } $colunmH .= $name . ","; } $colunmH .= "]"; $this->assign('aaColumn', $colunmH); return 'CRM/HRProfile/Page/HRProfile.tpl'; }
/** * returns the column headers as an array of tuples: * (name, sortName (key to the sort array)) * * @param string $action the action being performed * @param enum $output what should the result set include (web/email/csv) * * @return array the column headers that need to be displayed * @access public */ function &getColumnHeaders($action = NULL, $output = NULL) { static $skipFields = array('group', 'tag'); $multipleFields = array('url'); $direction = CRM_Utils_Sort::ASCENDING; $empty = TRUE; if (!isset(self::$_columnHeaders)) { self::$_columnHeaders = array(array('name' => ''), array('name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, 'field_name' => 'sort_name')); $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); foreach ($this->_fields as $name => $field) { // skip pseudo fields if (substr($name, 0, 9) == 'phone_ext') { continue; } if (!empty($field['in_selector']) && !in_array($name, $skipFields)) { if (strpos($name, '-') !== FALSE) { $value = explode('-', $name); $fieldName = CRM_Utils_Array::value(0, $value); $lType = CRM_Utils_Array::value(1, $value); $type = CRM_Utils_Array::value(2, $value); if (!in_array($fieldName, $multipleFields)) { if ($lType == 'Primary') { $locationTypeName = 1; } else { $locationTypeName = $locationTypes[$lType]; } if (in_array($fieldName, array('phone', 'im', 'email'))) { if ($type) { $name = "`{$locationTypeName}-{$fieldName}-{$type}`"; } else { $name = "`{$locationTypeName}-{$fieldName}`"; } } else { $name = "`{$locationTypeName}-{$fieldName}`"; } } else { $name = "website-{$lType}-{$fieldName}"; } } self::$_columnHeaders[] = array('name' => $field['title'], 'sort' => $name, 'direction' => $direction, 'field_name' => CRM_Core_BAO_UFField::isValidFieldName($name) ? $name : $fieldName); $direction = CRM_Utils_Sort::DONTCARE; $empty = FALSE; } } // if we dont have any valid columns, dont add the implicit ones // this allows the template to check on emptiness of column headers if ($empty) { self::$_columnHeaders = array(); } else { self::$_columnHeaders[] = array('desc' => ts('Actions')); } } return self::$_columnHeaders; }
/** * returns the column headers as an array of tuples: * (name, sortName (key to the sort array)) * * @param string $action the action being performed * @param enum $output what should the result set include (web/email/csv) * * @return array the column headers that need to be displayed * @access public */ function &getColumnHeaders($action = null, $output = null) { static $skipFields = array('group', 'tag'); $direction = CRM_Utils_Sort::ASCENDING; $empty = true; if (!isset(self::$_columnHeaders)) { self::$_columnHeaders = array(array('name' => ''), array('name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING)); require_once 'CRM/Core/PseudoConstant.php'; $locationTypes = CRM_Core_PseudoConstant::locationType(); foreach ($this->_fields as $name => $field) { if (CRM_Utils_Array::value('in_selector', $field) && !in_array($name, $skipFields)) { if (strpos($name, '-') !== false) { $value = explode('-', $name); $fieldName = CRM_Utils_Array::value(0, $value); $lType = CRM_Utils_Array::value(1, $value); $type = CRM_Utils_Array::value(2, $value); if ($lType == 'Primary') { $locationTypeName = 1; } else { $locationTypeName = $locationTypes[$lType]; } if (in_array($fieldName, array('phone', 'im', 'email'))) { if ($type) { $name = "`{$locationTypeName}-{$fieldName}-{$type}`"; } else { $name = "`{$locationTypeName}-{$fieldName}`"; } } else { $name = "`{$locationTypeName}-{$fieldName}`"; } } self::$_columnHeaders[] = array('name' => $field['title'], 'sort' => $name, 'direction' => $direction); $direction = CRM_Utils_Sort::DONTCARE; $empty = false; } } // if we dont have any valid columns, dont add the implicit ones // this allows the template to check on emptiness of column headers if ($empty) { self::$_columnHeaders = array(); } else { self::$_columnHeaders[] = array('desc' => ts('Actions')); } } return self::$_columnHeaders; }
/** * returns all the rows in the given offset and rowCount * * @param enum $action the action being performed * @param int $offset the row number to start from * @param int $rowCount the number of rows to return * @param string $sort the sql string that describes the sort order * @param enum $output what should the result set include (web/email/csv) * * @return int the total number of rows for this action */ function &getRows($action, $offset, $rowCount, $sort, $output = null) { //$sort object processing for location fields if ($sort) { $vars = $sort->_vars; $varArray = array(); foreach ($vars as $key => $field) { $field = $vars[$key]; $fieldArray = explode('-', $field['name']); if (is_numeric($fieldArray[1])) { $locationType =& new CRM_Core_DAO_LocationType(); $locationType->id = $fieldArray[1]; $locationType->find(true); if ($fieldArray[0] == 'email' || $fieldArray[0] == 'im' || $fieldArray[0] == 'phone') { $field['name'] = "`" . $locationType->name . "-" . $fieldArray[0] . "-1`"; } else { $field['name'] = "`" . $locationType->name . "-" . $fieldArray[0] . "`"; } } $varArray[$key] = $field; } } $sort->_vars = $varArray; $result = $this->_query->searchQuery($offset, $rowCount, $sort, null, null, null, null, null); // process the result of the query $rows = array(); $mask = CRM_Core_Action::mask(CRM_Core_Permission::getPermission()); require_once 'CRM/Core/PseudoConstant.php'; $locationTypes = CRM_Core_PseudoConstant::locationType(); $links =& CRM_Profile_Selector_Listings::links(); $names = array(); foreach ($this->_fields as $key => $field) { if ($field['in_selector'] && !in_array($key, $GLOBALS['_CRM_PROFILE_SELECTOR_LISTINGS']['skipFields'])) { if (strpos($key, '-') !== false) { list($fieldName, $id, $type) = explode('-', $key); $locationTypeName = CRM_Utils_Array::value($id, $locationTypes); if (!$locationTypeName) { continue; } if (in_array($fieldName, array('phone', 'im', 'email'))) { if ($type) { $names[] = "{$locationTypeName}-{$fieldName}-{$type}"; } else { $names[] = "{$locationTypeName}-{$fieldName}-1"; } } else { $names[] = "{$locationTypeName}-{$fieldName}"; } } else { $names[] = $field['name']; } } } while ($result->fetch()) { if (isset($result->country)) { // the query returns the untranslated country name $i18n =& CRM_Core_I18n::singleton(); $result->country = $i18n->translate($result->country); } $row = array(); $empty = true; $row[] = CRM_Contact_BAO_Contact::getImage($result->contact_type); $row['sort_name'] = $result->sort_name; foreach ($names as $name) { if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) { $row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$name}, $cfID, $this->_options); } else { $row[] = $result->{$name}; } if (!empty($result->{$name})) { $empty = false; } } $row[] = CRM_Core_Action::formLink(CRM_Profile_Selector_Listings::links(), $mask, array('id' => $result->contact_id, 'gid' => $this->_gid)); if (!$empty) { $rows[] = $row; } } return $rows; }