diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 52cfa0e5a655..762be28a2852 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -68,7 +68,7 @@ class AccountController extends \BaseController { if ($section == ACCOUNT_DETAILS) { $account = Account::with('users')->findOrFail(Auth::user()->account_id); - $countries = Country::orderBy('name')->get(); + $countries = Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(); return View::make('accounts.details', array('account'=>$account, 'countries'=>$countries)); } @@ -88,11 +88,11 @@ class AccountController extends \BaseController { 'account' => $account, 'accountGateway' => $accountGateway, 'config' => json_decode($config), - 'gateways' => Gateway::all(), - 'timezones' => Timezone::orderBy('location')->get(), - 'dateFormats' => DateFormat::all(), - 'datetimeFormats' => DatetimeFormat::all(), - 'currencies' => Currency::orderBy('name')->get(), + '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) diff --git a/app/controllers/ClientController.php b/app/controllers/ClientController.php index 8deb38eb2406..563c274085d6 100755 --- a/app/controllers/ClientController.php +++ b/app/controllers/ClientController.php @@ -86,10 +86,10 @@ class ClientController extends \BaseController { 'method' => 'POST', 'url' => 'clients', 'title' => '- New Client', - 'clientSizes' => ClientSize::orderBy('id')->get(), - 'clientIndustries' => ClientIndustry::orderBy('name')->get(), - 'currencies' => Currency::orderBy('name')->get(), - 'countries' => Country::orderBy('name')->get()); + 'clientSizes' => ClientSize::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), + 'clientIndustries' => ClientIndustry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), + 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), + 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get()); return View::make('clients.edit', $data); } @@ -138,10 +138,10 @@ class ClientController extends \BaseController { 'method' => 'PUT', 'url' => 'clients/' . $publicId, 'title' => '- ' . $client->name, - 'clientSizes' => ClientSize::orderBy('id')->get(), - 'clientIndustries' => ClientIndustry::orderBy('name')->get(), - 'currencies' => Currency::orderBy('name')->get(), - 'countries' => Country::orderBy('name')->get()); + 'clientSizes' => ClientSize::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), + 'clientIndustries' => ClientIndustry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), + 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), + 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get()); return View::make('clients.edit', $data); } diff --git a/app/controllers/CreditController.php b/app/controllers/CreditController.php index e435f606f746..27aa916136fe 100755 --- a/app/controllers/CreditController.php +++ b/app/controllers/CreditController.php @@ -76,7 +76,7 @@ class CreditController extends \BaseController { 'method' => 'POST', 'url' => 'credits', 'title' => '- New Credit', - 'currencies' => Currency::orderBy('name')->get(), + 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('credits.edit', $data); @@ -91,7 +91,7 @@ class CreditController extends \BaseController { 'method' => 'PUT', 'url' => 'credits/' . $publicId, 'title' => '- Edit Credit', - 'currencies' => Currency::orderBy('name')->get(), + 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('credit.edit', $data); } diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index b45e4b6cd97c..3f4572ec634b 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -310,8 +310,6 @@ class InvoiceController extends \BaseController { 'invoice' => $invoice, 'method' => 'PUT', 'invitationContactIds' => $contactIds, - 'clientSizes' => ClientSize::orderBy('id')->get(), - 'clientIndustries' => ClientIndustry::orderBy('name')->get(), 'url' => 'invoices/' . $publicId, 'title' => '- ' . $invoice->invoice_number, 'client' => $invoice->client); @@ -335,8 +333,6 @@ class InvoiceController extends \BaseController { 'invoiceNumber' => $invoiceNumber, 'method' => 'POST', 'url' => 'invoices', - 'clientSizes' => ClientSize::orderBy('id')->get(), - 'clientIndustries' => ClientIndustry::orderBy('name')->get(), 'title' => '- New Invoice', 'client' => $client, 'items' => json_decode(Input::old('items'))); @@ -349,10 +345,12 @@ class InvoiceController extends \BaseController { return [ 'account' => Auth::user()->account, 'products' => Product::scope()->get(array('product_key','notes','cost','qty')), - 'countries' => Country::orderBy('name')->get(), + 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), - 'currencies' => Currency::orderBy('name')->get(), + 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), + 'clientSizes' => ClientSize::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), + 'clientIndustries' => ClientIndustry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'frequencies' => array( 1 => 'Weekly', 2 => 'Two weeks', diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index 300419d9ae86..915f5677b84a 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -80,7 +80,7 @@ class PaymentController extends \BaseController 'method' => 'POST', 'url' => 'payments', 'title' => '- New Payment', - 'currencies' => Currency::orderBy('name')->get(), + 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('payments.edit', $data); @@ -97,7 +97,7 @@ class PaymentController extends \BaseController 'method' => 'PUT', 'url' => 'payments/' . $publicId, 'title' => '- Edit Payment', - 'currencies' => Currency::orderBy('name')->get(), + 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('payments.edit', $data); } diff --git a/app/models/Client.php b/app/models/Client.php index 5372a7b5f112..f97fb5b7c5bc 100755 --- a/app/models/Client.php +++ b/app/models/Client.php @@ -54,6 +54,18 @@ class Client extends EntityModel return $this->name; } + public function getDisplayName() + { + if ($this->name) + { + return $this->name; + } + + $contact = $this->contacts()->first(); + + return $contact->getFullName(); + } + public function getEntityType() { return ENTITY_CLIENT; diff --git a/app/routes.php b/app/routes.php index a5cc2c5aef88..91bbc3e01993 100755 --- a/app/routes.php +++ b/app/routes.php @@ -180,3 +180,5 @@ define('DEFAULT_CURRENCY', 1); // US Dollar define('DEFAULT_DATE_FORMAT', 'M j, Y'); define('DEFAULT_DATE_PICKER_FORMAT', 'yyyy-mm-dd'); define('DEFAULT_DATETIME_FORMAT', 'F j, Y, g:i a'); + +define('DEFAULT_QUERY_CACHE', 120); \ No newline at end of file diff --git a/app/views/header.blade.php b/app/views/header.blade.php index 1fb9d10f5d21..8c38327bcaf7 100755 --- a/app/views/header.blade.php +++ b/app/views/header.blade.php @@ -151,7 +151,7 @@
-