mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on charts
This commit is contained in:
parent
e94e7cca80
commit
9d8f2f1ebf
@ -103,7 +103,8 @@ class ReportController extends BaseController
|
||||
$config = [
|
||||
'date_field' => $dateField,
|
||||
'status_ids' => request()->status_ids,
|
||||
'group_dates_by' => request()->group_dates_by,
|
||||
'group' => request()->group,
|
||||
'subgroup' => request()->subgroup,
|
||||
'document_filter' => request()->document_filter,
|
||||
'currency_type' => request()->currency_type,
|
||||
'export_format' => $format,
|
||||
@ -154,7 +155,8 @@ class ReportController extends BaseController
|
||||
|
||||
unset($options['start_date']);
|
||||
unset($options['end_date']);
|
||||
unset($options['group_dates_by']);
|
||||
unset($options['group']);
|
||||
unset($options['subgroup']);
|
||||
|
||||
$schedule = ScheduledReport::createNew();
|
||||
$schedule->config = json_encode($options);
|
||||
|
@ -73,7 +73,7 @@ class AbstractReport
|
||||
}
|
||||
|
||||
if (strpos($field, 'date') !== false) {
|
||||
$class[] = 'group-date-' . (isset($this->options['group_dates_by']) ? $this->options['group_dates_by'] : 'monthyear');
|
||||
$class[] = 'group-date-' . (isset($this->options['group']) ? $this->options['group'] : 'monthyear');
|
||||
} elseif (in_array($field, ['client', 'vendor', 'product', 'user', 'method', 'category', 'project'])) {
|
||||
$class[] = 'group-letter-100';
|
||||
} elseif (in_array($field, ['amount', 'paid', 'balance'])) {
|
||||
@ -163,7 +163,7 @@ class AbstractReport
|
||||
|
||||
public function chartGroupBy()
|
||||
{
|
||||
$groupBy = empty($this->options['group_dates_by']) ? 'day' : $this->options['group_dates_by'];
|
||||
$groupBy = empty($this->options['group']) ? 'day' : $this->options['group'];
|
||||
|
||||
if ($groupBy == 'monthyear') {
|
||||
$groupBy = 'month';
|
||||
@ -247,8 +247,22 @@ class AbstractReport
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function isLineChartEnabled()
|
||||
{
|
||||
return $this->options['group'];
|
||||
}
|
||||
|
||||
public function isPieChartEnabled()
|
||||
{
|
||||
return $this->options['subgroup'];
|
||||
}
|
||||
|
||||
public function getPieChartData()
|
||||
{
|
||||
if (! $this->isPieChartEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$datasets = [];
|
||||
$labels = [];
|
||||
$totals = [];
|
||||
|
@ -2764,6 +2764,8 @@ $LANG = array(
|
||||
'mobile' => 'Mobile',
|
||||
'desktop' => 'Desktop',
|
||||
'webmail' => 'Webmail',
|
||||
'group' => 'Group',
|
||||
'subgroup' => 'Subgroup',
|
||||
|
||||
);
|
||||
|
||||
|
@ -101,25 +101,30 @@ function loadPieChart(data) {
|
||||
}
|
||||
|
||||
|
||||
@if ($report->isLineChartEnabled())
|
||||
$(function() {
|
||||
var lineChartData = {!! json_encode($report->getLineChartData()) !!};
|
||||
loadLineChart(lineChartData);
|
||||
//console.log(chartData);
|
||||
|
||||
var pieChartData = {!! json_encode($report->getPieChartData()) !!};
|
||||
loadPieChart(pieChartData);
|
||||
console.log(pieChartData);
|
||||
if (pieChartData) {
|
||||
loadPieChart(pieChartData);
|
||||
}
|
||||
});
|
||||
@endif
|
||||
|
||||
</script>
|
||||
|
||||
@if ($report->isLineChartEnabled())
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-{{ $report->isPieChartEnabled() ? 6 : 12 }}">
|
||||
<canvas id="lineChartCanvas" style="background-color:white; padding:20px; width:100%; height: 250px;"></canvas>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-6" style="display:{{ $report->isPieChartEnabled() ? 'block' : 'none' }}">
|
||||
<canvas id="pieChartCanvas" style="background-color:white; padding:20px; width:100%; height: 250px;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
@endif
|
||||
|
@ -170,13 +170,15 @@
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
{!! Former::select('group_dates_by')
|
||||
->label('group_when_sorted')
|
||||
->addOption(trans('texts.disabled'), '')
|
||||
{!! Former::select('group')
|
||||
->addOption('', '')
|
||||
->addOption(trans('texts.day'), 'day')
|
||||
->addOption(trans('texts.month'), 'monthyear')
|
||||
->addOption(trans('texts.year'), 'year') !!}
|
||||
|
||||
{!! Former::select('subgroup')
|
||||
->addOption('', '') !!}
|
||||
|
||||
<div id="statusField" style="display:none">
|
||||
|
||||
<div class="form-group">
|
||||
@ -456,6 +458,36 @@
|
||||
$('#cancelSchduleButton').toggle(!! scheduledReportMap[reportType]);
|
||||
}
|
||||
|
||||
function setSubgroupOptions() {
|
||||
var reportType = $('#report_type').val();
|
||||
var $subgroup = $('#subgroup');
|
||||
|
||||
$subgroup.find('option').remove().end();
|
||||
$subgroup.append(new Option('', ''));
|
||||
|
||||
if (['client'].indexOf(reportType) == -1) {
|
||||
$subgroup.append(new Option("{{ trans('texts.client') }}", 'client'));
|
||||
}
|
||||
|
||||
$subgroup.append(new Option("{{ trans('texts.user') }}", 'user'));
|
||||
|
||||
if (['activity', 'expense'].indexOf(reportType) >= 0) {
|
||||
$subgroup.append(new Option("{{ trans('texts.category') }}", 'category'));
|
||||
}
|
||||
|
||||
if (reportType == 'aging') {
|
||||
$subgroup.append(new Option("{{ trans('texts.age') }}", 'age'));
|
||||
} else if (reportType == 'expense') {
|
||||
$subgroup.append(new Option("{{ trans('texts.vendor') }}", 'vendor'));
|
||||
} else if (reportType == 'payment') {
|
||||
$subgroup.append(new Option("{{ trans('texts.method') }}", 'method'));
|
||||
} else if (reportType == 'profit_and_loss') {
|
||||
$subgroup.append(new Option("{{ trans('texts.type') }}", 'type'));
|
||||
} else if (reportType == 'task') {
|
||||
$subgroup.append(new Option("{{ trans('texts.project') }}", 'project'));
|
||||
}
|
||||
}
|
||||
|
||||
var sumColumns = [];
|
||||
@foreach ($columns as $column => $class)
|
||||
sumColumns.push("{{ in_array($column, ['amount', 'paid', 'balance', 'cost', 'duration', 'tax', 'qty']) ? trans("texts.{$column}") : false }}");
|
||||
@ -491,19 +523,22 @@
|
||||
@if (! auth()->user()->hasFeature(FEATURE_REPORTS))
|
||||
return;
|
||||
@endif
|
||||
|
||||
var val = $('#report_type').val();
|
||||
setFiltersShown();
|
||||
setDocumentZipShown();
|
||||
setScheduleButton();
|
||||
setSubgroupOptions();
|
||||
|
||||
$('#scheduleButton').prop('disabled', $('#format').val() == 'zip');
|
||||
if (isStorageSupported()) {
|
||||
localStorage.setItem('last:report_type', val);
|
||||
}
|
||||
});
|
||||
|
||||
$('#group_dates_by').change(function() {
|
||||
$('#group').change(function() {
|
||||
if (isStorageSupported()) {
|
||||
localStorage.setItem('last:report_group', $('#group_dates_by').val());
|
||||
localStorage.setItem('last:report_group', $('#group').val());
|
||||
}
|
||||
});
|
||||
|
||||
@ -537,11 +572,11 @@
|
||||
}).maximizeSelect2Height();
|
||||
|
||||
$(".tablesorter-data").tablesorter({
|
||||
@if (! request()->group_dates_by)
|
||||
@if (! request()->group)
|
||||
sortList: [[0,0]],
|
||||
@endif
|
||||
theme: 'bootstrap',
|
||||
widgets: ['zebra', 'uitheme', 'filter'{!! request()->group_dates_by ? ", 'group'" : "" !!}, 'columnSelector'],
|
||||
widgets: ['zebra', 'uitheme', 'filter'{!! request()->group ? ", 'group'" : "" !!}, 'columnSelector'],
|
||||
headerTemplate : '{content} {icon}',
|
||||
@if ($report)
|
||||
dateFormat: '{{ $report->convertDateFormat() }}',
|
||||
@ -596,6 +631,7 @@
|
||||
setFiltersShown();
|
||||
setDocumentZipShown();
|
||||
setScheduleButton();
|
||||
setSubgroupOptions();
|
||||
}, 1);
|
||||
|
||||
if (isStorageSupported()) {
|
||||
@ -604,8 +640,8 @@
|
||||
$('#report_type').val(lastReportType);
|
||||
}
|
||||
var lastGroup = localStorage.getItem('last:report_group');
|
||||
if (group_dates_by) {
|
||||
$('#group_dates_by').val(lastGroup);
|
||||
if (lastGroup) {
|
||||
$('#group').val(lastGroup);
|
||||
}
|
||||
var lastDocumentFilter = localStorage.getItem('last:document_filter');
|
||||
if (lastDocumentFilter) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user