Commit d104311a authored by colemanw's avatar colemanw

#561 - activity_date_time field -> datepicker

parent f01f6ac0
......@@ -207,6 +207,11 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
'api' => array('params' => array('is_deceased' => 0)),
),
),
'activity_date_time' => array(
'type' => 'datepicker',
'label' => ts('Date'),
'required' => TRUE,
),
'followup_assignee_contact_id' => array(
'type' => 'entityRef',
'label' => ts('Assigned to'),
......@@ -559,16 +564,6 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
$defaults = $this->_values + CRM_Core_Form_RecurringEntity::setDefaultValues();
// if we're editing...
if (isset($this->_activityId)) {
if (empty($defaults['activity_date_time'])) {
list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
}
elseif ($this->_action & CRM_Core_Action::UPDATE) {
$this->assign('current_activity_date_time', $defaults['activity_date_time']);
list($defaults['activity_date_time'],
$defaults['activity_date_time_time']
) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
}
if ($this->_context != 'standalone') {
$this->assign('target_contact_value',
......@@ -593,9 +588,10 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
$defaults['source_contact_id'] = $this->_sourceContactId;
$defaults['target_contact_id'] = $this->_targetContactId;
}
list($defaults['activity_date_time'], $defaults['activity_date_time_time'])
= CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
if (empty($defaults['activity_date_time'])) {
$defaults['activity_date_time'] = date('Y-m-d H:i:s');
}
if ($this->_activityTypeId) {
......@@ -759,7 +755,6 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
$this->addRule('duration',
ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger'
);
$this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
// Add followup date.
$this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
......@@ -948,9 +943,6 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
);
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// format params as arrays
foreach (array('target', 'assignee', 'followup_assignee') as $name) {
if (!empty($params["{$name}_contact_id"])) {
......
......@@ -272,12 +272,13 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
$this->assign('urlPath', 'civicrm/case/activity');
$encounterMediums = CRM_Case_PseudoConstant::encounterMedium();
// Fixme: what's the justification for this? It seems like it is just re-adding an option in case it is the default and disabled.
// Is that really a big problem?
if ($this->_activityTypeFile == 'OpenCase') {
$this->_encounterMedium = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId,
'medium_id'
);
if ($this->_action == CRM_Core_Action::UPDATE) {
$this->getElement('activity_date_time')->freeze();
}
// Fixme: what's the justification for this? It seems like it is just re-adding an option in case it is the default and disabled.
// Is that really a big problem?
$this->_encounterMedium = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'medium_id');
if (!array_key_exists($this->_encounterMedium, $encounterMediums)) {
$encounterMediums[$this->_encounterMedium] = CRM_Core_OptionGroup::getLabel('encounter_medium',
$this->_encounterMedium,
......
......@@ -135,7 +135,7 @@
<tr class="crm-activity-form-block-activity_date_time">
<td class="label">{$form.activity_date_time.label}</td>
{if $action neq 4}
<td class="view-value">{include file="CRM/common/jcalendar.tpl" elementName=activity_date_time}</td>
<td class="view-value">{$form.activity_date_time.html}</td>
{else}
<td class="view-value">{$form.activity_date_time.value|crmDate}</td>
{/if}
......
......@@ -145,15 +145,12 @@
</tr>
<tr class="crm-case-activity-form-block-activity_date_time">
<td class="label">{$form.activity_date_time.label}</td>
{if $action eq 2 && $activityTypeFile eq 'OpenCase'}
<td class="view-value">{$current_activity_date_time|crmDate}
<div class="description">Use a <a href="{$changeStartURL}">Change Start Date</a> activity to change the date</div>
{* avoid errors about missing field *}
<div style="display: none;">{include file="CRM/common/jcalendar.tpl" elementName=activity_date_time}</div>
</td>
{else}
<td class="view-value">{include file="CRM/common/jcalendar.tpl" elementName=activity_date_time}</td>
{/if}
<td class="view-value">
{$form.activity_date_time.html}
{if $action eq 2 && $activityTypeFile eq 'OpenCase'}
<div class="description">Use a <a class="open-inline" href="{$changeStartURL}">Change Start Date</a> activity to change the date</div>
{/if}
</td>
</tr>
{if $action eq 2 && $activityTypeFile eq 'OpenCase'}
<tr class="crm-case-activity-form-block-details">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment