mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on scheduled reports
This commit is contained in:
parent
ace4985d24
commit
5a17953c76
@ -76,11 +76,6 @@ class SendReminders extends Command
|
|||||||
|
|
||||||
$this->info('Done');
|
$this->info('Done');
|
||||||
|
|
||||||
if (\Utils::isNinjaDev()) {
|
|
||||||
$this->info('Stopping early on ninja dev');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($errorEmail = env('ERROR_EMAIL')) {
|
if ($errorEmail = env('ERROR_EMAIL')) {
|
||||||
\Mail::raw('EOM', function ($message) use ($errorEmail, $database) {
|
\Mail::raw('EOM', function ($message) use ($errorEmail, $database) {
|
||||||
$message->to($errorEmail)
|
$message->to($errorEmail)
|
||||||
|
@ -11,6 +11,7 @@ use Input;
|
|||||||
use Utils;
|
use Utils;
|
||||||
use View;
|
use View;
|
||||||
use Carbon;
|
use Carbon;
|
||||||
|
use Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ReportController.
|
* Class ReportController.
|
||||||
@ -133,22 +134,31 @@ class ReportController extends BaseController
|
|||||||
|
|
||||||
private function schedule($params, $options)
|
private function schedule($params, $options)
|
||||||
{
|
{
|
||||||
$options['report_type'] = $params['reportType'];
|
$validator = Validator::make(request()->all(), [
|
||||||
$options['range'] = request('range');
|
'frequency' => 'required|in:daily,weekly,biweekly,monthly',
|
||||||
$options['start_date_offset'] = $options['range'] ? '' : Carbon::parse($params['startDate'])->diffInDays(null, false); // null,false to get the relative/non-absolute diff
|
'send_date' => 'required',
|
||||||
$options['end_date_offset'] = $options['range'] ? '' : Carbon::parse($params['endDate'])->diffInDays(null, false);
|
]);
|
||||||
|
|
||||||
unset($options['start_date']);
|
if ($validator->fails()) {
|
||||||
unset($options['end_date']);
|
session()->now('message', trans('texts.scheduled_report_error'));
|
||||||
unset($options['group_dates_by']);
|
} else {
|
||||||
|
$options['report_type'] = $params['reportType'];
|
||||||
|
$options['range'] = request('range');
|
||||||
|
$options['start_date_offset'] = $options['range'] ? '' : Carbon::parse($params['startDate'])->diffInDays(null, false); // null,false to get the relative/non-absolute diff
|
||||||
|
$options['end_date_offset'] = $options['range'] ? '' : Carbon::parse($params['endDate'])->diffInDays(null, false);
|
||||||
|
|
||||||
$schedule = ScheduledReport::createNew();
|
unset($options['start_date']);
|
||||||
$schedule->config = json_encode($options);
|
unset($options['end_date']);
|
||||||
$schedule->frequency = request('frequency');
|
unset($options['group_dates_by']);
|
||||||
$schedule->send_date = Utils::toSqlDate(request('send_date'));
|
|
||||||
$schedule->save();
|
|
||||||
|
|
||||||
session()->now('message', trans('texts.created_scheduled_report'));
|
$schedule = ScheduledReport::createNew();
|
||||||
|
$schedule->config = json_encode($options);
|
||||||
|
$schedule->frequency = request('frequency');
|
||||||
|
$schedule->send_date = Utils::toSqlDate(request('send_date'));
|
||||||
|
$schedule->save();
|
||||||
|
|
||||||
|
session()->now('message', trans('texts.created_scheduled_report'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cancelSchdule()
|
private function cancelSchdule()
|
||||||
|
@ -99,25 +99,27 @@ class ExportReportResults extends Job
|
|||||||
$sheet->setAutoSize(true);
|
$sheet->setAutoSize(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$excel->sheet(trans("texts.totals"), function($sheet) use($report, $summary, $format) {
|
if (count($summary)) {
|
||||||
$sheet->setOrientation('landscape');
|
$excel->sheet(trans("texts.totals"), function($sheet) use($report, $summary, $format) {
|
||||||
$sheet->freezeFirstRow();
|
$sheet->setOrientation('landscape');
|
||||||
|
$sheet->freezeFirstRow();
|
||||||
|
|
||||||
if ($format == 'pdf') {
|
if ($format == 'pdf') {
|
||||||
$sheet->setAllBorders('thin');
|
$sheet->setAllBorders('thin');
|
||||||
}
|
}
|
||||||
$sheet->rows($summary);
|
$sheet->rows($summary);
|
||||||
|
|
||||||
// Styling header
|
// Styling header
|
||||||
$sheet->cells('A1:'.Utils::num2alpha(count($summary[0])-1).'1', function($cells) {
|
$sheet->cells('A1:'.Utils::num2alpha(count($summary[0])-1).'1', function($cells) {
|
||||||
$cells->setBackground('#777777');
|
$cells->setBackground('#777777');
|
||||||
$cells->setFontColor('#FFFFFF');
|
$cells->setFontColor('#FFFFFF');
|
||||||
$cells->setFontSize(13);
|
$cells->setFontSize(13);
|
||||||
$cells->setFontFamily('Calibri');
|
$cells->setFontFamily('Calibri');
|
||||||
$cells->setFontWeight('bold');
|
$cells->setFontWeight('bold');
|
||||||
|
});
|
||||||
|
$sheet->setAutoSize(true);
|
||||||
});
|
});
|
||||||
$sheet->setAutoSize(true);
|
}
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ class ActivityReport extends AbstractReport
|
|||||||
{
|
{
|
||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
|
|
||||||
$startDate = $this->startDate->format('Y-m-d');
|
$startDate = $this->startDate;;
|
||||||
$endDate = $this->endDate->format('Y-m-d');
|
$endDate = $this->endDate;
|
||||||
|
|
||||||
$activities = Activity::scope()
|
$activities = Activity::scope()
|
||||||
->with('client.contacts', 'user', 'invoice', 'payment', 'credit', 'task', 'expense', 'account')
|
->with('client.contacts', 'user', 'invoice', 'payment', 'credit', 'task', 'expense', 'account')
|
||||||
@ -32,7 +32,7 @@ class ActivityReport extends AbstractReport
|
|||||||
$activity->present()->createdAt,
|
$activity->present()->createdAt,
|
||||||
$client ? ($this->isExport ? $client->getDisplayName() : $client->present()->link) : '',
|
$client ? ($this->isExport ? $client->getDisplayName() : $client->present()->link) : '',
|
||||||
$activity->present()->user,
|
$activity->present()->user,
|
||||||
$activity->getMessage(),
|
$this->isExport ? strip_tags($activity->getMessage()) : $activity->getMessage(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2553,7 +2553,7 @@ $LANG = array(
|
|||||||
'created_scheduled_report' => 'Successfully scheduled report',
|
'created_scheduled_report' => 'Successfully scheduled report',
|
||||||
'deleted_scheduled_report' => 'Successfully canceled scheduled report',
|
'deleted_scheduled_report' => 'Successfully canceled scheduled report',
|
||||||
'scheduled_report_attached' => 'Your scheduled :type report is attached.',
|
'scheduled_report_attached' => 'Your scheduled :type report is attached.',
|
||||||
|
'scheduled_report_error' => 'Failed to create schedule report',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
@ -101,10 +101,11 @@
|
|||||||
|
|
||||||
{!! Former::open()->addClass('report-form')->rules(['start_date' => 'required', 'end_date' => 'required']) !!}
|
{!! Former::open()->addClass('report-form')->rules(['start_date' => 'required', 'end_date' => 'required']) !!}
|
||||||
|
|
||||||
|
|
||||||
<div style="display:none">
|
<div style="display:none">
|
||||||
{!! Former::text('action') !!}
|
{!! Former::text('action')->forceValue('') !!}
|
||||||
{!! Former::text('range') !!}
|
{!! Former::text('range')->forceValue('') !!}
|
||||||
{!! Former::text('scheduled_report_id') !!}
|
{!! Former::text('scheduled_report_id')->forceValue('') !!}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!! Former::populateField('start_date', $startDate) !!}
|
{!! Former::populateField('start_date', $startDate) !!}
|
||||||
@ -212,7 +213,7 @@
|
|||||||
->appendIcon(Icon::create('remove')) !!}
|
->appendIcon(Icon::create('remove')) !!}
|
||||||
|
|
||||||
{!! Button::primary(trans('texts.schedule'))
|
{!! Button::primary(trans('texts.schedule'))
|
||||||
->withAttributes(['id'=>'scheduleButton', 'onclick' => 'showScheduleModal()'])
|
->withAttributes(['id'=>'scheduleButton', 'onclick' => 'showScheduleModal()', 'style' => 'display:none'])
|
||||||
->appendIcon(Icon::create('time')) !!}
|
->appendIcon(Icon::create('time')) !!}
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
@ -433,6 +434,13 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#format').change(function() {
|
||||||
|
var val = $('#format').val();
|
||||||
|
if (isStorageSupported() && val != 'zip') {
|
||||||
|
localStorage.setItem('last:report_format', val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#report_type').change(function() {
|
$('#report_type').change(function() {
|
||||||
var val = $('#report_type').val();
|
var val = $('#report_type').val();
|
||||||
setFiltersShown();
|
setFiltersShown();
|
||||||
@ -498,6 +506,12 @@
|
|||||||
widgets: ['zebra', 'uitheme'],
|
widgets: ['zebra', 'uitheme'],
|
||||||
}).show();
|
}).show();
|
||||||
|
|
||||||
|
setFiltersShown();
|
||||||
|
setDocumentZipShown();
|
||||||
|
setTimeout(function() {
|
||||||
|
setScheduleButton();
|
||||||
|
}, 1);
|
||||||
|
|
||||||
if (isStorageSupported()) {
|
if (isStorageSupported()) {
|
||||||
var lastReportType = localStorage.getItem('last:report_type');
|
var lastReportType = localStorage.getItem('last:report_type');
|
||||||
if (lastReportType) {
|
if (lastReportType) {
|
||||||
@ -507,11 +521,13 @@
|
|||||||
if (lastDocumentFilter) {
|
if (lastDocumentFilter) {
|
||||||
$('#document_filter').val(lastDocumentFilter);
|
$('#document_filter').val(lastDocumentFilter);
|
||||||
}
|
}
|
||||||
|
var lastFormat = localStorage.getItem('last:report_format');
|
||||||
|
if (lastFormat) {
|
||||||
|
setTimeout(function() {
|
||||||
|
$('#format').val(lastFormat);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setFiltersShown();
|
|
||||||
setDocumentZipShown();
|
|
||||||
setScheduleButton();
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user