display subscribers count in segments selection
This commit is contained in:
@ -75,6 +75,9 @@ define(
|
||||
filter: function(segment) {
|
||||
return !!(!segment.deleted_at && segment.type === 'default');
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
return segment.name + ' ('+ segment.subscribers +')';
|
||||
},
|
||||
getSearchLabel: function(segment, subscriber) {
|
||||
let label = '';
|
||||
|
||||
|
@ -259,7 +259,7 @@ class Menu {
|
||||
|
||||
$data = array(
|
||||
'settings' => $settings,
|
||||
'segments' => Segment::getPublic()->findArray(),
|
||||
'segments' => Segment::getSegmentsWithSubscriberCount(),
|
||||
'cron_trigger' => CronTrigger::getAvailableMethods(),
|
||||
'pages' => Pages::getAll(),
|
||||
'flags' => $flags,
|
||||
@ -303,7 +303,7 @@ class Menu {
|
||||
$data = array();
|
||||
|
||||
$data['items_per_page'] = $this->getLimitPerPage('subscribers');
|
||||
$data['segments'] = Segment::findArray();
|
||||
$data['segments'] = Segment::getSegmentsWithSubscriberCount($type = false);
|
||||
|
||||
$data['custom_fields'] = array_map(function($field) {
|
||||
$field['params'] = unserialize($field['params']);
|
||||
@ -416,7 +416,7 @@ class Menu {
|
||||
$data = array(
|
||||
'form' => $form,
|
||||
'pages' => Pages::getAll(),
|
||||
'segments' => Segment::getPublic()->findArray(),
|
||||
'segments' => Segment::getSegmentsWithSubscriberCount(),
|
||||
'styles' => FormRenderer::getStyles($form),
|
||||
'date_types' => Block\Date::getDateTypes(),
|
||||
'date_formats' => Block\Date::getDateFormats(),
|
||||
|
@ -143,7 +143,13 @@ class Segment extends Model {
|
||||
$query = self::selectMany(array(self::$_table.'.id', self::$_table.'.name'))
|
||||
->selectExpr(
|
||||
self::$_table.'.*, ' .
|
||||
'COUNT(IF('.MP_SUBSCRIBER_SEGMENT_TABLE.'.status="' . Subscriber::STATUS_SUBSCRIBED .'" AND '.MP_SUBSCRIBERS_TABLE.'.deleted_at IS NULL,1,NULL)) `subscribers`'
|
||||
'COUNT(IF('.
|
||||
MP_SUBSCRIBER_SEGMENT_TABLE.'.status="'.Subscriber::STATUS_SUBSCRIBED.'"'
|
||||
.' AND '.
|
||||
MP_SUBSCRIBERS_TABLE.'.deleted_at IS NULL'
|
||||
.' AND '.
|
||||
MP_SUBSCRIBERS_TABLE.'.status="'.Subscriber::STATUS_SUBSCRIBED.'"'
|
||||
.', 1, NULL)) `subscribers`'
|
||||
)
|
||||
->leftOuterJoin(
|
||||
MP_SUBSCRIBER_SEGMENT_TABLE,
|
||||
|
@ -58,7 +58,7 @@
|
||||
required
|
||||
>
|
||||
<% for segment in segments %>
|
||||
<option value="<%= segment.id %>"><%= segment.name %></option>
|
||||
<option value="<%= segment.id %>"><%= segment.name %> (<%= segment.subscribers %>)</option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
</div>
|
||||
|
@ -132,7 +132,7 @@
|
||||
<% if(segment.id in settings.subscribe.on_comment.segments) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= segment.name %></option>
|
||||
><%= segment.name %> (<%= segment.subscribers %>)</option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
</p>
|
||||
@ -196,7 +196,7 @@
|
||||
<% if(segment.id in settings.subscribe.on_register.segments) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= segment.name %></option>
|
||||
><%= segment.name %> (<%= segment.subscribers %>)</option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
</p>
|
||||
@ -257,7 +257,7 @@
|
||||
<% if(segment.id in settings.subscription.segments) %>
|
||||
selected="selected"
|
||||
<% endif %>
|
||||
><%= segment.name %></option>
|
||||
><%= segment.name %> (<%= segment.subscribers %>)</option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
</p>
|
||||
@ -330,7 +330,7 @@
|
||||
multiple
|
||||
>
|
||||
<% for segment in segments %>
|
||||
<option value="<%= segment.id %>"><%= segment.name %></option>
|
||||
<option value="<%= segment.id %>"><%= segment.name %> (<%= segment.subscribers %>)</option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
</p>
|
||||
@ -366,7 +366,7 @@
|
||||
multiple
|
||||
>
|
||||
<% for segment in segments %>
|
||||
<option value="<%= segment.id %>"><%= segment.name %></option>
|
||||
<option value="<%= segment.id %>"><%= segment.name %> (<%= segment.subscribers %>)</option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
</p>
|
||||
|
Reference in New Issue
Block a user