Skip to content

Commit

Permalink
Updated the filter options.
Browse files Browse the repository at this point in the history
  • Loading branch information
shinde-rahul committed Sep 15, 2023
1 parent 468238b commit 101bc69
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions EventListener/LeadSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ public function onListChoicesGenerate(LeadListFiltersChoicesEvent $event)

$eventNamesWithAny = array_merge(
[
'-' => '-',
'any' => $event->getTranslator()->trans('plugin.citrix.event.'.$product.'.any'),
'-' => '-',
$event->getTranslator()->trans('plugin.citrix.event.'.$product.'.any') => 'any',
],
$eventNames
);
Expand All @@ -198,8 +198,8 @@ public function onListChoicesGenerate(LeadListFiltersChoicesEvent $event)
'list' => $eventNamesWithAny,
],
'operators' => [
'in' => $event->getTranslator()->trans('mautic.core.operator.in'),
'!in' => $event->getTranslator()->trans('mautic.core.operator.notin'),
$event->getTranslator()->trans('mautic.core.operator.in') => 'in',
$event->getTranslator()->trans('mautic.core.operator.notin') => '!in',
],
]
);
Expand All @@ -215,8 +215,8 @@ public function onListChoicesGenerate(LeadListFiltersChoicesEvent $event)
'list' => $eventNamesWithAny,
],
'operators' => [
'in' => $event->getTranslator()->trans('mautic.core.operator.in'),
'!in' => $event->getTranslator()->trans('mautic.core.operator.notin'),
$event->getTranslator()->trans('mautic.core.operator.in') => 'in',
$event->getTranslator()->trans('mautic.core.operator.notin') => '!in',
],
]
);
Expand All @@ -231,7 +231,7 @@ public function onListChoicesGenerate(LeadListFiltersChoicesEvent $event)
'list' => $eventNamesWithoutAny,
],
'operators' => [
'in' => $event->getTranslator()->trans('mautic.core.operator.in'),
$event->getTranslator()->trans('mautic.core.operator.in') => 'in',
],
]
);
Expand Down Expand Up @@ -268,12 +268,17 @@ public function onListFiltering(LeadListFilteringEvent $event)

if (in_array($currentFilter, $eventFilters, true)) {
$eventNames = $details['filter'];
preg_match('#^([^ ]+ +[^ ]+) +(.*)$#', $eventNames, $matches);
$eventNames = $this->model->getIdByNameAndDate($matches[2], $matches[1]);
if (!$eventNames) {
break;

$isAnyEvent = in_array('any', $eventNames, true);
if (!$isAnyEvent) {
preg_match('#^([^ ]+ +[^ ]+) +(.*)$#', $eventNames, $matches);
$eventNames = $this->model->getIdByNameAndDate($matches[2], $matches[1]);

if (!$eventNames) {
break;
}
}
$isAnyEvent = in_array('any', $eventNames, true);

$subQueriesSQL = [];

$eventTypes = [GoToEventTypes::REGISTERED, GoToEventTypes::ATTENDED];
Expand Down Expand Up @@ -313,21 +318,21 @@ public function onListFiltering(LeadListFilteringEvent $event)
switch ($currentFilter) {
case $product.'-registration':
$event->setSubQuery(
sprintf('%s (%s)', 'including' === $func ? 'EXISTS' : 'NOT EXISTS',
sprintf('%s (%s)', 'in' === $func ? 'EXISTS' : 'NOT EXISTS',
$subQueriesSQL[GoToEventTypes::REGISTERED])
);
break;

case $product.'-attendance':
$event->setSubQuery(
sprintf('%s (%s)', 'including' === $func ? 'EXISTS' : 'NOT EXISTS',
sprintf('%s (%s)', 'in' === $func ? 'EXISTS' : 'NOT EXISTS',
$subQueriesSQL[GoToEventTypes::ATTENDED])
);
break;

case $product.'-no-attendance':
$queries = [
sprintf('%s (%s)', 'including' === $func ? 'NOT EXISTS' : 'EXISTS',
sprintf('%s (%s)', 'in' === $func ? 'NOT EXISTS' : 'EXISTS',
$subQueriesSQL[GoToEventTypes::ATTENDED]),
];

Expand Down

0 comments on commit 101bc69

Please sign in to comment.