diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index b57fad5e0660..d52caebe6c68 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -6,6 +6,7 @@ use Redirect; use Session; use Utils; use View; +use Event; use App\Models\Account; use App\Models\Country; diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 23681afb285e..8a777144760e 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -6,6 +6,7 @@ use Redirect; use App\Models\Account; use Auth; use View; +use Input; class HomeController extends BaseController { diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 84da87b0f611..bf76fd8edbcb 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -4,8 +4,21 @@ use Auth; use Session; use Utils; use View; +use Input; +use Cache; use App\Models\Invoice; +use App\Models\Client; +use App\Models\Account; +use App\Models\Product; +use App\Models\Country; +use App\Models\TaxRate; +use App\Models\Currency; +use App\Models\Size; +use App\Models\Industry; +use App\Models\PaymentTerm; +use App\Models\InvoiceDesign; + use App\Ninja\Mailers\ContactMailer as Mailer; use App\Ninja\Repositories\InvoiceRepository; use App\Ninja\Repositories\ClientRepository; @@ -300,6 +313,7 @@ class InvoiceController extends BaseController } } + /* return [ 'account' => Auth::user()->account, 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), @@ -323,6 +337,31 @@ class InvoiceController extends BaseController ), 'recurringHelp' => $recurringHelp ]; + */ + + return [ + 'account' => Auth::user()->account, + 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), + 'countries' => Country::orderBy('name')->get(), + 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), + 'taxRates' => TaxRate::scope()->orderBy('name')->get(), + 'currencies' => Cache::get('currencies'), + 'sizes' => Size::orderBy('id')->get(), + 'paymentTerms' => PaymentTerm::orderBy('num_days')->get(['name', 'num_days']), + 'industries' => Industry::orderBy('name')->get(), + 'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), + 'frequencies' => array( + 1 => 'Weekly', + 2 => 'Two weeks', + 3 => 'Four weeks', + 4 => 'Monthly', + 5 => 'Three months', + 6 => 'Six months', + 7 => 'Annually', + ), + 'recurringHelp' => $recurringHelp + ]; + } /** diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index 6e08ed94c3da..a9f974bd773b 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -6,6 +6,9 @@ use App; use Auth; use Input; use Redirect; +use Cache; + +use App\Models\Currency; class StartupCheck { @@ -34,6 +37,11 @@ class StartupCheck { return $next($request); } + // Check currency data has been cached + if (!Cache::has('currencies')) + { + Cache::forever('currencies', Currency::orderBy('name')->get()); + } // check the application is up to date and for any news feed messages if (Auth::check()) diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index c131ba9d5b5b..e9780fe6a722 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -9,6 +9,8 @@ use Request; use View; use App\Models\Currency; use DateTimeZone; +use Input; +use Log; class Utils { @@ -303,8 +305,8 @@ class Utils return; } - $timezone = Session::get(SESSION_TIMEZONE); - $format = Session::get(SESSION_DATE_FORMAT); + $timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE); + $format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT); $dateTime = DateTime::createFromFormat($format, $date, new DateTimeZone($timezone)); @@ -317,8 +319,8 @@ class Utils return ''; } - $timezone = Session::get(SESSION_TIMEZONE); - $format = Session::get(SESSION_DATE_FORMAT); + $timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE); + $format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT); $dateTime = DateTime::createFromFormat('Y-m-d', $date, new DateTimeZone($timezone)); @@ -327,8 +329,9 @@ class Utils public static function today($formatResult = true) { - $timezone = Session::get(SESSION_TIMEZONE); - $format = Session::get(SESSION_DATE_FORMAT); + $timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE); + $format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT); + $date = date_create(null, new DateTimeZone($timezone)); if ($formatResult) { diff --git a/app/Models/User.php b/app/Models/User.php index 983b8cde19ba..0967ed236069 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -1,5 +1,7 @@ @if (Auth::check()) @if (!Auth::user()->registered) - {!! Button::sm_success_primary(trans('texts.sign_up'), array('id' => 'signUpButton', 'data-toggle'=>'modal', 'data-target'=>'#signUpModal')) !!}   + {!! Button::success(trans('texts.sign_up'), array('id' => 'signUpButton', 'data-toggle'=>'modal', 'data-target'=>'#signUpModal')) !!}   @elseif (!Auth::user()->isPro()) - {!! Button::sm_success_primary(trans('texts.go_pro'), array('id' => 'proPlanButton', 'data-toggle'=>'modal', 'data-target'=>'#proPlanModal')) !!}   + {!! Button::success(trans('texts.go_pro'), array('id' => 'proPlanButton', 'data-toggle'=>'modal', 'data-target'=>'#proPlanModal')) !!}   @endif @endif diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 3537b641ecbe..fc64af3e0d91 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -1051,7 +1051,7 @@ function InvoiceModel(data) { var self = this; this.client = ko.observable(data ? false : new ClientModel()); - self.account = {{ $account }}; + self.account = {!! $account !!}; this.id = ko.observable(''); self.discount = ko.observable(''); self.is_amount_discount = ko.observable(0); @@ -1607,7 +1607,7 @@ var clientMap = {}; var $clientSelect = $('select#client'); - var invoiceDesigns = {{ $invoiceDesigns }}; + var invoiceDesigns = {!! $invoiceDesigns !!}; for (var i=0; igetInvoiceLabels()) }}; + var invoiceLabels = {!! json_encode($account->getInvoiceLabels()) !!}; var isRefreshing = false; var needsRefresh = false; diff --git a/resources/views/public/header.blade.php b/resources/views/public/header.blade.php index 32d0dffbfc5a..fe71592f4fd3 100644 --- a/resources/views/public/header.blade.php +++ b/resources/views/public/header.blade.php @@ -120,10 +120,10 @@ table.table thead .sorting_desc_disabled:after { content: '' !important } }(document, 'script', 'facebook-jssdk')); --> -{{ Form::open(array('url' => 'get_started', 'id' => 'startForm')) }} -{{ Form::hidden('guest_key') }} -{{ Form::hidden('sign_up', Input::get('sign_up')) }} -{{ Form::close() }} +{!! Form::open(array('url' => 'get_started', 'id' => 'startForm')) !!} +{!! Form::hidden('guest_key') !!} +{!! Form::hidden('sign_up', Input::get('sign_up')) !!} +{!! Form::close() !!}