Skip to content

Firefly III: a personal finances manager

Lots of work on the reminders.

Sander Dorigof69598c6aa90
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php b/app/lib/FireflyIII/Shared/Toolkit/Reminders.php
index bce26d910b..4841c6dbf0 100644
--- a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php
+++ b/app/lib/FireflyIII/Shared/Toolkit/Reminders.php
@@ -1,6 +1,7 @@
<?php
namespace FireflyIII\Shared\Toolkit;
+
use Carbon\Carbon;
/**
@@ -8,27 +9,40 @@ use Carbon\Carbon;
*
* @package FireflyIII\Shared\Toolkit
*/
-class Reminders {
+class Reminders
+{
- public function updateReminders() {
- $reminders = \Auth::user()->reminders()->get();
+ public function updateReminders()
+ {
+ $today = Carbon::now()->format('Y-m-d');
+ $reminders = \Auth::user()->reminders()
+ ->where('startdate', '<=', $today)
+ ->where('enddate', '>=', $today)
+ ->where('active', '=', 1)
+ ->get();
$hasTestReminder = false;
+
/** @var \Reminder $reminder */
- foreach($reminders as $reminder) {
- if($reminder->title == 'Test' && $reminder->active == true) {
+ foreach ($reminders as $reminder) {
+ if ($reminder->title == 'Test' && intval($reminder->active) == 1) {
$hasTestReminder = true;
}
}
- if(!$hasTestReminder) {
+ if (!$hasTestReminder) {
$reminder = new \Reminder;
$reminder->user()->associate(\Auth::user());
- $reminder->title = 'Test';
+ $reminder->title = 'Test';
$reminder->startdate = new Carbon;
- $reminder->enddate = Carbon::now()->addDays(4);
-
- $data = [1 => 2, 'money' => 100, 'amount' => 2.45,'type' => 'Test'];
+ $reminder->active = 1;
+ $reminder->enddate = Carbon::now()->addDays(4);
+ $data = ['type' => 'Test',
+ 'action_uri' => route('index'),
+ 'text' => 'hello!',
+ 'amount' => 50,
+ 'icon' => 'fa-bomb'
+ ];
$reminder->data = $data;
$reminder->save();
}
@@ -37,19 +51,20 @@ class Reminders {
/**
*
*/
- public function getReminders() {
- $reminders = \Auth::user()->reminders()->where('active',true)->get();
- $return = [];
+ public function getReminders()
+ {
+ $reminders = \Auth::user()->reminders()->where('active', true)->get();
+ $return = [];
/** @var \Reminder $reminder */
- foreach($reminders as $reminder) {
+ foreach ($reminders as $reminder) {
$set = [
'id' => $reminder->id
];
- switch($reminder->data->type) {
+ switch ($reminder->data->type) {
case 'Test':
- $set['title'] = 'Test reminder #'.$reminder->id;
- $set['icon'] = 'fa-bomb';
- $set['text'] = 'Bla bla';
+ $set['title'] = $reminder->title;
+ $set['icon'] = $reminder->data->icon;
+ $set['text'] = mf(floatval($reminder->data->amount));
}
$return[] = $set;
diff --git a/app/models/Reminder.php b/app/models/Reminder.php
index 3122be1aa8..6d101694d1 100644
--- a/app/models/Reminder.php
+++ b/app/models/Reminder.php
@@ -51,6 +51,13 @@ class Reminder extends Ardent
}
/**
+ * Expected data in this value:
+ *
+ * type: Piggybank, Test
+ * action_uri: where to go when the user wants to do this?
+ * text: full text to present to user
+ * amount: any relevant amount.
+ *
* @param $value
*
* @return mixed
diff --git a/app/views/accounts/index.blade.php b/app/views/accounts/index.blade.php
index 555105e477..ba78cd68d8 100644
--- a/app/views/accounts/index.blade.php
+++ b/app/views/accounts/index.blade.php
@@ -39,5 +39,5 @@
{{HTML::script('assets/javascript/firefly/gcharts.js')}}
-<script src="assets/javascript/firefly/accounts.js"></script>
+{{HTML::script('assets/javascript/firefly/accounts.js')}}
@stop
\ No newline at end of file
diff --git a/app/views/categories/index.blade.php b/app/views/categories/index.blade.php
index 7731f88fe6..1da13dcf19 100644
--- a/app/views/categories/index.blade.php
+++ b/app/views/categories/index.blade.php
@@ -33,7 +33,5 @@
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
{{HTML::script('assets/javascript/firefly/gcharts.options.js')}}
{{HTML::script('assets/javascript/firefly/gcharts.js')}}
-
-
-<script src="assets/javascript/firefly/categories.js"></script>
+{{HTML::script('assets/javascript/firefly/categories.js')}}
@stop
\ No newline at end of file
diff --git a/app/views/layouts/default.blade.php b/app/views/layouts/default.blade.php
index 94183c6c4b..508bf49a02 100644
--- a/app/views/layouts/default.blade.php
+++ b/app/views/layouts/default.blade.php
@@ -59,15 +59,6 @@
</div>
</div>
-<div class="modal fade" id="reminderModal" tabindex="-1" role="dialog"
- aria-labelledby="reminderModalLabel" aria-hidden="true">
- <div class="modal-dialog modal-lg">
- <div class="modal-content">
-
- </div><!-- /.modal-content -->
- </div><!-- /.modal-dialog -->
-</div><!-- /.modal -->
-
{{HTML::script('assets/javascript/jquery/jquery-2.1.1.min.js')}}
{{HTML::script('assets/javascript/bootstrap/bootstrap.min.js')}}
{{HTML::script('assets/javascript/metisMenu/jquery.metisMenu.min.js')}}
diff --git a/app/views/migrate/index.blade.php b/app/views/migrate/index.blade.php
deleted file mode 100644
index dec6859517..0000000000
--- a/app/views/migrate/index.blade.php
+++ /dev/null
@@ -1,24 +0,0 @@
-@extends('layouts.default')
-@section('content')
-<div class="row">
- <div class="col-lg-8 col-md-8 col-sm-12">
- <p class="text-info">
- Read <a href="https://github.com/JC5/firefly-iii/wiki/Importing-data-from-Firefly-II">the wiki</a> to read more about how data migration.
- </p>
- <ol>
- <li>Upload <code>firefly-export-****-**-**.json</code></li>
- <li>Wait..</li>
- <li>Done!</li>
- </ol>
- {{Form::open(['files' => true,'url' => route('migrate.upload')])}}
- <div class="form-group">
- <label for="file">Export file</label>
- <input name="file" type="file" id="exportFile">
- <p class="help-block">Upload the export file here.</p>
- </div>
- <button type="submit" class="btn btn-info">Import</button>
- {{Form::close()}}
- </div>
-</div>
-
-@stop
\ No newline at end of file
diff --git a/app/views/migrate/result.blade.php b/app/views/migrate/result.blade.php
deleted file mode 100644
index 0e41f4ab59..0000000000
--- a/app/views/migrate/result.blade.php
+++ /dev/null
@@ -1,21 +0,0 @@
-@extends('layouts.default')
-@section('content')
-<div class="row">
- <div class="col-lg-8 col-md-8 col-sm-12">
- <h1>Firefly<br/>
- <small>Migration results</small>
- </h1>
- <p class="lead">
- The migration was successful! You can now return to <a href="{{route('index')}}">the home page</a>
- and start using Firefly.
- </p>
-
- <ul>
- @foreach($messages as $m)
- <li>{{$m}}</li>
- @endforeach
- </ul>
- </div>
-</div>
-
-@stop
\ No newline at end of file
diff --git a/app/views/migrate/select-user.blade.php b/app/views/migrate/select-user.blade.php
deleted file mode 100644
index 9ff7198ca9..0000000000
--- a/app/views/migrate/select-user.blade.php
+++ /dev/null
@@ -1,35 +0,0 @@
-@extends('layouts.default')
-@section('content')
-<div class="row">
- <div class="col-lg-8 col-md-8 col-sm-12">
- <h1>Firefly<br/>
- <small>Select a user for migration.</small>
- </h1>
- <p>
- Select a user from the list below. Then press import.
- </p>
-
- {{Form::open(['class' => 'form-horizontal'])}}
-
- <div class="form-group">
- <label for="inputUser" class="col-sm-2 control-label">User</label>
- <div class="col-sm-10">
- <select class="form-control" name="user">
- @foreach($oldUsers as $old)
- <option value="{{$old->id}}" label="# {{$old->id}}: {{$old->username}} ({{$old->email}})">
- # {{$old->id}}: {{$old->username}} ({{$old->email}})</option>
- @endforeach
- </select>
- </div>
- </div>
- <div class="form-group">
- <div class="col-sm-offset-2 col-sm-10">
- <button type="submit" class="btn btn-info">Import</button><br />
- <small>Please be patient; importing data may take some time.</small>
- </div>
- </div>
- {{Form::close()}}
- </div>
-</div>
-
-@stop
\ No newline at end of file
diff --git a/app/views/partials/menu.blade.php b/app/views/partials/menu.blade.php
index 635277bee4..31094add19 100644
--- a/app/views/partials/menu.blade.php
+++ b/app/views/partials/menu.blade.php
@@ -25,7 +25,7 @@
<a href="{{route('reminders.show',$reminder['id'])}}">
<div>
<i class="fa {{$reminder['icon']}} fa-fw"></i> {{{$reminder['title']}}}
- <span class="pull-right text-muted small">{{{$reminder['text']}}}</span>
+ <span class="pull-right text-muted small">{{$reminder['text']}}</span>
</div>
</a>
</li>
diff --git a/app/views/transactions/create.blade.php b/app/views/transactions/create.blade.php
index 5a4b0600ce..456ec7a40f 100644
--- a/app/views/transactions/create.blade.php
+++ b/app/views/transactions/create.blade.php
@@ -91,7 +91,5 @@
@stop
@section('scripts')
{{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/transactions.js')}}
@stop
\ No newline at end of file
diff --git a/app/views/transactions/edit.blade.php b/app/views/transactions/edit.blade.php
index e802d31f68..cf53264c48 100644
--- a/app/views/transactions/edit.blade.php
+++ b/app/views/transactions/edit.blade.php
@@ -91,7 +91,5 @@
@stop
@section('scripts')
{{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/transactions.js')}}
@stop
\ No newline at end of file