From 47315363116966315bb36ec636cd9509289f789d Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 12 Jan 2014 18:55:33 +0000 Subject: [PATCH] bug fixes --- README.md | 2 +- app/controllers/AccountController.php | 2 +- app/controllers/CreditController.php | 7 ++++-- app/controllers/InvoiceController.php | 18 ++++----------- app/controllers/PaymentController.php | 9 +++++--- app/controllers/UserController.php | 10 ++++---- app/models/Activity.php | 1 - app/models/Contact.php | 14 +++++------- app/models/User.php | 18 ++++++++------- app/ninja/repositories/CreditRepository.php | 5 ++++ app/ninja/repositories/InvoiceRepository.php | 23 +++++++++++++++++++ app/ninja/repositories/PaymentRepository.php | 5 ++++ app/routes.php | 5 +--- app/views/header.blade.php | 2 +- app/views/invoices/edit.blade.php | 4 ++-- app/views/splash.blade.php | 4 ++-- app/views/users/login.blade.php | 8 +++---- public/js/script.js | 24 +++++++++++++------- 18 files changed, 98 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 58d501e02ead..3ce1ef3e10ee 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Invoice Ninja ## Simple, Intuitive Invoicing -### Live demo: [http://www.invoiceninja.com](http://www.invoiceninja.com) +### [http://www.invoiceninja.com](http://www.invoiceninja.com) ### Introduction 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 this codebase will serve as a sample site for Laravel as well as other JavaScript technologies. diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 75d87ad1ba93..af642671c917 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -201,7 +201,7 @@ class AccountController extends \BaseController { $count = 0; $hasHeaders = Input::get('header_checkbox'); - $countries = Country::all(); + $countries = Country::remember(DEFAULT_QUERY_CACHE)->all(); $countryMap = []; foreach ($countries as $country) { $countryMap[strtolower($country->name)] = $country->id; diff --git a/app/controllers/CreditController.php b/app/controllers/CreditController.php index e00221283976..42483b8514da 100755 --- a/app/controllers/CreditController.php +++ b/app/controllers/CreditController.php @@ -131,8 +131,11 @@ class CreditController extends \BaseController { $ids = Input::get('id') ? Input::get('id') : Input::get('ids'); $count = $this->creditRepo->bulk($ids, $action); - $message = Utils::pluralize('Successfully '.$action.'d ? credit', $count); - Session::flash('message', $message); + if ($count > 0) + { + $message = Utils::pluralize('Successfully '.$action.'d ? credit', $count); + Session::flash('message', $message); + } return Redirect::to('credits'); } diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index ed104a56e3b6..355b1cd162f1 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -500,22 +500,14 @@ class InvoiceController extends \BaseController { { $action = Input::get('action'); $ids = Input::get('id') ? Input::get('id') : Input::get('ids'); - $invoices = Invoice::scope($ids)->get(); + $count = $this->invoiceRepo->bulk($ids, $action); - foreach ($invoices as $invoice) - { - if ($action == 'delete') - { - $invoice->is_deleted = true; - $invoice->save(); - } - - $invoice->delete(); + if ($count > 0) + { + $message = Utils::pluralize('Successfully '.$action.'d ? invoice', $count); + Session::flash('message', $message); } - $message = Utils::pluralize('Successfully '.$action.'d ? invoice', count($invoices)); - Session::flash('message', $message); - return Redirect::to('invoices'); } diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index 70b8efd642f1..1dcf603aecf8 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -132,9 +132,12 @@ class PaymentController extends \BaseController $ids = Input::get('id') ? Input::get('id') : Input::get('ids'); $count = $this->paymentRepo->bulk($ids, $action); - $message = Utils::pluralize('Successfully '.$action.'d ? payment', count($payments)); - Session::flash('message', $message); - + if ($count > 0) + { + $message = Utils::pluralize('Successfully '.$action.'d ? payment', count($payments)); + Session::flash('message', $message); + } + return Redirect::to('payments'); } diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index f6082cb5e4ac..60735bfc4cf7 100755 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -90,9 +90,9 @@ class UserController extends BaseController { public function do_login() { $input = array( - 'email' => Input::get( 'email' ), // May be the username too - 'username' => Input::get( 'email' ), // so we have to pass both - 'password' => Input::get( 'password' ), + 'email' => Input::get( 'login_email' ), // May be the username too + 'username' => Input::get( 'login_email' ), // so we have to pass both + 'password' => Input::get( 'login_password' ), 'remember' => true, ); @@ -100,7 +100,7 @@ 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, Config::get('confide::signup_confirm') ) ) + if ( Confide::logAttempt( $input, false ) ) { Event::fire('user.login'); // Redirect the user to the URL they were trying to access before @@ -130,7 +130,7 @@ class UserController extends BaseController { } return Redirect::action('UserController@login') - ->withInput(Input::except('password')) + ->withInput(Input::except('login_password')) ->with( 'error', $err_msg ); } } diff --git a/app/models/Activity.php b/app/models/Activity.php index 98fb5ce865e0..303f9e5ec0f4 100755 --- a/app/models/Activity.php +++ b/app/models/Activity.php @@ -145,7 +145,6 @@ class Activity extends Eloquent $client->save(); } - $userName = Auth::check() ? Auth::user()->getFullName() : 'System'; $activity = Activity::getBlank($invitation); $activity->client_id = $invitation->invoice->client_id; $activity->invoice_id = $invitation->invoice_id; diff --git a/app/models/Contact.php b/app/models/Contact.php index b6179ce8cfc5..f30ced94d0e7 100755 --- a/app/models/Contact.php +++ b/app/models/Contact.php @@ -33,28 +33,26 @@ class Contact extends EntityModel public function getDisplayName() { - if (!$this->first_name && !$this->last_name) + if ($this->getFullName()) { - return $this->email; + return $this->getFullName(); } else { - return $this->getFullName(); + return $this->email; } } public function getFullName() { - $fullName = $this->first_name . ' ' . $this->last_name; - - if ($fullName == ' ') + if ($this->first_name || $this->last_name) { - return ''; + return $this->first_name . ' ' . $this->last_name; } else { - return $fullName; + return ''; } } diff --git a/app/models/User.php b/app/models/User.php index f5c71a7a9ae6..df730a0cbdc3 100755 --- a/app/models/User.php +++ b/app/models/User.php @@ -71,28 +71,30 @@ class User extends ConfideUser implements UserInterface, RemindableInterface public function getDisplayName() { - if (!$this->first_name && !$this->last_name) + if ($this->getFullName()) + { + return $this->getFullName(); + } + else if ($this->email) { return $this->email; } else { - return $this->getFullName(); + return 'Guest'; } - } + public function getFullName() { - $fullName = $this->first_name . ' ' . $this->last_name; - - if ($fullName == ' ') + if ($this->first_name || $this->last_name) { - return "Guest"; + return $this->first_name . ' ' . $this->last_name; } else { - return $fullName; + return ''; } } diff --git a/app/ninja/repositories/CreditRepository.php b/app/ninja/repositories/CreditRepository.php index 86c64f1aba31..68309316cddf 100755 --- a/app/ninja/repositories/CreditRepository.php +++ b/app/ninja/repositories/CreditRepository.php @@ -57,6 +57,11 @@ class CreditRepository public function bulk($ids, $action) { + if (!$ids) + { + return 0; + } + $credits = Credit::scope($ids)->get(); foreach ($credits as $credit) diff --git a/app/ninja/repositories/InvoiceRepository.php b/app/ninja/repositories/InvoiceRepository.php index e44642aec2be..88d29c9b611c 100755 --- a/app/ninja/repositories/InvoiceRepository.php +++ b/app/ninja/repositories/InvoiceRepository.php @@ -200,4 +200,27 @@ class InvoiceRepository return $invoice; } + + public function bulk($ids, $action) + { + if (!$ids) + { + return 0; + } + + $invoices = Invoice::scope($ids)->get(); + + foreach ($invoices as $invoice) + { + if ($action == 'delete') + { + $invoice->is_deleted = true; + $invoice->save(); + } + + $invoice->delete(); + } + + return count($invoices); + } } diff --git a/app/ninja/repositories/PaymentRepository.php b/app/ninja/repositories/PaymentRepository.php index 99728456b8f7..f5b019b6ce00 100755 --- a/app/ninja/repositories/PaymentRepository.php +++ b/app/ninja/repositories/PaymentRepository.php @@ -58,6 +58,11 @@ class PaymentRepository public function bulk($ids, $action) { + if (!$ids) + { + return 0; + } + $payments = Payment::scope($ids)->get(); foreach ($payments as $payment) diff --git a/app/routes.php b/app/routes.php index 482263f94e78..d35655527256 100755 --- a/app/routes.php +++ b/app/routes.php @@ -22,9 +22,6 @@ //Log::error('test'); - - -/* Event::listen('illuminate.query', function($query, $bindings, $time, $name) { $data = compact('bindings', 'time', 'name'); @@ -48,7 +45,7 @@ Event::listen('illuminate.query', function($query, $bindings, $time, $name) Log::info($query, $data); }); -*/ + /* Route::get('/test', function() { diff --git a/app/views/header.blade.php b/app/views/header.blade.php index bc875286294c..85c896519d21 100755 --- a/app/views/header.blade.php +++ b/app/views/header.blade.php @@ -300,7 +300,7 @@ $('.signUpForm').submit(); } else { $('#errorTaken').show(); - $('form.signUpForm #email').closest('div.form-group').removeClass('has-success').addClass('has-error'); + $('form.signUpForm #new_email').closest('div.form-group').removeClass('has-success').addClass('has-error'); $('#signUpDiv, #signUpFooter').show(); $('#working').hide(); } diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index cfbe446716e6..c4b3def76960 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -191,8 +191,8 @@
{{ Former::text('action') }} @if ($invoice) - {{ Former::text('id') }} - {{ Former::populateField('id', $invoice->id) }} + {{ Former::populateField('id', $invoice->public_id) }} + {{ Former::text('id') }} @endif
diff --git a/app/views/splash.blade.php b/app/views/splash.blade.php index cef44362059d..ca90fd3b9b25 100755 --- a/app/views/splash.blade.php +++ b/app/views/splash.blade.php @@ -14,10 +14,10 @@