Avoid CiviCRM running full drupal cache flush, as this results in CiviCRM clobbering...
[civicrm-core.git] / CRM / Profile / Page / MultipleRecordFieldsListing.php
index e395d00bcd1c73d71c24e8199cf78d6f0bb0c138..f04a4ff2d3867e17e7343500599dea8c1439fe6c 100644 (file)
@@ -171,6 +171,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
   public function browse() {
     $dateFields = NULL;
     $cgcount = 0;
+    $attributes = array();
     $dateFieldsVals = NULL;
     if ($this->_pageViewType == 'profileDataView' && $this->_profileId) {
       $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL,
@@ -235,6 +236,9 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
         CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
         if ($returnValues['data_type'] == 'Date') {
           $dateFields[$fieldIDs[$key]] = 1;
+          $actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
+          $dateFormat = (array) CRM_Utils_Array::value($returnValues['date_format'], $actualPHPFormats);
+          $timeFormat = CRM_Utils_Array::value('time_format', $returnValues);
         }
 
         $optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]);
@@ -298,8 +302,24 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
             if (is_numeric($fieldId)) {
               $customValue = &$val;
               if (!empty($dateFields) && array_key_exists($fieldId, $dateFields)) {
-                // formated date capture value capture
+                // formatted date capture value capture
                 $dateFieldsVals[$fieldId][$recId] = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options);
+
+                //set date and time format
+                switch ($timeFormat) {
+                  case 1:
+                    $dateFormat[1] = 'g:iA';
+                    break;
+
+                  case 2:
+                    $dateFormat[1] = 'G:i';
+                    break;
+
+                  default:
+                    // if time is not selected remove time from value
+                    $result[$recId][$fieldId] = substr($result[$recId][$fieldId], 0, 10);
+                }
+                $result[$recId][$fieldId] = CRM_Utils_Date::processDate($result[$recId][$fieldId], NULL, FALSE, implode(" ", $dateFormat));
               }
               else {
                 // assign to $result