From a57a4fcfc109c7f1d9edd65926a18c2378e36fb5 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 9 Jan 2014 21:38:18 +0000 Subject: [PATCH] bug fixes --- app/controllers/AccountController.php | 3 +++ app/libraries/utils.php | 2 +- app/models/Client.php | 4 ++-- app/ninja/repositories/AccountRepository.php | 3 +++ app/views/header.blade.php | 3 +++ app/views/invoices/edit.blade.php | 4 ++-- public/js/script.js | 4 ++-- 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index dd436cc168..75d87ad1ba 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -170,6 +170,9 @@ class AccountController extends \BaseController { $payments = Payment::where('account_id','=',Auth::user()->account_id)->get(); AccountController::exportData($output, $payments->toArray()); + $credits = Credit::where('account_id','=',Auth::user()->account_id)->get(); + AccountController::exportData($output, $credits->toArray()); + fclose($output); exit; } diff --git a/app/libraries/utils.php b/app/libraries/utils.php index feb12d2eb6..9bae76a191 100755 --- a/app/libraries/utils.php +++ b/app/libraries/utils.php @@ -41,7 +41,7 @@ class Utils public static function formatPhoneNumber($phoneNumber) { - $phoneNumber = preg_replace('/[^0-9]/','',$phoneNumber); + $phoneNumber = preg_replace('/[^0-9a-zA-Z]/','',$phoneNumber); if (!$phoneNumber) { return ''; diff --git a/app/models/Client.php b/app/models/Client.php index 54d2f3fe5c..ac56c095c3 100755 --- a/app/models/Client.php +++ b/app/models/Client.php @@ -117,9 +117,9 @@ class Client extends EntityModel { $str = ''; - if ($this->notes) + if ($this->private_notes) { - $str .= '' . $this->notes . ''; + $str .= '' . $this->private_notes . ''; } return $str; diff --git a/app/ninja/repositories/AccountRepository.php b/app/ninja/repositories/AccountRepository.php index fd22d39bf9..23bef9c541 100755 --- a/app/ninja/repositories/AccountRepository.php +++ b/app/ninja/repositories/AccountRepository.php @@ -9,17 +9,20 @@ class AccountRepository { $clients = \DB::table('clients') ->where('clients.deleted_at', '=', null) + ->where('clients.account_id', '=', \Auth::user()->account_id) ->whereRaw("clients.name <> ''") ->select(\DB::raw("'Clients' as type, clients.public_id, clients.name, '' as token")); $contacts = \DB::table('clients') ->join('contacts', 'contacts.client_id', '=', 'clients.id') ->where('clients.deleted_at', '=', null) + ->where('clients.account_id', '=', \Auth::user()->account_id) ->whereRaw("CONCAT(contacts.first_name, contacts.last_name, contacts.email) <> ''") ->select(\DB::raw("'Contacts' as type, clients.public_id, CONCAT(contacts.first_name, ' ', contacts.last_name, ' ', contacts.email) as name, '' as token")); $invoices = \DB::table('clients') ->join('invoices', 'invoices.client_id', '=', 'clients.id') + ->where('clients.account_id', '=', \Auth::user()->account_id) ->where('clients.deleted_at', '=', null) ->where('invoices.deleted_at', '=', null) ->select(\DB::raw("'Invoices' as type, invoices.public_id, CONCAT(invoices.invoice_number, ': ', clients.name) as name, invoices.invoice_number as token")); diff --git a/app/views/header.blade.php b/app/views/header.blade.php index e93b31dad1..bc87528629 100755 --- a/app/views/header.blade.php +++ b/app/views/header.blade.php @@ -343,6 +343,9 @@ local: data[type] }); } + if (datasets.length == 0) { + return; + } $('#search').typeahead(datasets).on('typeahead:selected', function(element, datum, name) { var type = name == 'Contacts' ? 'clients' : name.toLowerCase(); window.location = '{{ URL::to('/') }}' + '/' + type + '/' + datum.public_id; diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index e7506af840..cfbe446716 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -149,7 +149,7 @@ {{ Former::textarea('terms')->data_bind("value: wrapped_terms, valueUpdate: 'afterkeydown'") ->label(false)->placeholder('Invoice terms')->style('width: 520px; resize: none') ->addGroupClass('less-space-bottom') }} -