Lots of work on the reminders.

This commit is contained in:
Sander Dorigo 2014-11-17 16:14:28 +01:00
parent 5fc31f3c1e
commit f69598c6aa
11 changed files with 43 additions and 116 deletions

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')}}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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