dev/core#561 - Convert campaign form date fields
authorColeman Watts <coleman@civicrm.org>
Tue, 8 Jan 2019 17:08:39 +0000 (12:08 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 8 Jan 2019 17:08:39 +0000 (12:08 -0500)
CRM/Campaign/Form/Campaign.php
templates/CRM/Campaign/Form/Campaign.tpl

index 8b655775de254b6f44f321d66ab68c1638fed1aa..f94cb29a63f3f498a641c852a95e365606ce2376 100644 (file)
@@ -136,18 +136,8 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
   public function setDefaultValues() {
     $defaults = $this->_values;
 
-    if (isset($defaults['start_date'])) {
-      list($defaults['start_date'], $defaults['start_date_time'])
-        = CRM_Utils_Date::setDateDefaults($defaults['start_date'], 'activityDateTime');
-    }
-    else {
-      list($defaults['start_date'], $defaults['start_date_time'])
-        = CRM_Utils_Date::setDateDefaults();
-    }
-
-    if (isset($defaults['end_date'])) {
-      list($defaults['end_date'], $defaults['end_date_time'])
-        = CRM_Utils_Date::setDateDefaults($defaults['end_date'], 'activityDateTime');
+    if (empty($defaults['start_date'])) {
+      $defaults['start_date'] = date('Y-m-d H:i:s');
     }
 
     if (!isset($defaults['is_active'])) {
@@ -208,10 +198,10 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
     $this->add('textarea', 'description', ts('Description'), $attributes['description']);
 
     // add campaign start date
-    $this->addDateTime('start_date', ts('Start Date'), TRUE, array('formatType' => 'activityDateTime'));
+    $this->add('datepicker', 'start_date', ts('Start Date'), [], TRUE);
 
     // add campaign end date
-    $this->addDateTime('end_date', ts('End Date'), FALSE, array('formatType' => 'activityDateTime'));
+    $this->add('datepicker', 'end_date', ts('End Date'));
 
     // add campaign type
     $this->addSelect('campaign_type_id', array('onChange' => "CRM.buildCustomData( 'Campaign', this.value );"), TRUE);
@@ -313,8 +303,6 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
       $params['created_date'] = date('YmdHis');
     }
     // format params
-    $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
-    $params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], TRUE);
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['last_modified_id'] = $session->get('userID');
     $params['last_modified_date'] = date('YmdHis');
index ce8ed37f6a13c1cc377e2c5b970e4daaf0c15b9a..c9d576d16690d4e8d0783dc1ac76f9c5b5084a84 100644 (file)
   </tr>
   <tr class="crm-campaign-form-block-start_date">
       <td class="label">{$form.start_date.label}</td>
-      <td class="view-value">{include file="CRM/common/jcalendar.tpl" elementName=start_date}
-      </td>
+      <td class="view-value">{$form.start_date.html}</td>
   </tr>
   <tr class="crm-campaign-form-block-end_date">
       <td class="label">{$form.end_date.label}</td>
-      <td class="view-value">{include file="CRM/common/jcalendar.tpl" elementName=end_date}</td>
+      <td class="view-value">{$form.end_date.html}</td>
   </tr>
   <tr class="crm-campaign-form-block-status_id">
       <td class="label">{$form.status_id.label}</td>