1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/resources/views/clients/statement.blade.php

207 lines
7.9 KiB
PHP
Raw Normal View History

2018-04-30 19:14:50 +02:00
@extends(! empty($extends) ? $extends : 'header')
2017-01-23 16:00:44 +01:00
@section('head')
@parent
<script src="{{ asset('js/daterangepicker.min.js') }}" type="text/javascript"></script>
<link href="{{ asset('css/daterangepicker.css') }}" rel="stylesheet" type="text/css"/>
2017-01-23 16:00:44 +01:00
@include('money_script')
2018-04-30 22:00:22 +02:00
@foreach ($account->getFontFolders() as $font)
2017-01-23 16:00:44 +01:00
<script src="{{ asset('js/vfs_fonts/'.$font.'.js') }}" type="text/javascript"></script>
@endforeach
<script src="{{ asset('pdf.built.js') }}?no_cache={{ NINJA_VERSION }}" type="text/javascript"></script>
<script>
2018-04-30 22:00:22 +02:00
var invoiceDesign = JSON.stringify({!! Utils::getFromCache($account->invoice_design_id ?: 1, 'invoiceDesigns')->pdfmake !!});
2017-01-23 16:00:44 +01:00
var invoiceFonts = {!! Cache::get('fonts') !!};
var statementStartDate = moment("{{ $startDate }}");
var statementEndDate = moment("{{ $endDate }}");
var dateRanges = {!! $account->present()->dateRangeOptions !!};
2017-01-23 16:00:44 +01:00
function getPDFString(cb) {
invoice.is_statement = true;
invoice.image = window.accountLogo;
invoice.features = {
2018-04-30 22:00:22 +02:00
customize_invoice_design:{{ $account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ? 'true' : 'false' }},
remove_created_by:{{ $account->hasFeature(FEATURE_REMOVE_CREATED_BY) ? 'true' : 'false' }},
invoice_settings:{{ $account->hasFeature(FEATURE_INVOICE_SETTINGS) ? 'true' : 'false' }}
2017-01-23 16:00:44 +01:00
};
2018-04-30 22:00:22 +02:00
generatePDF(invoice, invoiceDesign, true, cb);
2017-01-23 16:00:44 +01:00
}
$(function() {
if (isStorageSupported()) {
var lastRange = localStorage.getItem('last:statement_range');
var lastStatusId = localStorage.getItem('last:statement_status_id');
2018-05-01 17:08:37 +02:00
var lastShowPayments = localStorage.getItem('last:statement_show_payments');
var lastShowAging = localStorage.getItem('last:statement_show_aging');
lastRange = dateRanges[lastRange];
if (lastRange) {
statementStartDate = lastRange[0];
statementEndDate = lastRange[1];
}
if (lastStatusId) {
$('#status_id').val(lastStatusId);
2018-05-01 17:08:37 +02:00
}
if (lastShowPayments) {
$('#show_payments').prop('checked', true);
}
if (lastShowAging) {
$('#show_aging').prop('checked', true);
}
}
// Initialize date range selector
function cb(start, end, label) {
statementStartDate = start;
statementEndDate = end;
$('#reportrange span').html(start.format('{{ $account->getMomentDateFormat() }}') + ' - ' + end.format('{{ $account->getMomentDateFormat() }}'));
$('#start_date').val(start.format('YYYY-MM-DD'));
$('#end_date').val(end.format('YYYY-MM-DD'));
if (isStorageSupported() && label && label != "{{ trans('texts.custom_range') }}") {
localStorage.setItem('last:statement_range', label);
}
refreshData();
}
$('#reportrange').daterangepicker({
locale: {
2017-12-07 13:12:34 +01:00
format: "{{ $account->getMomentDateFormat() }}",
customRangeLabel: "{{ trans('texts.custom_range') }}",
applyLabel: "{{ trans('texts.apply') }}",
cancelLabel: "{{ trans('texts.cancel') }}",
},
startDate: statementStartDate,
endDate: statementEndDate,
linkedCalendars: false,
ranges: dateRanges,
}, cb);
cb(statementStartDate, statementEndDate);
2017-01-23 16:00:44 +01:00
});
function refreshData() {
var statusId = $('#status_id').val();
if (statusId == {{ INVOICE_STATUS_UNPAID }}) {
$('#reportrange').css('color', '#AAA');
$('#reportrange').css('pointer-events', 'none');
} else {
$('#reportrange').css('color', '#000');
$('#reportrange').css('pointer-events', 'auto');
}
2018-05-01 14:47:19 +02:00
var url = '/{{ request()->path() }}' +
2018-04-29 08:00:37 +02:00
'?status_id=' + statusId +
'&start_date=' + statementStartDate.format('YYYY-MM-DD') +
'&end_date=' + statementEndDate.format('YYYY-MM-DD') +
2018-04-29 16:27:55 +02:00
'&show_payments=' + ($('#show_payments').is(':checked') ? '1' : '') +
'&show_aging=' + ($('#show_aging').is(':checked') ? '1' : '') +
2018-04-29 08:00:37 +02:00
'&json=true';
$.get(url, function(response) {
invoice = currentInvoice = JSON.parse(response);
refreshPDF();
});
if (isStorageSupported()) {
localStorage.setItem('last:statement_status_id', $('#status_id').val());
2018-05-01 17:08:37 +02:00
localStorage.setItem('last:statement_show_payments', $('#show_payments').is(':checked') ? '1' : '');
localStorage.setItem('last:statement_show_aging', $('#show_aging').is(':checked') ? '1' : '');
}
}
2017-01-23 16:00:44 +01:00
function onDownloadClick() {
2018-04-30 22:00:22 +02:00
var doc = generatePDF(invoice, invoiceDesign, true);
2017-01-23 16:00:44 +01:00
doc.save("{{ str_replace(' ', '_', trim($client->getDisplayName())) . '-' . trans('texts.statement') }}" + '.pdf');
}
</script>
@stop
@section('content')
2018-04-30 19:14:50 +02:00
@if (empty($extends))
<div class="pull-right">
{!! Button::normal(trans('texts.download'))
->withAttributes(['onclick' => 'onDownloadClick()'])
->appendIcon(Icon::create('download-alt')) !!}
{!! Button::primary(trans('texts.view_client'))
->asLinkTo($client->present()->url) !!}
</div>
2017-01-23 16:00:44 +01:00
2018-04-30 19:14:50 +02:00
<ol class="breadcrumb pull-left">
<li>{{ link_to('/clients', trans('texts.clients')) }}</li>
<li class='active'>{{ $client->getDisplayName() }}</li>
</ol>
2017-01-23 16:00:44 +01:00
2018-04-30 19:14:50 +02:00
<p>&nbsp;</p>
<p>&nbsp;</p>
@endif
2017-01-23 16:00:44 +01:00
2018-04-30 19:42:53 +02:00
<div class="well" style="background: #eeeeee; padding-bottom:30px;">
<div class="pull-left">
{!! Former::inline_open()->onchange('refreshData()') !!}
2018-04-30 19:42:53 +02:00
{{ trans('texts.status') }}
2018-04-30 19:42:53 +02:00
&nbsp;&nbsp;
2018-04-30 19:42:53 +02:00
{!! Former::select('status_id')
->label('status')
2018-05-01 17:08:37 +02:00
->addOption(trans('texts.all'), 'false')
2018-04-30 19:42:53 +02:00
->addOption(trans('texts.unpaid'), INVOICE_STATUS_UNPAID)
2018-05-01 17:08:37 +02:00
->addOption(trans('texts.paid'), INVOICE_STATUS_PAID) !!}
2018-04-30 19:42:53 +02:00
&nbsp;&nbsp;&nbsp;&nbsp;
2018-04-30 19:42:53 +02:00
{{ trans('texts.date_range') }}
2018-04-30 19:42:53 +02:00
&nbsp;&nbsp;
2018-04-30 19:42:53 +02:00
<span id="reportrange" style="background: #f9f9f9; cursor: pointer; padding: 9px 14px; border: 1px solid #dfe0e1; margin-top: 0px;">
<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>&nbsp;
<span></span> <b class="caret"></b>
</span>
2018-04-30 19:42:53 +02:00
<div style="display:none">
{!! Former::text('start_date') !!}
{!! Former::text('end_date') !!}
</div>
2018-04-30 19:42:53 +02:00
&nbsp;&nbsp;&nbsp;&nbsp;
2018-04-29 08:00:37 +02:00
2018-04-30 19:42:53 +02:00
@if (empty($extends))
{!! Former::checkbox('show_payments')->text('show_payments') !!}
&nbsp;&nbsp;&nbsp;&nbsp;
{!! Former::checkbox('show_aging')->text('show_aging') !!}
@else
{!! Former::checkbox('show_payments')->text('show_payments')->inline() !!}
&nbsp;&nbsp;&nbsp;&nbsp;
{!! Former::checkbox('show_aging')->text('show_aging')->inline() !!}
@endif
2018-04-29 08:00:37 +02:00
2018-04-30 19:42:53 +02:00
{!! Former::close() !!}
2018-04-29 08:00:37 +02:00
2018-04-30 19:42:53 +02:00
</div>
2018-04-29 08:00:37 +02:00
2018-04-30 19:42:53 +02:00
@if (! empty($extends))
<div class="pull-right">
{!! Button::normal(trans('texts.download') . ' &nbsp; ')
->withAttributes(['onclick' => 'onDownloadClick()'])
->appendIcon(Icon::create('download-alt')) !!}
</div>
@endif
&nbsp;
</div>
2018-04-30 22:00:22 +02:00
@include('invoices.pdf', ['account' => $account])
2017-01-23 16:00:44 +01:00
@stop