From 284a90dd2562fad22b1477def315a59f08105fc7 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 18 Feb 2014 17:07:22 +0200 Subject: [PATCH] bug fixes --- app/controllers/AccountController.php | 91 +++++++++++-------- app/routes.php | 11 ++- app/views/accounts/details.blade.php | 24 +++-- app/views/accounts/import.blade.php | 12 --- app/views/accounts/import_export.blade.php | 17 ++++ app/views/accounts/import_map.blade.php | 4 +- app/views/accounts/nav.blade.php | 8 +- app/views/accounts/notifications.blade.php | 24 +++++ ...{settings.blade.php => payments.blade.php} | 20 ---- app/views/emails/invoice_paid_html.blade.php | 2 +- app/views/emails/invoice_paid_text.blade.php | 2 +- app/views/emails/invoice_sent_html.blade.php | 2 +- app/views/emails/invoice_sent_text.blade.php | 2 +- .../emails/invoice_viewed_html.blade.php | 2 +- .../emails/invoice_viewed_text.blade.php | 2 +- app/views/header.blade.php | 11 ++- app/views/master.blade.php | 3 + app/views/splash.blade.php | 2 - 18 files changed, 136 insertions(+), 103 deletions(-) delete mode 100755 app/views/accounts/import.blade.php create mode 100755 app/views/accounts/import_export.blade.php create mode 100755 app/views/accounts/notifications.blade.php rename app/views/accounts/{settings.blade.php => payments.blade.php} (67%) diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index a8f716619097..cb5239fa69cf 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -74,11 +74,15 @@ class AccountController extends \BaseController { 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), + 'timezones' => Timezone::remember(DEFAULT_QUERY_CACHE)->orderBy('location')->get(), + 'dateFormats' => DateFormat::remember(DEFAULT_QUERY_CACHE)->get(), + 'datetimeFormats' => DatetimeFormat::remember(DEFAULT_QUERY_CACHE)->get(), + 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), ]; return View::make('accounts.details', $data); } - else if ($section == ACCOUNT_SETTINGS) + else if ($section == ACCOUNT_PAYMENTS) { $account = Account::with('account_gateways')->findOrFail(Auth::user()->account_id); $accountGateway = null; @@ -95,10 +99,6 @@ class AccountController extends \BaseController { 'accountGateway' => $accountGateway, 'config' => json_decode($config), 'gateways' => Gateway::remember(DEFAULT_QUERY_CACHE)->get(), - 'timezones' => Timezone::remember(DEFAULT_QUERY_CACHE)->orderBy('location')->get(), - 'dateFormats' => DateFormat::remember(DEFAULT_QUERY_CACHE)->get(), - 'datetimeFormats' => DatetimeFormat::remember(DEFAULT_QUERY_CACHE)->get(), - 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), ]; foreach ($data['gateways'] as $gateway) @@ -111,15 +111,19 @@ class AccountController extends \BaseController { } } - return View::make('accounts.settings', $data); + return View::make('accounts.payments', $data); } - else if ($section == ACCOUNT_IMPORT) + else if ($section == ACCOUNT_NOTIFICATIONS) { - return View::make('accounts.import'); + $data = [ + 'account' => Account::with('users')->findOrFail(Auth::user()->account_id), + ]; + + return View::make('accounts.notifications', $data); } - else if ($section == ACCOUNT_EXPORT) + else if ($section == ACCOUNT_IMPORT_EXPORT) { - return View::make('accounts.export'); + return View::make('accounts.import_export'); } } @@ -129,11 +133,11 @@ class AccountController extends \BaseController { { return AccountController::saveDetails(); } - else if ($section == ACCOUNT_SETTINGS) + else if ($section == ACCOUNT_PAYMENTS) { - return AccountController::saveSettings(); + return AccountController::savePayments(); } - else if ($section == ACCOUNT_IMPORT) + else if ($section == ACCOUNT_IMPORT_EXPORT) { return AccountController::importFile(); } @@ -141,6 +145,10 @@ class AccountController extends \BaseController { { return AccountController::mapFile(); } + else if ($section == ACCOUNT_NOTIFICATIONS) + { + return AccountController::saveNotifications(); + } else if ($section == ACCOUNT_EXPORT) { return AccountController::export(); @@ -306,7 +314,7 @@ class AccountController extends \BaseController { if (count($csv->data) + Client::scope()->count() > MAX_NUM_CLIENTS) { Session::flash('error', "Sorry, this wll exceed the limit of " . MAX_NUM_CLIENTS . " clients"); - return Redirect::to('account/import'); + return Redirect::to('company/import_export'); } Session::put('data', $csv->data); @@ -396,7 +404,24 @@ class AccountController extends \BaseController { return View::make('accounts.import_map', $data); } - private function saveSettings() + private function saveNotifications() + { + $account = Account::findOrFail(Auth::user()->account_id); + $account->invoice_terms = Input::get('invoice_terms'); + $account->email_footer = Input::get('email_footer'); + $account->save(); + + $user = Auth::user(); + $user->notify_sent = Input::get('notify_sent'); + $user->notify_viewed = Input::get('notify_viewed'); + $user->notify_paid = Input::get('notify_paid'); + $user->save(); + + Session::flash('message', 'Successfully updated settings'); + return Redirect::to('company/notifications'); + } + + private function savePayments() { $rules = array(); @@ -418,33 +443,15 @@ class AccountController extends \BaseController { if ($validator->fails()) { - return Redirect::to('account/settings') + return Redirect::to('company/settings') ->withErrors($validator) ->withInput(); } else { - $account = Account::findOrFail(Auth::user()->account_id); + $account = Account::findOrFail(Auth::user()->account_id); $account->account_gateways()->forceDelete(); - $account->timezone_id = Input::get('timezone_id') ? Input::get('timezone_id') : null; - $account->date_format_id = Input::get('date_format_id') ? Input::get('date_format_id') : null; - $account->datetime_format_id = Input::get('datetime_format_id') ? Input::get('datetime_format_id') : null; - $account->currency_id = Input::get('currency_id') ? Input::get('currency_id') : 1; - - $account->invoice_terms = Input::get('invoice_terms'); - $account->email_footer = Input::get('email_footer'); - - $account->save(); - - $user = Auth::user(); - $user->notify_sent = Input::get('notify_sent'); - $user->notify_viewed = Input::get('notify_viewed'); - $user->notify_paid = Input::get('notify_paid'); - $user->save(); - - Event::fire('user.refresh'); - if ($gatewayId) { $accountGateway = AccountGateway::createNew(); @@ -455,15 +462,13 @@ class AccountController extends \BaseController { { $config->$field = trim(Input::get($gateway->id.'_'.$field)); } - //dd(Input::all()); - //dd($config); $accountGateway->config = json_encode($config); $account->account_gateways()->save($accountGateway); } Session::flash('message', 'Successfully updated settings'); - return Redirect::to('account/settings'); + return Redirect::to('company/payments'); } } @@ -478,7 +483,7 @@ class AccountController extends \BaseController { if ($validator->fails()) { - return Redirect::to('account/details') + return Redirect::to('company/details') ->withErrors($validator) ->withInput(); } @@ -494,6 +499,10 @@ class AccountController extends \BaseController { $account->country_id = Input::get('country_id') ? Input::get('country_id') : null; $account->size_id = Input::get('size_id') ? Input::get('size_id') : null; $account->industry_id = Input::get('industry_id') ? Input::get('industry_id') : null; + $account->timezone_id = Input::get('timezone_id') ? Input::get('timezone_id') : null; + $account->date_format_id = Input::get('date_format_id') ? Input::get('date_format_id') : null; + $account->datetime_format_id = Input::get('datetime_format_id') ? Input::get('datetime_format_id') : null; + $account->currency_id = Input::get('currency_id') ? Input::get('currency_id') : 1; $account->save(); $user = Auth::user(); @@ -512,8 +521,10 @@ class AccountController extends \BaseController { Image::make($path)->resize(120, 80, true, false)->save('logo/' . $account->account_key . '.jpg'); } + Event::fire('user.refresh'); + Session::flash('message', 'Successfully updated details'); - return Redirect::to('account/details'); + return Redirect::to('company/details'); } } diff --git a/app/routes.php b/app/routes.php index cf6af334d1a5..21ccf56c9f4d 100755 --- a/app/routes.php +++ b/app/routes.php @@ -86,8 +86,8 @@ Route::group(array('before' => 'auth'), function() { Route::get('dashboard', 'DashboardController@index'); Route::get('account/getSearchData', array('as' => 'getSearchData', 'uses' => 'AccountController@getSearchData')); - Route::get('account/{section?}', 'AccountController@showSection'); - Route::post('account/{section?}', 'AccountController@doSection'); + Route::get('company/{section?}', 'AccountController@showSection'); + Route::post('company/{section?}', 'AccountController@doSection'); Route::post('user/setTheme', 'UserController@setTheme'); Route::resource('clients', 'ClientController'); @@ -164,7 +164,7 @@ HTML::macro('breadcrumbs', function() { for ($i=0; $iusers()->first()->phone) }}
-
+
{{ Former::legend('Account') }} {{ Former::text('name') }} {{ Former::file('logo')->max(2, 'MB')->accept('image')->wrap('test')->inlineHelp('Recommnded size: 120px width, 80px height') }} + {{ Former::select('size_id')->addOption('','')->label('Size') + ->fromQuery($sizes, 'name', 'id') }} + {{ Former::select('industry_id')->addOption('','')->label('Industry') + ->fromQuery($industries, 'name', 'id') }} @if (file_exists($account->getLogoPath()))
@@ -46,7 +50,7 @@
-
+
{{ Former::legend('Users') }} {{ Former::text('first_name') }} @@ -54,11 +58,17 @@ {{ Former::text('email') }} {{ Former::text('phone') }} - {{ Former::legend('Additional Info') }} - {{ Former::select('size_id')->addOption('','')->label('Size') - ->fromQuery($sizes, 'name', 'id') }} - {{ Former::select('industry_id')->addOption('','')->label('Industry') - ->fromQuery($industries, 'name', 'id') }} + + {{ Former::legend('Localization') }} + {{ Former::select('currency_id')->addOption('','')->label('Currency') + ->fromQuery($currencies, 'name', 'id') }} + {{ Former::select('timezone_id')->addOption('','')->label('Timezone') + ->fromQuery($timezones, 'location', 'id') }} + {{ Former::select('date_format_id')->addOption('','')->label('Date Format') + ->fromQuery($dateFormats, 'label', 'id') }} + {{ Former::select('datetime_format_id')->addOption('','')->label('Date/Time Format') + ->fromQuery($datetimeFormats, 'label', 'id') }} +
diff --git a/app/views/accounts/import.blade.php b/app/views/accounts/import.blade.php deleted file mode 100755 index 548a587c2431..000000000000 --- a/app/views/accounts/import.blade.php +++ /dev/null @@ -1,12 +0,0 @@ -@extends('accounts.nav') - -@section('content') - @parent - - {{ Former::open_for_files('account/import_map')->addClass('col-md-9 col-md-offset-1') }} - {{ Former::legend('Import Client Data') }} - {{ Former::file('file')->label('Select CSV file') }} - {{ Former::actions( Button::lg_primary_submit('Upload') ) }} - {{ Former::close() }} - -@stop \ No newline at end of file diff --git a/app/views/accounts/import_export.blade.php b/app/views/accounts/import_export.blade.php new file mode 100755 index 000000000000..4f3841092ebd --- /dev/null +++ b/app/views/accounts/import_export.blade.php @@ -0,0 +1,17 @@ +@extends('accounts.nav') + +@section('content') + @parent + + {{ Former::open_for_files('company/import_map')->addClass('col-md-9 col-md-offset-1') }} + {{ Former::legend('Import Client Data') }} + {{ Former::file('file')->label('Select CSV file') }} + {{ Former::actions( Button::lg_primary_submit('Upload') ) }} + {{ Former::close() }} + + {{ Former::open('company/export')->addClass('col-md-9 col-md-offset-1') }} + {{ Former::legend('Export Client Data') }} + {{ Former::actions( Button::lg_primary_submit('Download') ) }} + {{ Former::close() }} + +@stop \ No newline at end of file diff --git a/app/views/accounts/import_map.blade.php b/app/views/accounts/import_map.blade.php index b49125f83f7e..d56146bf95e2 100755 --- a/app/views/accounts/import_map.blade.php +++ b/app/views/accounts/import_map.blade.php @@ -3,7 +3,7 @@ @section('content') @parent - {{ Former::open('account/import') }} + {{ Former::open('company/import_export') }} {{ Former::legend('Import Clients') }} @if ($headers) @@ -33,7 +33,7 @@ @endif - {{ Former::actions( Button::lg_primary_submit('Import'), ' | ', link_to('account/import', 'Cancel') ) }} + {{ Former::actions( Button::lg_primary_submit('Import'), ' | ', link_to('company/import', 'Cancel') ) }} {{ Former::close() }}