Skip to content

Commit

Permalink
Convert ManageEvent Registration to datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Oct 19, 2018
1 parent dcd3b49 commit 97129f2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 33 deletions.
6 changes: 5 additions & 1 deletion CRM/Event/DAO/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Event/Event.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:6c0950f3a5f6305f8d7e0a05d4703018)
* (GenCodeChecksum:44df1cb5691958b88be856f793adabca)
*/

/**
Expand Down Expand Up @@ -670,6 +670,7 @@ public static function &fields() {
'localizable' => 0,
'html' => [
'type' => 'Select Date',
'formatType' => 'activityDateTime',
],
],
'event_end_date' => [
Expand All @@ -688,6 +689,7 @@ public static function &fields() {
'localizable' => 0,
'html' => [
'type' => 'Select Date',
'formatType' => 'activityDateTime',
],
],
'is_online_registration' => [
Expand Down Expand Up @@ -730,6 +732,7 @@ public static function &fields() {
'localizable' => 0,
'html' => [
'type' => 'Select Date',
'formatType' => 'activityDateTime',
],
],
'registration_end_date' => [
Expand All @@ -743,6 +746,7 @@ public static function &fields() {
'localizable' => 0,
'html' => [
'type' => 'Select Date',
'formatType' => 'activityDateTime',
],
],
'max_participants' => [
Expand Down
34 changes: 4 additions & 30 deletions CRM/Event/Form/ManageEvent/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,6 @@ public function setDefaultValues() {
$defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering'));
$defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'));

if (!empty($defaults['registration_start_date'])) {
list($defaults['registration_start_date'], $defaults['registration_start_date_time'])
= CRM_Utils_Date::setDateDefaults($defaults['registration_start_date'], 'activityDateTime');
}

if (!empty($defaults['registration_end_date'])) {
list($defaults['registration_end_date'], $defaults['registration_end_date_time'])
= CRM_Utils_Date::setDateDefaults($defaults['registration_end_date'], 'activityDateTime');
}

return $defaults;
}

Expand Down Expand Up @@ -250,8 +240,8 @@ public function buildQuickForm() {
$this->add('text', 'registration_link_text', ts('Registration Link Text'));

if (!$this->_isTemplate) {
$this->addDateTime('registration_start_date', ts('Registration Start Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->addDateTime('registration_end_date', ts('Registration End Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->add('datepicker', 'registration_start_date', ts('Registration Start Date'), [], FALSE, array('time' => TRUE));
$this->add('datepicker', 'registration_end_date', ts('Registration End Date'), [], FALSE, array('time' => TRUE));
}

$params = array(
Expand Down Expand Up @@ -482,13 +472,8 @@ public static function formRule($values, $files, $form) {
}
}

if (
isset($values['registration_start_date']) &&
isset($values['registration_end_date'])
) {
$start = CRM_Utils_Date::processDate($values['registration_start_date']);
$end = CRM_Utils_Date::processDate($values['registration_end_date']);
if ($end < $start) {
if (isset($values['registration_start_date']) && isset($values['registration_end_date'])) {
if ($values['registration_end_date'] < $values['registration_start_date']) {
$errorMsg['registration_end_date'] = ts('Registration end date should be after Registration start date');
}
}
Expand Down Expand Up @@ -821,17 +806,6 @@ public function postProcess() {
$params['selfcancelxfer_time'] = !empty($params['selfcancelxfer_time']) ? $params['selfcancelxfer_time'] : 0;
}

if (!$this->_isTemplate) {
$params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'],
$params['registration_start_date_time'],
TRUE
);
$params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'],
$params['registration_end_date_time'],
TRUE
);
}

CRM_Event_BAO_Event::add($params);

// also update the ProfileModule tables
Expand Down
4 changes: 2 additions & 2 deletions templates/CRM/Event/Form/ManageEvent/Registration.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
{if !$isTemplate}
<tr class="crm-event-manage-registration-form-block-registration_start_date">
<td scope="row" class="label" width="20%">{$form.registration_start_date.label}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=registration_start_date}</td>
<td>{$form.registration_start_date.html}</td>
</tr>
<tr class="crm-event-manage-registration-form-block-registration_end_date">
<td scope="row" class="label" width="20%">{$form.registration_end_date.label}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=registration_end_date}</td>
<td>{$form.registration_end_date.html}</td>
</tr>
{/if}
<tr class="crm-event-manage-registration-form-block-is_multiple_registrations">
Expand Down
4 changes: 4 additions & 0 deletions xml/schema/Event/Event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<add>1.7</add>
<html>
<type>Select Date</type>
<formatType>activityDateTime</formatType>
</html>
</field>
<field>
Expand All @@ -135,6 +136,7 @@
<add>1.7</add>
<html>
<type>Select Date</type>
<formatType>activityDateTime</formatType>
</html>
</field>
<field>
Expand Down Expand Up @@ -167,6 +169,7 @@
<add>1.8</add>
<html>
<type>Select Date</type>
<formatType>activityDateTime</formatType>
</html>
</field>
<field>
Expand All @@ -176,6 +179,7 @@
<add>1.8</add>
<html>
<type>Select Date</type>
<formatType>activityDateTime</formatType>
</html>
</field>
<field>
Expand Down

0 comments on commit 97129f2

Please sign in to comment.