Commit fdb42943 authored by colemanw's avatar colemanw Committed by GitHub

Merge pull request #10355 from eileenmcnaughton/deprecation

Deprecation: 	CRM-20572 Remove jcalendar from Contrib Sybunt custom Search
parents 2d3fdfe5 9c41fa61
......@@ -183,6 +183,13 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch {
}
}
if ($customSearchClass = CRM_Utils_Array::value('customSearchClass', $result)) {
// check if there is a special function - formatSavedSearchFields defined in the custom search form
if (method_exists($customSearchClass, 'formatSavedSearchFields')) {
$customSearchClass::formatSavedSearchFields($result);
}
}
return $result;
}
......
......@@ -43,7 +43,7 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Searc
* @param $formValues
*/
public function __construct(&$formValues) {
$this->_formValues = $formValues;
$this->_formValues = self::formatSavedSearchFields($formValues);
$this->_permissionedComponent = 'CiviContribute';
$this->_columns = array(
......@@ -83,7 +83,7 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Searc
foreach ($this->_dates as $name => $title) {
if (!empty($this->_formValues[$name])) {
$this->{$name} = CRM_Utils_Date::processDate($this->_formValues[$name]);
$this->{$name} = $this->_formValues[$name];
}
}
}
......@@ -101,7 +101,7 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Searc
}
foreach ($this->_dates as $name => $title) {
$form->addDate($name, $title, FALSE, array('formatType' => 'custom'));
$form->add('datepicker', $name, $title, array(), FALSE, array('time' => FALSE));
}
foreach ($this->_checkboxes as $name => $title) {
......@@ -194,7 +194,7 @@ ORDER BY donation_amount desc
if ($justIDs) {
CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS CustomSearch_SYBNT_temp");
$query = "CREATE TEMPORARY TABLE CustomSearch_SYBNT_temp AS ({$sql})";
$dao = CRM_Core_DAO::executeQuery($query);
CRM_Core_DAO::executeQuery($query);
$sql = "SELECT contact_a.id as contact_id FROM CustomSearch_SYBNT_temp as contact_a";
}
return $sql;
......@@ -246,22 +246,22 @@ count(contrib_1.id) AS donation_count
$clauses = array();
if (!empty($this->start_date_1)) {
$clauses[] = "contrib_1.receive_date >= {$this->start_date_1}";
$clauses[] = CRM_Core_DAO::composeQuery('contrib_1.receive_date >= %1', array(1 => array($this->start_date_1, 'String')));
}
if (!empty($this->end_date_1)) {
$clauses[] = "contrib_1.receive_date <= {$this->end_date_1}";
$clauses[] = CRM_Core_DAO::composeQuery('contrib_1.receive_date <= %1', array(1 => array($this->end_date_1, 'String')));
}
if (!empty($this->start_date_2) || !empty($this->end_date_2)) {
$clauses[] = "contrib_2.is_test = 0";
if (!empty($this->start_date_2)) {
$clauses[] = "contrib_2.receive_date >= {$this->start_date_2}";
$clauses[] = CRM_Core_DAO::composeQuery('contrib_2.receive_date >= %1', array(1 => array($this->start_date_2, 'String')));
}
if (!empty($this->end_date_2)) {
$clauses[] = "contrib_2.receive_date <= {$this->end_date_2}";
$clauses[] = CRM_Core_DAO::composeQuery('contrib_2.receive_date <= %1', array(1 => array($this->end_date_2, 'String')));
}
}
......@@ -279,11 +279,11 @@ count(contrib_1.id) AS donation_count
$excludeClauses = array();
if ($this->exclude_start_date) {
$excludeClauses[] = "c.receive_date >= {$this->exclude_start_date}";
$excludeClauses[] = CRM_Core_DAO::composeQuery('c.receive_date >= %1', array(1 => array($this->exclude_start_date, 'String')));
}
if ($this->exclude_end_date) {
$excludeClauses[] = "c.receive_date <= {$this->exclude_end_date}";
$excludeClauses[] = CRM_Core_DAO::composeQuery('c.receive_date <= %1', array(1 => array($this->exclude_end_date, 'String')));
}
$excludeClause = NULL;
......@@ -317,7 +317,7 @@ GROUP BY c.contact_id
$havingClause
";
$dao = CRM_Core_DAO::executeQuery($query);
CRM_Core_DAO::executeQuery($query);
}
// now ensure we dont consider donors that are not first time
......@@ -329,7 +329,7 @@ FROM civicrm_contribution c
WHERE c.is_test = 0
AND c.receive_date < {$this->start_date_1}
";
$dao = CRM_Core_DAO::executeQuery($query);
CRM_Core_DAO::executeQuery($query);
}
$clauses[] = " xg.contact_id IS NULL ";
......@@ -400,4 +400,26 @@ AND c.receive_date < {$this->start_date_1}
list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
}
/**
* Format saved search fields for this custom group
*
* @param array $formValues
*
*/
public static function formatSavedSearchFields(&$formValues) {
$dateFields = array(
'start_date_1',
'end_date_1',
'start_date_2',
'end_date_2',
'exclude_start_date',
'exclude_end_date',
);
foreach ($formValues as $element => $value) {
if (in_array($element, $dateFields) && !empty($value)) {
$formValues[$element] = date('Y-m-d', strtotime($value));
}
}
}
}
......@@ -297,7 +297,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
$contactQueryObj = $this->_search->getQueryObj();
}
$dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
$dao = CRM_Core_DAO::executeQuery($sql);
$columns = $this->_search->columns();
$columnNames = array_values($columns);
......
......@@ -556,10 +556,7 @@ FROM civicrm_action_schedule cas
'provider_id' => $schedule->sms_provider_id,
'activity_subject' => $messageSubject,
);
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type',
'SMS',
'name'
);
$activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'SMS');
$activityParams = array(
'source_contact_id' => $userID,
'activity_type_id' => $activityTypeID,
......
......@@ -456,6 +456,16 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
$this->addTask('Remove broken Contribution_logging reports', 'removeContributionLoggingReports');
}
/**
* Upgrade function.
*
* @param string $rev
*/
public function upgrade_4_7_27($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
$this->addTask('CRM-20572: Fix date fields in save search criteria of Contrib Sybunt custom search ', 'fixDateFieldsInSmartGroups');
}
/*
* Important! All upgrade functions MUST add a 'runSql' task.
* Uncomment and use the following template for a new upgrade version
......@@ -1287,4 +1297,22 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
return $config->imageUploadDir && $config->imageUploadURL && $check->isDirAccessible($config->imageUploadDir, $config->imageUploadURL);
}
/**
* CRM-20572 - Format date fields in Contrib Sybunt custom search's saved criteria.
*
* @param \CRM_Queue_TaskContext $ctx
*
* @return bool
*/
public static function fixDateFieldsInSmartGroups(CRM_Queue_TaskContext $ctx) {
$dao = CRM_Core_DAO::executeQuery("SELECT id, form_values FROM civicrm_saved_search WHERE form_values LIKE '%CRM_Contact_Form_Search_Custom_ContribSYBNT%'");
while ($dao->fetch()) {
$formValues = unserialize($dao->form_values);
CRM_Contact_Form_Search_Custom_ContribSYBNT::formatSavedSearchFields($formValues);
CRM_Core_DAO::executeQuery("UPDATE civicrm_saved_search SET form_values = %1 WHERE id = {$dao->id}", array(1 => array(serialize($formValues), 'String')));
}
return TRUE;
}
}
......@@ -42,8 +42,8 @@
</tr>
<tr class="crm-contact-custom-search-contribSYBNT-form-block-inclusion_date_one">
<td><label>Inclusion Date One: Start/End</label></td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=start_date_1}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=end_date_1}</td>
<td>{$form.start_date_1.html}</td>
<td>{$form.end_date_1.html}</td>
<td>{$form.is_first_amount.html}&nbsp;{ts}First time donor only?{/ts}</td>
</tr>
<tr class="crm-contact-custom-search-contribSYBNT-form-block-min_amount_2">
......@@ -54,8 +54,8 @@
</tr>
<tr class="crm-contact-custom-search-contribSYBNT-form-block-inclusion_date_two">
<td><label>Inclusion Date Two: Start/End</label></td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=start_date_2}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=end_date_2}</td>
<td>{$form.start_date_2.html}</td>
<td>{$form.end_date_2.html}</td>
<td>&nbsp;</td>
</tr>
<tr class="crm-contact-custom-search-contribSYBNT-form-block-exclude_min_amount">
......@@ -66,8 +66,8 @@
</tr>
<tr class="crm-contact-custom-search-contribSYBNT-form-block-exclusion_date">
<td><label>Exclusion Date: Start/End</label></td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=exclude_start_date}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=exclude_end_date}</td>
<td>{$form.exclude_start_date.html}</td>
<td>{$form.exclude_end_date.html}</td>
<td>&nbsp;</td>
</tr>
</table>
......
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