Skip to content

Commit

Permalink
Convert register_date to datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Oct 21, 2018
1 parent 8f86a6b commit bf450a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 33 deletions.
39 changes: 13 additions & 26 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public function getDefaultContext() {
* Set variables up before form is built.
*
* @return void
* @throws \CRM_Core_Exception
*/
public function preProcess() {
parent::preProcess();
Expand Down Expand Up @@ -420,8 +421,8 @@ public function preProcess() {
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
* @return array
* @throws \CRM_Core_Exception
*/
public function setDefaultValues() {
if ($this->_showFeeBlock) {
Expand Down Expand Up @@ -467,15 +468,6 @@ public function setDefaultValues() {
}
}

if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::BROWSE)) {
$inactiveNeeded = TRUE;
$viewMode = TRUE;
}
else {
$viewMode = FALSE;
$inactiveNeeded = FALSE;
}

//setting default register date
if ($this->_action == CRM_Core_Action::ADD) {
$statuses = array_flip(CRM_Event_PseudoConstant::participantStatus());
Expand Down Expand Up @@ -513,6 +505,7 @@ public function setDefaultValues() {
if (!empty($submittedEvent[0])) {
$eventID = $submittedEvent[0];
}
$defaults[$this->_id]['register_date'] = date('Y-m-d H:i:s');
}
else {
$defaults[$this->_id]['record_contribution'] = 0;
Expand All @@ -532,9 +525,6 @@ public function setDefaultValues() {
}
}

list($defaults[$this->_id]['register_date'], $defaults[$this->_id]['register_date_time'])
= CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_id]), 'activityDateTime');

//assign event and role id, this is needed for Custom data building
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
if (!empty($defaults[$this->_id]['participant_role_id'])) {
Expand Down Expand Up @@ -586,6 +576,8 @@ public function setDefaultValues() {
* Build the form object.
*
* @return void
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function buildQuickForm() {
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
Expand Down Expand Up @@ -680,8 +672,7 @@ public function buildQuickForm() {
}
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);

$this->addDateTime('register_date', ts('Registration Date'), TRUE, array('formatType' => 'activityDateTime'));
$this->add('datepicker', 'register_date', ts('Registration Date'), [], TRUE, array('time' => TRUE));

if ($this->_id) {
$this->assign('entityID', $this->_id);
Expand Down Expand Up @@ -780,7 +771,6 @@ public function buildQuickForm() {
/**
* Add local and global form rules.
*
*
* @return void
*/
public function addRules() {
Expand Down Expand Up @@ -972,7 +962,9 @@ public function postProcess() {
*
* @param array $params
*
* @return array
* @return string
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function submit($params) {
$participantStatus = CRM_Event_PseudoConstant::participantStatus();
Expand Down Expand Up @@ -1027,12 +1019,9 @@ public function submit($params) {
}
else {

//check if discount is selected
if (!empty($params['discount_id'])) {
$discountId = $params['discount_id'];
}
else {
$discountId = $params['discount_id'] = 'null';
// check that discount_id is set
if (empty($params['discount_id'])) {
$params['discount_id'] = 'null';
}

//lets carry currency, CRM-4453
Expand Down Expand Up @@ -1100,8 +1089,6 @@ public function submit($params) {
$amountOwed = $params['amount'];
unset($params['amount']);
}
$params['register_date'] = CRM_Utils_Date::processDate($params['register_date'], $params['register_date_time']);
$params['receive_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $params), CRM_Utils_Array::value('receive_date_time', $params));
$params['contact_id'] = $this->_contactId;

// overwrite actual payment amount if entered
Expand Down
8 changes: 1 addition & 7 deletions templates/CRM/Event/Form/Participant.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,7 @@
</tr>
<tr class="crm-participant-form-block-register_date">
<td class="label">{$form.register_date.label}</td>
<td>
{if $hideCalendar neq true}
{include file="CRM/common/jcalendar.tpl" elementName=register_date}
{else}
{$form.register_date.value|crmDate}
{/if}
</td>
<td>{$form.register_date.html}</td>
</tr>
<tr class="crm-participant-form-block-status_id">
<td class="label">{$form.status_id.label}</td>
Expand Down

0 comments on commit bf450a9

Please sign in to comment.