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()
|
||||
{
|
||||
if (! auth()->user()->hasPermission('view_all')) {
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
$this->loadOverallStats();
|
||||
$this->loadSentStats();
|
||||
$this->loadPlatformStats();
|
||||
@ -50,9 +54,9 @@ class LoadPostmarkStats extends Job
|
||||
$records = [];
|
||||
|
||||
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 {
|
||||
$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) {
|
||||
@ -95,17 +99,18 @@ class LoadPostmarkStats extends Job
|
||||
|
||||
private function loadSentStats() {
|
||||
$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 = [
|
||||
'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)),
|
||||
//'spam' => sprintf('%s | %s%%', $account->formatNumber($data->spamcomplaints), $account->formatNumber($data->spamcomplaintsrate, 3))
|
||||
];
|
||||
}
|
||||
|
||||
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;
|
||||
$str = '';
|
||||
$total = 0;
|
||||
@ -113,14 +118,15 @@ class LoadPostmarkStats extends Job
|
||||
$total = $data['desktop'] + $data['mobile'] + $data['webmail'];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
$str = '';
|
||||
$total = 0;
|
||||
@ -138,7 +144,7 @@ class LoadPostmarkStats extends Job
|
||||
arsort($clients);
|
||||
|
||||
foreach ($clients as $key => $val) {
|
||||
$percent = $val / $total * 100;
|
||||
$percent = $total ? ($val / $total * 100) : 0;
|
||||
if ($percent < 0.5) {
|
||||
continue;
|
||||
}
|
||||
|
@ -239,10 +239,12 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@if (Auth::user()->hasPermission('view_all'))
|
||||
<div id="progress-div" class="progress">
|
||||
<div class="progress-bar progress-bar-striped active" role="progressbar"
|
||||
aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
|
||||
</div>
|
||||
@endif
|
||||
<canvas id="chart-canvas" height="70px" style="background-color:white;padding:20px;display:none"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
@ -257,7 +259,7 @@
|
||||
<i class="glyphicon glyphicon-phone"></i> {{ trans('texts.platforms') }}
|
||||
</h3>
|
||||
</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>
|
||||
</div>
|
||||
@ -270,7 +272,7 @@
|
||||
<i class="glyphicon glyphicon-inbox"></i> {{ trans('texts.email_clients') }}
|
||||
</h3>
|
||||
</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>
|
||||
</div>
|
||||
|
@ -37,7 +37,7 @@
|
||||
@stop
|
||||
|
||||
@section('top-right')
|
||||
@if (config('services.postmark'))
|
||||
@if (auth()->user()->hasPermission('view_all') && auth()->user()->hasPermission('view_all'))
|
||||
{!! Button::normal(trans('texts.emails'))
|
||||
->asLinkTo(url('/reports/emails'))
|
||||
->appendIcon(Icon::create('envelope')) !!}
|
||||
|
Loading…
x
Reference in New Issue
Block a user