From 48064313cced05db120775076e943400b0f51188 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 5 Oct 2014 12:35:51 +0300 Subject: [PATCH] Working on d3 viz --- README.md | 4 +++- app/controllers/ReportController.php | 22 +++++++++++++++------- app/lang/de/texts.php | 5 +++-- app/lang/en/texts.php | 6 ++++-- app/lang/es/texts.php | 5 +++-- app/lang/fr/texts.php | 4 +++- app/lang/it/texts.php | 4 +++- app/lang/lt/texts.php | 4 +++- app/lang/nb_NO/texts.php | 4 +++- app/lang/nl/texts.php | 4 +++- app/lang/pt_BR/texts.php | 4 +++- app/models/Account.php | 2 ++ app/routes.php | 4 ++-- app/views/accounts/nav_advanced.blade.php | 2 +- app/views/plans.blade.php | 6 +++--- app/views/reports/d3.blade.php | 13 +++++++------ app/views/reports/report_builder.blade.php | 4 ++++ 17 files changed, 65 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 19cf8ffcb8..99c2e35413 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ To connect follow [@invoiceninja](https://twitter.com/invoiceninja) or join the If you'd like to translate the site please use [caouecs/Laravel4-long](https://github.com/caouecs/Laravel4-lang) for the starter files. -Site design by [kantorp-wegl.in](http://kantorp-wegl.in/) +Developed by [@hillelcoren](https://twitter.com/hillelcoren) | Designed by [kantorp-wegl.in](http://kantorp-wegl.in/). ### Features @@ -27,6 +27,8 @@ Site design by [kantorp-wegl.in](http://kantorp-wegl.in/) * Recurring invoices * Tax rates and payment terms * Multi-user support +* [Zapier](https://zapier.com/) integration +* [D3.js](http://d3js.org/) visualizations ### Steps to setup diff --git a/app/controllers/ReportController.php b/app/controllers/ReportController.php index 05ece2f02e..1d1e734921 100755 --- a/app/controllers/ReportController.php +++ b/app/controllers/ReportController.php @@ -4,16 +4,24 @@ class ReportController extends \BaseController { public function d3() { - $account = Auth::user()->account; - $account = $account->with(['clients.invoices.invoice_items', 'clients.contacts'])->first(); + $message = ''; - $account = $account->hideFieldsForViz(); - $clients = $account->clients; - //dd($clients->toJson()); + if (Auth::user()->account->isPro()) { + $account = Auth::user()->account; + $account = $account->with(['clients.invoices.invoice_items', 'clients.contacts'])->first(); + $account = $account->hideFieldsForViz(); + $clients = $account->clients->toJson(); + } else if (isset($_ENV['DATA_VIZ_SAMPLE'])) { + $clients = $_ENV['DATA_VIZ_SAMPLE']; + $message = trans('texts.sample_data'); + } else { + $clients = '[]'; + } $data = [ - 'feature' => ACCOUNT_DATA_VISUALIZER, - 'clients' => $clients + 'feature' => ACCOUNT_DATA_VISUALIZATIONS, + 'clients' => $clients, + 'message' => $message ]; return View::make('reports.d3', $data); diff --git a/app/lang/de/texts.php b/app/lang/de/texts.php index 86025be7e7..c4c44257cf 100644 --- a/app/lang/de/texts.php +++ b/app/lang/de/texts.php @@ -420,6 +420,7 @@ return array( 'cancel_account_message' => 'Warning: This will permanently erase all of your data, there is no undo.', 'go_back' => 'Go Back', - 'data_visualizer' => 'Data Visualizer', - + 'data_visualizations' => 'Data Visualizations', + 'sample_data' => 'Sample data shown', + ); diff --git a/app/lang/en/texts.php b/app/lang/en/texts.php index 38acf5da56..f7a2e0295b 100644 --- a/app/lang/en/texts.php +++ b/app/lang/en/texts.php @@ -428,6 +428,8 @@ return array( 'cancel_account_message' => 'Warning: This will permanently erase all of your data, there is no undo.', 'go_back' => 'Go Back', - 'data_visualizer' => 'Data Visualizer', - + 'data_visualizations' => 'Data Visualizations', + 'sample_data' => 'Sample data shown', + + ); \ No newline at end of file diff --git a/app/lang/es/texts.php b/app/lang/es/texts.php index cdee606660..05a63547e3 100644 --- a/app/lang/es/texts.php +++ b/app/lang/es/texts.php @@ -418,6 +418,7 @@ return array( 'cancel_account_message' => 'Warning: This will permanently erase all of your data, there is no undo.', 'go_back' => 'Go Back', - 'data_visualizer' => 'Data Visualizer', - + 'data_visualizations' => 'Data Visualizations', + 'sample_data' => 'Sample data shown', + ); diff --git a/app/lang/fr/texts.php b/app/lang/fr/texts.php index 5add2301c6..5565e5be70 100644 --- a/app/lang/fr/texts.php +++ b/app/lang/fr/texts.php @@ -420,6 +420,8 @@ return array( 'cancel_account_message' => 'Warning: This will permanently erase all of your data, there is no undo.', 'go_back' => 'Go Back', - 'data_visualizer' => 'Data Visualizer', + 'data_visualizations' => 'Data Visualizations', + 'sample_data' => 'Sample data shown', + ); diff --git a/app/lang/it/texts.php b/app/lang/it/texts.php index 4c1e002d8b..a2c8ad2dec 100644 --- a/app/lang/it/texts.php +++ b/app/lang/it/texts.php @@ -420,5 +420,7 @@ return array( 'cancel_account_message' => 'Warning: This will permanently erase all of your data, there is no undo.', 'go_back' => 'Go Back', - 'data_visualizer' => 'Data Visualizer', + 'data_visualizations' => 'Data Visualizations', + 'sample_data' => 'Sample data shown', + ); diff --git a/app/lang/lt/texts.php b/app/lang/lt/texts.php index 14d3773f07..9364251271 100644 --- a/app/lang/lt/texts.php +++ b/app/lang/lt/texts.php @@ -428,7 +428,9 @@ return array( 'cancel_account_message' => 'Warning: This will permanently erase all of your data, there is no undo.', 'go_back' => 'Go Back', - 'data_visualizer' => 'Data Visualizer', + 'data_visualizations' => 'Data Visualizations', + 'sample_data' => 'Sample data shown', + ); diff --git a/app/lang/nb_NO/texts.php b/app/lang/nb_NO/texts.php index 47e9155c7e..e590a2cb4e 100644 --- a/app/lang/nb_NO/texts.php +++ b/app/lang/nb_NO/texts.php @@ -428,6 +428,8 @@ return array( 'cancel_account_message' => 'Warning: This will permanently erase all of your data, there is no undo.', 'go_back' => 'Go Back', - 'data_visualizer' => 'Data Visualizer', + 'data_visualizations' => 'Data Visualizations', + 'sample_data' => 'Sample data shown', + ); \ No newline at end of file diff --git a/app/lang/nl/texts.php b/app/lang/nl/texts.php index 060a04cf08..f5b3718995 100644 --- a/app/lang/nl/texts.php +++ b/app/lang/nl/texts.php @@ -421,6 +421,8 @@ return array( 'cancel_account_message' => 'Warning: This will permanently erase all of your data, there is no undo.', 'go_back' => 'Go Back', - 'data_visualizer' => 'Data Visualizer', + 'data_visualizations' => 'Data Visualizations', + 'sample_data' => 'Sample data shown', + ); diff --git a/app/lang/pt_BR/texts.php b/app/lang/pt_BR/texts.php index 3a478d6874..5084cff31f 100644 --- a/app/lang/pt_BR/texts.php +++ b/app/lang/pt_BR/texts.php @@ -409,6 +409,8 @@ return array( 'cancel_account_message' => 'Warning: This will permanently erase all of your data, there is no undo.', 'go_back' => 'Go Back', - 'data_visualizer' => 'Data Visualizer', + 'data_visualizations' => 'Data Visualizations', + 'sample_data' => 'Sample data shown', + ); diff --git a/app/models/Account.php b/app/models/Account.php index 10ada5ec49..c8327c8d66 100755 --- a/app/models/Account.php +++ b/app/models/Account.php @@ -258,6 +258,7 @@ class Account extends Eloquent foreach ($this->clients as $client) { $client->setVisible([ + 'public_id', 'name', 'balance', 'paid_to_date', @@ -268,6 +269,7 @@ class Account extends Eloquent foreach ($client->invoices as $invoice) { $invoice->setVisible([ + 'public_id', 'invoice_number', 'amount', 'balance', diff --git a/app/routes.php b/app/routes.php index e2aed07458..9befd80562 100755 --- a/app/routes.php +++ b/app/routes.php @@ -80,7 +80,7 @@ Route::group(array('before' => 'auth'), function() Route::resource('products', 'ProductController'); Route::get('products/{product_id}/archive', 'ProductController@archive'); - Route::get('company/advanced_settings/data_visualizer', 'ReportController@d3'); + Route::get('company/advanced_settings/data_visualizations', 'ReportController@d3'); Route::get('company/advanced_settings/chart_builder', 'ReportController@report'); Route::post('company/advanced_settings/chart_builder', 'ReportController@report'); @@ -171,7 +171,7 @@ define('ACCOUNT_CUSTOM_FIELDS', 'custom_fields'); define('ACCOUNT_INVOICE_DESIGN', 'invoice_design'); define('ACCOUNT_CHART_BUILDER', 'chart_builder'); define('ACCOUNT_USER_MANAGEMENT', 'user_management'); -define('ACCOUNT_DATA_VISUALIZER', 'data_visualizer'); +define('ACCOUNT_DATA_VISUALIZATIONS', 'data_visualizations'); define('DEFAULT_INVOICE_NUMBER', '0001'); define('RECENTLY_VIEWED_LIMIT', 8); diff --git a/app/views/accounts/nav_advanced.blade.php b/app/views/accounts/nav_advanced.blade.php index 224b5177c8..498a28d43b 100644 --- a/app/views/accounts/nav_advanced.blade.php +++ b/app/views/accounts/nav_advanced.blade.php @@ -1,7 +1,7 @@ diff --git a/app/views/plans.blade.php b/app/views/plans.blade.php index 6aa004835e..1617aeb9dd 100644 --- a/app/views/plans.blade.php +++ b/app/views/plans.blade.php @@ -11,7 +11,7 @@
Multi-user support
Quotes/pro-forma invoices
Custom invoice fields and colors
-
Dynamic chart builder
+
Dynamic data vizualizations
Priority email support
Remove "Created by Invoice Ninja"
Latest and greatest features
@@ -29,7 +29,7 @@
Multi-user support
Quotes/pro-forma invoices
Custom fields and invoice colors
-
Dynamic chart builder
+
Dynamic data vizualizations
Priority email support
Remove "Created by Invoice Ninja"
Latest and greatest features
@@ -47,7 +47,7 @@
Multi-user support
Quotes/pro-forma invoices
Custom invoice fields and colors
-
Dynamic chart builder
+
Dynamic data vizualizations
Priority email support
Remove "Created by Invoice Ninja"
Latest and greatest features
diff --git a/app/views/reports/d3.blade.php b/app/views/reports/d3.blade.php index 7a879312d8..70099d20bc 100644 --- a/app/views/reports/d3.blade.php +++ b/app/views/reports/d3.blade.php @@ -32,6 +32,10 @@ @parent @include('accounts.nav_advanced') + {{ Former::open() }} + {{ Former::legend('data_visualizations') }} + {{ Former::close() }} +