First set of code.

This commit is contained in:
Sander Dorigo 2014-10-11 21:23:31 +02:00
parent f68c1aff26
commit 7d2dab7ca0
4 changed files with 260 additions and 108 deletions

View File

@ -19,7 +19,6 @@ class JsonController extends BaseController
$this->helper = $helper;
}
/**
@ -97,11 +96,32 @@ class JsonController extends BaseController
return Response::json($resultSet);
}
/**
*
*/
public function recurringjournals(RecurringTransaction $recurringTransaction)
{
$parameters = $this->helper->dataTableParameters();
$parameters['transactionTypes'] = ['Withdrawal'];
$parameters['amount'] = 'negative';
$query = $this->helper->journalQuery($parameters);
$query->where('recurring_transaction_id', $recurringTransaction->id);
$resultSet = $this->helper->journalDataset($parameters, $query);
/*
* Build return data:
*/
return Response::json($resultSet);
}
public function recurring()
{
$parameters = $this->helper->dataTableParameters();
$query = $this->helper->recurringTransactionsQuery($parameters);
$resultSet = $this->helper->recurringTransactionsDataset($parameters, $query);
$query = $this->helper->recurringTransactionsQuery($parameters);
$resultSet = $this->helper->recurringTransactionsDataset($parameters, $query);
return Response::json($resultSet);
}

View File

@ -187,6 +187,7 @@ Route::group(['before' => 'auth'], function () {
Route::get('/json/revenue', ['uses' => 'JsonController@revenue', 'as' => 'json.revenue']);
Route::get('/json/transfers', ['uses' => 'JsonController@transfers', 'as' => 'json.transfers']);
Route::get('/json/recurring', ['uses' => 'JsonController@recurring', 'as' => 'json.recurring']);
Route::get('/json/recurringjournals/{recurring}', ['uses' => 'JsonController@recurringjournals', 'as' => 'json.recurringjournals']);
// limit controller:
Route::get('/budgets/limits/create/{budget?}',['uses' => 'LimitController@create','as' => 'budgets.limits.create']);

View File

@ -54,4 +54,43 @@
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-sm-12 col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
Connected transaction journals
</div>
<div class="panel-body">
<table id="transactionTable" class="table table-striped table-bordered" >
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th>Amount (&euro;)</th>
<th>From</th>
<th>To</th>
<th>Budget / category</th>
<th>ID</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
@stop
@section('scripts')
<script type="text/javascript">
var URL = '{{route('json.recurringjournals',$recurring->id)}}';
</script>
{{HTML::script('assets/javascript/typeahead/bootstrap3-typeahead.min.js')}}
{{HTML::script('assets/javascript/datatables/jquery.dataTables.min.js')}}
{{HTML::script('assets/javascript/datatables/dataTables.bootstrap.js')}}
{{HTML::script('assets/javascript/firefly/recurring.js')}}
@stop
@section('styles')
{{HTML::style('assets/stylesheets/datatables/dataTables.bootstrap.css')}}
@stop

View File

@ -1,112 +1,204 @@
$(document).ready(function () {
$('#recurringTable').DataTable(
{
serverSide: true,
ajax: URL,
paging: true,
processing: true,
order: [],
"lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]],
columns: [
if ($('#recurringTable').length > 0) {
$('#recurringTable').DataTable(
{
name: 'name',
data: 'name',
searchable: true,
title: 'Name',
render: function (data) {
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'match',
data: 'match',
searchable: true,
title: 'Matches on',
render: function (data) {
var str = '';
for (x in data) {
str += '<span class="label label-info">' + data[x] + '</span> ';
}
return str;//return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'amount_min',
data: 'amount_min',
searchable: false,
title: '&rarr;',
render: function (data) {
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';
}
},
{
name: 'amount_max',
data: 'amount_max',
searchable: false,
title: '&larr;',
render: function (data) {
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';
}
serverSide: true,
ajax: URL,
paging: true,
processing: true,
order: [],
"lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]],
columns: [
{
name: 'name',
data: 'name',
searchable: true,
title: 'Name',
render: function (data) {
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'match',
data: 'match',
searchable: true,
title: 'Matches on',
render: function (data) {
var str = '';
for (x in data) {
str += '<span class="label label-info">' + data[x] + '</span> ';
}
return str;//return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'amount_min',
data: 'amount_min',
searchable: false,
title: '&rarr;',
render: function (data) {
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';
}
},
{
name: 'amount_max',
data: 'amount_max',
searchable: false,
title: '&larr;',
render: function (data) {
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';
}
},
{
name: 'date',
data: 'date',
title: 'Expected on',
searchable: false
},
},
{
name: 'date',
data: 'date',
title: 'Expected on',
searchable: false
},
{
name: 'active',
data: 'active',
searchable: false,
sortable: false,
render: function(data) {
if(data == 1) {
return '<i class="fa fa-check fa-faw"></i>';
} else {
return '<i class="fa fa-remove fa-faw"></i>';
{
name: 'active',
data: 'active',
searchable: false,
sortable: false,
render: function (data) {
if (data == 1) {
return '<i class="fa fa-check fa-faw"></i>';
} else {
return '<i class="fa fa-remove fa-faw"></i>';
}
},
title: 'Is active?'
},
{
name: 'automatch',
data: 'automatch',
sortable: false,
searchable: false,
render: function (data) {
if (data == 1) {
return '<i class="fa fa-check fa-faw"></i>';
} else {
return '<i class="fa fa-remove fa-faw"></i>';
}
},
title: 'Automatch?'
},
{
name: 'repeat_freq',
data: 'repeat_freq',
searchable: false,
sortable: false,
title: 'Repeat frequency'
},
{
name: 'id',
data: 'id',
searchable: false,
sortable: false,
title: '',
render: function (data, type, full, meta) {
return '<div class="btn-group btn-group-xs">' +
'<a class="btn btn-default btn-xs" href="' + data.edit + '">' +
'<span class="glyphicon glyphicon-pencil"</a>' +
'<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +
'<span class="glyphicon glyphicon-trash"</a>' +
'</a></div>';
}
}
},
title: 'Is active?'
},
{
name: 'automatch',
data: 'automatch',
sortable: false,
searchable: false,
render: function(data) {
if(data == 1) {
return '<i class="fa fa-check fa-faw"></i>';
} else {
return '<i class="fa fa-remove fa-faw"></i>';
}
},
title: 'Automatch?'
},
{
name: 'repeat_freq',
data: 'repeat_freq',
searchable: false,
sortable: false,
title: 'Repeat frequency'
},
{
name: 'id',
data: 'id',
searchable: false,
sortable: false,
title: '',
render: function (data, type, full, meta) {
return '<div class="btn-group btn-group-xs">' +
'<a class="btn btn-default btn-xs" href="' + data.edit + '">' +
'<span class="glyphicon glyphicon-pencil"</a>' +
'<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +
'<span class="glyphicon glyphicon-trash"</a>' +
'</a></div>';
}
]
}
]
);
}
);
});
if ($('#transactionTable').length > 0) {
$('#transactionTable').DataTable(
{
serverSide: true,
ajax: URL,
paging: true,
processing: true,
order: [],
"lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]],
columns: [
{
name: 'date',
data: 'date',
searchable: false
},
{
name: 'description',
data: 'description',
render: function (data, type, full, meta) {
icon = 'glyphicon-arrow-left';
return '<span class="glyphicon ' + icon + '"></span> ' +
'<a href="' + data.url + '" title="' + data.description + '">' + data.description + '</a>';
}
},
{
name: 'amount',
data: 'amount',
'title': 'Amount (\u20AC)',
searchable: false,
render: function (data, type, full, meta) {
return '<span class="text-danger">\u20AC ' + data.toFixed(2) + '</span>';
}
},
{
name: 'from',
data: 'from',
searchable: false,
render: function (data, type, full, meta) {
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'to',
data: 'to',
searchable: false,
render: function (data, type, full, meta) {
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'components',
data: 'components',
searchable: true,
sortable: false,
title: '',
render: function (data, type, full, meta) {
var html = '';
if (data.budget_id > 0) {
html += '<a href="' + data.budget_url + '" title="' + data.budget_name + '"><i class="fa fa-tasks fa-fw"></i></a> ';
}
if (data.category_id > 0) {
html += '<a href="' + data.category_url + '" title="' + data.category_name + '"><i class="fa fa-bar-chart fa-fw"></i></a> ';
}
if (data.recurring_id > 0) {
html += '<a href="' + data.recurring_url + '" title="' + data.recurring_name + '"><i class="fa fa-rotate-right fa-fw"></i></a> ';
}
return html;
}
},
{
name: 'id',
data: 'id',
searchable: false,
sortable: false,
title: '',
render: function (data, type, full, meta) {
return '<div class="btn-group btn-group-xs">' +
'<a class="btn btn-default btn-xs" href="' + data.edit + '">' +
'<span class="glyphicon glyphicon-pencil"</a>' +
'<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +
'<span class="glyphicon glyphicon-trash"</a>' +
'</a></div>';
}
}
]
}
);
}
}
);