Eileen has uploaded a new change for review. https://gerrit.wikimedia.org/r/317994
Change subject: Add decile field to prospect. ...................................................................... Add decile field to prospect. Rosie has altered the options associated with this field and logged a ticket for us to update our scripts. It turns out the field was not already in the script for dev environments. I have added it & taken a baby-step towards a tidier way of managing these custom fields Bug: T147965 Change-Id: Iec797f7ed2c451c0d6953cdde22d0355da87b1f3 --- A sites/all/modules/wmf_civicrm/update_custom_fields.php M sites/all/modules/wmf_civicrm/wmf_civicrm.install 2 files changed, 130 insertions(+), 79 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/94/317994/1 diff --git a/sites/all/modules/wmf_civicrm/update_custom_fields.php b/sites/all/modules/wmf_civicrm/update_custom_fields.php new file mode 100644 index 0000000..c9b2547 --- /dev/null +++ b/sites/all/modules/wmf_civicrm/update_custom_fields.php @@ -0,0 +1,113 @@ +<?php + +/** + * Update the receipt to match the version in the templates folder. + */ +function _wmf_civicrm_update_custom_fields() { + civicrm_initialize(); + $customGroup = civicrm_api3('CustomGroup', 'get', array('name' => 'Prospect')); + if (!$customGroup['count']) { + $customGroup = civicrm_api3('CustomGroup', 'create', array( + 'name' => 'Prospect', + 'title' => 'Prospect', + 'extends' => 'Contact', + 'style' => 'tab', + 'is_active' => 1, + )); + } + // We mostly are trying to ensure a unique weight since weighting can be re-orded in the UI but it gets messy + // if they are all set to 1. + $weight = CRM_Core_DAO::singleValueQuery('SELECT max(weight) FROM civicrm_custom_field WHERE custom_group_id = %1', + array(1 => array($customGroup['id'], 'Integer')) + ); + + foreach (_wmf_civicrm_get_prospect_fields() as $field) { + if (!civicrm_api3('CustomField', 'getcount', array( + 'custom_group_id' => $customGroup['id'], + 'name' => $field['name'], + ))){ + $weight++; + civicrm_api3('CustomField', 'create', array_merge( + $field, + array( + 'custom_group_id' => $customGroup['id'], + 'weight' => $weight, + ) + )); + } + } +} + +function _wmf_civicrm_get_prospect_fields() { + return array( + 'ask_amount' => array( + 'name' => 'ask_amount', + 'label' => 'Ask Amount', + 'data_type' => 'Money', + 'html_type' => 'Text', + 'is_searchable' => 1, + 'is_search_range' => 1, + ), + 'expected_amount' => array( + 'name' => 'expected_amount', + 'label' => 'Expected Amount', + 'data_type' => 'Money', + 'html_type' => 'Text', + 'is_searchable' => 1, + 'is_search_range' => 1, + ), + 'likelihood' => array( + 'name' => 'likelihood', + 'label' => 'Likelihood (%)', + 'data_type' => 'Integer', + 'html_type' => 'Text', + 'is_searchable' => 1, + 'is_search_range' => 1, + ), + 'expected_close_date' => array( + 'name' => 'expected_close_date', + 'label' => 'Expected Close Date', + 'data_type' => 'Date', + 'html_type' => 'Select Date', + 'is_searchable' => 1, + 'is_search_range' => 1, + ), + 'close_date' => array( + 'name' => 'close_date', + 'label' => 'Close Date', + 'data_type' => 'Date', + 'html_type' => 'Select Date', + 'is_searchable' => 1, + 'is_search_range' => 1, + ), + 'next_step' => array( + 'name' => 'next_step', + 'label' => 'Next Step', + 'data_type' => 'Memo', + 'html_type' => 'RichTextEditor', + 'note_columns' => 60, + 'note_rows' => 4, + ), + 'Disc_Income_Decile' => array( + 'name' => 'Disc_Income_Decile', + 'label' => 'Disc Income Decile', + 'data_type' => 'String', + 'html_type' => 'Select', + 'is_searchable' => 1, + 'text_length' => 255, + 'note_columns' => 60, + 'note_rows' => 4, + 'option_values' => array( + 'A' => 'A', + 'B' => 'B', + 'C' => 'C', + 'D' => 'D', + 'E' => 'E', + 'F' => 'F', + 'G' => 'G', + 'H' => 'H', + 'I' => 'I', + ) + ), + ); +} diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.install b/sites/all/modules/wmf_civicrm/wmf_civicrm.install index 137ef9f..ead87ac 100644 --- a/sites/all/modules/wmf_civicrm/wmf_civicrm.install +++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.install @@ -56,11 +56,11 @@ wmf_civicrm_update_7200(); wmf_civicrm_update_7205(); wmf_civicrm_update_7210(); - wmf_civicrm_update_7220(); wmf_civicrm_update_7230(); wmf_civicrm_update_7235(); wmf_civicrm_update_7280(); wmf_civicrm_update_7290(); + wmf_civicrm_update_7300(); } /** @@ -2006,84 +2006,8 @@ * Create additional prospecting custom fields. */ function wmf_civicrm_update_7220() { - civicrm_initialize(); - $customGroup = civicrm_api3('CustomGroup', 'get', array('name' => 'Prospect')); - if (!$customGroup['count']) { - $customGroup = civicrm_api3('CustomGroup', 'create', array( - 'name' => 'Prospect', - 'title' => 'Prospect', - 'extends' => 'Contact', - 'style' => 'tab', - 'is_active' => 1, - )); - } - $fields = array( - 'ask_amount' => array( - 'name' => 'ask_amount', - 'label' => 'Ask Amount', - 'data_type' => 'Money', - 'html_type' => 'Text', - 'is_searchable' => 1, - 'is_search_range' => 1, - ), - 'expected_amount' => array( - 'name' => 'expected_amount', - 'label' => 'Expected Amount', - 'data_type' => 'Money', - 'html_type' => 'Text', - 'is_searchable' => 1, - 'is_search_range' => 1, - ), - 'likelihood' => array( - 'name' => 'likelihood', - 'label' => 'Likelihood (%)', - 'data_type' => 'Integer', - 'html_type' => 'Text', - 'is_searchable' => 1, - 'is_search_range' => 1, - ), - 'expected_close_date' => array( - 'name' => 'expected_close_date', - 'label' => 'Expected Close Date', - 'data_type' => 'Date', - 'html_type' => 'Select Date', - 'is_searchable' => 1, - 'is_search_range' => 1, - ), - 'close_date' => array( - 'name' => 'close_date', - 'label' => 'Close Date', - 'data_type' => 'Date', - 'html_type' => 'Select Date', - 'is_searchable' => 1, - 'is_search_range' => 1, - ), - 'next_step' => array( - 'name' => 'next_step', - 'label' => 'Next Step', - 'data_type' => 'Memo', - 'html_type' => 'RichTextEditor', - 'note_columns' => 60, - 'note_rows' => 4, - ), - ); - // We mostly are trying to ensure a unique weight since weighting can be re-orded in the UI but it gets messy - // if they are all set to 1. - $weight = CRM_Core_DAO::singleValueQuery('SELECT max(weight) FROM civicrm_custom_field WHERE custom_group_id = %1', - array(1 => array($customGroup['id'], 'Integer')) - ); - - foreach ($fields as $field) { - $weight++; - civicrm_api3('CustomField', 'create', array_merge( - $field, - array( - 'custom_group_id' => $customGroup['id'], - 'weight' => $weight, - ) - ) - ); - } + require_once 'update_custom_fields.php'; + _wmf_civicrm_update_custom_fields(); } /** @@ -2364,3 +2288,17 @@ civicrm_initialize(); civicrm_api3('Setting', 'create', array('moneyformat' => '%c%a')); } + +/** + * Update custom fields to match fields defined on live. + * + * Note that these are generally created on live by non-tech staff + * (e.g major gifts) and we add them in the script to keep our dev + * environments in sync. + * + * Bug: T147965 + */ +function wmf_civicrm_update_7300() { + require_once 'update_custom_fields.php'; + _wmf_civicrm_update_custom_fields(); +} -- To view, visit https://gerrit.wikimedia.org/r/317994 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iec797f7ed2c451c0d6953cdde22d0355da87b1f3 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits