more cleanup and preview fixes CRM-12963
authorKurund Jalmi <kurund@civicrm.org>
Tue, 16 Jul 2013 18:20:27 +0000 (23:50 +0530)
committerKurund Jalmi <kurund@civicrm.org>
Tue, 16 Jul 2013 18:20:27 +0000 (23:50 +0530)
CRM/Badge/BAO/Badge.php
CRM/Badge/Form/Layout.php

index 70ba84216ff5bf980c5a6777ed5589a51422e37d..04ef2c42b7e067979178d26b686621ac277aba71 100644 (file)
@@ -91,7 +91,7 @@ class CRM_Badge_BAO_Badge {
           $value = $row[$element];
           // hack to fix date field display format
           if (strpos($element, '_date')) {
-            $value = CRM_Utils_Date::customFormat($value, "%e %b");
+            $value = CRM_Utils_Date::customFormat($value, "%B %E%f");
           }
         }
 
index 5c9931a99aeea49f05c2db4243f8ba6eedfb6ae3..4d4f2d435c38030f421ac6f70ebbdaad260e7f12 100644 (file)
@@ -221,6 +221,7 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     $badgeInfo = CRM_Badge_BAO_Layout::create($params);
 
     if (isset($params['_qf_Layout_refresh'])) {
+      $this->set('id', $badgeInfo->id);
       $params['badge_id'] = $badgeInfo->id;
       self::buildPreview($params);
     }
@@ -235,6 +236,12 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     // get a max participant id
     $participantID = CRM_Core_DAO::singleValueQuery('select max(id) from civicrm_participant');
 
+    if (!$participantID) {
+      CRM_Core_Session::setStatus(ts('Preview requires at least one event and one participant record.
+       If you are just getting started, you can add a test participant record.'), ts('Preview Requirements'), 'alert');
+      return;
+    }
+
     $this->_single = TRUE;
     $this->_participantIds = array($participantID);
     $this->_componentClause = " civicrm_participant.id = $participantID ";