mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-25 16:18:05 +02:00
SK/FB work
This commit is contained in:
parent
16f2b6235d
commit
a4c9251f5e
10 changed files with 163 additions and 233 deletions
|
@ -24,6 +24,11 @@ class Processor {
|
||||||
->addOrderBy('execution_order')
|
->addOrderBy('execution_order')
|
||||||
->execute()->getArrayCopy();
|
->execute()->getArrayCopy();
|
||||||
|
|
||||||
|
// Check the last item is the 'default' one.
|
||||||
|
if ((end($this->categories)['search_type'] ?? '') !== 'default') {
|
||||||
|
throw new CRM_Core_Exception("ContactCategoryDefinition unconfigured; no default category.");
|
||||||
|
}
|
||||||
|
|
||||||
// Identify groups and searches used by definitions.
|
// Identify groups and searches used by definitions.
|
||||||
$groupIDs = $searchIDs = [];
|
$groupIDs = $searchIDs = [];
|
||||||
foreach ($this->categories as $cat) {
|
foreach ($this->categories as $cat) {
|
||||||
|
@ -72,8 +77,10 @@ class Processor {
|
||||||
// TODO: check things like searches that group by contact_id
|
// TODO: check things like searches that group by contact_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main calling point.
|
||||||
|
*/
|
||||||
public function run() {
|
public function run() {
|
||||||
|
|
||||||
$this->refreshSmartGroups();
|
$this->refreshSmartGroups();
|
||||||
$summary = [];
|
$summary = [];
|
||||||
\CRM_Core_Transaction::create()->run(function($tx) use (&$summary) {
|
\CRM_Core_Transaction::create()->run(function($tx) use (&$summary) {
|
||||||
|
@ -85,6 +92,12 @@ class Processor {
|
||||||
elseif ($cat['search_type'] === 'search') {
|
elseif ($cat['search_type'] === 'search') {
|
||||||
$this->assignCategoryFromSearch($cat);
|
$this->assignCategoryFromSearch($cat);
|
||||||
}
|
}
|
||||||
|
elseif ($cat['search_type'] === 'default') {
|
||||||
|
$this->assignDefaultCategory($cat);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new CRM_Core_DAO("Invalid search_type: $cat[search_type] for category $cat[id]");
|
||||||
|
}
|
||||||
// future...
|
// future...
|
||||||
}
|
}
|
||||||
$summary = $this->createChangeActivities();
|
$summary = $this->createChangeActivities();
|
||||||
|
@ -96,10 +109,10 @@ class Processor {
|
||||||
protected function createChangeActivities() {
|
protected function createChangeActivities() {
|
||||||
Civi::log()->debug("Calculate changes", ['=' => 'timed', '=start' => "changes"]);
|
Civi::log()->debug("Calculate changes", ['=' => 'timed', '=start' => "changes"]);
|
||||||
$changes = CRM_Core_DAO::executeQuery(<<<SQL
|
$changes = CRM_Core_DAO::executeQuery(<<<SQL
|
||||||
SELECT id, category, next_category
|
SELECT id, category_definition_id, next_category
|
||||||
FROM civicrm_contact_category
|
FROM civicrm_contact_category
|
||||||
WHERE next_category <> category
|
WHERE next_category <> category_definition_id
|
||||||
ORDER BY category, next_category
|
ORDER BY category_definition_id, next_category
|
||||||
SQL);
|
SQL);
|
||||||
$lastChange = [0, 0];
|
$lastChange = [0, 0];
|
||||||
$batch = [];
|
$batch = [];
|
||||||
|
@ -147,10 +160,11 @@ class Processor {
|
||||||
|
|
||||||
Civi::log()->debug('Apply changes', ['=change' => 'applyChanges', '=timed' => 1]);
|
Civi::log()->debug('Apply changes', ['=change' => 'applyChanges', '=timed' => 1]);
|
||||||
CRM_Core_DAO::executeQuery("UPDATE civicrm_contact_category
|
CRM_Core_DAO::executeQuery("UPDATE civicrm_contact_category
|
||||||
SET category = next_category WHERE category <> next_category")->free();
|
SET category_definition_id = next_category
|
||||||
|
WHERE category_definition_id IS NULL OR category_definition_id <> next_category")->free();
|
||||||
Civi::log()->debug('', ['=pop' => 1]);
|
Civi::log()->debug('', ['=pop' => 1]);
|
||||||
|
|
||||||
$summary = CRM_Core_DAO::executeQuery("SELECT next_category, count(*) from civicrm_contact_category group by next_category")->fetchAll();
|
$summary = CRM_Core_DAO::executeQuery("SELECT next_category, count(*) from civicrm_contact_category GROUP BY next_category")->fetchAll();
|
||||||
$summary['changes'] = $n;
|
$summary['changes'] = $n;
|
||||||
$_ = memory_get_peak_usage(TRUE);
|
$_ = memory_get_peak_usage(TRUE);
|
||||||
$summary['memory_use'] = @round($_ / pow(1024, ($i = floor(log($_, 1024)))), 2) . ' ' . ['b', 'kb', 'mb', 'gb', 'tb', 'pb'][$i];
|
$summary['memory_use'] = @round($_ / pow(1024, ($i = floor(log($_, 1024)))), 2) . ' ' . ['b', 'kb', 'mb', 'gb', 'tb', 'pb'][$i];
|
||||||
|
@ -176,12 +190,14 @@ class Processor {
|
||||||
Civi::log()->debug('Resetting table', ['=' => 'start,timed']);
|
Civi::log()->debug('Resetting table', ['=' => 'start,timed']);
|
||||||
// clear out temp space.
|
// clear out temp space.
|
||||||
CRM_Core_DAO::executeQuery("UPDATE civicrm_contact_category SET next_category = 0;")->free();
|
CRM_Core_DAO::executeQuery("UPDATE civicrm_contact_category SET next_category = 0;")->free();
|
||||||
|
Civi::log()->debug('Resetting table stage 2');
|
||||||
// ensure we have all our contacts covered.
|
// ensure we have all our contacts covered.
|
||||||
// TODO: is it quicker to do a WHERE NOT EXISTS?
|
// Q: is it quicker to do a WHERE NOT EXISTS? A: nope.
|
||||||
CRM_Core_DAO::executeQuery(<<<SQL
|
CRM_Core_DAO::executeQuery(<<<SQL
|
||||||
INSERT IGNORE INTO civicrm_contact_category
|
INSERT INTO civicrm_contact_category
|
||||||
SELECT id, id contact_id, 0 as category, 0 next_category
|
SELECT id, id contact_id, NULL as category_definition_id, 0 next_category
|
||||||
FROM civicrm_contact
|
FROM civicrm_contact
|
||||||
|
WHERE NOT EXISTS (SELECT id FROM civicrm_contact_category WHERE id = civicrm_contact.id)
|
||||||
SQL)->free();
|
SQL)->free();
|
||||||
Civi::log()->debug('', ['=' => 'pop']);
|
Civi::log()->debug('', ['=' => 'pop']);
|
||||||
}
|
}
|
||||||
|
@ -205,6 +221,7 @@ class Processor {
|
||||||
WHERE next_category = 0
|
WHERE next_category = 0
|
||||||
SQL;
|
SQL;
|
||||||
CRM_Core_DAO::executeQuery($sql)->free();
|
CRM_Core_DAO::executeQuery($sql)->free();
|
||||||
|
Civi::log()->debug('', ['=' => 'pop']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,6 +229,7 @@ class Processor {
|
||||||
*/
|
*/
|
||||||
protected function assignCategoryFromSearch(array $cat) {
|
protected function assignCategoryFromSearch(array $cat) {
|
||||||
$search = $this->searchDetails[$cat['search_data']['saved_search_id']];
|
$search = $this->searchDetails[$cat['search_data']['saved_search_id']];
|
||||||
|
Civi::log()->debug("Doing $cat[id] $cat[label]", ['=' => 'timed', '=start' => "ss" . $cat['search_data']['saved_search_id']]);
|
||||||
|
|
||||||
$apiParams = $search['api_params'];
|
$apiParams = $search['api_params'];
|
||||||
if ($search['api_entity'] === 'Contact' && in_array('id', $apiParams['select'] ?? [])) {
|
if ($search['api_entity'] === 'Contact' && in_array('id', $apiParams['select'] ?? [])) {
|
||||||
|
@ -225,7 +243,7 @@ class Processor {
|
||||||
// We don't need them ordered.
|
// We don't need them ordered.
|
||||||
unset($apiParams['orderBy']);
|
unset($apiParams['orderBy']);
|
||||||
|
|
||||||
$contactIDs = civicrm_api4($search['api_entity'], $search['get'], $apiParams)->column($contactIdKey);
|
$contactIDs = civicrm_api4($search['api_entity'], 'get', $apiParams)->column($contactIdKey);
|
||||||
// Unsure if this batching is needed
|
// Unsure if this batching is needed
|
||||||
$batchSize = 10000;
|
$batchSize = 10000;
|
||||||
while ($batch = array_splice($contactIDs, 0, $batchSize)) {
|
while ($batch = array_splice($contactIDs, 0, $batchSize)) {
|
||||||
|
@ -241,6 +259,12 @@ class Processor {
|
||||||
SQL;
|
SQL;
|
||||||
CRM_Core_DAO::executeQuery($sql)->free();
|
CRM_Core_DAO::executeQuery($sql)->free();
|
||||||
}
|
}
|
||||||
|
Civi::log()->debug('', ['=' => 'pop']);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assignDefaultCategory(array $cat) {
|
||||||
|
$id = (int) $cat['id'];
|
||||||
|
CRM_Core_DAO::executeQuery("UPDATE civicrm_contact_category SET next_category = $id WHERE next_category = 0;")->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<div af-fieldset="" af-title="Contacts by Category">
|
<div af-fieldset="">
|
||||||
<af-field name="Contact_ContactCategory_contact_id_01.category" defn="{input_attrs: {multiple: true}}" />
|
<div class="af-container af-layout-inline af-container-style-pane" af-title="Filters">
|
||||||
<af-field name="contact_sub_type" defn="{input_attrs: {multiple: true}}" />
|
<af-field name="Contact_ContactCategory_contact_id_01.category_definition_id" defn="{search_operator: 'IN', input_attrs: {autoOpen: true, multiple: true}, security: 'FBAC', label: 'Category'}" />
|
||||||
|
<af-field name="display_name" defn="{search_operator: 'CONTAINS', input_attrs: {}, label: 'Name'}" />
|
||||||
|
</div>
|
||||||
<crm-search-display-table search-name="Contacts_by_category" display-name="Contacts_by_category_Table_1"></crm-search-display-table>
|
<crm-search-display-table search-name="Contacts_by_category" display-name="Contacts_by_category_Table_1"></crm-search-display-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
{
|
{
|
||||||
"type": "search",
|
"type": "search",
|
||||||
|
"requires": null,
|
||||||
|
"entity_type": null,
|
||||||
|
"join_entity": null,
|
||||||
"title": "Contacts by category",
|
"title": "Contacts by category",
|
||||||
"description": "Individuals only",
|
"description": "Individuals only",
|
||||||
"placement": [],
|
"placement": [],
|
||||||
|
"summary_contact_type": null,
|
||||||
|
"summary_weight": null,
|
||||||
"icon": "fa-tags",
|
"icon": "fa-tags",
|
||||||
"server_route": "civicrm/contact/search/category",
|
"server_route": "civicrm/contact/search/category",
|
||||||
|
"is_public": false,
|
||||||
"permission": [
|
"permission": [
|
||||||
"access CiviCRM"
|
"access CiviCRM"
|
||||||
],
|
],
|
||||||
"permission_operator": "AND",
|
"permission_operator": "AND",
|
||||||
|
"redirect": null,
|
||||||
|
"submit_enabled": true,
|
||||||
|
"submit_limit": null,
|
||||||
|
"create_submission": false,
|
||||||
|
"manual_processing": false,
|
||||||
|
"allow_verification_by_email": false,
|
||||||
|
"email_confirmation_template_id": null,
|
||||||
"navigation": {
|
"navigation": {
|
||||||
"parent": "Search",
|
"parent": "Search",
|
||||||
"label": "Contacts by category",
|
"label": "Contacts by category",
|
||||||
"weight": 0
|
"weight": 0
|
||||||
},
|
},
|
||||||
"modified_date": "2024-02-28 16:59:26",
|
"modified_date": "2025-02-25 14:51:17"
|
||||||
"requires": null,
|
|
||||||
"entity_type": null,
|
|
||||||
"join_entity": null,
|
|
||||||
"summary_contact_type": null,
|
|
||||||
"summary_weight": null,
|
|
||||||
"is_public": false,
|
|
||||||
"redirect": null,
|
|
||||||
"submit_enabled": true,
|
|
||||||
"submit_limit": null,
|
|
||||||
"create_submission": null,
|
|
||||||
"manual_processing": null,
|
|
||||||
"allow_verification_by_email": null,
|
|
||||||
"email_confirmation_template_id": null
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,21 @@
|
||||||
ctrl.moveIdx = null;
|
ctrl.moveIdx = null;
|
||||||
ctrl.categoryToEdit = null;
|
ctrl.categoryToEdit = null;
|
||||||
ctrl.categoryDefinitions = null;
|
ctrl.categoryDefinitions = null;
|
||||||
ctrl.categoryDefinitions = await crmApi4("ContactCategoryDefinition", 'get', { orderBy: { label: 'ASC' }, withLabels: true });
|
ctrl.categoryDefinitions = await crmApi4("ContactCategoryDefinition", 'get', { orderBy: { execution_order: 'ASC' }, withLabels: true });
|
||||||
|
// Ensure we have the minimum of what we need.
|
||||||
|
if (!ctrl.categoryDefinitions.find(c => c.search_type === 'default')) {
|
||||||
|
// There's no default one.
|
||||||
|
ctrl.categoryDefinitions.push({
|
||||||
|
id: 0,
|
||||||
|
execution_order: ctrl.categoryDefinitions.length,
|
||||||
|
label: '9999 ' + ts('Other'),
|
||||||
|
search_type: 'default',
|
||||||
|
search_data: {},
|
||||||
|
color: '#666666',
|
||||||
|
icon: 'fa-person-circle-question',
|
||||||
|
description: ts('Any contact not matching any of the categories is assigned this category.'),
|
||||||
|
})
|
||||||
|
}
|
||||||
updateOrders();
|
updateOrders();
|
||||||
console.log("Got", ctrl.categoryDefinitions);
|
console.log("Got", ctrl.categoryDefinitions);
|
||||||
|
|
||||||
|
@ -89,7 +103,7 @@
|
||||||
ctrl.categoryDefinitions.splice(idx, 0, item);
|
ctrl.categoryDefinitions.splice(idx, 0, item);
|
||||||
ctrl.moveIdx = null;
|
ctrl.moveIdx = null;
|
||||||
updateOrders();
|
updateOrders();
|
||||||
$ctrl.dirty = 'dirty';
|
ctrl.dirty = 'dirty';
|
||||||
};
|
};
|
||||||
|
|
||||||
ctrl.deleteCategory = idx => {
|
ctrl.deleteCategory = idx => {
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<button ng-if="$ctrl.moveIdx === null && row.deleted" ng-click="row.deleted = false;$ctrl.dirty = 'dirty';">
|
<button ng-if="$ctrl.moveIdx === null && row.deleted" ng-click="row.deleted = false;$ctrl.dirty = 'dirty';">
|
||||||
<i class="fa-trash crm-i"></i> {{ts('Un-Delete')}}
|
<i class="fa-trash crm-i"></i> {{ts('Un-Delete')}}
|
||||||
</button>
|
</button>
|
||||||
<button ng-if="$ctrl.moveIdx === null && !row.deleted" ng-click="$ctrl.moveIdx = idx"
|
<button ng-if="$ctrl.moveIdx === null && !row.deleted && row.search_type !== 'default'" ng-click="$ctrl.moveIdx = idx"
|
||||||
class="btn"
|
class="btn"
|
||||||
ng-disabled="$ctrl.categoryDefinitions.length === 1"
|
ng-disabled="$ctrl.categoryDefinitions.length === 1"
|
||||||
>
|
>
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
<i class="fa-circle-xmark crm-i"></i> {{ts('Cancel Move')}}
|
<i class="fa-circle-xmark crm-i"></i> {{ts('Cancel Move')}}
|
||||||
</button>
|
</button>
|
||||||
<button ng-click="$ctrl.moveTo(idx+1)" ng-show="$ctrl.moveIdx !== null && (idx === 0 && $ctrl.moveIdx > 0)" ><i class="fa-sort-up crm-i" ></i>{{ts('Before this')}}</button>
|
<button ng-click="$ctrl.moveTo(idx+1)" ng-show="$ctrl.moveIdx !== null && (idx === 0 && $ctrl.moveIdx > 0)" ><i class="fa-sort-up crm-i" ></i>{{ts('Before this')}}</button>
|
||||||
<button ng-click="$ctrl.moveTo(idx+1)" ng-show="$ctrl.moveIdx !== null && (idx + 1 < $ctrl.moveIdx || idx > $ctrl.moveIdx)"><i class="fa-sort-down crm-i" ></i>{{ts('After this')}}</button>
|
<button ng-click="$ctrl.moveTo(idx+1)" ng-show="$ctrl.moveIdx !== null && row.search_type !== 'default' && (idx + 1 < $ctrl.moveIdx || idx > $ctrl.moveIdx)"><i class="fa-sort-down crm-i" ></i>{{ts('After this')}}</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -113,6 +113,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div crm-ui-field="{name: 'cc.icon', title: ts('Icon')}" >
|
<div crm-ui-field="{name: 'cc.icon', title: ts('Icon')}" >
|
||||||
|
<!-- this seems buggy, doesn't update to show the icon given. -->
|
||||||
<input
|
<input
|
||||||
crm-ui-id="cc.icon"
|
crm-ui-id="cc.icon"
|
||||||
crm-ui-icon-picker
|
crm-ui-icon-picker
|
||||||
|
@ -130,7 +131,7 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div crm-ui-field="{name: 'cc.search_type', title: ts('How are contacts identified?')}" >
|
<div ng-if="cc.search_type !== 'default'" crm-ui-field="{name: 'cc.search_type', title: ts('How are contacts identified?')}" >
|
||||||
<select
|
<select
|
||||||
crm-ui-id="ci.search_type"
|
crm-ui-id="ci.search_type"
|
||||||
name="search_type"
|
name="search_type"
|
||||||
|
@ -161,7 +162,6 @@
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
>Cancel</button>
|
>Cancel</button>
|
||||||
<button ng-click="$ctrl.updateEditedThing()" >Done</button>
|
<button ng-click="$ctrl.updateEditedThing()" >Done</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
use CRM_Contactcats_ExtensionUtil as E;
|
|
||||||
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'name' => 'OptionValue_changed_contact_category',
|
|
||||||
'entity' => 'OptionValue',
|
|
||||||
'cleanup' => 'unused',
|
|
||||||
'update' => 'unmodified',
|
|
||||||
'params' => [
|
|
||||||
'version' => 4,
|
|
||||||
'values' => [
|
|
||||||
'option_group_id.name' => 'activity_type',
|
|
||||||
'label' => E::ts('Changed Contact Category'),
|
|
||||||
'name' => 'changed_contact_category',
|
|
||||||
'icon' => 'fa-tags',
|
|
||||||
],
|
|
||||||
'match' => [
|
|
||||||
'option_group_id',
|
|
||||||
'name',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
|
@ -1,83 +0,0 @@
|
||||||
<?php
|
|
||||||
use CRM_Contactcats_ExtensionUtil as E;
|
|
||||||
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'name' => 'SavedSearch_Contact_Category_Summary',
|
|
||||||
'entity' => 'SavedSearch',
|
|
||||||
'cleanup' => 'always',
|
|
||||||
'update' => 'unmodified',
|
|
||||||
'params' => [
|
|
||||||
'version' => 4,
|
|
||||||
'values' => [
|
|
||||||
'name' => 'Contact_Category_Summary',
|
|
||||||
'label' => E::ts('Contact Category Summary'),
|
|
||||||
'api_entity' => 'ContactCategory',
|
|
||||||
'api_params' => [
|
|
||||||
'version' => 4,
|
|
||||||
'select' => [
|
|
||||||
'category:label',
|
|
||||||
'COUNT(contact_id) AS COUNT_contact_id',
|
|
||||||
],
|
|
||||||
'orderBy' => [],
|
|
||||||
'where' => [],
|
|
||||||
'groupBy' => [
|
|
||||||
'category',
|
|
||||||
],
|
|
||||||
'join' => [],
|
|
||||||
'having' => [],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'match' => [
|
|
||||||
'name',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'SavedSearch_Contact_Category_Summary_SearchDisplay_Contact_Category_Summary',
|
|
||||||
'entity' => 'SearchDisplay',
|
|
||||||
'cleanup' => 'always',
|
|
||||||
'update' => 'unmodified',
|
|
||||||
'params' => [
|
|
||||||
'version' => 4,
|
|
||||||
'values' => [
|
|
||||||
'name' => 'Contact_Category_Summary',
|
|
||||||
'label' => E::ts('Contact Category Summary'),
|
|
||||||
'saved_search_id.name' => 'Contact_Category_Summary',
|
|
||||||
'type' => 'table',
|
|
||||||
'settings' => [
|
|
||||||
'description' => NULL,
|
|
||||||
'sort' => [],
|
|
||||||
'limit' => 0,
|
|
||||||
'pager' => FALSE,
|
|
||||||
'placeholder' => 5,
|
|
||||||
'columns' => [
|
|
||||||
[
|
|
||||||
'type' => 'field',
|
|
||||||
'key' => 'category:label',
|
|
||||||
'dataType' => 'Integer',
|
|
||||||
'label' => E::ts('Category'),
|
|
||||||
'sortable' => TRUE,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'type' => 'field',
|
|
||||||
'key' => 'COUNT_contact_id',
|
|
||||||
'dataType' => 'Integer',
|
|
||||||
'label' => E::ts('Count'),
|
|
||||||
'sortable' => TRUE,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'actions' => TRUE,
|
|
||||||
'classes' => [
|
|
||||||
'table',
|
|
||||||
'table-striped',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'match' => [
|
|
||||||
'saved_search_id',
|
|
||||||
'name',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
|
@ -19,11 +19,7 @@ return [
|
||||||
'id',
|
'id',
|
||||||
'contact_sub_type:label',
|
'contact_sub_type:label',
|
||||||
'display_name',
|
'display_name',
|
||||||
'Contact_ContactCategory_contact_id_01.category:label',
|
'Contact_ContactCategory_contact_id_01_ContactCategory_ContactCategoryDefinition_category_definition_id_01.label',
|
||||||
'Synopsis_Fields.Amount_of_last_contribution',
|
|
||||||
'Synopsis_Fields.Date_of_Last_Contribution',
|
|
||||||
'Synopsis_Fields.Total_Lifetime_Contributions',
|
|
||||||
'Synopsis_Fields.Total_count_of_contributions',
|
|
||||||
],
|
],
|
||||||
'orderBy' => [],
|
'orderBy' => [],
|
||||||
'where' => [
|
'where' => [
|
||||||
|
@ -43,6 +39,25 @@ return [
|
||||||
'=',
|
'=',
|
||||||
'Contact_ContactCategory_contact_id_01.contact_id',
|
'Contact_ContactCategory_contact_id_01.contact_id',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'Contact_ContactCategory_contact_id_01.id',
|
||||||
|
'=',
|
||||||
|
'id',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'ContactCategoryDefinition AS Contact_ContactCategory_contact_id_01_ContactCategory_ContactCategoryDefinition_category_definition_id_01',
|
||||||
|
'INNER',
|
||||||
|
[
|
||||||
|
'Contact_ContactCategory_contact_id_01.category_definition_id',
|
||||||
|
'=',
|
||||||
|
'Contact_ContactCategory_contact_id_01_ContactCategory_ContactCategoryDefinition_category_definition_id_01.id',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'Contact_ContactCategory_contact_id_01_ContactCategory_ContactCategoryDefinition_category_definition_id_01.id',
|
||||||
|
'=',
|
||||||
|
'Contact_ContactCategory_contact_id_01.category_definition_id',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'having' => [],
|
'having' => [],
|
||||||
|
@ -77,13 +92,6 @@ return [
|
||||||
'pager' => [],
|
'pager' => [],
|
||||||
'placeholder' => 5,
|
'placeholder' => 5,
|
||||||
'columns' => [
|
'columns' => [
|
||||||
[
|
|
||||||
'type' => 'field',
|
|
||||||
'key' => 'Contact_ContactCategory_contact_id_01.category:label',
|
|
||||||
'dataType' => 'Integer',
|
|
||||||
'label' => E::ts('Category'),
|
|
||||||
'sortable' => TRUE,
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'type' => 'field',
|
'type' => 'field',
|
||||||
'key' => 'display_name',
|
'key' => 'display_name',
|
||||||
|
@ -108,34 +116,10 @@ return [
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'type' => 'field',
|
'type' => 'field',
|
||||||
'key' => 'Synopsis_Fields.Total_Lifetime_Contributions',
|
'key' => 'Contact_ContactCategory_contact_id_01_ContactCategory_ContactCategoryDefinition_category_definition_id_01.label',
|
||||||
'dataType' => 'Money',
|
'dataType' => 'String',
|
||||||
'label' => E::ts('£ total'),
|
'label' => E::ts('Category'),
|
||||||
'sortable' => TRUE,
|
'sortable' => TRUE,
|
||||||
'alignment' => 'text-right',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'type' => 'field',
|
|
||||||
'key' => 'Synopsis_Fields.Total_count_of_contributions',
|
|
||||||
'dataType' => 'Integer',
|
|
||||||
'label' => E::ts('Count donations'),
|
|
||||||
'sortable' => TRUE,
|
|
||||||
'alignment' => 'text-right',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'type' => 'field',
|
|
||||||
'key' => 'Synopsis_Fields.Date_of_Last_Contribution',
|
|
||||||
'dataType' => 'Timestamp',
|
|
||||||
'label' => E::ts('Latest donation'),
|
|
||||||
'sortable' => TRUE,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'type' => 'field',
|
|
||||||
'key' => 'Synopsis_Fields.Amount_of_last_contribution',
|
|
||||||
'dataType' => 'Money',
|
|
||||||
'label' => E::ts('£ latest'),
|
|
||||||
'sortable' => TRUE,
|
|
||||||
'alignment' => 'text-right',
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'actions' => TRUE,
|
'actions' => TRUE,
|
||||||
|
@ -143,9 +127,11 @@ return [
|
||||||
'table-striped',
|
'table-striped',
|
||||||
],
|
],
|
||||||
'headerCount' => TRUE,
|
'headerCount' => TRUE,
|
||||||
|
'actions_display_mode' => 'menu',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'match' => [
|
'match' => [
|
||||||
|
'saved_search_id',
|
||||||
'name',
|
'name',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
|
@ -46,14 +46,22 @@ return [
|
||||||
'category_definition_id' => [
|
'category_definition_id' => [
|
||||||
'title' => E::ts('Category Definition'),
|
'title' => E::ts('Category Definition'),
|
||||||
'sql_type' => 'int unsigned',
|
'sql_type' => 'int unsigned',
|
||||||
'required' => TRUE,
|
'required' => FALSE,
|
||||||
'default' => 0,
|
'default' => NULL,
|
||||||
'input_type' => 'EntityRef',
|
// 'input_type' => 'EntityRef',
|
||||||
|
'input_type' => 'Select',
|
||||||
'entity_reference' => [
|
'entity_reference' => [
|
||||||
'entity' => 'ContactCategoryDefinition',
|
'entity' => 'ContactCategoryDefinition',
|
||||||
'key' => 'id',
|
'key' => 'id',
|
||||||
'on_delete' => 'CASCADE',
|
'on_delete' => 'CASCADE',
|
||||||
],
|
],
|
||||||
|
'pseudoconstant' => [
|
||||||
|
'prefetch' => TRUE,
|
||||||
|
'table' => 'civicrm_contact_category_definition',
|
||||||
|
'key_column' => 'id',
|
||||||
|
'label_column' => 'label',
|
||||||
|
'name_column' => 'id',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'next_category' => [
|
'next_category' => [
|
||||||
'title' => E::ts('Next Category'),
|
'title' => E::ts('Next Category'),
|
||||||
|
|
|
@ -10,6 +10,8 @@ return [
|
||||||
'title_plural' => E::ts('Contact Category Definitions'),
|
'title_plural' => E::ts('Contact Category Definitions'),
|
||||||
'description' => E::ts('Holds definition of a "Contact category"'),
|
'description' => E::ts('Holds definition of a "Contact category"'),
|
||||||
'log' => FALSE,
|
'log' => FALSE,
|
||||||
|
'label_field' => 'label',
|
||||||
|
'icon' => 'fa-tags',
|
||||||
],
|
],
|
||||||
'getFields' => fn() => [
|
'getFields' => fn() => [
|
||||||
'id' => [
|
'id' => [
|
||||||
|
@ -42,6 +44,7 @@ return [
|
||||||
// 'name' => 'title',
|
// 'name' => 'title',
|
||||||
'search' => E::ts('Search Kit search'),
|
'search' => E::ts('Search Kit search'),
|
||||||
'group' => E::ts('Group'),
|
'group' => E::ts('Group'),
|
||||||
|
'default' => E::ts('Default category'),
|
||||||
// Future:
|
// Future:
|
||||||
// 'sql' => E::ts('SQL template'),
|
// 'sql' => E::ts('SQL template'),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue