diff --git a/Jenkinsfile b/Jenkinsfile index 3eaec096865..796e3a10120 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -49,7 +49,7 @@ pipeline { steps { script { // Build site with CV Buildkit - sh "civibuild create ${params.CIVIHR_BUILDNAME} --type drupal-clean --civi-ver 5.7.0 --url $WEBURL --admin-pass $ADMIN_PASS" + sh "civibuild create ${params.CIVIHR_BUILDNAME} --type drupal-clean --civi-ver 5.9 --url $WEBURL --admin-pass $ADMIN_PASS" // Get target and PR branches name def prBranch = env.CHANGE_BRANCH diff --git a/com.civicrm.hrjobroles/hrjobroles.php b/com.civicrm.hrjobroles/hrjobroles.php index 6bdd456a055..7a599914bdf 100644 --- a/com.civicrm.hrjobroles/hrjobroles.php +++ b/com.civicrm.hrjobroles/hrjobroles.php @@ -125,6 +125,7 @@ function hrjobroles_civicrm_tabset($tabsetName, &$tabs, $context) { $tabs[] = array( 'id' => 'hrjobroles', 'url' => $url, 'title' => 'Job Roles', + 'icon' => 'fa fa-list-alt', 'weight' => -180, ); } diff --git a/contactsummary/contactsummary.php b/contactsummary/contactsummary.php index 0fe22fd666c..1c0c324d3ce 100644 --- a/contactsummary/contactsummary.php +++ b/contactsummary/contactsummary.php @@ -157,6 +157,7 @@ function contactsummary_civicrm_tabset($tabsetName, &$tabs, $context) { 'id' => 'contactsummary', 'url' => CRM_Utils_System::url('civicrm/contact-summary'), 'title' => ts('Contact Summary'), + 'icon' => 'fa fa-user', 'weight' => -200, ); } diff --git a/contactsummary/js/src/contact-summary/controllers/key-dates.html b/contactsummary/js/src/contact-summary/controllers/key-dates.html index 620fe1e2e14..a2c0f16048c 100644 --- a/contactsummary/js/src/contact-summary/controllers/key-dates.html +++ b/contactsummary/js/src/contact-summary/controllers/key-dates.html @@ -1,7 +1,6 @@ -
+

Key Dates

-
diff --git a/contactsummary/js/src/contact-summary/controllers/key-details.html b/contactsummary/js/src/contact-summary/controllers/key-details.html index 8a8d34fc43a..bd614817d95 100644 --- a/contactsummary/js/src/contact-summary/controllers/key-details.html +++ b/contactsummary/js/src/contact-summary/controllers/key-details.html @@ -1,8 +1,7 @@ -

Key Details

-
diff --git a/hrbank/hrbank.php b/hrbank/hrbank.php index 502f0583b39..3f9ac611314 100644 --- a/hrbank/hrbank.php +++ b/hrbank/hrbank.php @@ -104,3 +104,22 @@ function hrbank_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { function hrbank_civicrm_managed(&$entities) { return _hrbank_civix_civicrm_managed($entities); } + +/** + * Implementation of hook_civicrm_tabset + * + * @param string $tabsetName + * @param array $tabs + * @param mixed $context + */ +function hrbank_civicrm_tabset($tabsetName, &$tabs, $context) { + if ($tabsetName != 'civicrm/contact/view') { + return; + } + + foreach ($tabs as $i => $tab) { + if ($tab['title'] == 'Bank Details') { + $tabs[$i]['icon'] = 'fa fa-bank'; + } + } +} diff --git a/hrcareer/hrcareer.php b/hrcareer/hrcareer.php index b4ccc91b659..9a52ded7cbb 100644 --- a/hrcareer/hrcareer.php +++ b/hrcareer/hrcareer.php @@ -192,3 +192,22 @@ function hrcareer_civicrm_pageRun($page) { ->addScriptFile('org.civicrm.hrcareer', 'js/dist/hrcareer.min.js', 1010); } } + +/** + * Implementation of hook_civicrm_tabset + * + * @param string $tabsetName + * @param array $tabs + * @param mixed $context + */ +function hrcareer_civicrm_tabset($tabsetName, &$tabs, $context) { + if ($tabsetName != 'civicrm/contact/view') { + return; + } + + foreach ($tabs as $i => $tab) { + if ($tab['title'] == 'Career History') { + $tabs[$i]['icon'] = 'fa fa-history'; + } + } +} diff --git a/hrjobcontract/CRM/Export/BAO/Export.php b/hrjobcontract/CRM/Export/BAO/Export.php index f8a50920aa2..f7de0d5d07b 100644 --- a/hrjobcontract/CRM/Export/BAO/Export.php +++ b/hrjobcontract/CRM/Export/BAO/Export.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2018 + * @copyright CiviCRM LLC (c) 2004-2019 */ /** @@ -176,14 +176,7 @@ public static function getGroupBy($processor, $returnProperties, $query) { $groupBy = array('contact_a.id', 'hrjobcontract.id'); } - if (!empty($groupBy)) { - if (!Civi::settings()->get('searchPrimaryDetailsOnly')) { - CRM_Core_DAO::disableFullGroupByMode(); - } - $groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($query->_select, $groupBy); - } - - return $groupBy; + return $groupBy ? ' GROUP BY ' . $groupBy : ''; } /** @@ -238,15 +231,8 @@ public static function exportComponents( $processor = new CRM_Export_BAO_ExportProcessor($exportMode, $fields, $queryOperator, $mergeSameHousehold); $returnProperties = array(); - - $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); - // Warning - this imProviders var is used in a somewhat fragile way - don't rename it - // without manually testing the export of IM provider still works. - $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); self::$relationshipTypes = $processor->getRelationshipTypes(); - $queryMode = $processor->getQueryMode(); - if ($fields) { foreach ($fields as $key => $value) { $fieldName = CRM_Utils_Array::value(1, $value); @@ -315,6 +301,7 @@ public static function exportComponents( if (!array_key_exists($column, $returnProperties)) { $returnProperties[$column] = 1; $column = $column == 'id' ? 'civicrm_primary_id' : $column; + $processor->setColumnAsCalculationOnly($column); $exportParams['merge_same_address']['temp_columns'][$column] = 1; } } @@ -347,6 +334,7 @@ public static function exportComponents( if (!array_key_exists($column, $returnProperties)) { $returnProperties[$column] = 1; $exportParams['postal_mailing_export']['temp_columns'][$column] = 1; + $processor->setColumnAsCalculationOnly($column); } } } @@ -371,11 +359,13 @@ public static function exportComponents( $returnProperties[$householdRelationshipType][$key] = $value; } } + // @todo - don't use returnProperties above. + $processor->setHouseholdMergeReturnProperties($returnProperties[$householdRelationshipType]); } } } - list($relationQuery, $allRelContactArray) = self::buildRelatedContactArray($selectAll, $ids, $processor, $componentTable, $returnProperties); + self::buildRelatedContactArray($selectAll, $ids, $processor, $componentTable); // make sure the groups stuff is included only if specifically specified // by the fields param (CRM-1969), else we limit the contacts outputted to only @@ -444,29 +434,19 @@ public static function exportComponents( $paymentDetails = array(); if ($processor->isExportPaymentFields()) { - // get payment related in for event and members $paymentDetails = CRM_Contribute_BAO_Contribution::getContributionDetails($exportMode, $ids); //get all payment headers. // If we haven't selected specific payment fields, load in all the // payment headers. if (!$processor->isExportSpecifiedPaymentFields()) { - $paymentHeaders = self::componentPaymentFields(); if (!empty($paymentDetails)) { $addPaymentHeader = TRUE; } } - // If we have selected specific payment fields, leave the payment headers - // as an empty array; the headers for each selected field will be added - // elsewhere. - else { - $paymentHeaders = array(); - } - $nullContributionDetails = array_fill_keys(array_keys($paymentHeaders), NULL); } $componentDetails = array(); - $setHeader = TRUE; $rowCount = self::EXPORT_ROW_COUNT; $offset = 0; @@ -475,15 +455,27 @@ public static function exportComponents( $count = -1; - // for CRM-3157 purposes - $i18n = CRM_Core_I18n::singleton(); + list($outputColumns, $sqlColumns, $metadata) = self::getExportStructureArrays($returnProperties, $processor); + $headerRows = $processor->getHeaderRows(); - list($outputColumns, $headerRows, $sqlColumns, $metadata) = self::getExportStructureArrays($returnProperties, $processor); + // add payment headers if required + if ($addPaymentHeader && $processor->isExportPaymentFields()) { + // @todo rather than do this for every single row do it before the loop starts. + // where other header definitions take place. + $headerRows = array_merge($headerRows, $processor->getPaymentHeaders()); + foreach (array_keys($processor->getPaymentHeaders()) as $paymentHdr) { + self::sqlColumnDefn($processor, $sqlColumns, $paymentHdr); + } + } + $exportTempTable = self::createTempTable($sqlColumns); $limitReached = FALSE; + while (!$limitReached) { $limitQuery = "{$queryString} LIMIT {$offset}, {$rowCount}"; + CRM_Core_DAO::disableFullGroupByMode(); $iterationDAO = CRM_Core_DAO::executeQuery($limitQuery); + CRM_Core_DAO::reenableFullGroupByMode(); // If this is less than our limit by the end of the iteration we do not need to run the query again to // check if some remain. $rowsThisIteration = 0; @@ -491,88 +483,7 @@ public static function exportComponents( while ($iterationDAO->fetch()) { $count++; $rowsThisIteration++; - $row = array(); - $query->convertToPseudoNames($iterationDAO); - - //first loop through output columns so that we return what is required, and in same order. - foreach ($outputColumns as $field => $value) { - - // add im_provider to $dao object - if ($field == 'im_provider' && property_exists($iterationDAO, 'provider_id')) { - $iterationDAO->im_provider = $iterationDAO->provider_id; - } - - //build row values (data) - $fieldValue = NULL; - if (property_exists($iterationDAO, $field)) { - $fieldValue = $iterationDAO->$field; - // to get phone type from phone type id - if ($field == 'phone_type_id' && isset($phoneTypes[$fieldValue])) { - $fieldValue = $phoneTypes[$fieldValue]; - } - elseif ($field == 'provider_id' || $field == 'im_provider') { - $fieldValue = CRM_Utils_Array::value($fieldValue, $imProviders); - } - elseif (strstr($field, 'master_id')) { - $masterAddressId = NULL; - if (isset($iterationDAO->$field)) { - $masterAddressId = $iterationDAO->$field; - } - // get display name of contact that address is shared. - $fieldValue = CRM_Contact_BAO_Contact::getMasterDisplayName($masterAddressId); - } - } - - if ($processor->isRelationshipTypeKey($field)) { - $relDAO = CRM_Utils_Array::value($iterationDAO->contact_id, $allRelContactArray[$field]); - $relationQuery[$field]->convertToPseudoNames($relDAO); - self::fetchRelationshipDetails($relDAO, $value, $field, $row); - } - else { - $row[$field] = self::getTransformedFieldValue($field, $iterationDAO, $fieldValue, $i18n, $metadata, $paymentDetails, $processor); - } - } - - // add payment headers if required - if ($addPaymentHeader && $processor->isExportPaymentFields()) { - // @todo rather than do this for every single row do it before the loop starts. - // where other header definitions take place. - $headerRows = array_merge($headerRows, $paymentHeaders); - foreach (array_keys($paymentHeaders) as $paymentHdr) { - self::sqlColumnDefn($processor, $sqlColumns, $paymentHdr); - } - } - - if ($setHeader) { - $exportTempTable = self::createTempTable($sqlColumns); - } - - //build header only once - $setHeader = FALSE; - - // If specific payment fields have been selected for export, payment - // data will already be in $row. Otherwise, add payment related - // information, if appropriate. - if ($addPaymentHeader) { - if (!$processor->isExportSpecifiedPaymentFields()) { - if ($processor->isExportPaymentFields()) { - $paymentData = CRM_Utils_Array::value($row[$paymentTableId], $paymentDetails); - if (!is_array($paymentData) || empty($paymentData)) { - $paymentData = $nullContributionDetails; - } - $row = array_merge($row, $paymentData); - } - elseif (!empty($paymentDetails)) { - $row = array_merge($row, $nullContributionDetails); - } - } - } - //remove organization name for individuals if it is set for current employer - if (!empty($row['contact_type']) && - $row['contact_type'] == 'Individual' && array_key_exists('organization_name', $row) - ) { - $row['organization_name'] = ''; - } + $row = $processor->buildRow($query, $iterationDAO, $outputColumns, $metadata, $paymentDetails, $addPaymentHeader, $paymentTableId); // add component info // write the row to a file @@ -598,12 +509,12 @@ public static function exportComponents( if (isset($exportParams['postal_mailing_export']['postal_mailing_export']) && $exportParams['postal_mailing_export']['postal_mailing_export'] == 1 ) { - self::postalMailingFormat($exportTempTable, $headerRows, $sqlColumns, $exportMode); + self::postalMailingFormat($exportTempTable, $sqlColumns, $exportMode); } // do merge same address and merge same household processing if ($mergeSameAddress) { - self::mergeSameAddress($exportTempTable, $headerRows, $sqlColumns, $exportParams); + self::mergeSameAddress($exportTempTable, $sqlColumns, $exportParams); } // merge the records if they have corresponding households @@ -614,12 +525,12 @@ public static function exportComponents( } // call export hook - CRM_Utils_Hook::export($exportTempTable, $headerRows, $sqlColumns, $exportMode); + CRM_Utils_Hook::export($exportTempTable, $headerRows, $sqlColumns, $exportMode, $componentTable, $ids); // In order to be able to write a unit test against this function we need to suppress // the csv writing. In future hopefully the csv writing & the main processing will be in separate functions. if (empty($exportParams['suppress_csv_for_testing'])) { - self::writeCSVFromTable($exportTempTable, $headerRows, $sqlColumns, $exportMode); + self::writeCSVFromTable($exportTempTable, $headerRows, $sqlColumns, $processor); } else { // return tableName sqlColumns headerRows in test context @@ -638,45 +549,6 @@ public static function exportComponents( } } - /** - * Name of the export file based on mode. - * - * @param string $output - * Type of output. - * @param int $mode - * Export mode. - * - * @return string - * name of the file - */ - public static function getExportFileName($output = 'csv', $mode = CRM_Export_Form_Select::CONTACT_EXPORT) { - switch ($mode) { - case CRM_Export_Form_Select::CONTACT_EXPORT: - return ts('CiviCRM Contact Search'); - - case CRM_Export_Form_Select::CONTRIBUTE_EXPORT: - return ts('CiviCRM Contribution Search'); - - case CRM_Export_Form_Select::MEMBER_EXPORT: - return ts('CiviCRM Member Search'); - - case CRM_Export_Form_Select::EVENT_EXPORT: - return ts('CiviCRM Participant Search'); - - case CRM_Export_Form_Select::PLEDGE_EXPORT: - return ts('CiviCRM Pledge Search'); - - case CRM_Export_Form_Select::CASE_EXPORT: - return ts('CiviCRM Case Search'); - - case CRM_Export_Form_Select::GRANT_EXPORT: - return ts('CiviCRM Grant Search'); - - case CRM_Export_Form_Select::ACTIVITY_EXPORT: - return ts('CiviCRM Activity Search'); - } - } - /** * Handle import error file creation. */ @@ -763,7 +635,7 @@ public static function exportCustom($customSearchClass, $formValues, $order) { $rows[] = $row; } - CRM_Core_Report_Excel::writeCSVFile(self::getExportFileName(), $header, $rows); + CRM_Core_Report_Excel::writeCSVFile(ts('CiviCRM Contact Search'), $header, $rows); CRM_Utils_System::civiExit(); } @@ -870,11 +742,10 @@ public static function createTempTable($sqlColumns) { /** * @param string $tableName - * @param $headerRows * @param $sqlColumns * @param array $exportParams */ - public static function mergeSameAddress($tableName, &$headerRows, &$sqlColumns, $exportParams) { + public static function mergeSameAddress($tableName, &$sqlColumns, $exportParams) { // check if any records are present based on if they have used shared address feature, // and not based on if city / state .. matches. $sql = " @@ -971,7 +842,7 @@ public static function mergeSameAddress($tableName, &$headerRows, &$sqlColumns, $unsetKeys = array_keys($sqlColumns); foreach ($unsetKeys as $headerKey => $sqlColKey) { if (array_key_exists($sqlColKey, $exportParams['merge_same_address']['temp_columns'])) { - unset($sqlColumns[$sqlColKey], $headerRows[$headerKey]); + unset($sqlColumns[$sqlColKey]); } } } @@ -1163,16 +1034,11 @@ public static function _buildMasterCopyArray($sql, $exportParams, $sharedAddress */ public static function mergeSameHousehold($exportTempTable, &$sqlColumns, $prefix) { $prefixColumn = $prefix . '_'; - $allKeys = array_keys($sqlColumns); $replaced = array(); // name map of the non standard fields in header rows & sql columns $mappingFields = array( 'civicrm_primary_id' => 'id', - 'contact_source' => 'source', - 'current_employer_id' => 'employer_id', - 'contact_is_deleted' => 'is_deleted', - 'name' => 'address_name', 'provider_id' => 'im_service_provider', 'phone_type_id' => 'phone_type', ); @@ -1221,7 +1087,9 @@ public static function mergeSameHousehold($exportTempTable, &$sqlColumns, $prefi FROM {$exportTempTable} GROUP BY civicrm_primary_id "; + CRM_Core_DAO::disableFullGroupByMode(); CRM_Core_DAO::executeQuery($query); + CRM_Core_DAO::reenableFullGroupByMode(); $query = "DROP TABLE $exportTempTable"; CRM_Core_DAO::executeQuery($query); @@ -1234,11 +1102,10 @@ public static function mergeSameHousehold($exportTempTable, &$sqlColumns, $prefi * @param $exportTempTable * @param $headerRows * @param $sqlColumns - * @param $exportMode - * @param null $saveFile - * @param string $batchItems + * @param \CRM_Export_BAO_ExportProcessor $processor */ - public static function writeCSVFromTable($exportTempTable, $headerRows, $sqlColumns, $exportMode, $saveFile = NULL, $batchItems = '') { + public static function writeCSVFromTable($exportTempTable, $headerRows, $sqlColumns, $processor) { + $exportMode = $processor->getExportMode(); $writeHeader = TRUE; $offset = 0; $limit = self::EXPORT_ROW_COUNT; @@ -1264,52 +1131,26 @@ public static function writeCSVFromTable($exportTempTable, $headerRows, $sqlColu } $componentDetails[] = $row; } - if ($exportMode == 'financial') { - $getExportFileName = 'CiviCRM Contribution Search'; - } - else { - $getExportFileName = self::getExportFileName('csv', $exportMode); - } - $csvRows = CRM_Core_Report_Excel::writeCSVFile($getExportFileName, + CRM_Core_Report_Excel::writeCSVFile($processor->getExportFileName(), $headerRows, $componentDetails, NULL, - $writeHeader, - $saveFile); - - if ($saveFile && !empty($csvRows)) { - $batchItems .= $csvRows; - } + $writeHeader + ); $writeHeader = FALSE; $offset += $limit; } } - /** - * Manipulate header rows for relationship fields. - * - * @param $headerRows - */ - public static function manipulateHeaderRows(&$headerRows) { - foreach ($headerRows as & $header) { - $split = explode('-', $header); - if ($relationTypeName = CRM_Utils_Array::value($split[0], self::$relationshipTypes)) { - $split[0] = $relationTypeName; - $header = implode('-', $split); - } - } - } - /** * Exclude contacts who are deceased, have "Do not mail" privacy setting, * or have no street address * @param $exportTempTable - * @param $headerRows * @param $sqlColumns * @param $exportParams */ - public static function postalMailingFormat($exportTempTable, &$headerRows, &$sqlColumns, $exportParams) { + public static function postalMailingFormat($exportTempTable, &$sqlColumns, $exportParams) { $whereClause = array(); if (array_key_exists('is_deceased', $sqlColumns)) { @@ -1352,7 +1193,7 @@ public static function postalMailingFormat($exportTempTable, &$headerRows, &$sql $unsetKeys = array_keys($sqlColumns); foreach ($unsetKeys as $headerKey => $sqlColKey) { if (array_key_exists($sqlColKey, $exportParams['postal_mailing_export']['temp_columns'])) { - unset($sqlColumns[$sqlColKey], $headerRows[$headerKey]); + unset($sqlColumns[$sqlColKey]); } } } @@ -1360,6 +1201,11 @@ public static function postalMailingFormat($exportTempTable, &$headerRows, &$sql /** * Build componentPayment fields. + * + * This is no longer used by export but BAO_Mapping still calls it & we + * should find a generic way to handle this or move this to that class. + * + * @deprecated */ public static function componentPaymentFields() { static $componentPaymentFields; @@ -1375,42 +1221,6 @@ public static function componentPaymentFields() { return $componentPaymentFields; } - /** - * Set the definition for the header rows and sql columns based on the field to output. - * - * @param string $field - * @param array $headerRows - * @param \CRM_Export_BAO_ExportProcessor $processor - * - * @return array - */ - public static function setHeaderRows($field, $headerRows, $processor) { - - $queryFields = $processor->getQueryFields(); - if (substr($field, -11) == 'campaign_id') { - // @todo - set this correctly in the xml rather than here. - $headerRows[] = ts('Campaign ID'); - } - elseif ($processor->isMergeSameHousehold() && $field === 'id') { - $headerRows[] = ts('Household ID'); - } - elseif (isset($queryFields[$field]['title'])) { - $headerRows[] = $queryFields[$field]['title']; - } - elseif ($field == 'provider_id') { - // @todo - set this correctly in the xml rather than here. - $headerRows[] = ts('IM Service Provider'); - } - elseif ($processor->isExportPaymentFields() && array_key_exists($field, self::componentPaymentFields())) { - $headerRows[] = CRM_Utils_Array::value($field, self::componentPaymentFields()); - } - else { - $headerRows[] = $field; - } - - return $headerRows; - } - /** * Get the various arrays that we use to structure our output. * @@ -1440,14 +1250,14 @@ public static function setHeaderRows($field, $headerRows, $processor) { * yet find a way to comment them for posterity. */ public static function getExportStructureArrays($returnProperties, $processor) { - $metadata = $headerRows = $outputColumns = $sqlColumns = array(); + $metadata = $outputColumns = $sqlColumns = array(); $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); $queryFields = $processor->getQueryFields(); foreach ($returnProperties as $key => $value) { if (($key != 'location' || !is_array($value)) && !$processor->isRelationshipTypeKey($key)) { $outputColumns[$key] = $value; - $headerRows = self::setHeaderRows($key, $headerRows, $processor); + $processor->addOutputSpecification($key); self::sqlColumnDefn($processor, $sqlColumns, $key); } elseif ($processor->isRelationshipTypeKey($key)) { @@ -1456,39 +1266,11 @@ public static function getExportStructureArrays($returnProperties, $processor) { foreach ($value as $relationField => $relationValue) { // below block is same as primary block (duplicate) if (isset($queryFields[$relationField]['title'])) { - if ($queryFields[$relationField]['name'] == 'name') { - $headerName = $field . '-' . $relationField; - } - else { - if ($relationField == 'current_employer') { - $headerName = $field . '-' . 'current_employer'; - } - else { - $headerName = $field . '-' . $queryFields[$relationField]['name']; - } - } - if (!$processor->isHouseholdMergeRelationshipTypeKey($field)) { // Do not add to header row if we are only generating for merge reasons. - $headerRows[] = $headerName; + $processor->addOutputSpecification($relationField, $key); } - - self::sqlColumnDefn($processor, $sqlColumns, $headerName); - } - elseif ($relationField == 'phone_type_id') { - $headerName = $field . '-' . 'Phone Type'; - $headerRows[] = $headerName; - self::sqlColumnDefn($processor, $sqlColumns, $headerName); - } - elseif ($relationField == 'provider_id') { - $headerName = $field . '-' . 'Im Service Provider'; - $headerRows[] = $headerName; - self::sqlColumnDefn($processor, $sqlColumns, $headerName); - } - elseif ($relationField == 'state_province_id') { - $headerName = $field . '-' . 'state_province_id'; - $headerRows[] = $headerName; - self::sqlColumnDefn($processor, $sqlColumns, $headerName); + self::sqlColumnDefn($processor, $sqlColumns, $field . '-' . $relationField); } elseif (is_array($relationValue) && $relationField == 'location') { // fix header for location type case @@ -1506,14 +1288,12 @@ public static function getExportStructureArrays($returnProperties, $processor) { $hdr .= "-" . CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_IM', 'provider_id', $type[1]); } } - $headerName = $field . '-' . $hdr; - $headerRows[] = $headerName; - self::sqlColumnDefn($processor, $sqlColumns, $headerName); + $processor->addOutputSpecification($field, $key, $ltype, CRM_Utils_Array::value(1, $type)); + self::sqlColumnDefn($processor, $sqlColumns, $field . '-' . $hdr); } } } } - self::manipulateHeaderRows($headerRows); } else { foreach ($value as $locationType => $locationFields) { @@ -1538,7 +1318,7 @@ public static function getExportStructureArrays($returnProperties, $processor) { $metadata[$daoFieldName]['pseudoconstant']['var'] = 'imProviders'; } self::sqlColumnDefn($processor, $sqlColumns, $outputFieldName); - $headerRows = self::setHeaderRows($outputFieldName, $headerRows, $processor); + $processor->addOutputSpecification($outputFieldName, NULL, $locationType, CRM_Utils_Array::value(1, $type)); self::sqlColumnDefn($processor, $sqlColumns, $outputFieldName); if ($actualDBFieldName == 'country' || $actualDBFieldName == 'world_region') { $metadata[$daoFieldName] = array('context' => 'country'); @@ -1551,7 +1331,7 @@ public static function getExportStructureArrays($returnProperties, $processor) { } } } - return array($outputColumns, $headerRows, $sqlColumns, $metadata); + return array($outputColumns, $sqlColumns, $metadata); } /** @@ -1566,6 +1346,8 @@ private static function fetchRelationshipDetails($relDAO, $value, $field, &$row) $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); $i18n = CRM_Core_I18n::singleton(); + $field = $field . '_'; + foreach ($value as $relationField => $relationValue) { if (is_object($relDAO) && property_exists($relDAO, $relationField)) { $fieldValue = $relDAO->$relationField; @@ -1596,7 +1378,6 @@ private static function fetchRelationshipDetails($relDAO, $value, $field, &$row) else { $fieldValue = ''; } - $field = $field . '_'; $relPrefix = $field . $relationField; if (is_object($relDAO) && $relationField == 'id') { @@ -1713,171 +1494,76 @@ protected static function getIDsForRelatedContact($ids, $exportMode) { * @param $ids * @param \CRM_Export_BAO_ExportProcessor $processor * @param $componentTable - * @param $returnProperties - * - * @return array */ - protected static function buildRelatedContactArray($selectAll, $ids, $processor, $componentTable, $returnProperties) { + protected static function buildRelatedContactArray($selectAll, $ids, $processor, $componentTable) { $allRelContactArray = $relationQuery = array(); $queryMode = $processor->getQueryMode(); $exportMode = $processor->getExportMode(); - foreach (self::$relationshipTypes as $rel => $dnt) { - if ($relationReturnProperties = CRM_Utils_Array::value($rel, $returnProperties)) { - $allRelContactArray[$rel] = array(); - // build Query for each relationship - $relationQuery[$rel] = new CRM_Contact_BAO_Query(NULL, $relationReturnProperties, - NULL, FALSE, FALSE, $queryMode - ); - list($relationSelect, $relationFrom, $relationWhere, $relationHaving) = $relationQuery[$rel]->query(); - - list($id, $direction) = explode('_', $rel, 2); - // identify the relationship direction - $contactA = 'contact_id_a'; - $contactB = 'contact_id_b'; - if ($direction == 'b_a') { - $contactA = 'contact_id_b'; - $contactB = 'contact_id_a'; - } - $relIDs = self::getIDsForRelatedContact($ids, $exportMode); - $relationshipJoin = $relationshipClause = ''; - if (!$selectAll && $componentTable) { - $relationshipJoin = " INNER JOIN {$componentTable} ctTable ON ctTable.contact_id = {$contactA}"; - } - elseif (!empty($relIDs)) { - $relID = implode(',', $relIDs); - $relationshipClause = " AND crel.{$contactA} IN ( {$relID} )"; - } + foreach ($processor->getRelationshipReturnProperties() as $relationshipKey => $relationReturnProperties) { + $allRelContactArray[$relationshipKey] = array(); + // build Query for each relationship + $relationQuery = new CRM_Contact_BAO_Query(NULL, $relationReturnProperties, + NULL, FALSE, FALSE, $queryMode + ); + list($relationSelect, $relationFrom, $relationWhere, $relationHaving) = $relationQuery->query(); + + list($id, $direction) = explode('_', $relationshipKey, 2); + // identify the relationship direction + $contactA = 'contact_id_a'; + $contactB = 'contact_id_b'; + if ($direction == 'b_a') { + $contactA = 'contact_id_b'; + $contactB = 'contact_id_a'; + } + $relIDs = self::getIDsForRelatedContact($ids, $exportMode); - $relationFrom = " {$relationFrom} - INNER JOIN civicrm_relationship crel ON crel.{$contactB} = contact_a.id AND crel.relationship_type_id = {$id} - {$relationshipJoin} "; - - //check for active relationship status only - $today = date('Ymd'); - $relationActive = " AND (crel.is_active = 1 AND ( crel.end_date is NULL OR crel.end_date >= {$today} ) )"; - $relationWhere = " WHERE contact_a.is_deleted = 0 {$relationshipClause} {$relationActive}"; - $relationGroupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($relationQuery[$rel]->_select, "crel.{$contactA}"); - $relationSelect = "{$relationSelect}, {$contactA} as refContact "; - $relationQueryString = "$relationSelect $relationFrom $relationWhere $relationHaving $relationGroupBy"; - - $allRelContactDAO = CRM_Core_DAO::executeQuery($relationQueryString); - while ($allRelContactDAO->fetch()) { - //FIX Me: Migrate this to table rather than array - // build the array of all related contacts - $allRelContactArray[$rel][$allRelContactDAO->refContact] = clone($allRelContactDAO); - } - $allRelContactDAO->free(); + $relationshipJoin = $relationshipClause = ''; + if (!$selectAll && $componentTable) { + $relationshipJoin = " INNER JOIN {$componentTable} ctTable ON ctTable.contact_id = {$contactA}"; + } + elseif (!empty($relIDs)) { + $relID = implode(',', $relIDs); + $relationshipClause = " AND crel.{$contactA} IN ( {$relID} )"; } - } - return array($relationQuery, $allRelContactArray); - } - /** - * @param $field - * @param $iterationDAO - * @param $fieldValue - * @param $i18n - * @param $metadata - * @param $paymentDetails - * - * @param \CRM_Export_BAO_ExportProcessor $processor - * - * @return string - */ - protected static function getTransformedFieldValue($field, $iterationDAO, $fieldValue, $i18n, $metadata, $paymentDetails, $processor) { + $relationFrom = " {$relationFrom} + INNER JOIN civicrm_relationship crel ON crel.{$contactB} = contact_a.id AND crel.relationship_type_id = {$id} + {$relationshipJoin} "; - if ($field == 'id') { - return $iterationDAO->contact_id; - // special case for calculated field - } - elseif ($field == 'source_contact_id') { - return $iterationDAO->contact_id; - } - elseif ($field == 'pledge_balance_amount') { - return $iterationDAO->pledge_amount - $iterationDAO->pledge_total_paid; - // special case for calculated field - } - elseif ($field == 'pledge_next_pay_amount') { - return $iterationDAO->pledge_next_pay_amount + $iterationDAO->pledge_outstanding_amount; - } - elseif (isset($fieldValue) && - $fieldValue != '' - ) { - //check for custom data - if ($cfID = CRM_Core_BAO_CustomField::getKeyID($field)) { - return CRM_Core_BAO_CustomField::displayValue($fieldValue, $cfID); - } + //check for active relationship status only + $today = date('Ymd'); + $relationActive = " AND (crel.is_active = 1 AND ( crel.end_date is NULL OR crel.end_date >= {$today} ) )"; + $relationWhere = " WHERE contact_a.is_deleted = 0 {$relationshipClause} {$relationActive}"; + CRM_Core_DAO::disableFullGroupByMode(); + $relationSelect = "{$relationSelect}, {$contactA} as refContact "; + $relationQueryString = "$relationSelect $relationFrom $relationWhere $relationHaving GROUP BY crel.{$contactA}"; - elseif (in_array($field, array( - 'email_greeting', - 'postal_greeting', - 'addressee', - ))) { - //special case for greeting replacement - $fldValue = "{$field}_display"; - return $iterationDAO->$fldValue; - } - else { - //normal fields with a touch of CRM-3157 - switch ($field) { - case 'country': - case 'world_region': - return $i18n->crm_translate($fieldValue, array('context' => 'country')); - - case 'state_province': - return $i18n->crm_translate($fieldValue, array('context' => 'province')); - - case 'gender': - case 'preferred_communication_method': - case 'preferred_mail_format': - case 'communication_style': - return $i18n->crm_translate($fieldValue); - - default: - if (isset($metadata[$field])) { - // No I don't know why we do it this way & whether we could - // make better use of pseudoConstants. - if (!empty($metadata[$field]['context'])) { - return $i18n->crm_translate($fieldValue, $metadata[$field]); - } - if (!empty($metadata[$field]['pseudoconstant'])) { - // This is not our normal syntax for pseudoconstants but I am a bit loath to - // call an external function until sure it is not increasing php processing given this - // may be iterated 100,000 times & we already have the $imProvider var loaded. - // That can be next refactor... - // Yes - definitely feeling hatred for this bit of code - I know you will beat me up over it's awfulness - // but I have to reach a stable point.... - $varName = $metadata[$field]['pseudoconstant']['var']; - if ($varName === 'imProviders') { - return CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_IM', 'provider_id', $fieldValue); - } - if ($varName === 'phoneTypes') { - return CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_Phone', 'phone_type_id', $fieldValue); - } - } + $allRelContactDAO = CRM_Core_DAO::executeQuery($relationQueryString); + CRM_Core_DAO::reenableFullGroupByMode(); + while ($allRelContactDAO->fetch()) { + $relationQuery->convertToPseudoNames($allRelContactDAO); + $row = []; + // @todo pass processor to fetchRelationshipDetails and set fields directly within it. + self::fetchRelationshipDetails($allRelContactDAO, $relationReturnProperties, $relationshipKey, $row); + foreach (array_keys($relationReturnProperties) as $property) { + if ($property === 'location') { + // @todo - simplify location in self::fetchRelationshipDetails - remove handling here. Or just call + // $processor->setRelationshipValue from fetchRelationshipDetails + foreach ($relationReturnProperties['location'] as $locationName => $locationValues) { + foreach (array_keys($locationValues) as $locationValue) { + $key = str_replace(' ', '_', $locationName) . '-' . $locationValue; + $processor->setRelationshipValue($relationshipKey, $allRelContactDAO->refContact, $key, $row[$relationshipKey . '__' . $key]); + } } - return $fieldValue; + } + else { + $processor->setRelationshipValue($relationshipKey, $allRelContactDAO->refContact, $property, $row[$relationshipKey . '_' . $property]); + } } } } - elseif ($processor->isExportSpecifiedPaymentFields() && array_key_exists($field, self::componentPaymentFields())) { - $paymentTableId = $processor->getPaymentTableID(); - $paymentData = CRM_Utils_Array::value($iterationDAO->$paymentTableId, $paymentDetails); - $payFieldMapper = array( - 'componentPaymentField_total_amount' => 'total_amount', - 'componentPaymentField_contribution_status' => 'contribution_status', - 'componentPaymentField_payment_instrument' => 'pay_instru', - 'componentPaymentField_transaction_id' => 'trxn_id', - 'componentPaymentField_received_date' => 'receive_date', - ); - return CRM_Utils_Array::value($payFieldMapper[$field], $paymentData, ''); - } - else { - // if field is empty or null - return ''; - } } } diff --git a/hrjobcontract/CRM/Hrjobcontract/Dedupe/Merger.php b/hrjobcontract/CRM/Hrjobcontract/Dedupe/Merger.php index c13c8eef2c0..f64396c7bd7 100644 --- a/hrjobcontract/CRM/Hrjobcontract/Dedupe/Merger.php +++ b/hrjobcontract/CRM/Hrjobcontract/Dedupe/Merger.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2018 + * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Hrjobcontract_Dedupe_Merger { diff --git a/hrjobcontract/CRM/Hrjobcontract/Form/Merge.php b/hrjobcontract/CRM/Hrjobcontract/Form/Merge.php index 5dda31f9d95..f9fc7f29f4c 100644 --- a/hrjobcontract/CRM/Hrjobcontract/Form/Merge.php +++ b/hrjobcontract/CRM/Hrjobcontract/Form/Merge.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2018 + * @copyright CiviCRM LLC (c) 2004-2019 */ /** diff --git a/hrjobcontract/hrjobcontract.php b/hrjobcontract/hrjobcontract.php index dc8efb12aa6..99673b6e3e5 100644 --- a/hrjobcontract/hrjobcontract.php +++ b/hrjobcontract/hrjobcontract.php @@ -288,6 +288,7 @@ function hrjobcontract_civicrm_tabset($tabsetName, &$tabs, $context) { 'id' => 'hrjobcontract', 'url' => CRM_Utils_System::url('civicrm/contact/view/hrjobcontract', array('cid' => $context['contact_id'])), 'title' => ts('Job Contract'), + 'icon' => 'fa fa-file-o', 'weight' => -190, ); } diff --git a/hrjobcontract/templates/CRM/Hrjobcontract/Form/Merge.hlp b/hrjobcontract/templates/CRM/Hrjobcontract/Form/Merge.hlp index 1898e57360a..3062af37036 100644 --- a/hrjobcontract/templates/CRM/Hrjobcontract/Form/Merge.hlp +++ b/hrjobcontract/templates/CRM/Hrjobcontract/Form/Merge.hlp @@ -2,7 +2,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | diff --git a/hrjobcontract/templates/CRM/Hrjobcontract/Form/Merge.tpl b/hrjobcontract/templates/CRM/Hrjobcontract/Form/Merge.tpl index 510c9745d90..89f75b0784a 100644 --- a/hrjobcontract/templates/CRM/Hrjobcontract/Form/Merge.tpl +++ b/hrjobcontract/templates/CRM/Hrjobcontract/Form/Merge.tpl @@ -2,7 +2,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | diff --git a/hrmed/hrmed.php b/hrmed/hrmed.php index d1633938a91..c28d3779e81 100644 --- a/hrmed/hrmed.php +++ b/hrmed/hrmed.php @@ -166,3 +166,22 @@ function hrmed_civicrm_pageRun($page) { ->addScriptFile('org.civicrm.hrmed', 'js/dist/hrmed.min.js', 1010); } } + +/** + * Implementation of hook_civicrm_tabset + * + * @param string $tabsetName + * @param array $tabs + * @param mixed $context + */ +function hrmed_civicrm_tabset($tabsetName, &$tabs, $context) { + if ($tabsetName != 'civicrm/contact/view') { + return; + } + + foreach ($tabs as $i => $tab) { + if ($tab['title'] == 'Medical & Disability') { + $tabs[$i]['icon'] = 'fa fa-wheelchair'; + } + } +} diff --git a/hrqual/hrqual.php b/hrqual/hrqual.php index 7d6d8f84ae3..58b2711dbdc 100644 --- a/hrqual/hrqual.php +++ b/hrqual/hrqual.php @@ -191,6 +191,12 @@ function hrqual_civicrm_tabset($tabsetName, &$tabs, $context) { 'optionGroups' => $val, ), )); + + foreach ($tabs as $i => $tab) { + if ($tab['title'] == 'Qualifications') { + $tabs[$i]['icon'] = 'fa fa-certificate'; + } + } } } diff --git a/hrui/templates/CRM/common/footer.tpl b/hrui/templates/CRM/common/footer.tpl index 0b8567f4fe0..4cd2c4d8c88 100644 --- a/hrui/templates/CRM/common/footer.tpl +++ b/hrui/templates/CRM/common/footer.tpl @@ -2,7 +2,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | diff --git a/org.civicrm.hremergency/hremergency.php b/org.civicrm.hremergency/hremergency.php index 71321f822b2..0898249a283 100644 --- a/org.civicrm.hremergency/hremergency.php +++ b/org.civicrm.hremergency/hremergency.php @@ -136,3 +136,22 @@ function hremergency_civicrm_container($container) { function hremergency_civicrm_alterAPIPermissions($entity, $action, &$params, &$permissions) { $permissions['contact']['deleteemergencycontact'] = 'access AJAX API'; } + +/** + * Implementation of hook_civicrm_tabset + * + * @param string $tabsetName + * @param array $tabs + * @param mixed $context + */ +function hremergency_civicrm_tabset($tabsetName, &$tabs, $context) { + if ($tabsetName != 'civicrm/contact/view') { + return; + } + + foreach ($tabs as $i => $tab) { + if ($tab['title'] == 'Emergency Contacts') { + $tabs[$i]['icon'] = 'fa fa-medkit'; + } + } +} diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/hrleaveandabsences.php b/uk.co.compucorp.civicrm.hrleaveandabsences/hrleaveandabsences.php index fd905f2b07a..9dbdf5d892a 100644 --- a/uk.co.compucorp.civicrm.hrleaveandabsences/hrleaveandabsences.php +++ b/uk.co.compucorp.civicrm.hrleaveandabsences/hrleaveandabsences.php @@ -384,6 +384,7 @@ function hrleaveandabsences_civicrm_tabset($tabsetName, &$tabs, $context) { 'id' => 'absence', 'url' => CRM_Utils_System::url('civicrm/contact/view/absence', ['cid' => $contactId]), 'title' => ts('Leave'), + 'icon' => 'fa fa-briefcase', 'weight' => 10 ]; }