diff --git a/.env.example b/.env.example index 20c977c663e9..66d2d5251b27 100644 --- a/.env.example +++ b/.env.example @@ -20,11 +20,25 @@ MAIL_FROM_ADDRESS MAIL_FROM_NAME MAIL_PASSWORD +#POSTMARK_API_TOKEN= + PHANTOMJS_CLOUD_KEY='a-demo-key-with-low-quota-per-ip-address' LOG=single REQUIRE_HTTPS=false API_SECRET=password -GOOGLE_CLIENT_ID -GOOGLE_CLIENT_SECRET -GOOGLE_OAUTH_REDIRECT=http://ninja.dev/auth/google \ No newline at end of file +#TRUSTED_PROXIES= + +#SESSION_DRIVER= +#SESSION_DOMAIN= +#SESSION_ENCRYPT= +#SESSION_SECURE= + +#CACHE_DRIVER= +#CACHE_HOST= +#CACHE_PORT1= +#CACHE_PORT2= + +#GOOGLE_CLIENT_ID= +#GOOGLE_CLIENT_SECRET= +#GOOGLE_OAUTH_REDIRECT=http://ninja.dev/auth/google \ No newline at end of file diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index 42bef1d1e5d7..10e21fd66745 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -189,7 +189,7 @@ class AccountRepository return $invitation; } - public function createNinjaInvoice($client, $account) + public function createNinjaInvoice($client, $clientAccount) { $account = $this->getNinjaAccount(); $lastInvoice = Invoice::withTrashed()->whereAccountId($account->id)->orderBy('public_id', 'DESC')->first(); @@ -201,7 +201,7 @@ class AccountRepository $invoice->public_id = $publicId; $invoice->client_id = $client->id; $invoice->invoice_number = $account->getNextInvoiceNumber($invoice); - $invoice->invoice_date = $account->getRenewalDate(); + $invoice->invoice_date = $clientAccount->getRenewalDate(); $invoice->amount = PRO_PLAN_PRICE; $invoice->balance = PRO_PLAN_PRICE; $invoice->save(); diff --git a/app/Ninja/Repositories/ClientRepository.php b/app/Ninja/Repositories/ClientRepository.php index 324d62a45943..2e8ce31b5c1c 100644 --- a/app/Ninja/Repositories/ClientRepository.php +++ b/app/Ninja/Repositories/ClientRepository.php @@ -1,6 +1,7 @@ with('contacts')->firstOrFail(); } + // convert currency code to id + if (isset($data['currency_code'])) { + $currencyCode = strtolower($data['currency_code']); + $currency = Cache::get('currencies')->filter(function($item) use ($currencyCode) { + return strtolower($item->code) == $currencyCode; + })->first(); + if ($currency) { + $data['currency_id'] = $currency->id; + } + } + $client->fill($data); $client->save(); diff --git a/public/built.js b/public/built.js index cfb777e86e0e..5e28b8fb3f18 100644 --- a/public/built.js +++ b/public/built.js @@ -30967,6 +30967,29 @@ function prettyJson(json) { return '' + match + ''; }); } + +function searchData(data, key, fuzzy) { + return function findMatches(q, cb) { + var matches, substringRegex; + if (fuzzy) { + var options = { + keys: [key], + } + var fuse = new Fuse(data, options); + matches = fuse.search(q); + } else { + matches = []; + substrRegex = new RegExp(q, 'i'); + $.each(data, function(i, obj) { + if (substrRegex.test(obj[key])) { + matches.push(obj); + } + }); + } + cb(matches); + } +}; + var NINJA = NINJA || {}; NINJA.TEMPLATES = { diff --git a/public/css/built.css b/public/css/built.css index 8fc151f77508..d4b3a8204e6b 100644 --- a/public/css/built.css +++ b/public/css/built.css @@ -2060,7 +2060,7 @@ See http://bgrins.github.io/spectrum/themes/ for instructions. /*root typeahead class*/ .twitter-typeahead { - display: inherit !important; + /*display: inherit !important;*/ width: 100%; } diff --git a/public/css/typeahead.js-bootstrap.css b/public/css/typeahead.js-bootstrap.css index da8cbf605407..9f4125d18e34 100644 --- a/public/css/typeahead.js-bootstrap.css +++ b/public/css/typeahead.js-bootstrap.css @@ -4,7 +4,7 @@ /*root typeahead class*/ .twitter-typeahead { - display: inherit !important; + /*display: inherit !important;*/ width: 100%; } diff --git a/public/js/script.js b/public/js/script.js index a8201d3c427e..67031a5fe3c9 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1074,4 +1074,26 @@ function prettyJson(json) { match = snakeToCamel(match); return '' + match + ''; }); -} \ No newline at end of file +} + +function searchData(data, key, fuzzy) { + return function findMatches(q, cb) { + var matches, substringRegex; + if (fuzzy) { + var options = { + keys: [key], + } + var fuse = new Fuse(data, options); + matches = fuse.search(q); + } else { + matches = []; + substrRegex = new RegExp(q, 'i'); + $.each(data, function(i, obj) { + if (substrRegex.test(obj[key])) { + matches.push(obj); + } + }); + } + cb(matches); + } +}; diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 9f9c3aa3ed3b..f541eec53329 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -259,13 +259,11 @@ } function showSearch() { - console.log('showSearch..'); - //$('#search').typeahead('setQuery', ''); + $('#search').typeahead('val', ''); $('#navbar-options').hide(); $('#search-form').show(); if (window.hasOwnProperty('loadedSearchData')) { - console.log('has data'); $('#search').focus(); } else { trackEvent('/activity', '/search'); @@ -275,68 +273,24 @@ $('#search').typeahead({ hint: true, highlight: true, - }, - { + } + @foreach (['clients', 'contacts', 'invoices', 'quotes', 'navigation'] as $type) + ,{ name: 'data', display: 'value', - source: searchData(data['clients']), + source: searchData(data['{{ $type }}'], 'value', true), templates: { - header: ' {{ trans('texts.clients') }}' + header: ' {{ trans("texts.{$type}") }}' } - }, - { - name: 'data', - display: 'value', - source: searchData(data['contacts']), - templates: { - header: ' {{ trans('texts.contacts') }}' - } - }, - { - name: 'data', - display: 'value', - source: searchData(data['invoices']), - templates: { - header: ' {{ trans('texts.contacts') }}' - } - }, - { - name: 'data', - display: 'value', - source: searchData(data['quotes']), - templates: { - header: ' {{ trans('texts.quotes') }}' - } - }, - { - name: 'data', - display: 'value', - source: searchData(data['navigation']), - templates: { - header: ' {{ trans('texts.navigation') }}' - } - }).on('typeahead:selected', function(element, datum, name) { + } + @endforeach + ).on('typeahead:selected', function(element, datum, name) { window.location = datum.url; }).focus(); - - //.typeahead('setQuery', $('#search').val()); }); } } - - function searchData(data) { - return function findMatches(q, cb) { - - var options = { - keys: ['value'], - } - var fuse = new Fuse(data, options); - var matches = fuse.search(q); - - cb(matches); - } - }; - + function hideSearch() { $('#search-form').hide(); $('#navbar-options').show(); diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 548cc41e232c..fc09aeaf6249 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -209,11 +209,7 @@ $parent.invoice_items().length > 1" class="fa fa-sort"> - {!! Former::text('product_key')->useDatalist($products->toArray(), 'product_key') - ->data_bind("value: product_key, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + \$index() + '][product_key]'}") - ->addClass('datalist') - ->raw() - !!} +