1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 07:33:04 +01:00
invoiceninja/resources/views/datatable.blade.php

103 lines
3.4 KiB
PHP
Raw Normal View History

2015-05-10 21:02:35 +02:00
<table class="table table-striped data-table {{ $class = str_random(8) }}">
2015-03-16 22:45:25 +01:00
<colgroup>
@for ($i = 0; $i < count($columns); $i++)
<col class="con{{ $i }}" />
@endfor
</colgroup>
<thead>
<tr>
@foreach($columns as $i => $c)
2016-03-02 14:36:42 +01:00
<th align="center" valign="middle" class="head{{ $i }}"
2015-03-16 22:45:25 +01:00
@if ($c == 'checkbox')
2016-03-02 14:36:42 +01:00
style="width:20px"
2015-03-16 22:45:25 +01:00
@endif
>
@if ($c == 'checkbox' && $hasCheckboxes = true)
<input type="checkbox" class="selectAll"/>
@else
{{ $c }}
@endif
</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach($data as $d)
<tr>
@foreach($d as $dd)
<td>{{ $dd }}</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
<script type="text/javascript">
@if (isset($values['clientId']) && $values['clientId'])
2015-11-29 17:00:50 +01:00
window.load_{{ $values['entityType'] }} = function load_{{ $values['entityType'] }}() {
load_{{ $class }}();
}
@else
jQuery(document).ready(function(){
load_{{ $class }}();
});
@endif
function refreshDatatable() {
window.dataTable.api().ajax.reload();
}
2015-11-29 17:00:50 +01:00
function load_{{ $class }}() {
window.dataTable = jQuery('.{{ $class }}').dataTable({
"stateSave": true,
"stateDuration": 0,
2016-03-02 14:36:42 +01:00
"fnRowCallback": function(row, data) {
2015-03-16 22:45:25 +01:00
if (data[0].indexOf('ENTITY_DELETED') > 0) {
$(row).addClass('entityDeleted');
}
if (data[0].indexOf('ENTITY_ARCHIVED') > 0) {
$(row).addClass('entityArchived');
}
},
2015-05-10 21:02:35 +02:00
"bAutoWidth": false,
2016-03-02 14:36:42 +01:00
"aoColumnDefs": [
@if (isset($hasCheckboxes) && $hasCheckboxes)
// Disable sorting on the first column
{
'bSortable': false,
'aTargets': [ 0, {{ count($columns) - 1 }} ]
},
@endif
{
'sClass': 'right',
'aTargets': {{ isset($values['rightAlign']) ? json_encode($values['rightAlign']) : '[]' }}
}
],
2015-03-16 22:45:25 +01:00
@foreach ($options as $k => $o)
{!! json_encode($k) !!}: {!! json_encode($o) !!},
2015-03-16 22:45:25 +01:00
@endforeach
@foreach ($callbacks as $k => $o)
{!! json_encode($k) !!}: {!! $o !!},
2015-03-16 22:45:25 +01:00
@endforeach
"fnDrawCallback": function(oSettings) {
2016-11-25 13:45:37 +01:00
@if (isset($values['entityType']))
if (window.onDatatableReady_{{ $values['entityType'] }}) {
window.onDatatableReady_{{ $values['entityType'] }}();
2016-11-25 15:02:39 +01:00
} else if (window.onDatatableReady) {
2016-11-25 13:45:37 +01:00
window.onDatatableReady();
}
@else
if (window.onDatatableReady) {
window.onDatatableReady();
}
@endif
2016-10-18 20:15:08 +02:00
},
"stateLoadParams": function (settings, data) {
// don't save filter to local storage
data.search.search = "";
2017-03-28 20:09:53 +02:00
// always start on first page of results
data.start = 0;
2015-03-16 22:45:25 +01:00
}
});
2015-11-29 17:00:50 +01:00
}
</script>