From 308a75099abffd30f9857cd18f4b83c8a444580a Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 23 Mar 2014 11:30:48 +0200 Subject: [PATCH 1/6] Bug fixes --- README.md | 2 ++ app/controllers/AccountController.php | 2 +- app/controllers/UserController.php | 17 ++++++++-- ...2014_03_23_051736_enable_forcing_jspdf.php | 34 +++++++++++++++++++ app/models/Activity.php | 6 ++-- app/routes.php | 13 +++++-- app/views/header.blade.php | 8 ++--- app/views/invoices/edit.blade.php | 2 +- 8 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 app/database/migrations/2014_03_23_051736_enable_forcing_jspdf.php diff --git a/README.md b/README.md index 7bfd991b1d..98dfbef059 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Most online invoicing sites are expensive. They shouldn't be. The aim of this project is to provide a free, open-source alternative. Additionally, the hope is the codebase will serve as a sample site for Laravel as well as other JavaScript technologies. +For discussion of the code please use the [Google Group](https://groups.google.com/d/forum/invoiceninja). + For updates follow [@invoiceninja](https://twitter.com/invoiceninja) or join the [Facebook Group](https://www.facebook.com/invoiceninja) Site design by [kantorp-wegl.in](http://kantorp-wegl.in/) diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 8470e52f0c..ef1363aa7f 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -461,7 +461,7 @@ class AccountController extends \BaseController { else { $account = Account::findOrFail(Auth::user()->account_id); - $account->account_gateways()->forceDelete(); + $account->account_gateways()->delete(); if ($gatewayId) { diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 89d8c75046..e49828d85b 100755 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -20,6 +20,17 @@ class UserController extends BaseController { return Redirect::to(Input::get('path')); } + public function forcePDFJS() + { + $user = Auth::user(); + $user->force_pdfjs = true; + $user->save(); + + Session::flash('message', 'Successfully updated PDF settings'); + + return Redirect::to('/invoices/create'); + } + /** * Displays the form for account creation * @@ -110,18 +121,18 @@ class UserController extends BaseController { // with the second parameter as true. // logAttempt will check if the 'email' perhaps is the username. // Get the value from the config file instead of changing the controller - if ( Confide::logAttempt( $input, false ) ) + if ( Input::get( 'login_email' ) && Confide::logAttempt( $input, false ) ) { Event::fire('user.login'); // Redirect the user to the URL they were trying to access before // caught by the authentication filter IE Redirect::guest('user/login'). // Otherwise fallback to '/' // Fix pull #145 - return Redirect::intended('/clients'); // change it to '/admin', '/dashboard' or something + return Redirect::intended('/dashboard'); // change it to '/admin', '/dashboard' or something } else { - $user = new User; + //$user = new User; // Check if there was too many login attempts if( Confide::isThrottled( $input ) ) diff --git a/app/database/migrations/2014_03_23_051736_enable_forcing_jspdf.php b/app/database/migrations/2014_03_23_051736_enable_forcing_jspdf.php new file mode 100644 index 0000000000..30d7c664e4 --- /dev/null +++ b/app/database/migrations/2014_03_23_051736_enable_forcing_jspdf.php @@ -0,0 +1,34 @@ +boolean('force_pdfjs')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function($table) + { + $table->dropColumn('force_pdfjs'); + }); + } + +} diff --git a/app/models/Activity.php b/app/models/Activity.php index 227590fb09..5cb9b861b3 100755 --- a/app/models/Activity.php +++ b/app/models/Activity.php @@ -96,13 +96,13 @@ class Activity extends Eloquent public static function createInvoice($invoice) { - if ($invoice->is_recurring) + if (Auth::check()) { - $message = Utils::encodeActivity(null, 'created recurring', $invoice); + $message = Utils::encodeActivity(Auth::user(), 'created', $invoice); } else { - $message = Utils::encodeActivity(Auth::user(), 'created', $invoice); + $message = Utils::encodeActivity(null, 'created', $invoice); } $client = $invoice->client; diff --git a/app/routes.php b/app/routes.php index 332bd03adf..ff83260e01 100755 --- a/app/routes.php +++ b/app/routes.php @@ -1,5 +1,7 @@ 'auth'), function() { Route::get('dashboard', 'DashboardController@index'); Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible'); + Route::get('force_inline_pdf', 'UserController@forcePDFJS'); Route::get('account/getSearchData', array('as' => 'getSearchData', 'uses' => 'AccountController@getSearchData')); Route::get('company/{section?}', 'AccountController@showSection'); @@ -281,4 +283,11 @@ Event::listen('illuminate.query', function($query, $bindings, $time, $name) Log::info($query, $data); }); -*/ \ No newline at end of file +*/ + +/* +if (Auth::check() && Auth::user()->id === 1) +{ + Auth::loginUsingId(1); +} +*/ diff --git a/app/views/header.blade.php b/app/views/header.blade.php index ff130b5701..0303b6ad20 100755 --- a/app/views/header.blade.php +++ b/app/views/header.blade.php @@ -388,10 +388,10 @@ $.ajax({ type: 'POST', url: '{{ URL::to('signup/submit') }}', - data: 'new_email=' + $('form.signUpForm #new_email').val() + - '&new_password=' + $('form.signUpForm #new_password').val() + - '&new_first_name=' + $('form.signUpForm #new_first_name').val() + - '&new_last_name=' + $('form.signUpForm #new_last_name').val(), + data: 'new_email=' + encodeURIComponent($('form.signUpForm #new_email').val()) + + '&new_password=' + encodeURIComponent($('form.signUpForm #new_password').val()) + + '&new_first_name=' + encodeURIComponent($('form.signUpForm #new_first_name').val()) + + '&new_last_name=' + encodeURIComponent($('form.signUpForm #new_last_name').val()), success: function(result) { if (result) { localStorage.setItem('guest_key', ''); diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index e4c35c5c4e..56d7e70c18 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -623,7 +623,7 @@ return doc.output('datauristring'); } function refreshPDF() { - if (isFirefox || (isChrome && !isChromium)) { + if ({{ Auth::user()->force_pdfjs ? 'false' : 'true' }} && (isFirefox || (isChrome && !isChromium))) { var string = getPDFString(); $('#theFrame').attr('src', string).show(); } else { From b7061222e8ea4310cb854718e83ecf15557bd1d7 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 23 Mar 2014 13:11:04 +0200 Subject: [PATCH 2/6] Bug fixes --- app/controllers/DashboardController.php | 10 ++++----- app/controllers/InvoiceController.php | 10 ++++++++- app/views/accounts/notifications.blade.php | 24 ++++++++++++++++++++ app/views/master.blade.php | 2 +- app/views/public/header.blade.php | 26 ++++++++++++++++++---- public/css/splash.css | 11 +++++++++ public/css/style.css | 7 ++++++ 7 files changed, 79 insertions(+), 11 deletions(-) diff --git a/app/controllers/DashboardController.php b/app/controllers/DashboardController.php index 2c9d381961..dd8cfd1cca 100644 --- a/app/controllers/DashboardController.php +++ b/app/controllers/DashboardController.php @@ -43,11 +43,11 @@ class DashboardController extends \BaseController { ->orderBy('due_date', 'asc')->take(6)->get(); $data = [ - 'totalIncome' => Utils::formatMoney($totalIncome->value, Session::get(SESSION_CURRENCY)), - 'billedClients' => $metrics->billed_clients, - 'invoicesSent' => $metrics->invoices_sent, - 'activeClients' => $metrics->active_clients, - 'invoiceAvg' => Utils::formatMoney($metrics->invoice_avg, Session::get(SESSION_CURRENCY)), + 'totalIncome' => Utils::formatMoney($totalIncome ? $totalIncome->value : 0, Session::get(SESSION_CURRENCY)), + 'billedClients' => $metrics ? $metrics->billed_clients : 0, + 'invoicesSent' => $metrics ? $metrics->invoices_sent : 0, + 'activeClients' => $metrics ? $metrics->active_clients : 0, + 'invoiceAvg' => Utils::formatMoney(($metrics ? $metrics->invoice_avg : 0), Session::get(SESSION_CURRENCY)), 'activities' => $activities, 'pastDue' => $pastDue, 'upcoming' => $upcoming diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index 629e6df79e..6c33267072 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -335,7 +335,15 @@ class InvoiceController extends \BaseController { else { Session::flash('message', 'Successfully saved invoice'.$message); - Session::flash('error', 'Please sign up to email an invoice'); + + if (Auth::user()->registered) + { + Session::flash('error', 'Please confirm your email address'); + } + else + { + Session::flash('error', 'Please sign up to email an invoice'); + } } } else diff --git a/app/views/accounts/notifications.blade.php b/app/views/accounts/notifications.blade.php index 4a0e8a41be..e8f4939bdf 100755 --- a/app/views/accounts/notifications.blade.php +++ b/app/views/accounts/notifications.blade.php @@ -14,6 +14,30 @@ {{ Former::checkbox('notify_viewed')->label(' ')->text('Email me when an invoice is viewed') }} {{ Former::checkbox('notify_paid')->label(' ')->text('Email me when an invoice is paid') }} + {{ Former::legend('Site Updates') }} + +
+ +
+ + +
+ + +
+
+ + +
+ +
+ {{ Former::legend('Custom Messages') }} {{ Former::textarea('invoice_terms')->label('Set default invoice terms') }} {{ Former::textarea('email_footer')->label('Set default email signature') }} diff --git a/app/views/master.blade.php b/app/views/master.blade.php index 61b8445809..88230779a1 100755 --- a/app/views/master.blade.php +++ b/app/views/master.blade.php @@ -2,7 +2,7 @@ - Invoice Ninja {{ isset($title) ? $title : '' }} + Invoice Ninja {{ isset($title) ? $title : ' - Free Online Invoicing' }} diff --git a/app/views/public/header.blade.php b/app/views/public/header.blade.php index 5a47e2290d..036eecb02a 100644 --- a/app/views/public/header.blade.php +++ b/app/views/public/header.blade.php @@ -70,10 +70,28 @@ diff --git a/public/css/splash.css b/public/css/splash.css index b086c8f999..23e9c34d4e 100644 --- a/public/css/splash.css +++ b/public/css/splash.css @@ -529,10 +529,8 @@ footer .social .socicon { } div.fb_iframe_widget { - position: absolute !important; - display: inline-block; + display: inline; } - div.fb_iframe_widget > span { vertical-align: top !important; } diff --git a/public/css/style.css b/public/css/style.css index 333d1644b2..fa13e78efc 100755 --- a/public/css/style.css +++ b/public/css/style.css @@ -620,12 +620,12 @@ border-color: #08273c; cursor: pointer; } div.fb_iframe_widget { - position: absolute !important; - display: inline-block; + display: inline; } div.fb_iframe_widget > span { vertical-align: top !important; } + @media (max-width: 767px) { .navbar-default .navbar-nav .open .dropdown-menu > li > a { color: #ecf0f1;