Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Thing with order and should fix Travis.
James Cole6dddd6629d14
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.phpindex 4149d9f44f..be952d0a99 100644--- a/app/Http/Controllers/TransactionController.php+++ b/app/Http/Controllers/TransactionController.php@@ -210,6 +210,15 @@ class TransactionController extends Controller}+ /**+ * Reorder transactions (which all must have the same date)+ */+ public function reorder()+ {+ $ids = Input::get('items');++ }+/*** @param TransactionJournal $journal*diff --git a/app/Http/routes.php b/app/Http/routes.phpindex 3bf64a8ceb..299799ea5b 100644--- a/app/Http/routes.php+++ b/app/Http/routes.php@@ -366,6 +366,7 @@ Route::group();Route::post('/transaction/update/{tj}', ['uses' => 'TransactionController@update', 'as' => 'transactions.update']);Route::post('/transaction/destroy/{tj}', ['uses' => 'TransactionController@destroy', 'as' => 'transactions.destroy']);+ Route::post('/transaction/reorder', ['uses' => 'TransactionController@reorder', 'as' => 'transactions.reorder']);/*** Auth\Auth Controllerdiff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.phpindex b4b95b1701..c4ecc34cd3 100644--- a/app/Validation/FireflyValidator.php+++ b/app/Validation/FireflyValidator.php@@ -80,18 +80,36 @@ class FireflyValidator extends Validatorpublic function validateUniqueAccountForUser($attribute, $value, $parameters){// get account type from data, we must have this:- $type = isset($this->data['what']) ? $this->data['what'] : Input::get('what');- $longType = Config::get('firefly.accountTypeByIdentifier.' . $type);- $dbType = AccountType::whereType($longType)->first();- if (!$dbType) {+ $type = isset($this->data['what']) ? $this->data['what'] : null;+ // some fallback:+ if(is_null($type)) {+ $type = Input::get('what');+ }+ // still null?+ if(is_null($type)) {+ // find by other field:+ $type = isset($this->data['account_type_id']) ? $this->data['account_type_id'] : 0;+ $dbType = AccountType::find($type);+ } else {+ $longType = Config::get('firefly.accountTypeByIdentifier.' . $type);+ $dbType = AccountType::whereType($longType)->first();+ }++ if (is_null($dbType)) {return false;}- $query = DB::table('accounts')->where('name', $value)->where('account_type_id', $dbType->id)->where('user_id', Auth::user()->id);++ // user id?+ $userId = Auth::check() ? Auth::user()->id : $this->data['user_id'];++ $query = DB::table('accounts')->where('name', $value)->where('account_type_id', $dbType->id)->where('user_id', $userId);+if (isset($parameters[0])) {$query->where('id', '!=', $parameters[0]);}$count = $query->count();if ($count == 0) {+return true;}diff --git a/database/migrations/2015_03_27_061038_changes_for_v333.php b/database/migrations/2015_03_27_061038_changes_for_v333.phpnew file mode 100644index 0000000000..3b8b2e81e0--- /dev/null+++ b/database/migrations/2015_03_27_061038_changes_for_v333.php@@ -0,0 +1,33 @@+<?php++use Illuminate\Database\Schema\Blueprint;+use Illuminate\Database\Migrations\Migration;++class ChangesForV333 extends Migration {++ /**+ * Run the migrations.+ *+ * @return void+ */+ public function up()+ {+ Schema::table(+ 'transaction_journals', function (Blueprint $table) {+ $table->smallInteger('order',false,true)->default(0);++ }+ );+ }++ /**+ * Reverse the migrations.+ *+ * @return void+ */+ public function down()+ {+ //+ }++}diff --git a/public/js/transactions.js b/public/js/transactions.jsindex 15d6a123b6..a6d5ee37e1 100644--- a/public/js/transactions.js+++ b/public/js/transactions.js@@ -31,45 +31,23 @@ $(document).ready(function () {$(".sortable-table tbody").sortable({helper: fixHelper,- connectWith: '.sortable-table tbody',- //stop: stopSorting,items: 'tr:not(.ignore)',stop: sortStop,- handle: '.handle'- //revert: 'invalid'+ handle: '.handle',+ revert: 'invalid'}).disableSelection();});-function sortChange() {- //console.log("change");-}--function sortSort(event, ui) {- //var current = $(ui.item);- //var thisDate = current.data('date');-- //if(current.prev().data('date') != thisDate && current.next().data('date') != thisDate) {- // console.log('FALSE ['+current.prev().data('date')+'] ['+thisDate+'] ['+current.next().data('date')+'] ('+current.index()+')');- // return true;-- // return false;- //}- //console.log('TRUE ['+current.prev().data('date')+'] ['+thisDate+'] ['+current.next().data('date')+'] ('+current.index()+')');--}-function sortStop(event, ui) {- console.log("stop");var current = $(ui.item);var thisDate = current.data('date');var originalBG = current.css('backgroundColor');if (current.prev().data('date') != thisDate && current.next().data('date') != thisDate) {- console.log('False!');- console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');-+ //console.log('False!');+ //console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');// animate something with color:current.animate({backgroundColor: "#d9534f"@@ -79,13 +57,23 @@ function sortStop(event, ui) {}, 200);});-- // fade back to original-return false;}- console.log('TRUE!');- console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');++ // do update+ var list = $('tr[data-date="' + thisDate + '"]');+ var submit = [];+ $.each(list, function (i, v) {+ var row = $(v);+ var id = row.data('id');+ submit.push(id);+ });++ $.post('/transaction/reorder',{items: submit,_token:token});+ console.log(submit);++ //console.log('TRUE!');+ //console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');current.animate({backgroundColor: "#5cb85c"@@ -95,6 +83,9 @@ function sortStop(event, ui) {}, 200);});+++//else update some order thing bla bla.//check if the item above OR under this one have the same date//if not. return falsediff --git a/resources/views/accounts/show.blade.php b/resources/views/accounts/show.blade.phpindex 462cbe5a9e..0fcd1ff2e7 100644--- a/resources/views/accounts/show.blade.php+++ b/resources/views/accounts/show.blade.php@@ -37,7 +37,7 @@<i class="fa fa-repeat fa-fw"></i> Transactions</div><div class="panel-body">- @include('list.journals-full')+ @include('list.journals-full',['sorting' => false])</div></div></div>diff --git a/resources/views/bills/show.blade.php b/resources/views/bills/show.blade.phpindex 2c0298f94d..4e9b77431a 100644--- a/resources/views/bills/show.blade.php+++ b/resources/views/bills/show.blade.php@@ -94,7 +94,7 @@Connected transaction journals</div><div class="panel-body">- @include('list.journals-full')+ @include('list.journals-full',['sorting' => false])</div></div></div>diff --git a/resources/views/budgets/noBudget.blade.php b/resources/views/budgets/noBudget.blade.phpindex d7653b58a0..0a4b964543 100644--- a/resources/views/budgets/noBudget.blade.php+++ b/resources/views/budgets/noBudget.blade.php@@ -8,7 +8,7 @@{{{$subTitle}}}</div><div class="panel-body">- @include('list.journals-full',['journals' => $list])+ @include('list.journals-full',['journals' => $list,'sorting' => false])</div></div></div>diff --git a/resources/views/budgets/show.blade.php b/resources/views/budgets/show.blade.phpindex a06710702b..bb218f1246 100644--- a/resources/views/budgets/show.blade.php+++ b/resources/views/budgets/show.blade.php@@ -16,7 +16,7 @@<div class="panel-heading">Transactions</div>- @include('list.journals-full')+ @include('list.journals-full',['sorting' => false])</div></div><div class="col-lg-3 col-md-3 col-sm-5">diff --git a/resources/views/categories/noCategory.blade.php b/resources/views/categories/noCategory.blade.phpindex b256c60423..fa173d40a9 100644--- a/resources/views/categories/noCategory.blade.php+++ b/resources/views/categories/noCategory.blade.php@@ -8,7 +8,7 @@{{{$subTitle}}}</div><div class="panel-body">- @include('list.journals-full',['journals' => $list])+ @include('list.journals-full',['journals' => $list,'sorting' => false])</div></div></div>diff --git a/resources/views/categories/show.blade.php b/resources/views/categories/show.blade.phpindex 627976e872..fda326fa4a 100644--- a/resources/views/categories/show.blade.php+++ b/resources/views/categories/show.blade.php@@ -34,7 +34,7 @@Transactions</div><div class="panel-body">- @include('list.journals-full')+ @include('list.journals-full',['sorting' => false])</div></div></div>diff --git a/resources/views/list/journals-full.blade.php b/resources/views/list/journals-full.blade.phpindex 8b6daf089e..2584d8c8f0 100644--- a/resources/views/list/journals-full.blade.php+++ b/resources/views/list/journals-full.blade.php@@ -32,10 +32,12 @@<td colspan="7"><em>Invalid journal: Found {{$journal->transactions()->count()}} transaction(s)</td></tr>@else- <tr class="drag" data-date="{{$journal->date->format('Y-m-d')}}">+ <tr class="drag" data-date="{{$journal->date->format('Y-m-d')}}" data-id="{{$journal->id}}"><td><div class="btn-group btn-group-xs">- <a href="#" class="handle btn btn-default btn-xs"><i class="fa fa-fw fa-arrows-v"></i></a>+ @if($sorting === true)+ <a href="#" class="handle btn btn-default btn-xs"><i class="fa fa-fw fa-arrows-v"></i></a>+ @endif<a href="{{route('transactions.edit',$journal->id)}}" class="btn btn-xs btn-default"><i class="fa fa-fw fa-pencil"></i></a><a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-xs btn-danger"><i class="fa fa-fw fa-trash-o"></i></a></div>diff --git a/resources/views/reports/modal-journal-list.blade.php b/resources/views/reports/modal-journal-list.blade.phpindex 50ad3086b6..eb91340660 100644--- a/resources/views/reports/modal-journal-list.blade.php+++ b/resources/views/reports/modal-journal-list.blade.php@@ -5,7 +5,7 @@<h4 class="modal-title">No budget bla bla.</h4></div><div class="modal-body">- @include('list.journals-full')+ @include('list.journals-full',['sorting' => false])</div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button>diff --git a/resources/views/transactions/index.blade.php b/resources/views/transactions/index.blade.phpindex 66d3b2da2a..b2712a60db 100644--- a/resources/views/transactions/index.blade.php+++ b/resources/views/transactions/index.blade.php@@ -7,7 +7,7 @@<div class="panel-heading"><i class="fa {{$subTitleIcon}}"></i> {{{$subTitle}}}</div>- @include('list.journals-full')+ @include('list.journals-full',['sorting' => true])</div></div></div>@@ -15,6 +15,9 @@@stop@section('scripts')+ <script type="text/javascript">+ var token = "{{csrf_token()}}";+ </script><script src="js/jquery-ui.min.js" type="text/javascript"></script><script src="js/transactions.js" type="text/javascript"></script>