2013-12-01 08:33:17 +01:00
|
|
|
@extends('header')
|
|
|
|
|
|
|
|
@section('content')
|
|
|
|
|
2013-12-03 18:32:33 +01:00
|
|
|
{{ Former::open($entityType . 's/bulk')->addClass('listForm') }}
|
2013-12-01 08:33:17 +01:00
|
|
|
<div style="display:none">{{ Former::text('action') }}</div>
|
|
|
|
|
|
|
|
{{ DropdownButton::normal('Archive',
|
|
|
|
Navigation::links(
|
|
|
|
array(
|
|
|
|
array('Archive', "javascript:submitForm('archive')"),
|
|
|
|
array('Delete', "javascript:submitForm('delete')"),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
, array('id'=>'archive'))->split(); }}
|
|
|
|
|
|
|
|
|
2013-12-01 21:58:25 +01:00
|
|
|
@if (in_array($entityType, [ENTITY_CLIENT, ENTITY_INVOICE]))
|
2013-12-01 08:33:17 +01:00
|
|
|
{{ Button::primary_link(URL::to($entityType . 's/create'), 'New ' . ucwords($entityType), array('class' => 'pull-right')) }}
|
2013-12-01 21:58:25 +01:00
|
|
|
@endif
|
2013-12-01 08:33:17 +01:00
|
|
|
|
|
|
|
{{ Datatable::table()
|
|
|
|
->addColumn($columns)
|
|
|
|
->setUrl(route('api.' . $entityType . 's'))
|
|
|
|
->setOptions('sPaginationType', 'bootstrap')
|
|
|
|
->setOptions('bFilter', false)
|
|
|
|
->render('datatable') }}
|
|
|
|
|
|
|
|
{{ Former::close() }}
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
function submitForm(action) {
|
2013-12-01 21:58:25 +01:00
|
|
|
if (action == 'delete') {
|
|
|
|
if (!confirm('Are you sure')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-12-01 08:33:17 +01:00
|
|
|
$('#action').val(action);
|
2013-12-03 18:32:33 +01:00
|
|
|
$('form.listForm').submit();
|
2013-12-01 08:33:17 +01:00
|
|
|
}
|
|
|
|
|
2013-12-01 21:58:25 +01:00
|
|
|
function deleteEntity(id) {
|
|
|
|
if (confirm("Are you sure?")) {
|
|
|
|
window.location = "{{ URL::to($entityType . 's') }}/" + id + "/delete";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-01 08:33:17 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
@stop
|
|
|
|
|
|
|
|
@section('onReady')
|
|
|
|
|
|
|
|
window.onDatatableReady = function() {
|
|
|
|
$(':checkbox').click(function() {
|
|
|
|
setArchiveEnabled();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('tbody tr').click(function(event) {
|
2013-12-01 21:58:25 +01:00
|
|
|
if (event.target.type !== 'checkbox' && event.target.type !== 'button' && event.target.tagName.toLowerCase() !== 'a') {
|
2013-12-01 08:33:17 +01:00
|
|
|
$checkbox = $(this).closest('tr').find(':checkbox');
|
|
|
|
var checked = $checkbox.prop('checked');
|
|
|
|
$checkbox.prop('checked', !checked);
|
|
|
|
setArchiveEnabled();
|
|
|
|
}
|
|
|
|
});
|
2013-12-01 21:58:25 +01:00
|
|
|
|
|
|
|
$('tbody tr').mouseover(function() {
|
|
|
|
$(this).closest('tr').find('.tr-action').show();
|
|
|
|
}).mouseout(function() {
|
|
|
|
$dropdown = $(this).closest('tr').find('.tr-action');
|
|
|
|
if (!$dropdown.hasClass('open')) {
|
|
|
|
$dropdown.hide();
|
|
|
|
}
|
|
|
|
});
|
2013-12-01 08:33:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$('#archive > button').prop('disabled', true);
|
|
|
|
$('#archive > button:first').click(function() {
|
|
|
|
submitForm('archive');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#selectAll').click(function() {
|
|
|
|
$(':checkbox').prop('checked', this.checked);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
function setArchiveEnabled() {
|
|
|
|
var checked = $('tbody :checkbox:checked').length > 0;
|
|
|
|
$('#archive > button').prop('disabled', !checked);
|
|
|
|
}
|
2013-12-01 21:58:25 +01:00
|
|
|
|
|
|
|
|
2013-12-01 08:33:17 +01:00
|
|
|
|
|
|
|
@stop
|