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