Skip to content

Commit

Permalink
additional fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Nov 9, 2017
1 parent 8922435 commit d75f046
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 42 deletions.
15 changes: 11 additions & 4 deletions CRM/Event/Form/ParticipantView.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,17 @@ public function preProcess() {
// only if logged in user have 'edit event participants' permission and
// participant status is not Cancelled or Transferred
if (CRM_Core_Permission::check('edit event participants') && !in_array($status, array('Cancelled', 'Transferred'))) {
$this->assign('transferOrCancelLink', CRM_Utils_System::url(
'civicrm/event/selfsvcupdate',
sprintf("reset=1&pid=%d&is_backoffice=1&cs=%s", $participantID, CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf'))
));
$this->assign('transferOrCancelLink',
CRM_Utils_System::url(
'civicrm/event/selfsvcupdate',
array(
'reset' => 1,
'is_backoffice' => 1,
'pid' => $participantID,
'cs' => CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf'),
)
)
);
}

if ($values[$participantID]['is_test']) {
Expand Down
46 changes: 32 additions & 14 deletions CRM/Event/Form/SelfSvcTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form {
*
* @array bool
*/
protected $_isBackoffice = FALSE;
protected $isBackoffice = FALSE;

/**
* Get source values for transfer based on participant id in URL. Line items will
Expand All @@ -154,7 +154,7 @@ public function preProcess() {
$this->_userContext = $session->readUserContext();
$this->_from_participant_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this, FALSE, NULL, 'REQUEST');
$this->_userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE, NULL, 'REQUEST');
$this->_isBackoffice = CRM_Utils_Request::retrieve('is_backoffice', 'String', $this, FALSE, NULL, 'REQUEST');
$this->isBackoffice = CRM_Utils_Request::retrieve('is_backoffice', 'String', $this, FALSE, NULL, 'REQUEST');
$params = array('id' => $this->_from_participant_id);
$participant = $values = array();
$this->_participant = CRM_Event_BAO_Participant::getValues($params, $values, $participant);
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -372,7 +390,7 @@ public function postProcess() {
$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('Registration Transferred'), 'success');
if (!empty($this->_isBackoffice)) {
if ($this->isBackoffice) {
return;
}
$url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}");
Expand Down
21 changes: 13 additions & 8 deletions CRM/Event/Form/SelfSvcUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form {
*
* @array bool
*/
protected $_isBackoffice = FALSE;
protected $isBackoffice = FALSE;
/**
* Set variables up before form is built based on participant ID from URL
*
Expand All @@ -125,7 +125,7 @@ public function preProcess() {
$participant = $values = array();
$this->_participant_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this, FALSE, NULL, 'REQUEST');
$this->_userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE, NULL, 'REQUEST');
$this->_isBackoffice = CRM_Utils_Request::retrieve('is_backoffice', 'String', $this, FALSE, NULL, 'REQUEST');
$this->isBackoffice = CRM_Utils_Request::retrieve('is_backoffice', 'String', $this, FALSE, NULL, 'REQUEST');
$params = array('id' => $this->_participant_id);
$this->_participant = CRM_Event_BAO_Participant::getValues($params, $values, $participant);
$this->_part_values = $values[$this->_participant_id];
Expand Down Expand Up @@ -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;
Expand All @@ -185,11 +185,11 @@ public function preProcess() {
}
$start_time = new Datetime($start_date);
$timenow = new Datetime();
if (!empty($start_time) && $start_time < $timenow) {
if (!$this->isBackoffice && !empty($start_time) && $start_time < $timenow) {
$status = ts("Registration for this event cannot be cancelled or transferred once the event has begun. Contact the event organizer if you have questions.");
CRM_Core_Error::statusBounce($status, $url, ts('Sorry'));
}
if (!empty($time_limit) && $time_limit > 0) {
if (!$this->isBackoffice && !empty($time_limit) && $time_limit > 0) {
$interval = $timenow->diff($start_time);
$days = $interval->format('%d');
$hours = $interval->format('%h');
Expand Down Expand Up @@ -281,10 +281,15 @@ public function postProcess() {
* return @void
*/
public function transferParticipant($params) {
$isBackOfficeArg = $this->_isBackoffice ? '&is_backoffice=1' : '';
$isBackOfficeArg = $this->isBackoffice ? '&is_backoffice=1' : '';
CRM_Utils_System::redirect(CRM_Utils_System::url(
'civicrm/event/selfsvctransfer',
'reset=1&action=add&pid=' . $this->_participant_id . $isBackOfficeArg . '&cs=' . $this->_userChecksum
array(
'reset' => 1,
'action' => 'add',
'pid' => $this->_participant_id,
'cs' => $this->_userChecksum,
)
));
}

Expand Down Expand Up @@ -365,7 +370,7 @@ public function cancelParticipant($params) {
$statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contact_name));
$statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', array(1 => $this->_contact_email));
CRM_Core_Session::setStatus($statusMsg, ts('Thanks'), 'success');
if (!empty($this->_isBackoffice)) {
if (!empty($this->isBackoffice)) {
return;
}
$url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}&noFullMsg=true");
Expand Down
42 changes: 26 additions & 16 deletions templates/CRM/Event/Form/SelfSvcTransfer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,32 @@
<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>
{if $form.contact_id}
<div class="crm-public-form-item crm-section selfsvctransfer-section">
<div class="crm-public-form-item crm-section selfsvctransfer-contact_id-section">
<div class="label">{$form.contact_id.label}</div>
<div class="content">{$form.contact_id.html}</div>
<div class="clear"></div>
</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>
{else}
<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>
{/if}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>

0 comments on commit d75f046

Please sign in to comment.