1 (function(angular
, $, _
) {
4 angular
.module('crmSearchAdmin').component('crmSearchAdmin', {
8 templateUrl
: '~/crmSearchAdmin/crmSearchAdmin.html',
9 controller: function($scope
, $element
, $location
, $timeout
, crmApi4
, dialogService
, searchMeta
, formatForSelect2
) {
10 var ts
= $scope
.ts
= CRM
.ts(),
13 this.DEFAULT_AGGREGATE_FN
= 'GROUP_CONCAT';
15 this.selectedRows
= [];
16 this.limit
= CRM
.cache
.get('searchPageSize', 30);
18 this.displayTypes
= _
.indexBy(CRM
.crmSearchAdmin
.displayTypes
, 'name');
19 // After a search this.results is an object of result arrays keyed by page,
20 // Initially this.results is an empty string because 1: it's falsey (unlike an empty object) and 2: it doesn't throw an error if you try to access undefined properties (unlike null)
22 this.rowCount
= false;
23 this.allRowsSelected
= false;
24 // Have the filters (WHERE, HAVING, GROUP BY, JOIN) changed?
27 $scope
.controls
= {tab
: 'compose'};
28 $scope
.joinTypes
= [{k
: false, v
: ts('Optional')}, {k
: true, v
: ts('Required')}];
29 $scope
.groupOptions
= CRM
.crmSearchActions
.groupOptions
;
30 $scope
.entities
= formatForSelect2(CRM
.vars
.search
.schema
, 'name', 'title_plural', ['description', 'icon']);
32 editGroups
: CRM
.checkPerm('edit groups')
35 this.$onInit = function() {
36 this.entityTitle
= searchMeta
.getEntity(this.savedSearch
.api_entity
).title_plural
;
38 this.savedSearch
.displays
= this.savedSearch
.displays
|| [];
39 this.savedSearch
.groups
= this.savedSearch
.groups
|| [];
40 this.groupExists
= !!this.savedSearch
.groups
.length
;
42 if (!this.savedSearch
.id
) {
45 expr
: '$ctrl.savedSearch.api_params',
49 select
: getDefaultSelect(),
56 $scope
.$watchCollection('$ctrl.savedSearch.api_params.select', onChangeSelect
);
58 $scope
.$watch('$ctrl.savedSearch.api_params.where', onChangeFilters
, true);
60 if (this.paramExists('groupBy')) {
61 this.savedSearch
.api_params
.groupBy
= this.savedSearch
.api_params
.groupBy
|| [];
62 $scope
.$watchCollection('$ctrl.savedSearch.api_params.groupBy', onChangeFilters
);
65 if (this.paramExists('join')) {
66 this.savedSearch
.api_params
.join
= this.savedSearch
.api_params
.join
|| [];
67 $scope
.$watch('$ctrl.savedSearch.api_params.join', onChangeFilters
, true);
70 if (this.paramExists('having')) {
71 this.savedSearch
.api_params
.having
= this.savedSearch
.api_params
.having
|| [];
72 $scope
.$watch('$ctrl.savedSearch.api_params.having', onChangeFilters
, true);
75 $scope
.$watch('$ctrl.savedSearch', onChangeAnything
, true);
77 // After watcher runs for the first time and messes up the status, set it correctly
79 $scope
.status
= ctrl
.savedSearch
&& ctrl
.savedSearch
.id
? 'saved' : 'unsaved';
85 function onChangeAnything() {
86 $scope
.status
= 'unsaved';
89 this.save = function() {
93 $scope
.status
= 'saving';
94 var params
= _
.cloneDeep(ctrl
.savedSearch
),
97 if (ctrl
.groupExists
) {
98 chain
.groups
= ['Group', 'save', {defaults
: {saved_search_id
: '$id'}, records
: params
.groups
}];
100 } else if (params
.id
) {
101 apiCalls
.deleteGroup
= ['Group', 'delete', {where
: [['saved_search_id', '=', params
.id
]]}];
103 if (params
.displays
&& params
.displays
.length
) {
104 chain
.displays
= ['SearchDisplay', 'replace', {where
: [['saved_search_id', '=', '$id']], records
: params
.displays
}];
105 } else if (params
.id
) {
106 apiCalls
.deleteDisplays
= ['SearchDisplay', 'delete', {where
: [['saved_search_id', '=', params
.id
]]}];
108 delete params
.displays
;
109 apiCalls
.saved
= ['SavedSearch', 'save', {records
: [params
], chain
: chain
}, 0];
110 crmApi4(apiCalls
).then(function(results
) {
111 // After saving a new search, redirect to the edit url
112 if (!ctrl
.savedSearch
.id
) {
113 $location
.url('edit/' + results
.saved
.id
);
115 // Set new status to saved unless the user changed something in the interim
116 var newStatus
= $scope
.status
=== 'unsaved' ? 'unsaved' : 'saved';
117 if (results
.saved
.groups
&& results
.saved
.groups
.length
) {
118 ctrl
.savedSearch
.groups
[0].id
= results
.saved
.groups
[0].id
;
120 ctrl
.savedSearch
.displays
= results
.saved
.displays
|| [];
121 // Wait until after onChangeAnything to update status
122 $timeout(function() {
123 $scope
.status
= newStatus
;
128 this.paramExists = function(param
) {
129 return _
.includes(searchMeta
.getEntity(ctrl
.savedSearch
.api_entity
).params
, param
);
132 this.addDisplay = function(type
) {
133 ctrl
.savedSearch
.displays
.push({
137 $scope
.selectTab('display_' + (ctrl
.savedSearch
.displays
.length
- 1));
140 this.removeDisplay = function(index
) {
141 var display
= ctrl
.savedSearch
.displays
[index
];
143 display
.trashed
= !display
.trashed
;
144 if ($scope
.controls
.tab
=== ('display_' + index
) && display
.trashed
) {
145 $scope
.selectTab('compose');
146 } else if (!display
.trashed
) {
147 $scope
.selectTab('display_' + index
);
150 $scope
.selectTab('compose');
151 ctrl
.savedSearch
.displays
.splice(index
, 1);
155 this.addGroup = function() {
156 ctrl
.savedSearch
.groups
.push({
159 visibility
: 'User and User Admin Only',
162 ctrl
.groupExists
= true;
163 $scope
.selectTab('group');
166 $scope
.selectTab = function(tab
) {
167 if (tab
=== 'group') {
168 $scope
.smartGroupColumns
= searchMeta
.getSmartGroupColumns(ctrl
.savedSearch
.api_entity
, ctrl
.savedSearch
.api_params
);
169 var smartGroupColumns
= _
.map($scope
.smartGroupColumns
, 'id');
170 if (smartGroupColumns
.length
&& !_
.includes(smartGroupColumns
, ctrl
.savedSearch
.api_params
.select
[0])) {
171 ctrl
.savedSearch
.api_params
.select
.unshift(smartGroupColumns
[0]);
174 ctrl
.savedSearch
.api_params
.select
= _
.uniq(ctrl
.savedSearch
.api_params
.select
);
175 $scope
.controls
.tab
= tab
;
178 this.removeGroup = function() {
179 ctrl
.groupExists
= !ctrl
.groupExists
;
180 if (!ctrl
.groupExists
&& (!ctrl
.savedSearch
.groups
.length
|| !ctrl
.savedSearch
.groups
[0].id
)) {
181 ctrl
.savedSearch
.groups
.length
= 0;
183 if ($scope
.controls
.tab
=== 'group') {
184 $scope
.selectTab('compose');
188 $scope
.getJoinEntities = function() {
189 var joinEntities
= _
.transform(CRM
.vars
.search
.links
[ctrl
.savedSearch
.api_entity
], function(joinEntities
, link
) {
190 var entity
= searchMeta
.getEntity(link
.entity
);
193 id
: link
.entity
+ ' AS ' + link
.alias
,
194 text
: entity
.title_plural
,
195 description
: '(' + link
.alias
+ ')',
200 return {results
: joinEntities
};
203 $scope
.addJoin = function() {
204 // Debounce the onchange event using timeout
205 $timeout(function() {
206 if ($scope
.controls
.join
) {
207 ctrl
.savedSearch
.api_params
.join
= ctrl
.savedSearch
.api_params
.join
|| [];
208 ctrl
.savedSearch
.api_params
.join
.push([$scope
.controls
.join
, false]);
211 $scope
.controls
.join
= '';
215 $scope
.changeJoin = function(idx
) {
216 if (ctrl
.savedSearch
.api_params
.join
[idx
][0]) {
217 ctrl
.savedSearch
.api_params
.join
[idx
].length
= 2;
220 ctrl
.clearParam('join', idx
);
224 $scope
.changeGroupBy = function(idx
) {
225 if (!ctrl
.savedSearch
.api_params
.groupBy
[idx
]) {
226 ctrl
.clearParam('groupBy', idx
);
228 // Remove aggregate functions when no grouping
229 if (!ctrl
.savedSearch
.api_params
.groupBy
.length
) {
230 _
.each(ctrl
.savedSearch
.api_params
.select
, function(col
, pos
) {
231 if (_
.contains(col
, '(')) {
232 var info
= searchMeta
.parseExpr(col
);
233 if (info
.fn
.category
=== 'aggregate') {
234 ctrl
.savedSearch
.api_params
.select
[pos
] = info
.path
+ info
.suffix
;
241 function validate() {
246 if (!ctrl
.savedSearch
.label
) {
247 errorEl
= '#crm-saved-search-label';
248 label
= ts('Search Label');
249 errors
.push(ts('%1 is a required field.', {1: label
}));
251 if (ctrl
.groupExists
&& !ctrl
.savedSearch
.groups
[0].title
) {
252 errorEl
= '#crm-search-admin-group-title';
253 label
= ts('Group Title');
254 errors
.push(ts('%1 is a required field.', {1: label
}));
257 _
.each(ctrl
.savedSearch
.displays
, function(display
, index
) {
258 if (!display
.trashed
&& !display
.label
) {
259 errorEl
= '#crm-search-admin-display-label';
260 label
= ts('Display Label');
261 errors
.push(ts('%1 is a required field.', {1: label
}));
262 tab
= 'display_' + index
;
267 $scope
.selectTab(tab
);
269 $(errorEl
).crmError(errors
.join('<br>'), ts('Error Saving'), {expires
: 5000});
271 return !errors
.length
;
275 * Called when clicking on a column header
279 $scope
.setOrderBy = function(col
, $event
) {
280 var dir
= $scope
.getOrderBy(col
) === 'fa-sort-asc' ? 'DESC' : 'ASC';
281 if (!$event
.shiftKey
|| !ctrl
.savedSearch
.api_params
.orderBy
) {
282 ctrl
.savedSearch
.api_params
.orderBy
= {};
284 ctrl
.savedSearch
.api_params
.orderBy
[col
] = dir
;
291 * Returns crm-i icon class for a sortable column
295 $scope
.getOrderBy = function(col
) {
296 var dir
= ctrl
.savedSearch
.api_params
.orderBy
&& ctrl
.savedSearch
.api_params
.orderBy
[col
];
298 return 'fa-sort-' + dir
.toLowerCase();
300 return 'fa-sort disabled';
303 $scope
.addParam = function(name
) {
304 if ($scope
.controls
[name
] && !_
.contains(ctrl
.savedSearch
.api_params
[name
], $scope
.controls
[name
])) {
305 ctrl
.savedSearch
.api_params
[name
].push($scope
.controls
[name
]);
306 if (name
=== 'groupBy') {
307 // Expand the aggregate block
308 $timeout(function() {
309 $('#crm-search-build-group-aggregate.collapsed .collapsible-title').click();
313 $scope
.controls
[name
] = '';
316 // Deletes an item from an array param
317 this.clearParam = function(name
, idx
) {
318 ctrl
.savedSearch
.api_params
[name
].splice(idx
, 1);
321 // Prevent visual jumps in results table height during loading
322 function lockTableHeight() {
323 var $table
= $('.crm-search-results', $element
);
324 $table
.css('height', $table
.height());
327 function unlockTableHeight() {
328 $('.crm-search-results', $element
).css('height', '');
331 // Ensure all non-grouped columns are aggregated if using GROUP BY
332 function aggregateGroupByColumns() {
333 if (ctrl
.savedSearch
.api_params
.groupBy
.length
) {
334 _
.each(ctrl
.savedSearch
.api_params
.select
, function(col
, pos
) {
335 if (!_
.contains(col
, '(') && ctrl
.canAggregate(col
)) {
336 ctrl
.savedSearch
.api_params
.select
[pos
] = ctrl
.DEFAULT_AGGREGATE_FN
+ '(' + col
+ ')';
342 // Debounced callback for loadResults
343 function _loadResultsCallback() {
344 // Multiply limit to read 2 pages at once & save ajax requests
345 var params
= _
.merge(_
.cloneDeep(ctrl
.savedSearch
.api_params
), {debug
: true, limit
: ctrl
.limit
* 2});
346 // Select the ids of joined entities (helps with displaying links)
347 _
.each(params
.join
, function(join
) {
348 var idField
= join
[0].split(' AS ')[1] + '.id';
349 if (!_
.includes(params
.select
, idField
) && !ctrl
.canAggregate(idField
)) {
350 params
.select
.push(idField
);
354 $scope
.error
= false;
357 ctrl
.rowCount
= false;
359 if (ctrl
.rowCount
=== false) {
360 params
.select
.push('row_count');
362 params
.offset
= ctrl
.limit
* (ctrl
.page
- 1);
363 crmApi4(ctrl
.savedSearch
.api_entity
, 'get', params
).then(function(success
) {
367 if (ctrl
.rowCount
=== false) {
368 ctrl
.rowCount
= success
.count
;
370 ctrl
.debug
= success
.debug
;
371 // populate this page & the next
372 ctrl
.results
[ctrl
.page
] = success
.slice(0, ctrl
.limit
);
373 if (success
.length
> ctrl
.limit
) {
374 ctrl
.results
[ctrl
.page
+ 1] = success
.slice(ctrl
.limit
);
376 $scope
.loading
= false;
380 $scope
.loading
= false;
383 ctrl
.debug
= error
.debug
;
384 $scope
.error
= errorMsg(error
);
386 .finally(function() {
388 ctrl
.debug
.params
= JSON
.stringify(params
, null, 2);
389 if (ctrl
.debug
.timeIndex
) {
390 ctrl
.debug
.timeIndex
= Number
.parseFloat(ctrl
.debug
.timeIndex
).toPrecision(2);
396 var _loadResults
= _
.debounce(_loadResultsCallback
, 250);
398 function loadResults() {
399 $scope
.loading
= true;
400 aggregateGroupByColumns();
404 // What to tell the user when search returns an error from the server
405 // Todo: parse error codes and give helpful feedback.
406 function errorMsg(error
) {
407 return ts('Ensure all search critera are set correctly and try again.');
410 this.changePage = function() {
411 if (ctrl
.stale
|| !ctrl
.results
[ctrl
.page
]) {
417 this.refreshAll = function() {
419 ctrl
.selectedRows
.length
= 0;
423 // Refresh results while staying on current page.
424 this.refreshPage = function() {
430 $scope
.onClickSearch = function() {
431 if (ctrl
.autoSearch
) {
432 ctrl
.autoSearch
= false;
438 $scope
.onClickAuto = function() {
439 ctrl
.autoSearch
= !ctrl
.autoSearch
;
440 if (ctrl
.autoSearch
&& ctrl
.stale
) {
443 $('.crm-search-auto-toggle').blur();
446 $scope
.onChangeLimit = function() {
447 // Refresh only if search has already been run
448 if (ctrl
.autoSearch
|| ctrl
.results
) {
449 // Save page size in localStorage
450 CRM
.cache
.set('searchPageSize', ctrl
.limit
);
455 function onChangeSelect(newSelect
, oldSelect
) {
456 // When removing a column from SELECT, also remove from ORDER BY
457 _
.each(_
.difference(_
.keys(ctrl
.savedSearch
.api_params
.orderBy
), newSelect
), function(col
) {
458 delete ctrl
.savedSearch
.api_params
.orderBy
[col
];
460 // Re-arranging or removing columns doesn't merit a refresh, only adding columns does
461 if (!oldSelect
|| _
.difference(newSelect
, oldSelect
).length
) {
462 if (ctrl
.autoSearch
) {
473 function onChangeFilters() {
475 ctrl
.selectedRows
.length
= 0;
479 if (ctrl
.autoSearch
) {
484 $scope
.selectAllRows = function() {
486 if (ctrl
.allRowsSelected
) {
487 ctrl
.allRowsSelected
= false;
488 ctrl
.selectedRows
.length
= 0;
492 ctrl
.allRowsSelected
= true;
493 if (ctrl
.page
=== 1 && ctrl
.results
[1].length
< ctrl
.limit
) {
494 ctrl
.selectedRows
= _
.pluck(ctrl
.results
[1], 'id');
497 // If more than one page of results, use ajax to fetch all ids
498 $scope
.loadingAllRows
= true;
499 var params
= _
.cloneDeep(ctrl
.savedSearch
.api_params
);
500 params
.select
= ['id'];
501 crmApi4(ctrl
.savedSearch
.api_entity
, 'get', params
, ['id']).then(function(ids
) {
502 $scope
.loadingAllRows
= false;
503 ctrl
.selectedRows
= _
.toArray(ids
);
507 $scope
.selectRow = function(row
) {
508 var index
= ctrl
.selectedRows
.indexOf(row
.id
);
510 ctrl
.selectedRows
.push(row
.id
);
511 ctrl
.allRowsSelected
= (ctrl
.rowCount
=== ctrl
.selectedRows
.length
);
513 ctrl
.allRowsSelected
= false;
514 ctrl
.selectedRows
.splice(index
, 1);
518 $scope
.isRowSelected = function(row
) {
519 return ctrl
.allRowsSelected
|| _
.includes(ctrl
.selectedRows
, row
.id
);
522 this.getFieldLabel
= searchMeta
.getDefaultLabel
;
524 // Is a column eligible to use an aggregate function?
525 this.canAggregate = function(col
) {
526 // If the query does not use grouping, never
527 if (!ctrl
.savedSearch
.api_params
.groupBy
.length
) {
530 var info
= searchMeta
.parseExpr(col
);
531 // If the column is used for a groupBy, no
532 if (ctrl
.savedSearch
.api_params
.groupBy
.indexOf(info
.path
) > -1) {
535 // If the entity this column belongs to is being grouped by id, then also no
536 return ctrl
.savedSearch
.api_params
.groupBy
.indexOf(info
.prefix
+ 'id') < 0;
539 $scope
.formatResult = function(row
, col
) {
540 var info
= searchMeta
.parseExpr(col
),
541 key
= info
.fn
? (info
.fn
.name
+ ':' + info
.path
+ info
.suffix
) : col
,
543 if (info
.fn
&& info
.fn
.name
=== 'COUNT') {
546 // Output user-facing name/label fields as a link, if possible
547 if (info
.field
&& _
.includes(['display_name', 'title', 'label', 'subject'], info
.field
.name
) && !info
.fn
&& typeof value
=== 'string') {
548 var link
= getEntityUrl(row
, info
);
550 return '<a href="' + _
.escape(link
.url
) + '" title="' + _
.escape(link
.title
) + '">' + formatFieldValue(info
.field
, value
) + '</a>';
553 return formatFieldValue(info
.field
, value
);
556 // Attempts to construct a view url for a given entity
557 function getEntityUrl(row
, info
) {
558 var entity
= searchMeta
.getEntity(info
.field
.entity
),
559 path
= _
.result(_
.findWhere(entity
.paths
, {action
: 'view'}), 'path');
560 // Only proceed if the path metadata exists for this entity
562 // Replace tokens in the path (e.g. [id])
563 var tokens
= path
.match(/\[\w*]/g) || [],
564 replacements
= _
.transform(tokens
, function(replacements
, token
) {
565 var fieldName
= info
.prefix
+ token
.slice(1, token
.length
- 1);
566 if (row
[fieldName
]) {
567 replacements
.push(row
[fieldName
]);
570 // Only proceed if the row contains all the necessary data to resolve tokens
571 if (tokens
.length
=== replacements
.length
) {
572 _
.each(tokens
, function(token
, index
) {
573 path
= path
.replace(token
, replacements
[index
]);
575 return {url
: CRM
.url(path
), title
: path
.title
};
580 function formatFieldValue(field
, value
) {
581 var type
= field
.data_type
,
583 if (_
.isArray(value
)) {
584 return _
.map(value
, function(val
) {
585 return formatFieldValue(field
, val
);
588 if (value
&& (type
=== 'Date' || type
=== 'Timestamp') && /^\d{4}-\d{2}-\d{2}/.test(value
)) {
589 result
= CRM
.utils
.formatDate(value
, null, type
=== 'Timestamp');
591 else if (type
=== 'Boolean' && typeof value
=== 'boolean') {
592 result
= value
? ts('Yes') : ts('No');
594 else if (type
=== 'Money' && typeof value
=== 'number') {
595 result
= CRM
.formatMoney(value
);
597 return _
.escape(result
);
600 $scope
.fieldsForGroupBy = function() {
601 return {results
: getAllFields('', function(key
) {
602 return _
.contains(ctrl
.savedSearch
.api_params
.groupBy
, key
);
607 $scope
.fieldsForSelect = function() {
608 return {results
: getAllFields(':label', function(key
) {
609 return _
.contains(ctrl
.savedSearch
.api_params
.select
, key
);
614 $scope
.fieldsForWhere = function() {
615 return {results
: getAllFields(':name', _
.noop
)};
618 $scope
.fieldsForHaving = function() {
619 return {results
: _
.transform(ctrl
.savedSearch
.api_params
.select
, function(fields
, name
) {
620 fields
.push({id
: name
, text
: ctrl
.getFieldLabel(name
)});
624 $scope
.sortableColumnOptions
= {
626 handle
: '.crm-draggable',
627 update: function(e
, ui
) {
628 // Don't allow items to be moved to position 0 if locked
629 if (!ui
.item
.sortable
.dropindex
&& ctrl
.groupExists
) {
630 ui
.item
.sortable
.cancel();
635 // Sets the default select clause based on commonly-named fields
636 function getDefaultSelect() {
637 var whitelist
= ['id', 'name', 'subject', 'display_name', 'label', 'title'];
638 return _
.transform(searchMeta
.getEntity(ctrl
.savedSearch
.api_entity
).fields
, function(select
, field
) {
639 if (_
.includes(whitelist
, field
.name
) || _
.includes(field
.name
, '_type_id')) {
640 select
.push(field
.name
+ (field
.options
? ':label' : ''));
645 function getAllFields(suffix
, disabledIf
) {
646 function formatFields(entityName
, prefix
) {
647 return _
.transform(searchMeta
.getEntity(entityName
).fields
, function(result
, field
) {
649 id
: prefix
+ field
.name
+ (field
.options
? suffix
: ''),
651 description
: field
.description
653 if (disabledIf(item
.id
)) {
654 item
.disabled
= true;
660 var mainEntity
= searchMeta
.getEntity(ctrl
.savedSearch
.api_entity
),
662 text
: mainEntity
.title_plural
,
663 icon
: mainEntity
.icon
,
664 children
: formatFields(ctrl
.savedSearch
.api_entity
, '')
666 _
.each(ctrl
.savedSearch
.api_params
.join
, function(join
) {
667 var joinName
= join
[0].split(' AS '),
668 joinEntity
= searchMeta
.getEntity(joinName
[0]);
670 text
: joinEntity
.title_plural
+ ' (' + joinName
[1] + ')',
671 icon
: joinEntity
.icon
,
672 children
: formatFields(joinEntity
.name
, joinName
[1] + '.')
679 * Fetch pseudoconstants for main entity + joined entities
681 * Sets an optionsLoaded property on each entity to avoid duplicate requests
683 function loadFieldOptions() {
684 var mainEntity
= searchMeta
.getEntity(ctrl
.savedSearch
.api_entity
),
687 function enqueue(entity
) {
688 entity
.optionsLoaded
= false;
689 entities
[entity
.name
] = [entity
.name
, 'getFields', {
690 loadOptions
: ['id', 'name', 'label', 'description', 'color', 'icon'],
691 where
: [['options', '!=', false]],
693 }, {name
: 'options'}];
696 if (typeof mainEntity
.optionsLoaded
=== 'undefined') {
699 _
.each(ctrl
.savedSearch
.api_params
.join
, function(join
) {
700 var joinName
= join
[0].split(' AS '),
701 joinEntity
= searchMeta
.getEntity(joinName
[0]);
702 if (typeof joinEntity
.optionsLoaded
=== 'undefined') {
706 if (!_
.isEmpty(entities
)) {
707 crmApi4(entities
).then(function(results
) {
708 _
.each(results
, function(fields
, entityName
) {
709 var entity
= searchMeta
.getEntity(entityName
);
710 _
.each(fields
, function(options
, fieldName
) {
711 _
.find(entity
.fields
, {name
: fieldName
}).options
= options
;
713 entity
.optionsLoaded
= true;
722 })(angular
, CRM
.$, CRM
._
);