From 3931213a80d2915fe69d5bc6f83838f31a462605 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Thu, 20 Jul 2017 21:26:43 +0530 Subject: [PATCH] additional fixes --- CRM/Event/Form/SelfSvcTransfer.php | 40 ++++++++++++++----- CRM/Event/Form/SelfSvcUpdate.php | 2 +- templates/CRM/Event/Form/SelfSvcTransfer.tpl | 42 ++++++++++++-------- 3 files changed, 56 insertions(+), 28 deletions(-) diff --git a/CRM/Event/Form/SelfSvcTransfer.php b/CRM/Event/Form/SelfSvcTransfer.php index 84a65e969009..8c7f1ded6873 100644 --- a/CRM/Event/Form/SelfSvcTransfer.php +++ b/CRM/Event/Form/SelfSvcTransfer.php @@ -212,9 +212,17 @@ public function preProcess() { * return @void */ 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); + // use entityRef select field for contact when this form is used by staff/admin user + if ($this->_isBackoffice) { + $this->addEntityRef("contact_id", ts('Select Contact'), array('create' => TRUE), TRUE); + } + // for front-end user show and use the basic three fields used to create a contact + else { + $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->addButtons(array( array( 'type' => 'submit', @@ -242,10 +250,15 @@ public function setDefaultValues() { */ public static function formRule($fields, $files, $self) { $errors = array(); - //check that either an email or firstname+lastname is included in the form(CRM-9587) - $to_contact_id = self::checkProfileComplete($fields, $errors, $self); + if (!empty($fields['contact_id'])) { + $to_contact_id = $fields['contact_id']; + } + else { + //check that either an email or firstname+lastname is included in the form(CRM-9587) + $to_contact_id = self::checkProfileComplete($fields, $errors, $self); + } //To check if the user is already registered for the event(CRM-2426) - if ($to_contact_id) { + if (!empty($to_contact_id)) { self::checkRegistration($fields, $self, $to_contact_id, $errors); } //return parent::formrule($fields, $files, $self); @@ -319,11 +332,16 @@ public static function checkRegistration($fields, $self, $contact_id, &$errors) public function postProcess() { //For transfer, process form to allow selection of transferree $params = $this->controller->exportValues($this->_name); - //cancel 'from' participant row - $query = "select contact_id from civicrm_email where email = '" . $params['email'] . "'"; - $dao = CRM_Core_DAO::executeQuery($query); - while ($dao->fetch()) { - $contact_id = $dao->contact_id; + if (!empty($params['contact_id'])) { + $contact_id = $params['contact_id']; + } + else { + //cancel 'from' participant row + $query = "select contact_id from civicrm_email where email = '" . $params['email'] . "'"; + $dao = CRM_Core_DAO::executeQuery($query); + while ($dao->fetch()) { + $contact_id = $dao->contact_id; + } } $from_participant = $params = array(); $query = "select role_id, source, fee_level, is_test, is_pay_later, fee_amount, discount_id, fee_currency,campaign_id, discount_amount from civicrm_participant where id = " . $this->_from_participant_id; diff --git a/CRM/Event/Form/SelfSvcUpdate.php b/CRM/Event/Form/SelfSvcUpdate.php index 1f3df843b5ba..b39774cbc795 100644 --- a/CRM/Event/Form/SelfSvcUpdate.php +++ b/CRM/Event/Form/SelfSvcUpdate.php @@ -166,7 +166,7 @@ public function preProcess() { while ($dao->fetch()) { $details['status'] = $dao->status; $details['role'] = $dao->role; - $details['fee_level'] = $dao->fee_level; + $details['fee_level'] = trim($dao->fee_level, CRM_Core_DAO::VALUE_SEPARATOR); $details['fee_amount'] = $dao->fee_amount; $details['register_date'] = $dao->register_date; $details['event_start_date'] = $dao->start_date; diff --git a/templates/CRM/Event/Form/SelfSvcTransfer.tpl b/templates/CRM/Event/Form/SelfSvcTransfer.tpl index bf56366f1405..d400079ea2a8 100644 --- a/templates/CRM/Event/Form/SelfSvcTransfer.tpl +++ b/templates/CRM/Event/Form/SelfSvcTransfer.tpl @@ -44,22 +44,32 @@ {$details.role} -
-
-
{$form.first_name.label}
-
{$form.first_name.html}
-
+ {if $form.contact_id} +
+
+
{$form.contact_id.label}
+
{$form.contact_id.html}
+
+
-
-
{$form.last_name.label}
-
{$form.last_name.html}
-
-
-
-
{$form.email.label}
-
{$form.email.html}
-
-
-
+ {else} +
+
+
{$form.first_name.label}
+
{$form.first_name.html}
+
+
+
+
{$form.last_name.label}
+
{$form.last_name.html}
+
+
+
+
{$form.email.label}
+
{$form.email.html}
+
+
+
+ {/if}
{include file="CRM/common/formButtons.tpl" location="bottom"}