From 81968c07d5c5f6fb665125602444566f2aec5ad9 Mon Sep 17 00:00:00 2001 From: Stephen Ostrow Date: Thu, 12 Jan 2017 00:03:01 -0500 Subject: [PATCH] Enhance the Top Segments Dashboard widget to link to Segment's Contacts Changes the displayed number of Contacts in the list of Top Segments to be a link to the Contacts listing page filtered by that Segment --- .../LeadBundle/EventListener/DashboardSubscriber.php | 7 +++++-- app/bundles/LeadBundle/Model/ListModel.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/bundles/LeadBundle/EventListener/DashboardSubscriber.php b/app/bundles/LeadBundle/EventListener/DashboardSubscriber.php index ba6ba12fa50..ac9085df110 100644 --- a/app/bundles/LeadBundle/EventListener/DashboardSubscriber.php +++ b/app/bundles/LeadBundle/EventListener/DashboardSubscriber.php @@ -167,8 +167,9 @@ public function onWidgetDetailGenerate(WidgetDetailEvent $event) // Build table rows with links if ($lists) { foreach ($lists as &$list) { - $listUrl = $this->router->generate('mautic_segment_action', ['objectAction' => 'edit', 'objectId' => $list['id']]); - $row = [ + $listUrl = $this->router->generate('mautic_segment_action', ['objectAction' => 'edit', 'objectId' => $list['id']]); + $contactUrl = $this->router->generate('mautic_contact_index', ['search' => 'segment:'.$list['alias']]); + $row = [ [ 'value' => $list['name'], 'type' => 'link', @@ -176,6 +177,8 @@ public function onWidgetDetailGenerate(WidgetDetailEvent $event) ], [ 'value' => $list['leads'], + 'type' => 'link', + 'link' => $contactUrl, ], ]; $items[] = $row; diff --git a/app/bundles/LeadBundle/Model/ListModel.php b/app/bundles/LeadBundle/Model/ListModel.php index 81bf7e1e71e..9b5122f01e5 100644 --- a/app/bundles/LeadBundle/Model/ListModel.php +++ b/app/bundles/LeadBundle/Model/ListModel.php @@ -1022,7 +1022,7 @@ protected function batchSleep() public function getTopLists($limit = 10, $dateFrom = null, $dateTo = null, $filters = []) { $q = $this->em->getConnection()->createQueryBuilder(); - $q->select('COUNT(t.date_added) AS leads, ll.id, ll.name') + $q->select('COUNT(t.date_added) AS leads, ll.id, ll.name, ll.alias') ->from(MAUTIC_TABLE_PREFIX.'lead_lists_leads', 't') ->join('t', MAUTIC_TABLE_PREFIX.'lead_lists', 'll', 'll.id = t.leadlist_id') ->orderBy('leads', 'DESC')