diff --git a/resources/views/conversations/search.blade.php b/resources/views/conversations/search.blade.php new file mode 100644 index 0000000..494be29 --- /dev/null +++ b/resources/views/conversations/search.blade.php @@ -0,0 +1,175 @@ +@extends('layouts.app') + +@section('title', ($q ? $q.' - ' : '').strip_tags(Eventy::filter('search.title', __('Search')))) +@section('body_class', 'body-search') + +@section('sidebar') + @include('partials/sidebar_menu_toggle') + + +@endsection + +@section('content') + + + +
+ + @if ($mode == App\Conversation::SEARCH_MODE_CONV) + @include('conversations/conversations_table', ['mailbox' => $search_mailbox, 'params' => ['target_blank' => true, 'show_mailbox' => (count(Auth::user()->mailboxesCanView(true)) > 1)]]) + @else + @include('freescout-restricted-customers::customers/partials/customers_table') + @endif +
+@endsection + +@include('partials/include_datepicker') + +@section('javascript') + @parent + searchInit(); +@endsection diff --git a/resources/views/customers/partials/customers_table.blade.php b/resources/views/customers/partials/customers_table.blade.php new file mode 100644 index 0000000..e70eb3c --- /dev/null +++ b/resources/views/customers/partials/customers_table.blade.php @@ -0,0 +1,26 @@ +@if (count($customers)) +
+
+ +
+ + @if ($customers->lastPage() > 1) +
+ {{ $customers->links('conversations/conversations_pagination') }} +
+ @endif +
+@else + @include('partials/empty', ['empty_text' => __('No customers found')]) +@endif diff --git a/src/Http/Controllers/ConversationsController.php b/src/Http/Controllers/ConversationsController.php index d30a511..c8ce45b 100644 --- a/src/Http/Controllers/ConversationsController.php +++ b/src/Http/Controllers/ConversationsController.php @@ -7,6 +7,7 @@ namespace MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers; use App\Conversation; +use App\User; use Illuminate\Http\Request; use App\Http\Controllers\ConversationsController as BaseConversationsController; use MillionsMissingFrance\FreescoutRestrictedCustomers\Customer; @@ -90,7 +91,7 @@ class ConversationsController extends BaseConversationsController { $search_mailbox = $mailboxes[0]; } - return view('conversations/search', [ + return view('freescout-restricted-customers::conversations/search', [ 'folder' => $folder, 'q' => $request->q, 'filters' => $filters, @@ -154,9 +155,11 @@ class ConversationsController extends BaseConversationsController { $query->orWhere('customers.phones', $like_op, '%"'.$phone_numeric.'"%'); } - }) - // Restrict the query to the Customers the current User is allowed to access. - ->whereIn('customers.mailbox_id', $mailbox_ids); + }); + // Restrict the query to the Customers the current User is allowed to access. + if ( $user->role != User::ROLE_ADMIN ) { + $query_customers->whereIn('customers.mailbox_id', $mailbox_ids); + } if (!empty($filters['mailbox']) && in_array($filters['mailbox'], $mailbox_ids)) { $query_customers->where('customers.mailbox_id', '=', $filters['mailbox']); diff --git a/src/Http/Controllers/CustomersController.php b/src/Http/Controllers/CustomersController.php index 59e2a7b..8a59737 100644 --- a/src/Http/Controllers/CustomersController.php +++ b/src/Http/Controllers/CustomersController.php @@ -377,7 +377,7 @@ class CustomersController extends BaseCustomersController { $response['status'] = 'success'; - $response['html'] = view('customers/partials/customers_table', [ + $response['html'] = view('freescout-restricted-customers::customers/partials/customers_table', [ 'customers' => $customers, ])->render(); break;