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

195 lines
7.0 KiB
PHP
Raw Normal View History

2017-01-23 16:00:44 +01:00
@extends('header')
@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')
@foreach (Auth::user()->account->getFontFolders() as $font)
<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>
var invoiceDesigns = {!! \App\Models\InvoiceDesign::getDesigns() !!};
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 = {
customize_invoice_design:{{ Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ? 'true' : 'false' }},
remove_created_by:{{ Auth::user()->hasFeature(FEATURE_REMOVE_CREATED_BY) ? 'true' : 'false' }},
invoice_settings:{{ Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS) ? 'true' : 'false' }}
};
var invoiceDesignId = parseInt(invoice.invoice_design_id);
// We don't currently support the hipster design to be used as a statement
if (invoiceDesignId == 8) {
invoiceDesignId = 1;
}
2017-01-23 16:00:44 +01:00
var invoiceDesign = _.findWhere(invoiceDesigns, {id: invoiceDesignId});
if (!invoiceDesign) {
invoiceDesign = invoiceDesigns[0];
}
2017-01-23 16:00:44 +01:00
generatePDF(invoice, invoiceDesign.javascript, true, cb);
}
$(function() {
if (isStorageSupported()) {
var lastRange = localStorage.getItem('last:statement_range');
var lastStatusId = localStorage.getItem('last:statement_status_id');
lastRange = dateRanges[lastRange];
if (lastRange) {
statementStartDate = lastRange[0];
statementEndDate = lastRange[1];
}
if (lastStatusId) {
$('#status_id').val(lastStatusId);
}
}
// 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-04-29 08:00:37 +02:00
var url = '{{ url('/clients/statement/' . $client->public_id) }}' +
'?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';
console.log(url);
$.get(url, function(response) {
invoice = currentInvoice = JSON.parse(response);
refreshPDF();
});
}
function onStatusChange() {
if (isStorageSupported()) {
localStorage.setItem('last:statement_status_id', $('#status_id').val());
}
}
2017-01-23 16:00:44 +01:00
function onDownloadClick() {
var doc = generatePDF(invoice, invoiceDesigns[0].javascript, true);
doc.save("{{ str_replace(' ', '_', trim($client->getDisplayName())) . '-' . trans('texts.statement') }}" + '.pdf');
}
</script>
@stop
@section('content')
<div class="pull-right">
2018-03-15 10:11:34 +01:00
{!! Button::normal(trans('texts.download'))
2017-01-23 16:00:44 +01:00
->withAttributes(['onclick' => 'onDownloadClick()'])
->appendIcon(Icon::create('download-alt')) !!}
{!! Button::primary(trans('texts.view_client'))
->asLinkTo($client->present()->url) !!}
</div>
<ol class="breadcrumb pull-left">
<li>{{ link_to('/clients', trans('texts.clients')) }}</li>
<li class='active'>{{ $client->getDisplayName() }}</li>
</ol>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="well" style="background: #eeeeee">
2018-04-29 08:00:37 +02:00
{!! Former::inline_open()->onchange('refreshData()') !!}
{{ trans('texts.status') }}
&nbsp;&nbsp;
{!! Former::select('status_id')
->onchange('onStatusChange()')
->label('status')
->addOption(trans('texts.unpaid'), INVOICE_STATUS_UNPAID)
->addOption(trans('texts.paid'), INVOICE_STATUS_PAID)
->addOption(trans('texts.all'), 'false') !!}
&nbsp;&nbsp;&nbsp;&nbsp;
{{ trans('texts.date_range') }}
&nbsp;&nbsp;
<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>
<div style="display:none">
{!! Former::text('start_date') !!}
{!! Former::text('end_date') !!}
</div>
2018-04-29 08:00:37 +02:00
&nbsp;&nbsp;&nbsp;&nbsp;
{!! Former::checkbox('show_payments')
->text('show_payments') !!}
&nbsp;&nbsp;&nbsp;&nbsp;
{!! Former::checkbox('show_aging')
->text('show_aging')!!}
{!! Former::close() !!}
</div>
2017-01-23 16:00:44 +01:00
@include('invoices.pdf', ['account' => Auth::user()->account, 'pdfHeight' => 800])
@stop