1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Working on users in L5

This commit is contained in:
Hillel Coren 2015-03-30 22:45:10 +03:00
parent 58746d9eec
commit f4930681b0
11 changed files with 70 additions and 16 deletions

View File

@ -6,6 +6,7 @@ use Redirect;
use Session;
use Utils;
use View;
use Event;
use App\Models\Account;
use App\Models\Country;

View File

@ -6,6 +6,7 @@ use Redirect;
use App\Models\Account;
use Auth;
use View;
use Input;
class HomeController extends BaseController
{

View File

@ -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
];
}
/**

View File

@ -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())

View File

@ -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) {

View File

@ -1,5 +1,7 @@
<?php namespace App\Models;
use Session;
use Auth;
use App\Libraries\Utils;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;

View File

@ -57,9 +57,9 @@
<div class="navbar-form navbar-right">
@if (Auth::check())
@if (!Auth::user()->registered)
{!! Button::sm_success_primary(trans('texts.sign_up'), array('id' => 'signUpButton', 'data-toggle'=>'modal', 'data-target'=>'#signUpModal')) !!} &nbsp;
{!! Button::success(trans('texts.sign_up'), array('id' => 'signUpButton', 'data-toggle'=>'modal', 'data-target'=>'#signUpModal')) !!} &nbsp;
@elseif (!Auth::user()->isPro())
{!! Button::sm_success_primary(trans('texts.go_pro'), array('id' => 'proPlanButton', 'data-toggle'=>'modal', 'data-target'=>'#proPlanModal')) !!} &nbsp;
{!! Button::success(trans('texts.go_pro'), array('id' => 'proPlanButton', 'data-toggle'=>'modal', 'data-target'=>'#proPlanModal')) !!} &nbsp;
@endif
@endif

View File

@ -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; i<clients.length; i++) {
var client = clients[i];

View File

@ -75,7 +75,7 @@
NINJA.primaryColor = "{{ $account->primary_color }}";
NINJA.secondaryColor = "{{ $account->secondary_color }}";
var invoiceLabels = {{ json_encode($account->getInvoiceLabels()) }};
var invoiceLabels = {!! json_encode($account->getInvoiceLabels()) !!};
var isRefreshing = false;
var needsRefresh = false;

View File

@ -120,10 +120,10 @@ table.table thead .sorting_desc_disabled:after { content: '' !important }
}(document, 'script', 'facebook-jssdk'));</script>
-->
{{ 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() !!}
<script>
if (isStorageSupported()) {

View File

@ -1,6 +1,6 @@
<script type="text/javascript">
var currencies = {!! \Cache::pull('currency') !!};
var currencies = {!! \Cache::get('currencies') !!};
var currencyMap = {};
for (var i=0; i<currencies.length; i++) {
var currency = currencies[i];