1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/resources/views/portal/default/invoices/index.blade.php

272 lines
8.1 KiB
PHP
Raw Normal View History

2019-07-23 05:31:53 +02:00
@extends('portal.default.layouts.master')
@section('header')
@parent
2019-08-05 01:42:20 +02:00
<link href="//cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css"/>
<link href="/vendors/css/select2.min.css" rel="stylesheet">
2019-07-23 05:31:53 +02:00
@stop
@section('body')
2019-08-21 01:17:46 +02:00
<main class="main">
<div class="container-fluid">
{!! Former::framework('TwitterBootstrap4'); !!}
{!! Former::horizontal_open()
->id('payment_form')
->route('client.invoices.bulk')
->method('POST'); !!}
{!! Former::hidden('hashed_ids')->id('hashed_ids') !!}
{!! Former::hidden('action')->id('action') !!}
{!! Former::close() !!}
<div class="row" style="padding-top: 30px;">
2019-10-08 04:03:40 +02:00
@include('portal.default.flash-message')
2019-08-21 01:17:46 +02:00
<div class="col-lg-12" style="padding-bottom: 10px;">
<div class="pull-left">
<div class="btn-group">
<button type="button" class="btn btn-success" id="pay_invoices">{{ ctrans('texts.pay_now') }}</button>
<button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" id="pay_invoices_drop" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" id="download_invoices">{{ctrans('texts.download_pdf')}}</a>
</div>
2019-07-29 05:59:28 +02:00
</div>
2019-08-21 01:17:46 +02:00
<select class="form-control" style="width: 220px;" id="statuses" name="client_status[]" multiple="multiple">
<option value="paid">{{ ctrans('texts.status_paid') }}</option>
<option value="unpaid">{{ ctrans('texts.status_unpaid') }}</option>
<option value="overdue">{{ ctrans('texts.overdue') }}</option>
</select>
2019-07-27 07:46:51 +02:00
2019-08-21 01:17:46 +02:00
</div>
2019-07-25 06:51:00 +02:00
2019-08-21 01:17:46 +02:00
<!-- Filters / Buttons in here.-->
<div id="top_right_buttons" class="pull-right">
2019-07-25 06:51:00 +02:00
2019-08-21 01:17:46 +02:00
<input id="table_filter" type="text" style="width:180px;background-color: white !important"
class="form-control pull-left" placeholder="{{ trans('texts.filter')}}" value=""/>
2019-07-23 05:31:53 +02:00
</div>
2019-09-26 07:14:07 +02:00
</div>
2019-07-29 05:59:28 +02:00
2019-09-26 07:14:07 +02:00
</div>
2019-08-21 01:17:46 +02:00
2019-09-26 07:14:07 +02:00
<div class="row">
<div class="animated fadeIn col-lg-12 card mt-10">
2019-08-21 01:17:46 +02:00
2019-09-26 07:14:07 +02:00
{!! $html->table(['class' => 'table table-hover table-striped', 'id' => 'datatable'], true) !!}
2019-07-23 05:31:53 +02:00
2019-09-26 07:14:07 +02:00
</div>
</div>
2019-08-21 01:17:46 +02:00
</div>
</main>
2019-07-23 05:31:53 +02:00
</body>
@endsection
2019-07-26 00:05:13 +02:00
@push('scripts')
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="//cdn.datatables.net/1.10.18/js/dataTables.bootstrap4.min.js"></script>
2019-08-05 01:42:20 +02:00
<script src="/vendors/js/select2.min.js"></script>
2019-07-27 07:46:51 +02:00
<script>
2019-07-30 00:28:38 +02:00
2019-07-30 13:08:39 +02:00
/*global json payload*/
2019-07-30 00:28:38 +02:00
var data;
2019-07-30 13:08:39 +02:00
/*status filter variable - comma separated*/
var client_statuses;
2019-08-04 21:59:28 +02:00
var table_filter;
var data_table;
2019-07-27 07:46:51 +02:00
$(function() {
2019-07-30 00:28:38 +02:00
2019-08-04 21:59:28 +02:00
data_table = $('#datatable').DataTable({
2019-07-27 07:46:51 +02:00
processing: true,
serverSide: true,
searching: false,
bLengthChange: false,
language: {
processing: " {{ trans('texts.processing_request') }}",
search: "{{ trans('texts.search') }}:",
// info: "{{ trans('texts.info') }}",
infoPostFix: "",
loadingRecords: "{{ trans('texts.loading') }}",
zeroRecords: "{{ trans('texts.no_records_found') }}"
},
2019-07-30 13:08:39 +02:00
ajax: {
url: '{!! route('client.invoices.index') !!}',
data: function(data) {
2019-07-30 13:21:17 +02:00
data.client_status = client_statuses;
2019-08-05 01:31:55 +02:00
data.filter = table_filter;
2019-07-30 13:08:39 +02:00
}
},
2019-07-30 00:28:38 +02:00
drawCallback: function(settings){
data = this.api().ajax.json().data;
},
2019-07-27 07:46:51 +02:00
columns: [
2019-08-28 07:19:36 +02:00
{data: 'checkbox', name: 'checkbox', title: '<input type="checkbox" class="select_all" >', searchable: false, orderable: false},
{data: 'number', name: 'number', title: '{{ctrans('texts.invoice_number')}}', visible: true},
{data: 'date', name: 'date', title: '{{ctrans('texts.invoice_date')}}', visible: true},
{data: 'amount', name: 'amount', title: '{{ctrans('texts.total')}}', visible: true},
{data: 'balance', name: 'balance', title: '{{ctrans('texts.balance')}}', visible: true},
{data: 'due_date', name: 'due_date', title: '{{ctrans('texts.due_date')}}', visible: true},
{data: 'status_id', name: 'status_id', title: '{{ctrans('texts.status')}}', visible: true},
2019-10-08 06:04:35 +02:00
{data: 'action', name: 'action', title: '', searchable: false, orderable: false, width: '10%'},
2019-07-27 07:46:51 +02:00
]
});
});
2019-07-30 00:28:38 +02:00
</script>
2019-07-29 05:59:28 +02:00
<script>
2019-08-14 05:22:47 +02:00
var searchTimeout = false;
var selected = [];
2019-07-29 05:59:28 +02:00
2019-07-30 00:28:38 +02:00
$(document).ready(function() {
2019-07-29 05:59:28 +02:00
2019-08-14 05:22:47 +02:00
toggleButtonGroup();
2019-07-30 08:10:31 +02:00
2019-08-28 07:19:36 +02:00
$('#datatable').on('click', '.odd, .even' ,function(e) {
if($(e.target).is(':checkbox')) return; //ignore when click on the checkbox
2019-07-30 08:10:31 +02:00
2019-08-28 07:19:36 +02:00
var $cb= $(this).find('input[type="checkbox"]');
$cb.prop('checked', !$cb.is(':checked'));
buildCheckboxArray();
});
$("#datatable").on('change', 'input[type=checkbox]', function() {
buildCheckboxArray();
2019-07-30 00:28:38 +02:00
});
2019-07-29 05:59:28 +02:00
2019-07-30 00:28:38 +02:00
$('#table_filter').on('keyup', function(){
2019-08-04 21:59:28 +02:00
if (searchTimeout) {
window.clearTimeout(searchTimeout);
}
searchTimeout = setTimeout(function() {
filterTable();
}, 500);
2019-07-30 00:28:38 +02:00
});
2019-07-29 05:59:28 +02:00
$('.select_all').change(function() {
$(this).closest('table').find(':checkbox:not(:disabled)').prop('checked', this.checked);
});
$('#pay_invoices').click(function() {
$('#pay_invoices').addClass('disabled');
$('#pay_invoices_drop').addClass('disabled');
$('#download_invoices').addClass('disabled');
2019-08-14 12:23:44 +02:00
$('#hashed_ids').val(selected);
2019-08-15 06:31:03 +02:00
$('#action').val('payment');
2019-08-14 12:23:44 +02:00
$('#payment_form').submit();
2019-07-30 00:28:38 +02:00
});
$('#download_invoices').click(function() {
$('#hashed_ids').val(selected);
$('#action').val('download');
$('#payment_form').submit();
2019-07-30 00:28:38 +02:00
});
2019-08-14 05:22:47 +02:00
});
2019-08-28 07:19:36 +02:00
function buildCheckboxArray()
{
selected = [];
$.each($("input[name='hashed_ids[]']:checked"), function(){
selected.push($(this).val());
});
toggleButtonGroup();
}
2019-08-14 05:22:47 +02:00
function toggleButtonGroup()
{
if(selected.length == 0)
{
$('#pay_invoices').addClass('disabled');
$('#pay_invoices_drop').addClass('disabled');
$('#download_invoices').addClass('disabled');
}
else
{
$('#pay_invoices').removeClass('disabled');
$('#pay_invoices_drop').removeClass('disabled');
$('#download_invoices').removeClass('disabled');
}
}
2019-07-30 00:28:38 +02:00
2019-08-04 21:59:28 +02:00
function filterTable() {
table_filter = $('#table_filter').val();
data_table.ajax.reload();
}
2019-08-05 04:02:32 +02:00
function payInvoice(hashed_id) {
$('#pay_invoices_drop').addClass('disabled');
$('#download_invoices').addClass('disabled');
$('#hashed_ids').val(hashed_id);
$('#action').val('payment');
$('#payment_form').submit();
}
2019-08-05 04:02:32 +02:00
// Setup status filter
$('#statuses').select2({
placeholder: "{{ ctrans('texts.status') }}",
//allowClear: true,
templateSelection: function(data, container) {
if (data.id == 'paid') {
2019-08-14 04:16:09 +02:00
$(container).css('color', '#fff');
$(container).css('background-color', '#00c979');
$(container).css('border-color', '#00a161');
} else if (data.id == 'unpaid') {
2019-08-05 04:02:32 +02:00
$(container).css('color', '#fff');
$(container).css('background-color', '#f0ad4e');
$(container).css('border-color', '#eea236');
2019-08-14 04:16:09 +02:00
} else if (data.id == 'overdue') {
2019-08-05 04:02:32 +02:00
$(container).css('color', '#fff');
$(container).css('background-color', '#d9534f');
2019-08-14 04:16:09 +02:00
$(container).css('border-color', '#d43f3a');
2019-08-05 04:02:32 +02:00
}
return data.text;
}
}).on('change', function() {
client_statuses = $('#statuses').val();
if (client_statuses) {
client_statuses = client_statuses.join(',');
} else {
client_statuses = '';
}
data_table.ajax.reload();
2019-08-05 04:02:32 +02:00
});
2019-07-27 07:46:51 +02:00
</script>
2019-08-21 01:17:46 +02:00
@endpush
2019-07-27 07:46:51 +02:00