261 lines
10 KiB
PHP
261 lines
10 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', __('managementtools::lang.executive_cockpit'))
|
|
|
|
@section('content')
|
|
@include('managementtools::layouts.nav')
|
|
|
|
<section class="content no-print mt-page">
|
|
<div class="mt-page-header">
|
|
<h1><i class="fas fa-tachometer-alt" style="color:#2563eb;margin-left:8px;"></i> @lang('managementtools::lang.executive_cockpit')</h1>
|
|
<div>
|
|
@can('managementtools.board_view')
|
|
<a href="{{ $export_urls['board_pack'] }}" id="mt-board-pack-link" class="btn btn-primary" style="margin-left:8px;">
|
|
<i class="fas fa-book-open"></i> @lang('managementtools::lang.board_pack_pdf')
|
|
</a>
|
|
<a href="{{ $export_urls['pdf'] }}" id="mt-pdf-export-link" class="btn btn-default" style="margin-left:8px;">
|
|
<i class="fas fa-file-pdf"></i> @lang('managementtools::lang.export_pdf')
|
|
</a>
|
|
@if(!empty($export_urls['bi_exports']))
|
|
<a href="{{ $export_urls['bi_exports'] }}" class="btn btn-default" style="margin-left:8px;">
|
|
<i class="fas fa-file-export"></i> @lang('integrationhub::lang.exports')
|
|
</a>
|
|
@endif
|
|
@endcan
|
|
<div class="mt-cockpit-toolbar" style="display:inline-flex;flex-wrap:wrap;align-items:center;gap:6px;margin-left:8px;">
|
|
@foreach($date_presets as $preset)
|
|
<button type="button" class="btn btn-default btn-sm mt-range-preset" data-start="{{ $preset['start'] }}" data-end="{{ $preset['end'] }}">{{ $preset['label'] }}</button>
|
|
@endforeach
|
|
<button type="button" class="btn btn-default btn-sm" id="mt-cockpit-refresh">
|
|
<i class="fas fa-sync-alt"></i> @lang('managementtools::lang.refresh_data')
|
|
</button>
|
|
<label class="mt-cockpit-auto-refresh" style="margin:0;font-weight:500;">
|
|
<input type="checkbox" id="mt-cockpit-auto-refresh"> @lang('managementtools::lang.auto_refresh')
|
|
</label>
|
|
<small id="mt-cockpit-updated-at" class="text-muted"></small>
|
|
</div>
|
|
{!! Form::open(['url' => action([\Modules\ManagementTools\Http\Controllers\ExecutiveCockpitController::class, 'index']), 'method' => 'get', 'class' => 'form-inline', 'id' => 'mt-cockpit-filter-form']) !!}
|
|
<input type="hidden" name="tab" id="mt_cockpit_tab" value="{{ $active_tab }}">
|
|
<input type="hidden" id="mt_cockpit_content_url" value="{{ $content_url }}">
|
|
<input type="hidden" id="mt_cockpit_drill_tab_url" value="{{ $drill_tab_url }}">
|
|
<div class="form-group" style="margin-left:8px;">
|
|
{!! Form::label('start_date', __('managementtools::lang.start_date').':') !!}
|
|
{!! Form::text('start_date', $start_date, ['class' => 'form-control mt-datepicker', 'id' => 'mt_cockpit_start', 'readonly', 'autocomplete' => 'off']) !!}
|
|
</div>
|
|
<div class="form-group" style="margin-left:8px;">
|
|
{!! Form::label('end_date', __('managementtools::lang.end_date').':') !!}
|
|
{!! Form::text('end_date', $end_date, ['class' => 'form-control mt-datepicker', 'id' => 'mt_cockpit_end', 'readonly', 'autocomplete' => 'off']) !!}
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">@lang('managementtools::lang.filters')</button>
|
|
{!! Form::close() !!}
|
|
</div>
|
|
</div>
|
|
|
|
@include('managementtools::executive_cockpit.partials.content')
|
|
</section>
|
|
@endsection
|
|
|
|
@section('javascript')
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js"></script>
|
|
<script src="{{ asset('modules/managementtools/js/executive_cockpit_charts.js?v=' . $asset_v) }}"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
var autoRefreshTimer = null;
|
|
var autoRefreshKey = 'mt_cockpit_auto_refresh';
|
|
|
|
function loadDrillTab(tabKey) {
|
|
if (!tabKey) {
|
|
return;
|
|
}
|
|
|
|
var pane = $('#dd-' + tabKey);
|
|
var lazy = pane.find('.mt-drill-lazy');
|
|
if (!lazy.length || lazy.data('loaded') === 1 || lazy.data('loaded') === '1') {
|
|
if (window.MtExecutiveCockpitCharts) {
|
|
window.MtExecutiveCockpitCharts.resize();
|
|
}
|
|
return;
|
|
}
|
|
|
|
var baseUrl = $('#mt_cockpit_drill_tab_url').val() || $('#mt-cockpit-meta').data('drill-tab-url');
|
|
if (!baseUrl) {
|
|
return;
|
|
}
|
|
|
|
var form = $('#mt-cockpit-filter-form');
|
|
var ajaxUrl = baseUrl + '?' + form.serialize() + '&tab=' + encodeURIComponent(tabKey);
|
|
lazy.addClass('mt-is-loading');
|
|
|
|
$.get(ajaxUrl, function(responseHtml) {
|
|
if (!responseHtml) {
|
|
return;
|
|
}
|
|
lazy.html(responseHtml).data('loaded', 1);
|
|
if (typeof __currency_convert_recursively === 'function') {
|
|
__currency_convert_recursively(lazy);
|
|
}
|
|
if (window.MtExecutiveCockpitCharts) {
|
|
window.MtExecutiveCockpitCharts.initTab('mt-drill-chart-' + tabKey);
|
|
window.MtExecutiveCockpitCharts.resize();
|
|
}
|
|
}).always(function() {
|
|
lazy.removeClass('mt-is-loading');
|
|
});
|
|
}
|
|
|
|
function activateDrillTab(tabKey, shouldScroll) {
|
|
if (!tabKey) {
|
|
return;
|
|
}
|
|
|
|
var tabSelector = '.mt-drill-tabs a[href="#dd-' + tabKey + '"]';
|
|
if ($(tabSelector).length) {
|
|
$(tabSelector).tab('show');
|
|
$('#mt_cockpit_tab').val(tabKey);
|
|
}
|
|
|
|
if (shouldScroll && $('#mt-drilldown-center').length) {
|
|
$('html, body').animate({
|
|
scrollTop: $('#mt-drilldown-center').offset().top - 80
|
|
}, 250);
|
|
}
|
|
}
|
|
|
|
function applyCockpitMeta() {
|
|
var meta = $('#mt-cockpit-meta');
|
|
if (!meta.length) {
|
|
return;
|
|
}
|
|
|
|
if (meta.data('board-pack-url')) {
|
|
$('#mt-board-pack-link').attr('href', meta.data('board-pack-url'));
|
|
}
|
|
if (meta.data('pdf-url')) {
|
|
$('#mt-pdf-export-link').attr('href', meta.data('pdf-url'));
|
|
}
|
|
if (meta.data('updated-at')) {
|
|
$('#mt-cockpit-updated-at').text('@lang('managementtools::lang.last_updated'): ' + meta.data('updated-at'));
|
|
}
|
|
}
|
|
|
|
function initCockpitBindings() {
|
|
$('.mt-kpi-card--clickable, .mt-metric-box--clickable')
|
|
.off('click keypress')
|
|
.on('click keypress', function(e) {
|
|
if (e.type === 'keypress' && e.which !== 13 && e.which !== 32) {
|
|
return;
|
|
}
|
|
|
|
activateDrillTab($(this).data('drill-tab'), true);
|
|
});
|
|
|
|
$('.mt-open-drill-tab')
|
|
.off('click')
|
|
.on('click', function() {
|
|
activateDrillTab($(this).data('drill-tab'), true);
|
|
});
|
|
|
|
$('.mt-drill-tabs a[data-toggle="tab"]')
|
|
.off('shown.bs.tab')
|
|
.on('shown.bs.tab', function(e) {
|
|
var tabKey = $(e.target).data('tab-key');
|
|
if (tabKey) {
|
|
$('#mt_cockpit_tab').val(tabKey);
|
|
loadDrillTab(tabKey);
|
|
}
|
|
if (window.MtExecutiveCockpitCharts) {
|
|
window.MtExecutiveCockpitCharts.resize();
|
|
}
|
|
});
|
|
}
|
|
|
|
function initCockpitUi() {
|
|
if (typeof MtDate !== 'undefined') {
|
|
MtDate.initDatepicker('#mt_cockpit_start, #mt_cockpit_end');
|
|
}
|
|
if (typeof __currency_convert_recursively === 'function') {
|
|
__currency_convert_recursively($('body'));
|
|
}
|
|
initCockpitBindings();
|
|
applyCockpitMeta();
|
|
if (window.MtExecutiveCockpitCharts) {
|
|
setTimeout(function() {
|
|
window.MtExecutiveCockpitCharts.init();
|
|
window.MtExecutiveCockpitCharts.resize();
|
|
}, 60);
|
|
}
|
|
}
|
|
|
|
function loadCockpitContent(updateHistory) {
|
|
var form = $('#mt-cockpit-filter-form');
|
|
var pageUrl = form.attr('action') + '?' + form.serialize();
|
|
var contentUrl = $('#mt_cockpit_content_url').val();
|
|
var ajaxUrl = contentUrl + '?' + form.serialize();
|
|
var content = $('#mt-cockpit-content');
|
|
if (window.MtExecutiveCockpitCharts) {
|
|
window.MtExecutiveCockpitCharts.destroy();
|
|
}
|
|
content.addClass('mt-is-loading');
|
|
|
|
$.get(ajaxUrl, function(responseHtml) {
|
|
if (responseHtml && responseHtml.indexOf('mt-cockpit-content') !== -1) {
|
|
content.replaceWith(responseHtml);
|
|
activateDrillTab($('#mt_cockpit_tab').val(), false);
|
|
if (updateHistory) {
|
|
window.history.replaceState({}, '', pageUrl);
|
|
}
|
|
initCockpitUi();
|
|
} else {
|
|
window.location.href = pageUrl;
|
|
}
|
|
}).fail(function() {
|
|
window.location.href = pageUrl;
|
|
}).always(function() {
|
|
$('#mt-cockpit-content').removeClass('mt-is-loading');
|
|
});
|
|
}
|
|
|
|
function setupAutoRefresh() {
|
|
if (autoRefreshTimer) {
|
|
clearInterval(autoRefreshTimer);
|
|
autoRefreshTimer = null;
|
|
}
|
|
|
|
if ($('#mt-cockpit-auto-refresh').is(':checked')) {
|
|
autoRefreshTimer = setInterval(function() {
|
|
loadCockpitContent(false);
|
|
}, 300000);
|
|
}
|
|
}
|
|
|
|
$('#mt-cockpit-filter-form').on('submit', function(e) {
|
|
e.preventDefault();
|
|
loadCockpitContent(true);
|
|
});
|
|
|
|
$('.mt-range-preset').on('click', function() {
|
|
$('#mt_cockpit_start').val($(this).data('start'));
|
|
$('#mt_cockpit_end').val($(this).data('end'));
|
|
loadCockpitContent(true);
|
|
});
|
|
|
|
$('#mt-cockpit-refresh').on('click', function() {
|
|
loadCockpitContent(false);
|
|
});
|
|
|
|
$('#mt-cockpit-auto-refresh').on('change', function() {
|
|
localStorage.setItem(autoRefreshKey, $(this).is(':checked') ? '1' : '0');
|
|
setupAutoRefresh();
|
|
});
|
|
|
|
if (localStorage.getItem(autoRefreshKey) === '1') {
|
|
$('#mt-cockpit-auto-refresh').prop('checked', true);
|
|
}
|
|
|
|
initCockpitUi();
|
|
activateDrillTab(@json($active_tab), false);
|
|
setupAutoRefresh();
|
|
});
|
|
</script>
|
|
@endsection
|