Skip to content

Commit

Permalink
Convert relationship form to datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Oct 19, 2018
1 parent 26b4525 commit f00528a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
4 changes: 3 additions & 1 deletion CRM/Contact/DAO/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Contact/Relationship.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:49381da59affbf165a4c9ce87c9a68ec)
* (GenCodeChecksum:ce5f84e10ef36ac340837227265123a4)
*/

/**
Expand Down Expand Up @@ -203,6 +203,7 @@ public static function &fields() {
'localizable' => 0,
'html' => [
'type' => 'Select Date',
'formatType' => 'activityDate',
],
],
'end_date' => [
Expand All @@ -216,6 +217,7 @@ public static function &fields() {
'localizable' => 0,
'html' => [
'type' => 'Select Date',
'formatType' => 'activityDate',
],
],
'is_active' => [
Expand Down
14 changes: 3 additions & 11 deletions CRM/Contact/Form/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ public function setDefaultValues() {
if (!empty($this->_values)) {
$defaults['relationship_type_id'] = $this->_rtypeId;
if (!empty($this->_values['start_date'])) {
list($defaults['start_date']) = CRM_Utils_Date::setDateDefaults($this->_values['start_date']);
$defaults['start_date'] = $this->_values['start_date'];
}
if (!empty($this->_values['end_date'])) {
list($defaults['end_date']) = CRM_Utils_Date::setDateDefaults($this->_values['end_date']);
$defaults['end_date'] = $this->_values['end_date'];
}
$defaults['description'] = CRM_Utils_Array::value('description', $this->_values);
$defaults['is_active'] = CRM_Utils_Array::value('is_active', $this->_values);
Expand Down Expand Up @@ -442,9 +442,7 @@ public static function dateRule($params) {

// check start and end date
if (!empty($params['start_date']) && !empty($params['end_date'])) {
$start_date = CRM_Utils_Date::format(CRM_Utils_Array::value('start_date', $params));
$end_date = CRM_Utils_Date::format(CRM_Utils_Array::value('end_date', $params));
if ($start_date && $end_date && (int ) $end_date < (int ) $start_date) {
if ($params['end_date'] < $params['start_date']) {
$errors['end_date'] = ts('The relationship end date cannot be prior to the start date.');
}
}
Expand Down Expand Up @@ -595,12 +593,6 @@ private function preparePostProcessParameters($values) {
else {
$params['id'] = $this->_relationshipId;
$params['contact_id_' . $b] = $params['related_contact_id'];

foreach (array('start_date', 'end_date') as $dateParam) {
if (!empty($params[$dateParam])) {
$params[$dateParam] = CRM_Utils_Date::processDate($params[$dateParam]);
}
}
}

// If this is a b_a relationship these form elements are flipped
Expand Down
3 changes: 1 addition & 2 deletions templates/CRM/Contact/Form/Relationship.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@
</tr>
<tr class="crm-relationship-form-block-start_date">
<td class="label">{$form.start_date.label}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=start_date}<span>{$form.end_date.label} {include file="CRM/common/jcalendar.tpl" elementName=end_date}</span><br />
<span class="description">{ts}If this relationship has start and/or end dates, specify them here.{/ts}</span></td>
<td>{$form.start_date.html} {$form.end_date.label} {$form.end_date.html}<br /><span class="description">{ts}If this relationship has start and/or end dates, specify them here.{/ts}</span></td>
</tr>
<tr class="crm-relationship-form-block-description">
<td class="label">{$form.description.label}</td>
Expand Down
2 changes: 2 additions & 0 deletions xml/schema/Contact/Relationship.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<add>1.1</add>
<html>
<type>Select Date</type>
<formatType>activityDate</formatType>
</html>
</field>
<field>
Expand All @@ -88,6 +89,7 @@
<add>1.1</add>
<html>
<type>Select Date</type>
<formatType>activityDate</formatType>
</html>
</field>
<field>
Expand Down

0 comments on commit f00528a

Please sign in to comment.