CRM-16761 - Form / UI fixes.
authorDave Greenberg <dave@civicrm.org>
Wed, 2 Dec 2015 04:46:13 +0000 (20:46 -0800)
committerDave Greenberg <dave@civicrm.org>
Wed, 2 Dec 2015 04:46:13 +0000 (20:46 -0800)
----------------------------------------
* CRM-16761: Self service view, update and cancel for CiviEvent
  https://issues.civicrm.org/jira/browse/CRM-16761

CRM/Event/Form/SelfSvcTransfer.php
CRM/Event/Form/SelfSvcUpdate.php
CRM/Event/xml/Menu/Event.xml
templates/CRM/Event/Form/SelfSvcTransfer.tpl
templates/CRM/Event/Form/SelfSvcUpdate.tpl

index 65d5368c1a887563b714fe5a921cfb950dd7e0ea..6d235f5bd62bf7ce92918f0b99e9423ef9222e9a 100644 (file)
@@ -134,6 +134,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
    * @array string
    */
   protected $contact_id;
+
   /**
    * Get source values for transfer based on participant id in URL. Line items will
    * be transferred to this participant - at this point no transaction changes processed
@@ -168,10 +169,11 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
     $details = CRM_Event_BAO_Participant::participantDetails($this->_from_participant_id);
     $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'participant_role', 'id', 'name');
     $query = "
-      SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date
+      SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date, civicrm_event.start_date
       FROM civicrm_participant cp
       LEFT JOIN civicrm_participant_status_type cpst ON cpst.id = cp.status_id
       LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = {$optionGroupId}
+      LEFT JOIN civicrm_event ON civicrm_event.id = cp.event_id
       WHERE cp.id = {$this->_from_participant_id}";
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     while ($dao->fetch()) {
@@ -180,6 +182,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
       $details['fee_level']   = $dao->fee_level;
       $details['fee_amount'] = $dao->fee_amount;
       $details['register_date'] = $dao->register_date;
+      $details['event_start_date'] = $dao->start_date; 
     }
     $this->assign('details', $details);
     //This participant row will be cancelled.  Get line item(s) to cancel
@@ -188,6 +191,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
     $this->selfsvctransferText = ts('Update');
     $this->selfsvctransferButtonText = ts('Update');
   }
+
   /**
    * Build form for input of transferree email, name
    *
@@ -195,20 +199,18 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
    */
   public function buildQuickForm() {
     $this->add('text', 'email', ts('To Email'), ts($this->_contact_email), TRUE);
-    $this->add('text', 'last_name', ts('To Last name'), ts($this->_to_contact_last_name), TRUE);
-    $this->add('text', 'first_name', ts('To First name'), ts($this->_to_contact_first_name), TRUE);
+    $this->add('text', 'last_name', ts('To Last Name'), ts($this->_to_contact_last_name), TRUE);
+    $this->add('text', 'first_name', ts('To First Name'), ts($this->_to_contact_first_name), TRUE);
     $this->addButtons(array(
       array(
         'type' => 'submit',
-        'name' => ts('Submit'),),
-      array(
-        'type' => 'cancel',
-        'name' => ts('Cancel'),),
+        'name' => ts('Transfer Registration'),),
       )
     );
     $this->addFormRule(array('CRM_Event_Form_SelfSvcTransfer', 'formRule'), $this);
     parent::buildQuickForm();
   }
+
   /**
    * Set defaults
    *
@@ -218,6 +220,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
     $this->_defaults = array();
     return $this->_defaults;
   }
+
   /**
    * Validate email and name input
    *
@@ -232,6 +235,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
     //return parent::formrule($fields, $files, $self);
     return empty($errors) ? TRUE : $errors;
   }
+
   /**
    * Check whether profile (name, email) is complete
    *
@@ -265,6 +269,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
     }
     return $contact_id;
   }
+
   /**
    * Check contact details
    *
@@ -287,6 +292,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
       }
     }
   }
+
   /**
    * Process transfer - first add the new participant to the event, then cancel
    * source participant - send confirmation email to transferee
@@ -350,8 +356,9 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
     list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id);
     $statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $displayName));
     $statusMsg .= ' ' . ts('A confirmation email has been sent to %1.', array(1 => $email));
-    CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
+    CRM_Core_Session::setStatus($statusMsg, ts('Registration Transferred'), 'success');
   }
+
   /**
    * Based on input, create participant row for transferee and send email
    *
@@ -414,6 +421,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
     //now registered_id can be updated (mail won't be send if it is set
     return $res;
   }
+
   /**
    * Send confirmation of cancellation to source participant
    *
index 1e99855f1a1629c700f4c0da124906e096a47213..733af64789c2c3f74693943fb01646b6a8930503 100644 (file)
@@ -1,10 +1,9 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                          |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -145,10 +144,11 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form {
     $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participant_id, 'contribution_id', 'participant_id');
     $this->assign('contributionId', $contributionId);
     $query = "
-      SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date, cp.status_id
+      SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date, cp.status_id, civicrm_event.start_date
       FROM civicrm_participant cp
       LEFT JOIN civicrm_participant_status_type cpst ON cpst.id = cp.status_id
       LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = {$optionGroupId}
+      LEFT JOIN civicrm_event ON civicrm_event.id = cp.event_id
       WHERE cp.id = {$this->_participant_id}";
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     while ($dao->fetch()) {
@@ -157,6 +157,7 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form {
       $details['fee_level']   = $dao->fee_level;
       $details['fee_amount'] = $dao->fee_amount;
       $details['register_date'] = $dao->register_date;
+      $details['event_start_date'] = $dao->start_date; 
     }
     //verify participant status is still Registered
     if ($details['status'] != "Registered") {
@@ -202,21 +203,16 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form {
    * return @void
    */
   public function buildQuickForm() {
-    $this->add('text', 'email', ts('Email'), ts($this->_contact_email), TRUE);
-    $this->add('text', 'participant', ts('Participant name'), ts($this->_contact_name), TRUE);
-    $this->add('select', 'action', 'Action', array('-select-', 'Transfer', 'Cancel'));
+    $this->add('select', 'action', ts('Transfer or Cancel Registration'), array(ts('-select-'), ts('Transfer'), ts('Cancel')), TRUE);
     $this->addButtons(array(
       array(
         'type' => 'submit',
         'name' => ts('Submit'),
       ),
-      array(
-        'type' => 'cancel',
-        'name' => ts('Cancel'),
-      ),
     ));
     parent::buildQuickForm();
   }
+
   /**
    * Set default values for contact
    *
@@ -224,11 +220,10 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form {
    */
   public function setDefaultValues() {
     $this->_defaults = array();
-    $this->_defaults['email'] = $this->_contact_email;
-    $this->_defaults['participant'] = $this->_contact_name;
     $this->_defaults['details'] = $this->_details;
     return $this->_defaults;
   }
+
   /**
    * Process submit form - based on user selection of action
    * transfer or cancel the event
@@ -249,6 +244,7 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form {
       $this->cancelParticipant($params);
     }
   }
+
   /**
    * Transfer to a new form, allowing selection of a new contact
    * based on email and name. The Event will be transferred to this new participant
@@ -262,6 +258,7 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form {
     $session = CRM_Core_Session::singleton();
     $session->replaceUserContext($url);
   }
+
   /**
    * Cancel this participant and finish, send cancellation email. At this point no
    * auto-cancellation of payment is handled, so payment needs to be manually cancelled
index 277f48894c6e36a3c85a8c810803786830c0860c..f9d1d464eff67c5941ca7e8d6a9b5129b6211e86 100644 (file)
      <page_type>1</page_type>
      <weight>850</weight>
   </item>
-    <item>
+  <item>
      <path>civicrm/event/selfsvcupdate</path>
-     <title>Self Service Update</title>
+     <title>Self-service Registration Update</title>
+     <is_public>true</is_public>
      <page_callback>CRM_Event_Form_SelfSvcUpdate</page_callback>
      <access_callback>1</access_callback>
      <page_type>1</page_type>
   </item>
   <item>
      <path>civicrm/event/selfsvctransfer</path>
-     <title>Self Service Transfer</title>
+     <title>Self-service Registration Transfer</title>
+     <is_public>true</is_public>
      <page_callback>CRM_Event_Form_SelfSvcTransfer</page_callback>
      <page_type>1</page_type>
      <access_callback>1</access_callback>
index a94d49a4ba6c5f3c34343d79bbd089da4a95efac..fc39e2e5f6b096ab412cf86fd012aab3c9bbe5ef 100644 (file)
@@ -1,8 +1,8 @@
 {*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
-<div>
-    <table class="form-layout">
-         <tr class="crm-selfsvctransfer-form-block-email">
-          <td class="label">{$form.email.label}</td>
-            <td>{$form.email.html}</td>
-        </tr>
-       <tr class="crm-selfsvctransfer-form-block-participant">
-          <td class="label">{$form.last_name.label}</td>
-            <td>{$form.last_name.html}</td>
-       <tr class="crm-selfsvctransfer-form-block-participant">
-          <td class="label">{$form.first_name.label}</td>
-            <td>{$form.first_name.html}</td>
-        </tr>
-      <table class="crm-selfsvctransfer-form-details"><col width="30"><col width="50"><col width="20"><col width="10"><col width="10"><col width="12"><col width="10">
-         <tr><th>Participant</th><th>Event</th><th>Fee Level</th><th>Fee Amt</th><th>Reg Date</th><th>Status</th><th>Role</th>
-         </tr>
-          <tr class="crm-selfsvctransfer-form-details">
-            <td>{$details.name}</td><td>{$details.title}</td>
-            <td class="crm-participant-participant_fee_level">{$details.fee_level}</td>
-            <td class="right nowrap crm-paticipant-participant_fee_amount">{$details.fee_amount}</td>
-            <td>{$details.register_date|truncate:10:''|crmDate}</td>
-            <td>{$details.status}</td><td class="crm-participant-participant_role">{$details.role}</td>
-         </tr>
-       </table>
-   </table>
- <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
+<div class="crm-selfsvctransfer-form">
+  <table class="crm-selfsvctransfer-form-details">
+    <tr>
+      <th>{ts}Current<br />Participant{/ts}</th>
+      <th>{ts}Event{/ts}</th>
+      <th>{ts}Fee Level{/ts}</th>
+      <th>{ts}Amount{/ts}</th>
+      <th>{ts}Registered{/ts}</th>
+      <th>{ts}Status{/ts}</th>
+      <th>{ts}Role{/ts}</th>
+    </tr>
+    <tr class="crm-selfsvctransfer-form-details">
+      <td>{$details.name}</td>
+      <td>{$details.title}<br />{$details.event_start_date|truncate:10:''|crmDate}</td>
+      <td class="crm-participant-participant_fee_level">{$details.fee_level}</td>
+      <td class="right nowrap crm-paticipant-participant_fee_amount">{$details.fee_amount}</td>
+      <td>{$details.register_date|truncate:10:''|crmDate}</td>
+      <td>{$details.status}</td>
+      <td class="crm-participant-participant_role">{$details.role}</td>
+    </tr>
+  </table>
+  <div class="crm-public-form-item crm-section selfsvctransfer-section">
+    <div class="crm-public-form-item crm-section selfsvctransfer-firstname-section">
+      <div class="label">{$form.first_name.label}</div>
+      <div class="content">{$form.first_name.html}</div>
+      <div class="clear"></div>
+    </div>
+    <div class="crm-public-form-item crm-section selfsvctransfer-lastname-section">
+      <div class="label">{$form.last_name.label}</div>
+      <div class="content">{$form.last_name.html}</div>
+      <div class="clear"></div>
+   </div>
+   <div class="crm-public-form-item crm-section selfsvctransfer-email-section">
+     <div class="label">{$form.email.label}</div>
+     <div class="content">{$form.email.html}</div>
+     <div class="clear"></div>
+   </div>
+  </div>
+  <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
index 463fde90fa0db2428dda7f91d7071a25e8e7ae1d..7e54c18378dfc68ec1934f86a2a08a4ced7e14be 100644 (file)
@@ -1,8 +1,8 @@
 {*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
-<div>
-    <table class="form-layout">
-        <tr class="crm-selfsvcupdate-form-block-email">
-          <td class="label">{$form.email.label}</td>
-          <td>{$form.email.html}</td>
-        </tr>
-        <tr class="crm-selfsvcupdate-form-block-participant">
-          <td class="label">{$form.participant.label}</td>
-          <td>{$form.participant.html}</td>
-        </tr>
-          <tr class="crm-selfsvcupdate-form-block-participant">
-            <td class="label">{$form.action.label}</td>
-            <td>{$form.action.html}</td>
-        </tr>
-      <table class="crm-selfsvcupdate-form-details"><col width="30"><col width="50"><col width="20"><col width="10"><col width="10"><col width="12"><col width="10">
-         <tr><th>Participant</th><th>Event</th><th>Fee Level</th><th>Fee Amt</th><th>Reg Date</th><th>Status</th><th>Role</th>
-         </tr>
-          <tr class="crm-selfsvcupdate-form-details">
-            <td>{$details.name}</td><td>{$details.title}</td>
-            <td class="crm-participant-participant_fee_level">{$details.fee_level}</td>
-            <td class="right nowrap crm-paticipant-participant_fee_amount">{$details.fee_amount}</td>
-            <td>{$details.register_date|truncate:10:''|crmDate}</td>
-            <td>{$details.status}</td><td class="crm-participant-participant_role">{$details.role}</td>
-         </tr>
-       </table>
-   </table>
- <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
+<div class="crm-selfsvcupdate-form">
+  <table class="crm-selfsvcupdate-form-details">
+    <tr>
+      <th>{ts}Participant{/ts}</th>
+      <th>{ts}Event{/ts}</th>
+      <th>{ts}Fee Level{/ts}</th>
+      <th>{ts}Amount{/ts}</th>
+      <th>{ts}Registered{/ts}</th>
+      <th>{ts}Status{/ts}</th>
+      <th>{ts}Role{/ts}</th>
+    </tr>
+    <tr class="crm-selfsvcupdate-form-details">
+      <td>{$details.name}</td><td>{$details.title}<br />{$details.event_start_date|truncate:10:''|crmDate}</td>
+      <td class="crm-participant-participant_fee_level">{$details.fee_level}</td>
+      <td class="right nowrap crm-paticipant-participant_fee_amount">{$details.fee_amount}</td>
+      <td>{$details.register_date|truncate:10:''|crmDate}</td>
+      <td>{$details.status}</td><td class="crm-participant-participant_role">{$details.role}</td>
+    </tr>
+  </table>
+  <div class="crm-public-form-item crm-section selfsvcupdate-section">
+    <div class="label">{$form.action.label}</div>
+    <div class="content">{$form.action.html}</div>
+    <div class="clear"></div>
+  </div>
+  <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
 {literal}
 <script type="text/javascript">