From 1e5634c305bfe8110ddf17c8dfbfb29d31980dab Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 9 Jan 2014 19:00:08 +0000 Subject: [PATCH] bug fixes --- app/commands/SendRecurringInvoices.php | 4 +- app/config/packages/zizaco/confide/config.php | 2 +- app/controllers/ClientController.php | 14 ++-- app/controllers/UserController.php | 2 +- app/models/Account.php | 12 +++ app/ninja/repositories/ClientRepository.php | 5 +- app/routes.php | 9 ++- app/views/invoices/edit.blade.php | 13 +-- app/views/users/reset_password.blade.php | 79 +++++++++++++++++++ app/views/users/reset_password.php | 55 +++++++++++++ 10 files changed, 176 insertions(+), 19 deletions(-) create mode 100755 app/views/users/reset_password.blade.php create mode 100755 app/views/users/reset_password.php diff --git a/app/commands/SendRecurringInvoices.php b/app/commands/SendRecurringInvoices.php index 7ae6f1f4270b..d634c1c1187b 100755 --- a/app/commands/SendRecurringInvoices.php +++ b/app/commands/SendRecurringInvoices.php @@ -24,11 +24,13 @@ class SendRecurringInvoices extends Command { $today = new DateTime(); - $invoices = Invoice::with('account', 'invoice_items')->whereRaw('is_recurring is true AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', array($today, $today))->get(); + $invoices = Invoice::with('account.timezone', 'invoice_items')->whereRaw('is_recurring is true AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', array($today, $today))->get(); $this->info(count($invoices) . ' recurring invoice(s) found'); foreach ($invoices as $recurInvoice) { + date_default_timezone_set($recurInvoice->account->getTimezone()); + $this->info('Processing Invoice ' . $recurInvoice->id . ' - Should send ' . ($recurInvoice->shouldSendToday() ? 'YES' : 'NO')); if (!$recurInvoice->shouldSendToday()) diff --git a/app/config/packages/zizaco/confide/config.php b/app/config/packages/zizaco/confide/config.php index 21cc78fec664..76ea482697f2 100755 --- a/app/config/packages/zizaco/confide/config.php +++ b/app/config/packages/zizaco/confide/config.php @@ -50,7 +50,7 @@ return array( 'login_form' => 'users.login', 'signup_form' => 'confide::signup', 'forgot_password_form' => 'users.forgot_password', - 'reset_password_form' => 'confide::reset_password', + 'reset_password_form' => 'users.reset_password', /* |-------------------------------------------------------------------------- diff --git a/app/controllers/ClientController.php b/app/controllers/ClientController.php index 4020bc9e7432..57effd9b04e0 100755 --- a/app/controllers/ClientController.php +++ b/app/controllers/ClientController.php @@ -37,7 +37,7 @@ class ClientController extends \BaseController { ->addColumn('first_name', function($model) { return link_to('clients/' . $model->public_id, $model->first_name . ' ' . $model->last_name); }) ->addColumn('email', function($model) { return link_to('clients/' . $model->public_id, $model->email); }) ->addColumn('created_at', function($model) { return Utils::timestampToDateString(strtotime($model->created_at)); }) - ->addColumn('last_login', function($model) { return Utils::timestampToDateString($model->last_login); }) + ->addColumn('last_login', function($model) { return Utils::timestampToDateString(strtotime($model->last_login)); }) ->addColumn('balance', function($model) { return Utils::formatMoney($model->balance, $model->currency_id); }) ->addColumn('dropdown', function($model) { @@ -213,12 +213,14 @@ class ClientController extends \BaseController { $contact->delete(); } } - - Activity::createClient($client); - - if ($publicId) { + + if ($publicId) + { Session::flash('message', 'Successfully updated client'); - } else { + } + else + { + Activity::createClient($client); Session::flash('message', 'Successfully created client'); } diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 1d431209695e..f6082cb5e4ac 100755 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -216,7 +216,7 @@ class UserController extends BaseController { 'password'=>Input::get( 'password' ), 'password_confirmation'=>Input::get( 'password_confirmation' ), ); - + // By passing an array with the token, password and confirmation if( Confide::resetPassword( $input ) ) { diff --git a/app/models/Account.php b/app/models/Account.php index 6f0058d63cff..58ced9dfa2a1 100755 --- a/app/models/Account.php +++ b/app/models/Account.php @@ -73,6 +73,18 @@ class Account extends Eloquent } } + public function getTimezone() + { + if ($this->timezone) + { + return $this->timezone->name; + } + else + { + return 'US/Eastern'; + } + } + public function getGatewayConfig($gatewayId) { foreach ($this->account_gateways as $gateway) diff --git a/app/ninja/repositories/ClientRepository.php b/app/ninja/repositories/ClientRepository.php index 4103e3b512e8..80b861f4e7e4 100755 --- a/app/ninja/repositories/ClientRepository.php +++ b/app/ninja/repositories/ClientRepository.php @@ -96,7 +96,10 @@ class ClientRepository $client->save(); - \Activity::createClient($client); + if ($publicId == "-1") + { + \Activity::createClient($client); + } return $client; } diff --git a/app/routes.php b/app/routes.php index 7a93c6c613a1..482263f94e78 100755 --- a/app/routes.php +++ b/app/routes.php @@ -59,11 +59,12 @@ Route::get('/test', function() { }); */ +/* // TODO_FIX replace with cron Route::get('/send_emails', function() { Artisan::call('ninja:send-invoices'); }); - +*/ //Route::get('/', 'HomeController@showComingSoon'); Route::get('/', 'HomeController@showWelcome'); @@ -83,11 +84,11 @@ Route::post('signup/submit', 'AccountController@submitSignup'); // Confide routes Route::get('login', 'UserController@login'); Route::post('login', 'UserController@do_login'); -Route::get( 'user/confirm/{code}', 'UserController@confirm'); +Route::get('user/confirm/{code}', 'UserController@confirm'); Route::get('forgot_password', 'UserController@forgot_password'); Route::post('forgot_password', 'UserController@do_forgot_password'); -//Route::get('user/reset_password/{token}', 'UserController@reset_password'); -//Route::post('user/reset_password', 'UserController@do_reset_password'); +Route::get('user/reset/{token}', 'UserController@reset_password'); +Route::post('user/reset', 'UserController@do_reset_password'); Route::get('logout', 'UserController@logout'); diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index 12ee304bcb91..e7506af84025 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -47,7 +47,7 @@
@@ -1156,11 +1156,14 @@ self.phone = ko.observable(''); self.send_invoice = ko.observable(false); - /* - self.displayName = ko.computed(function() { - return self.first_name() + ' ' + self.last_name() + ' - ' + self.email(); + self.email.display = ko.computed(function() { + var str = ''; + if (self.first_name() || self.last_name()) { + str += self.first_name() + ' ' + self.last_name() + ' - '; + } + return str + self.email(); }); - */ + if (data) { ko.mapping.fromJS(data, {}, this); diff --git a/app/views/users/reset_password.blade.php b/app/views/users/reset_password.blade.php new file mode 100755 index 000000000000..f64a5347e6a6 --- /dev/null +++ b/app/views/users/reset_password.blade.php @@ -0,0 +1,79 @@ +@extends('master') + +@section('head') + + + +@stop + +@section('body') +
+ + {{ Former::open('user/reset')->addClass('form-signin') }} + + + +

+ {{ Former::password('password') }} + {{ Former::password('password_confirmation')->label('Confirm') }} + +

+ +

{{ Button::primary_submit('Save', array('class' => 'btn-lg'))->block() }}

+ + + @if ( Session::get('error') ) +
{{{ Session::get('error') }}}
+ @endif + + @if ( Session::get('notice') ) +
{{{ Session::get('notice') }}}
+ @endif + + + {{ Former::close() }} + +
+ +@stop \ No newline at end of file diff --git a/app/views/users/reset_password.php b/app/views/users/reset_password.php new file mode 100755 index 000000000000..caa9c3f24e7d --- /dev/null +++ b/app/views/users/reset_password.php @@ -0,0 +1,55 @@ +@extends('master') + +@section('head') + + + +@stop + +@section('body') +
+ +
+ +@stop \ No newline at end of file