mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
working on email stats
This commit is contained in:
parent
e97a35f916
commit
26c1799043
@ -27,6 +27,10 @@ class LoadPostmarkStats extends Job
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
if (! auth()->user()->hasPermission('view_all')) {
|
||||||
|
return $this->response;
|
||||||
|
}
|
||||||
|
|
||||||
$this->loadOverallStats();
|
$this->loadOverallStats();
|
||||||
$this->loadSentStats();
|
$this->loadSentStats();
|
||||||
$this->loadPlatformStats();
|
$this->loadPlatformStats();
|
||||||
@ -50,9 +54,9 @@ class LoadPostmarkStats extends Job
|
|||||||
$records = [];
|
$records = [];
|
||||||
|
|
||||||
if ($eventType == 'sent') {
|
if ($eventType == 'sent') {
|
||||||
$response = $this->postmark->getOutboundSendStatistics(null, request()->start_date, request()->end_date);
|
$response = $this->postmark->getOutboundSendStatistics($this->account->account_key, request()->start_date, request()->end_date);
|
||||||
} else {
|
} else {
|
||||||
$response = $this->postmark->getOutboundOpenStatistics(null, request()->start_date, request()->end_date);
|
$response = $this->postmark->getOutboundOpenStatistics($this->account->account_key, request()->start_date, request()->end_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($response->days as $key => $val) {
|
foreach ($response->days as $key => $val) {
|
||||||
@ -95,17 +99,18 @@ class LoadPostmarkStats extends Job
|
|||||||
|
|
||||||
private function loadSentStats() {
|
private function loadSentStats() {
|
||||||
$account = $this->account;
|
$account = $this->account;
|
||||||
$data = $this->postmark->getOutboundOverviewStatistics(null, request()->start_date, request()->end_date);
|
$data = $this->postmark->getOutboundOverviewStatistics($this->account->account_key, request()->start_date, request()->end_date);
|
||||||
|
$percent = $data->sent ? ($data->uniqueopens / $data->sent * 100) : 0;
|
||||||
$this->response->totals = [
|
$this->response->totals = [
|
||||||
'sent' => $account->formatNumber($data->sent),
|
'sent' => $account->formatNumber($data->sent),
|
||||||
'opened' => sprintf('%s | %s%%', $account->formatNumber($data->uniqueopens), $account->formatNumber($data->uniqueopens / $data->sent * 100)),
|
'opened' => sprintf('%s | %s%%', $account->formatNumber($data->uniqueopens), $account->formatNumber($percent)),
|
||||||
'bounced' => sprintf('%s | %s%%', $account->formatNumber($data->bounced), $account->formatNumber($data->bouncerate, 3)),
|
'bounced' => sprintf('%s | %s%%', $account->formatNumber($data->bounced), $account->formatNumber($data->bouncerate, 3)),
|
||||||
//'spam' => sprintf('%s | %s%%', $account->formatNumber($data->spamcomplaints), $account->formatNumber($data->spamcomplaintsrate, 3))
|
//'spam' => sprintf('%s | %s%%', $account->formatNumber($data->spamcomplaints), $account->formatNumber($data->spamcomplaintsrate, 3))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadPlatformStats() {
|
private function loadPlatformStats() {
|
||||||
$data = $this->postmark->getOutboundPlatformStatistics(null, request()->start_date, request()->end_date);
|
$data = $this->postmark->getOutboundPlatformStatistics($this->account->account_key, request()->start_date, request()->end_date);
|
||||||
$account = $this->account;
|
$account = $this->account;
|
||||||
$str = '';
|
$str = '';
|
||||||
$total = 0;
|
$total = 0;
|
||||||
@ -113,14 +118,15 @@ class LoadPostmarkStats extends Job
|
|||||||
$total = $data['desktop'] + $data['mobile'] + $data['webmail'];
|
$total = $data['desktop'] + $data['mobile'] + $data['webmail'];
|
||||||
|
|
||||||
foreach (['mobile', 'desktop', 'webmail'] as $platform) {
|
foreach (['mobile', 'desktop', 'webmail'] as $platform) {
|
||||||
$str .= sprintf('<tr><td>%s</td><td>%s%%</td></tr>', trans('texts.' . $platform), $account->formatNumber($data[$platform] / $total * 100));
|
$percent = $total ? ($data[$platform] / $total * 100) : 0;
|
||||||
|
$str .= sprintf('<tr><td>%s</td><td>%s%%</td></tr>', trans('texts.' . $platform), $account->formatNumber($percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->platforms = $str;
|
$this->response->platforms = $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadEmailClientStats() {
|
private function loadEmailClientStats() {
|
||||||
$data = $this->postmark->getOutboundEmailClientStatistics(null, request()->start_date, request()->end_date);
|
$data = $this->postmark->getOutboundEmailClientStatistics($this->account->account_key, request()->start_date, request()->end_date);
|
||||||
$account = $this->account;
|
$account = $this->account;
|
||||||
$str = '';
|
$str = '';
|
||||||
$total = 0;
|
$total = 0;
|
||||||
@ -138,7 +144,7 @@ class LoadPostmarkStats extends Job
|
|||||||
arsort($clients);
|
arsort($clients);
|
||||||
|
|
||||||
foreach ($clients as $key => $val) {
|
foreach ($clients as $key => $val) {
|
||||||
$percent = $val / $total * 100;
|
$percent = $total ? ($val / $total * 100) : 0;
|
||||||
if ($percent < 0.5) {
|
if ($percent < 0.5) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -239,10 +239,12 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@if (Auth::user()->hasPermission('view_all'))
|
||||||
<div id="progress-div" class="progress">
|
<div id="progress-div" class="progress">
|
||||||
<div class="progress-bar progress-bar-striped active" role="progressbar"
|
<div class="progress-bar progress-bar-striped active" role="progressbar"
|
||||||
aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
|
aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
<canvas id="chart-canvas" height="70px" style="background-color:white;padding:20px;display:none"></canvas>
|
<canvas id="chart-canvas" height="70px" style="background-color:white;padding:20px;display:none"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -257,7 +259,7 @@
|
|||||||
<i class="glyphicon glyphicon-phone"></i> {{ trans('texts.platforms') }}
|
<i class="glyphicon glyphicon-phone"></i> {{ trans('texts.platforms') }}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body" style="height:260px;overflow-y:auto;">
|
<div class="panel-body" style="height:280px;overflow-y:auto;">
|
||||||
<table class="table table-striped" id="platformsTable">
|
<table class="table table-striped" id="platformsTable">
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -270,7 +272,7 @@
|
|||||||
<i class="glyphicon glyphicon-inbox"></i> {{ trans('texts.email_clients') }}
|
<i class="glyphicon glyphicon-inbox"></i> {{ trans('texts.email_clients') }}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body" style="height:260px;overflow-y:auto;">
|
<div class="panel-body" style="height:280px;overflow-y:auto;">
|
||||||
<table class="table table-striped" id="emailClientsTable">
|
<table class="table table-striped" id="emailClientsTable">
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
@stop
|
@stop
|
||||||
|
|
||||||
@section('top-right')
|
@section('top-right')
|
||||||
@if (config('services.postmark'))
|
@if (auth()->user()->hasPermission('view_all') && auth()->user()->hasPermission('view_all'))
|
||||||
{!! Button::normal(trans('texts.emails'))
|
{!! Button::normal(trans('texts.emails'))
|
||||||
->asLinkTo(url('/reports/emails'))
|
->asLinkTo(url('/reports/emails'))
|
||||||
->appendIcon(Icon::create('envelope')) !!}
|
->appendIcon(Icon::create('envelope')) !!}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user