Skip to content

Firefly III: a personal finances manager

All kinds of new stuff.

James Cole1b54b146715a
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index aaf3224318..490dbe1b45 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -1,5 +1,6 @@
<?php namespace FireflyIII\Http\Controllers;
+
class HomeController extends Controller
{
@@ -22,6 +23,7 @@ class HomeController extends Controller
public function __construct()
{
$this->middleware('auth');
+ $this->middleware('range');
//$this->middleware('guest');
}
@@ -33,12 +35,13 @@ class HomeController extends Controller
public function index()
{
// count is fake
- $count = 0;
+ $count = \Auth::user()->accounts()->accountTypeIn(['Asset account', 'Default account'])->count();
$title = 'Firefly';
$subTitle = 'What\'s playing?';
$mainTitleIcon = 'fa-fire';
+ $transactions = [];
- return view('index', compact('count', 'title', 'subTitle', 'mainTitleIcon'));
+ return view('index', compact('count', 'title', 'subTitle', 'mainTitleIcon','transactions'));
}
}
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 79d94aa578..fc8fe07e52 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -2,31 +2,35 @@
use Illuminate\Foundation\Http\Kernel as HttpKernel;
-class Kernel extends HttpKernel {
+class Kernel extends HttpKernel
+{
- /**
- * The application's global HTTP middleware stack.
- *
- * @var array
- */
- protected $middleware = [
- 'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
- 'Illuminate\Cookie\Middleware\EncryptCookies',
- 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
- 'Illuminate\Session\Middleware\StartSession',
- 'Illuminate\View\Middleware\ShareErrorsFromSession',
- 'FireflyIII\Http\Middleware\VerifyCsrfToken',
- ];
+ /**
+ * The application's global HTTP middleware stack.
+ *
+ * @var array
+ */
+ protected $middleware
+ = [
+ 'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
+ 'Illuminate\Cookie\Middleware\EncryptCookies',
+ 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
+ 'Illuminate\Session\Middleware\StartSession',
+ 'Illuminate\View\Middleware\ShareErrorsFromSession',
+ 'FireflyIII\Http\Middleware\VerifyCsrfToken',
+ ];
- /**
- * The application's route middleware.
- *
- * @var array
- */
- protected $routeMiddleware = [
- 'auth' => 'FireflyIII\Http\Middleware\Authenticate',
- 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
- 'guest' => 'FireflyIII\Http\Middleware\RedirectIfAuthenticated',
- ];
+ /**
+ * The application's route middleware.
+ *
+ * @var array
+ */
+ protected $routeMiddleware
+ = [
+ 'auth' => 'FireflyIII\Http\Middleware\Authenticate',
+ 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
+ 'guest' => 'FireflyIII\Http\Middleware\RedirectIfAuthenticated',
+ 'range' => 'FireflyIII\Http\Middleware\Range',
+ ];
}
diff --git a/app/Http/routes.php b/app/Http/routes.php
index abe433788a..878edade9b 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -1,6 +1,12 @@
<?php
+/*
+ * Home Controller
+ */
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
+Route::get('/prev', ['uses' => 'HomeController@sessionPrev', 'as' => 'sessionPrev']);
+Route::get('/next', ['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']);
+Route::get('/jump/{range}', ['uses' => 'HomeController@rangeJump', 'as' => 'rangeJump']);
/*
* Account Controller
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 0fc0d17393..167b301a8d 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -1,7 +1,7 @@
<?php namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
-
+use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
/**
* Class Account
*
@@ -25,5 +25,13 @@ class Account extends Model
return $this->belongsTo('FireflyIII\User');
}
+ public function scopeAccountTypeIn(EloquentBuilder $query, array $types)
+ {
+ if (is_null($this->joinedAccountTypes)) {
+ $query->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id');
+ $this->joinedAccountTypes = true;
+ }
+ $query->whereIn('account_types.type', $types);
+ }
}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index 0a8c96c315..9de0455111 100644
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -1,44 +1,64 @@
<?php namespace FireflyIII\Providers;
-use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
+use Illuminate\Http\Request;
+use Illuminate\Routing\Router;
+
+class RouteServiceProvider extends ServiceProvider
+{
+
+ /**
+ * This namespace is applied to the controller routes in your routes file.
+ *
+ * In addition, it is set as the URL generator's root namespace.
+ *
+ * @var string
+ */
+ protected $namespace = 'FireflyIII\Http\Controllers';
+
+ /**
+ * Define your route model bindings, pattern filters, etc.
+ *
+ * @param \Illuminate\Routing\Router $router
+ *
+ * @return void
+ */
+ public function boot(Router $router)
+ {
+ parent::boot($router);
+
+ $router->before(
+ function (Request $request) {
+
+ // put IP in session if not already there.
+
+ $reminders = [];
+
+ if ($request->user()) {
+ //Filter::setSessionDateRange();
+ //Reminders::updateReminders();
+ //Steam::removeEmptyBudgetLimits();
+ //$reminders = Reminders::getReminders();
+ }
+// View::share('reminders', $reminders);
+ }
+ );
+ }
-class RouteServiceProvider extends ServiceProvider {
-
- /**
- * This namespace is applied to the controller routes in your routes file.
- *
- * In addition, it is set as the URL generator's root namespace.
- *
- * @var string
- */
- protected $namespace = 'FireflyIII\Http\Controllers';
-
- /**
- * Define your route model bindings, pattern filters, etc.
- *
- * @param \Illuminate\Routing\Router $router
- * @return void
- */
- public function boot(Router $router)
- {
- parent::boot($router);
-
- //
- }
-
- /**
- * Define the routes for the application.
- *
- * @param \Illuminate\Routing\Router $router
- * @return void
- */
- public function map(Router $router)
- {
- $router->group(['namespace' => $this->namespace], function($router)
- {
- require app_path('Http/routes.php');
- });
- }
+ /**
+ * Define the routes for the application.
+ *
+ * @param \Illuminate\Routing\Router $router
+ *
+ * @return void
+ */
+ public function map(Router $router)
+ {
+ $router->group(
+ ['namespace' => $this->namespace], function ($router) {
+ require app_path('Http/routes.php');
+ }
+ );
+ }
}
diff --git a/config/app.php b/config/app.php
index 0017677efd..5dc7850701 100644
--- a/config/app.php
+++ b/config/app.php
@@ -146,6 +146,7 @@ return [
'FireflyIII\Providers\ConfigServiceProvider',
'FireflyIII\Providers\EventServiceProvider',
'FireflyIII\Providers\RouteServiceProvider',
+ 'FireflyIII\Providers\FireflyServiceProvider',
],
@@ -162,40 +163,41 @@ return [
'aliases' => [
- 'App' => 'Illuminate\Support\Facades\App',
- 'Artisan' => 'Illuminate\Support\Facades\Artisan',
- 'Auth' => 'Illuminate\Support\Facades\Auth',
- 'Blade' => 'Illuminate\Support\Facades\Blade',
- 'Bus' => 'Illuminate\Support\Facades\Bus',
- 'Cache' => 'Illuminate\Support\Facades\Cache',
- 'Config' => 'Illuminate\Support\Facades\Config',
- 'Cookie' => 'Illuminate\Support\Facades\Cookie',
- 'Crypt' => 'Illuminate\Support\Facades\Crypt',
- 'DB' => 'Illuminate\Support\Facades\DB',
- 'Eloquent' => 'Illuminate\Database\Eloquent\Model',
- 'Event' => 'Illuminate\Support\Facades\Event',
- 'File' => 'Illuminate\Support\Facades\File',
- 'Hash' => 'Illuminate\Support\Facades\Hash',
- 'Input' => 'Illuminate\Support\Facades\Input',
- 'Inspiring' => 'Illuminate\Foundation\Inspiring',
- 'Lang' => 'Illuminate\Support\Facades\Lang',
- 'Log' => 'Illuminate\Support\Facades\Log',
- 'Mail' => 'Illuminate\Support\Facades\Mail',
- 'Password' => 'Illuminate\Support\Facades\Password',
- 'Queue' => 'Illuminate\Support\Facades\Queue',
- 'Redirect' => 'Illuminate\Support\Facades\Redirect',
- 'Redis' => 'Illuminate\Support\Facades\Redis',
- 'Request' => 'Illuminate\Support\Facades\Request',
- 'Response' => 'Illuminate\Support\Facades\Response',
- 'Route' => 'Illuminate\Support\Facades\Route',
- 'Schema' => 'Illuminate\Support\Facades\Schema',
- 'Session' => 'Illuminate\Support\Facades\Session',
- 'Storage' => 'Illuminate\Support\Facades\Storage',
- 'URL' => 'Illuminate\Support\Facades\URL',
- 'Validator' => 'Illuminate\Support\Facades\Validator',
- 'View' => 'Illuminate\Support\Facades\View',
- 'Form' => 'Illuminate\Html\FormFacade',
- 'Html' => 'Illuminate\Html\HtmlFacade',
+ 'App' => 'Illuminate\Support\Facades\App',
+ 'Artisan' => 'Illuminate\Support\Facades\Artisan',
+ 'Auth' => 'Illuminate\Support\Facades\Auth',
+ 'Blade' => 'Illuminate\Support\Facades\Blade',
+ 'Bus' => 'Illuminate\Support\Facades\Bus',
+ 'Cache' => 'Illuminate\Support\Facades\Cache',
+ 'Config' => 'Illuminate\Support\Facades\Config',
+ 'Cookie' => 'Illuminate\Support\Facades\Cookie',
+ 'Crypt' => 'Illuminate\Support\Facades\Crypt',
+ 'DB' => 'Illuminate\Support\Facades\DB',
+ 'Eloquent' => 'Illuminate\Database\Eloquent\Model',
+ 'Event' => 'Illuminate\Support\Facades\Event',
+ 'File' => 'Illuminate\Support\Facades\File',
+ 'Hash' => 'Illuminate\Support\Facades\Hash',
+ 'Input' => 'Illuminate\Support\Facades\Input',
+ 'Inspiring' => 'Illuminate\Foundation\Inspiring',
+ 'Lang' => 'Illuminate\Support\Facades\Lang',
+ 'Log' => 'Illuminate\Support\Facades\Log',
+ 'Mail' => 'Illuminate\Support\Facades\Mail',
+ 'Password' => 'Illuminate\Support\Facades\Password',
+ 'Queue' => 'Illuminate\Support\Facades\Queue',
+ 'Redirect' => 'Illuminate\Support\Facades\Redirect',
+ 'Redis' => 'Illuminate\Support\Facades\Redis',
+ 'Request' => 'Illuminate\Support\Facades\Request',
+ 'Response' => 'Illuminate\Support\Facades\Response',
+ 'Route' => 'Illuminate\Support\Facades\Route',
+ 'Schema' => 'Illuminate\Support\Facades\Schema',
+ 'Session' => 'Illuminate\Support\Facades\Session',
+ 'Storage' => 'Illuminate\Support\Facades\Storage',
+ 'URL' => 'Illuminate\Support\Facades\URL',
+ 'Validator' => 'Illuminate\Support\Facades\Validator',
+ 'View' => 'Illuminate\Support\Facades\View',
+ 'Form' => 'Illuminate\Html\FormFacade',
+ 'Html' => 'Illuminate\Html\HtmlFacade',
+ 'Preferences' => 'FireflyIII\Support\Facades\Preferences',
],
diff --git a/config/firefly.php b/config/firefly.php
new file mode 100644
index 0000000000..c17ca873e3
--- /dev/null
+++ b/config/firefly.php
@@ -0,0 +1,49 @@
+<?php
+
+return [
+ 'index_periods' => ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'],
+ 'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
+ 'piggy_bank_periods' => [
+ 'week' => 'Week',
+ 'month' => 'Month',
+ 'quarter' => 'Quarter',
+ 'year' => 'Year'
+ ],
+ 'periods_to_text' => [
+ 'weekly' => 'A week',
+ 'monthly' => 'A month',
+ 'quarterly' => 'A quarter',
+ 'half-year' => 'Six months',
+ 'yearly' => 'A year',
+ ],
+
+ 'accountRoles' => [
+ 'defaultExpense' => 'Default expense account',
+ 'sharedExpense' => 'Shared expense account'
+ ],
+
+ 'range_to_text' => [
+ '1D' => 'day',
+ '1W' => 'week',
+ '1M' => 'month',
+ '3M' => 'three months',
+ '6M' => 'half year',
+ 'custom' => '(custom)'
+ ],
+ 'range_to_name' => [
+ '1D' => 'one day',
+ '1W' => 'one week',
+ '1M' => 'one month',
+ '3M' => 'three months',
+ '6M' => 'six months',
+ '1Y' => 'one year',
+ ],
+ 'range_to_repeat_freq' => [
+ '1D' => 'weekly',
+ '1W' => 'weekly',
+ '1M' => 'monthly',
+ '3M' => 'quarterly',
+ '6M' => 'half-year',
+ 'custom' => 'monthly'
+ ],
+];
diff --git a/public/css/sb.css b/public/css/sb.css
index f1600b673a..e6f76ff222 100755
--- a/public/css/sb.css
+++ b/public/css/sb.css
@@ -10,7 +10,7 @@ body {
.google-chart-error {
height:30px;
- background:url('../../images/error.png') no-repeat center center
+ background:url('../images/error.png') no-repeat center center
}
.google-visualization-table-tr-head td:first-child {width:100px;}
diff --git a/public/images/error.png b/public/images/error.png
new file mode 100755
index 0000000000..628cf2dae3
Binary files /dev/null and b/public/images/error.png differ