Eileen has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/293793

Change subject: Add prospecting custom fields
......................................................................

Add prospecting custom fields

Bug: T128818
Change-Id: I904e7233d9d3199790463b4b44e669f719f42802
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.install
1 file changed, 85 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/93/293793/1

diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.install 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
index 689ca7c..9018477 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.install
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
@@ -56,6 +56,7 @@
     wmf_civicrm_update_7200();
     wmf_civicrm_update_7205();
     wmf_civicrm_update_7210();
+    wmf_civicrm_update_7220();
 }
 
 /**
@@ -1996,3 +1997,87 @@
        WHERE ov.name = 'Contact Deleted By Merge' AND og.name = 
'activity_type'"
   );
 }
+
+/**
+ * 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_field_id = %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,
+        )
+      )
+    );
+  }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/293793
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I904e7233d9d3199790463b4b44e669f719f42802
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

Reply via email to