From c03ba8270296603ae4b0d14c3db0785f04fb2702 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Fri, 19 Oct 2018 21:29:48 +0100 Subject: [PATCH] Convert ManageEvent Registration to datepicker --- CRM/Event/DAO/Event.php | 6 +++- CRM/Event/Form/ManageEvent/Registration.php | 34 +++---------------- .../Event/Form/ManageEvent/Registration.tpl | 4 +-- xml/schema/Event/Event.xml | 4 +++ 4 files changed, 15 insertions(+), 33 deletions(-) diff --git a/CRM/Event/DAO/Event.php b/CRM/Event/DAO/Event.php index 1f13607d0c..c50e80fbcc 100644 --- a/CRM/Event/DAO/Event.php +++ b/CRM/Event/DAO/Event.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Event/Event.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:6c0950f3a5f6305f8d7e0a05d4703018) + * (GenCodeChecksum:44df1cb5691958b88be856f793adabca) */ /** @@ -670,6 +670,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO { 'localizable' => 0, 'html' => [ 'type' => 'Select Date', + 'formatType' => 'activityDateTime', ], ], 'event_end_date' => [ @@ -688,6 +689,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO { 'localizable' => 0, 'html' => [ 'type' => 'Select Date', + 'formatType' => 'activityDateTime', ], ], 'is_online_registration' => [ @@ -730,6 +732,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO { 'localizable' => 0, 'html' => [ 'type' => 'Select Date', + 'formatType' => 'activityDateTime', ], ], 'registration_end_date' => [ @@ -743,6 +746,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO { 'localizable' => 0, 'html' => [ 'type' => 'Select Date', + 'formatType' => 'activityDateTime', ], ], 'max_participants' => [ diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index aed44b7ad4..a39bc136a5 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -178,16 +178,6 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $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; } @@ -250,8 +240,8 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $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( @@ -482,13 +472,8 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } } - 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'); } } @@ -821,17 +806,6 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $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 diff --git a/templates/CRM/Event/Form/ManageEvent/Registration.tpl b/templates/CRM/Event/Form/ManageEvent/Registration.tpl index 20e52fd53f..e4c5361e4a 100644 --- a/templates/CRM/Event/Form/ManageEvent/Registration.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Registration.tpl @@ -72,11 +72,11 @@ {if !$isTemplate} {$form.registration_start_date.label} - {include file="CRM/common/jcalendar.tpl" elementName=registration_start_date} + {$form.registration_start_date.html} {$form.registration_end_date.label} - {include file="CRM/common/jcalendar.tpl" elementName=registration_end_date} + {$form.registration_end_date.html} {/if} diff --git a/xml/schema/Event/Event.xml b/xml/schema/Event/Event.xml index 200eed0159..77a43a7c10 100644 --- a/xml/schema/Event/Event.xml +++ b/xml/schema/Event/Event.xml @@ -122,6 +122,7 @@ 1.7 Select Date + activityDateTime @@ -135,6 +136,7 @@ 1.7 Select Date + activityDateTime @@ -167,6 +169,7 @@ 1.8 Select Date + activityDateTime @@ -176,6 +179,7 @@ 1.8 Select Date + activityDateTime -- 2.25.1