Samson Mutunga 1 рік тому
батько
коміт
edf8766637
21 змінених файлів з 639 додано та 44 видалено
  1. 24 0
      app/Http/Controllers/CustomerController.php
  2. 8 0
      app/Http/Controllers/InvoiceController.php
  3. 0 2
      app/Http/Controllers/MessageController.php
  4. 1 0
      app/Http/Kernel.php
  5. 0 5
      app/Http/Middleware/EnsureCompanyClient.php
  6. 22 0
      app/Http/Middleware/EnsureDefaultCompanyClient.php
  7. 55 0
      resources/views/app/invoice-center/ic-payment-methods.blade.php
  8. 30 0
      resources/views/app/patient/company-client/customer.blade.php
  9. 52 0
      resources/views/app/patient/company-client/customers.blade.php
  10. 1 1
      resources/views/app/patient/company-client/messages.blade.php
  11. 21 0
      resources/views/app/patient/company-client/partials/create-company-client-customer-form.blade.php
  12. 31 12
      resources/views/app/patient/company-client/partials/create-company-client-form.blade.php
  13. 21 0
      resources/views/app/patient/company-client/partials/customer-add-invoice-form.blade.php
  14. 45 0
      resources/views/app/patient/company-client/partials/customer-add-payment-method-form.blade.php
  15. 212 0
      resources/views/app/patient/company-client/partials/customer-invoices.blade.php
  16. 74 0
      resources/views/app/patient/company-client/partials/customer-payment-methods.blade.php
  17. 6 3
      resources/views/app/patient/company-client/show-set-company-client.blade.php
  18. 3 19
      resources/views/layouts/company-client-layout.blade.php
  19. 22 0
      resources/views/layouts/default-company-client-layout.blade.php
  20. 3 0
      resources/views/layouts/patient.blade.php
  21. 8 2
      routes/web.php

+ 24 - 0
app/Http/Controllers/CustomerController.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Support\Facades\Route;
+
+use Illuminate\Http\Request;
+use App\Models\Client;
+use App\Models\Customer;
+
+class CustomerController extends Controller
+{
+
+    public function customers(Request $request, Client $patient){
+       $customers = Customer::where('client_id', $patient->id)->paginate(25);
+        return view('app.patient.company-client.customers', compact('patient', 'customers'));
+    }
+
+    public function customer(Request $request, Client $patient, $slug){
+        $customer = Customer::where('slug', $slug)->first();
+         return view('app.patient.company-client.customer', compact('patient', 'customer'));
+     } 
+
+}

+ 8 - 0
app/Http/Controllers/InvoiceController.php

@@ -164,6 +164,14 @@ class InvoiceController extends Controller
         $company = $customer->company;
         return view('app.invoice-center.ic-pay-invoice', compact('invoice', 'customer', 'company'));
     }
+    public function icPaymentMethods(Request $request, $invoiceUid, $sessionKey = '') {
+        $customer = $this->getICCustomer($sessionKey);
+        if(!$customer) {
+            abort(404);
+        }
+        $company = $customer->company;
+        return view('app.invoice-center.ic-payment-methods', compact('customer', 'company'));
+    }
 
     public function icCustomerPortal(Request $request, $sessionKey = '') {
         $customer = $this->getICCustomer($sessionKey);

+ 0 - 2
app/Http/Controllers/MessageController.php

@@ -39,8 +39,6 @@ class MessageController extends Controller
         view()->share('otToken',$this->otToken);
     }
 
-
-
     public function messages(Request $request, Client $patient){
         $defaultCompanyClient = $this->getDefaultCompanyClientFromSession($patient);
         $defaultCompany = $defaultCompanyClient->company;

+ 1 - 0
app/Http/Kernel.php

@@ -71,5 +71,6 @@ class Kernel extends HttpKernel
         'pro.auth.can-access-patient' => \App\Http\Middleware\EnsureProCanAccessPatient::class,
         'client.not-shadow-of-pro' => \App\Http\Middleware\EnsureClientIsNotShadowOfPro::class,
         'client.has-company-client' => \App\Http\Middleware\EnsureCompanyClient::class,
+        'client.has-default-company-client' => \App\Http\Middleware\EnsureDefaultCompanyClient::class,
     ];
 }

+ 0 - 5
app/Http/Middleware/EnsureCompanyClient.php

@@ -16,11 +16,6 @@ class EnsureCompanyClient
             return redirect()->to(route('patients.view.show-set-company-client', $patient));
         }
 
-        $defaultCompanyClientUid = session()->get('DEFAULT_COMPANY_CLIENT_UID_'.@$patient->id);
-        if(!$defaultCompanyClientUid){
-            return redirect()->to(route('patients.view.show-set-default-company-client', $patient));
-        }
-
         return $next($request);
     }
 }

+ 22 - 0
app/Http/Middleware/EnsureDefaultCompanyClient.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Models\AppSession;
+use Closure;
+
+class EnsureDefaultCompanyClient
+{
+    public function handle($request, Closure $next)
+    {
+        $patient = $request->route()->parameter('patient');
+        if(!$patient) abort(403);
+        
+        $defaultCompanyClientUid = session()->get('DEFAULT_COMPANY_CLIENT_UID_'.@$patient->id);
+        if(!$defaultCompanyClientUid){
+            return redirect()->to(route('patients.view.show-set-default-company-client', $patient));
+        }
+
+        return $next($request);
+    }
+}

+ 55 - 0
resources/views/app/invoice-center/ic-payment-methods.blade.php

@@ -0,0 +1,55 @@
+@extends ('layouts.ic')
+@section('content')
+    <div class="container mcp-theme-1">
+        <div class="d-flex align-items-baseline mt-3 mb-2">
+            <h3 class="font-size-16 font-weight-bold text-dark">Payment Methods</h3>
+            <a href="{{ route('icCustomerPortal') }}" class="ml-auto">
+                <i class="fa fa-chevron-left"></i>
+                Back to Home
+            </a>
+        </div>
+        <hr class="mt-0 mb-3">
+        <div class="row">
+            <div class="col-md-8">
+                <div class="mb-3">Hi <b class="text-dark">{{ $customer->client->displayName() }}</b>, please provide your
+                    payment methods:</div>
+                <div class="">
+                    <div class="d-flex align-items-baseline mt-4">
+                        <h4 class="title-sm m-0">Payment Methods</h4>
+                        <div class="ml-3">
+                            @include('app.invoice-center._ic-add-payment-method-moe')
+                        </div>
+                    </div>
+                    <hr class="red-underline">
+                    @if (count($customer->paymentMethods))
+                        @php
+                            $index = 1;
+                        @endphp
+                        @foreach ($customer->paymentMethods as $method)
+                            <div class="mb-2 px-3 py-2 bg-light border">
+                                <div class="d-flex align-items-center flex-nowrap">
+                                    <span>{!! $method->displayName() !!}</span>
+                                    <div moe class="ml-3">
+                                        <a start show href="#" class="text-nowrap text-sm">Remove</a>
+                                        <form url="/api/paymentMethod/deactivate">
+                                            <input type="hidden" name="uid" value="{{ $method->uid }}">
+                                            <p class="text-secondary font-weight-bold mb-2 text-nowrap">Remove this Payment
+                                                Method?</p>
+                                            <div class="d-flex align-items-center">
+                                                <button submit class="btn btn-sm btn-primary me-2">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                </div>
+                            </div>
+                        @endforeach
+                    @else
+                        <div class="my-3">You have not set up any payment methods!</div>
+                    @endif
+                </div>
+            </div>
+
+        </div>
+    </div>
+@endsection

+ 30 - 0
resources/views/app/patient/company-client/customer.blade.php

@@ -0,0 +1,30 @@
+@extends ('layouts.company-client-layout')
+@section('company-client-content')
+<div>
+    <a href="{{ route('patients.view.customers', $patient) }}">
+        < Back to customers</a>
+</div>
+<div class="mb-1 bg-light">
+    <div class="row">
+        <div class="col-md-12">
+            <div>
+                <div class="d-flex align-items-end pb-3">
+                    <h4 class="font-weight-bold m-0">
+                        Customer: {{ $customer->company->name }}
+                    </h4>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>
+
+<div class="row">
+    <div class="col-md-6">
+        @include('app.patient.company-client.partials.customer-invoices')
+    </div>
+    <div class="col-md-6">
+        @include('app.patient.company-client.partials.customer-payment-methods')
+    </div>
+</div>
+@endsection

+ 52 - 0
resources/views/app/patient/company-client/customers.blade.php

@@ -0,0 +1,52 @@
+@extends ('layouts.company-client-layout')
+@section('company-client-content')
+<div class="mb-1 bg-light">
+    <div class="row">
+        <div class="col-md-12">
+            <div>
+                <div class="d-flex align-items-end pb-3">
+                    <h4 class="font-weight-bold m-0">
+                        Customer Records ({{ $customers->total()}})
+                    </h4>
+                    <span class="mx-2 text-secondary">|</span>
+                    @include('app.patient.company-client.partials.create-company-client-customer-form')
+                    <span class="mx-2 text-secondary">|</span>
+                    @include('app.patient.company-client.partials.create-company-client-form')
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>
+
+<div>
+    <div class="">
+        <table class="table table-striped table-sm table-bordered mb-0">
+            <thead class="bg-light">
+                <tr>
+                    <th class="border-0 text-secondary w-50">Company</th>
+                    <th class="border-0 text-secondary">Customer Balance</th>
+                    <th class="border-0 text-secondary">Pending Invoices Balance</th>
+                    <th class="border-0 text-secondary w-25">Created At</th>
+                    <th class="border-0 text-secondary delete-column">&nbsp;</th>
+                </tr>
+            </thead>
+            <tbody>
+                @foreach($customers as $customer)
+                    <tr>
+                        <td>{{ $customer->company->name }}</td>
+                        <td>${{ friendly_money($customer->customer_balance) }}</td>
+                        <td>${{ friendly_money($customer->pending_invoices_balance_total) }}</td>
+                        <td>{{ friendly_date($customer->created_at) }}</td>
+                        <td>
+                            <div class="d-flex align-items-center">
+                                <a href="{{ route('patients.view.customer', ['patient' => $patient, 'slug' => $customer->slug]) }}" class="ml-2">View</a>
+                            </div>
+                        </td>
+                    </tr>
+                @endforeach
+            </tbody>
+        </table>
+    </div>
+</div>
+@endsection

+ 1 - 1
resources/views/app/patient/company-client/messages.blade.php

@@ -1,4 +1,4 @@
-@extends ('layouts.company-client-layout')
+@extends ('layouts.default-company-client-layout')
 @section('company-client-content')
     <script src="https://static.opentok.com/v2/js/opentok.min.js"></script>
     <link rel="stylesheet" href="{{ asset('css/messages.css') }}">

+ 21 - 0
resources/views/app/patient/company-client/partials/create-company-client-customer-form.blade.php

@@ -0,0 +1,21 @@
+<div moe relative class="">
+    <a href="#" start show class="col-2-button">
+    + Add Patient as Customer
+    </a>
+    <form url="/api/customer/create" class="mcp-theme-1">
+        <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Company</label>
+            <select name="companyUid" id="" class="form-control">
+                <option value=""></option>
+                @foreach($patient->companyClients as $companyClient)
+                    <option value="{{ $companyClient->company->uid }}">{{ $companyClient->company->name }}</option>
+                @endforeach
+            </select>
+        </div>
+        <div>
+            <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        </div>
+    </form>
+</div>

+ 31 - 12
resources/views/app/patient/company-client/partials/create-company-client-form.blade.php

@@ -1,23 +1,26 @@
 <div moe relative class="">
     <a href="#" start show class="col-2-button">
-        + Add
+        + Create company client
     </a>
     <form url="/api/companyClient/create" class="mcp-theme-1">
         <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
         <div class="mb-2">
-            <label class="text-secondary text-sm">Company</label>
-            <select name="companyUid" class="form-control form-control-sm" required>
-                <option value="">--select--</option>
-                @foreach ($companies as $company)
-                    @if ($company->name)
-                        <!-- remove blank companies-->
-                        <option value="{{ $company->uid }}">{{ $company->name }}</option>
-                    @endif
-                @endforeach
-            </select>
+            <label class="text-sm text-secondary mb-1">Company</label>
+            <input type="hidden" name="companyUid" value="">
+            <input type="text"
+                    name="companyName"
+                    target-key="uid"
+                    target-field="companyUid"
+                    autocomplete="off"
+                    class="form-control form-control-sm"
+                    stag-suggest
+                    stag-suggest-ep="/company-suggest"
+                    value="{{@$company ? @$company->name : ''}}"
+                    {{@$company ? 'disabled readonly' : ''}}
+                    required>
         </div>
         <div class="mb-2">
-            <label for="" class="control-label">Date Referred</label>
+            <label for="" class="control-label">Date Referred (Optional)</label>
             <input type="date" name="dateReferred" class="form-control">
         </div>
         <div>
@@ -26,3 +29,19 @@
         </div>
     </form>
 </div>
+
+<script>
+    (function () {
+        function init() {
+            initStagSuggest();
+            let parentSegment = $('body');
+            parentSegment.find('input[stag-suggest][target-key][target-field]')
+                .off('stag-suggest-selected')
+                .on('stag-suggest-selected', (_e, _input, _data) => {
+                    _input = $(_input);
+                    _input.closest('form').find('input[name="' + _input.attr('target-field') + '"]').val(_data[_input.attr('target-key')]);
+                });
+        }
+        addMCInitializer('create-company-client', init)
+    }).call(window);
+</script>

+ 21 - 0
resources/views/app/patient/company-client/partials/customer-add-invoice-form.blade.php

@@ -0,0 +1,21 @@
+<div moe>
+    <a href="" start show>
+        + Add Invoice
+    </a>
+    <form url="/api/invoice/create" class="mcp-theme-1">
+        <p class="mb-2 text-secondary font-weight-bold">Add Invoice</p>
+        <input type="hidden" name="customerUid" value="{{ $customer->uid }}">
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Amount</label>
+            <input type="text" name="amount" autocomplete="off" class="form-control form-control-sm" required>
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Description</label>
+            <textarea rows="2" name="description" autocomplete="off" class="form-control form-control-sm" required></textarea>
+        </div>
+        <div>
+            <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        </div>
+    </form>
+</div>

+ 45 - 0
resources/views/app/patient/company-client/partials/customer-add-payment-method-form.blade.php

@@ -0,0 +1,45 @@
+<div moe relative>
+    <a start show href="#" class="text-nowrap">+ Payment Method</a>
+    <form url="/api/paymentMethod/createCard" right>
+        <input type="hidden" name="customerUid" value="{{$customer->uid}}">
+        <p class="text-secondary font-weight-bold mb-1 text-nowrap">Add Payment Method</p>
+        <div class="mb-2">
+            <label class="mb-1 text-secondary text-sm">Card Number</label>
+            <input type="text" name="cardNumber" value="" class="form-control form-control-sm min-width-200px" required>
+        </div>
+        <div class="mb-2">
+            <label class="mb-1 text-secondary text-sm">Expiry Date</label>
+            <div class="d-flex align-items-start">
+                <select class="form-control form-control-sm" name="expirationMonth" required>
+                    <option value="">-- select --</option>
+                    <option value="1">January</option>
+                    <option value="2">February</option>
+                    <option value="3">March</option>
+                    <option value="4">April</option>
+                    <option value="5">May</option>
+                    <option value="6">June</option>
+                    <option value="7">July</option>
+                    <option value="8">August</option>
+                    <option value="9">September</option>
+                    <option value="10">October</option>
+                    <option value="11">November</option>
+                    <option value="12">December</option>
+                </select>
+                <input type="number" name="expirationYear" class="form-control form-control-sm ml-2" placeholder="Expiry Year" required>
+                
+            </div>
+        </div>
+        <div class="mb-2">
+            <label class="mb-1 text-secondary text-sm">CVV/CCV Number</label>
+            <input type="text" name="ccv" value="" class="form-control form-control-sm min-width-200px" required>
+        </div>
+        <div class="mb-2">
+            <label class="mb-1 text-secondary text-sm">Billing Zip</label>
+            <input type="text" name="billingZip" value="" class="form-control form-control-sm min-width-200px">
+        </div>
+        <div class="d-flex align-items-center">
+            <button submit class="btn btn-sm btn-primary me-2">Submit</button>
+            <button cancel class="btn btn-sm btn-default">Cancel</button>
+        </div>
+    </form>
+</div>

+ 212 - 0
resources/views/app/patient/company-client/partials/customer-invoices.blade.php

@@ -0,0 +1,212 @@
+<?php
+$invoices = $customer->invoices;
+?>
+<div id="generic-customer-invoices" class="">
+    <div class="d-flex align-items-end pb-3">
+        <h4 class="font-weight-bold m-0">
+            Invoices
+        </h4>
+        <span class="mx-2 text-secondary">|</span>
+        @include('app.patient.company-client.partials.customer-add-invoice-form')
+    </div>
+    @if (!count($invoices))
+        <div class="border p-2">This customer does not have any invoices yet.</div>
+    @else
+        <table class="table table-sm table-bordered table-striped m-0">
+            <thead>
+                <tr>
+                    <th class="border-bottom-0"></th>
+                    <th class="border-bottom-0">Company</th>
+                    <th class="border-bottom-0">Created</th>
+                    <th class="border-bottom-0">Amount</th>
+                    <th class="border-bottom-0">Description</th>
+                    <th class="border-bottom-0">Pay Link</th>
+                    <th class="border-bottom-0">Paid</th>
+                    <th class="border-bottom-0">Balance</th>
+                    <th class="border-bottom-0">Active?</th>
+                    <th>Status</th>
+                    <th class="border-bottom-0"></th>
+                </tr>
+            </thead>
+            <tbody>
+                <?php $i = 1; ?>
+                @foreach ($invoices as $record)
+                    <tr>
+                        <td>{{ $i++ }}</td>
+                        <td>{{ $record->customer->company->name }}</td>
+                        <td>{{ friendly_date($record->created_at) }}</td>
+                        <td>${{ is_null($record->amount) ? 0 : $record->amount }}
+                            <div moe relative class="ml-1">
+                                <a href="#" start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                                <form url="/api/invoice/changeAmount">
+                                    <input type="hidden" name="invoiceUid" value="{{ $record->uid }}">
+                                    <div class="mb-2">
+                                        <label class="text-sm text-secondary mb-1">Amount</label>
+                                        <input type="text" name="amount" autocomplete="off"
+                                            class="form-control form-control-sm" value="{{ $record->amount }}" required>
+                                    </div>
+                                    <div>
+                                        <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                        <td>{{ $record->description ?: '' }}
+                            <div moe relative class="ml-1">
+                                <a href="#" start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                                <form url="/api/invoice/changeDescription">
+                                    <input type="hidden" name="invoiceUid" value="{{ $record->uid }}">
+                                    <div class="mb-2">
+                                        <label class="text-sm text-secondary mb-1">Description</label>
+                                        <textarea rows="2" name="description" autocomplete="off" class="form-control form-control-sm" required>{{ $record->description }}</textarea>
+                                    </div>
+                                    <div>
+                                        <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                        <td>
+                            <a href="#" data-invoice-uid="{{ $record->uid }}"
+                                data-uid="{{ $record->customer->uid }}" class="generate-and-visit-ic-pay" native
+                                target="_blank">Visit</a>
+                            <a href="#" data-invoice-uid="{{ $record->uid }}"
+                                data-uid="{{ $record->customer->uid }}" class="generate-and-copy-ic-pay-url ml-1"
+                                native target="_blank">Copy</a>
+                        </td>
+                        <td>${{ is_null($record->paid) ? 0 : $record->paid }}</td>
+                        <td>${{ is_null($record->balance) ? 0 : $record->balance }}</td>
+                        <td class="{{ !$record->is_active ? 'text-warning-dark' : '' }}">
+                            {{ $record->is_active ? 'Yes' : 'No' }}</td>
+                        <td>
+                            @if ($record->balance <= 0)
+                                <div class="text-left font-weight-bold mt-1">
+                                    <i class="fa fa-check text-success"></i>
+                                    <span class="text-success">PAID</span>
+                                </div>
+                            @else
+                                <div class="text-left font-weight-bold mt-1">
+                                    <span class="text-danger">PENDING</span>
+                                </div>
+                            @endif
+                        </td>
+                        <td>
+                            <div class="d-flex flex-wrap">
+                                @if ($record->is_active)
+                                    <div moe class="mr-2">
+                                        <a href="" start show>Deactivate</a>
+                                        <form url="/api/invoice/deactivate" class="mcp-theme-1" right>
+                                            <p class="mb-2 text-nowrap">Deactivate this invoice?</p>
+                                            <input type="hidden" name="uid" value="{{ $record->uid }}">
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @else
+                                    <div moe class="mr-2">
+                                        <a href="" start show>Reactivate</a>
+                                        <form url="/api/invoice/reactivate" class="mcp-theme-1" right>
+                                            <p class="mb-2 text-nowrap">Reactivate this invoice?</p>
+                                            <input type="hidden" name="uid" value="{{ $record->uid }}">
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                                <a href="{{ route('patients.view.invoicing-invoice-transactions', ['patient' => $patient, 'invoice' => $record]) }}"
+                                    class="mr-2">Transactions</a>
+                            </div>
+                        </td>
+                    </tr>
+                @endforeach
+            </tbody>
+        </table>
+    @endif
+</div>
+
+<script>
+    (function() {
+        function init() {
+            initStagSuggest();
+            let parentSegment = $('body');
+            parentSegment.find('input[stag-suggest][target-key][target-field]')
+                .off('stag-suggest-selected')
+                .on('stag-suggest-selected', (_e, _input, _data) => {
+                    _input = $(_input);
+                    _input.closest('form').find('input[name="' + _input.attr('target-field') + '"]').val(_data[
+                        _input.attr('target-key')]);
+                });
+            parentSegment.find('.copy-target')
+                .off('click.copy-target')
+                .on('click.copy-target', function() {
+                    copyTextToClipboard($(this).attr('data-target'));
+                    return false;
+                });
+
+            parentSegment.find('.generate-and-visit-ic-portal')
+                .off('click.generate-and-visit-ic-portal')
+                .on('click.generate-and-visit-ic-portal', function() {
+                    $.post('/api/session/proLogInAsCustomer', {
+                        customerUid: $(this).attr('data-uid')
+                    }, _data => {
+                        if (!hasResponseError(_data)) {
+                            window.location.href = '/ic/home/' + _data.data;
+                            return false;
+                        }
+                    });
+                    return false;
+                });
+
+            parentSegment.find('.generate-and-copy-ic-portal-url')
+                .off('click.generate-and-copy-ic-portal-url')
+                .on('click.generate-and-copy-ic-portal-url', function() {
+                    $.post('/api/session/proLogInAsCustomer', {
+                        customerUid: $(this).attr('data-uid')
+                    }, _data => {
+                        if (!hasResponseError(_data)) {
+                            copyTextToClipboard('{{ config('app.url') }}/ic/home/' + _data.data);
+                            return false;
+                        }
+                    });
+                    return false;
+                });
+
+            parentSegment.find('.generate-and-visit-ic-pay')
+                .off('click.generate-and-visit-ic-pay')
+                .on('click.generate-and-visit-ic-pay', function() {
+                    $.post('/api/session/proLogInAsCustomer', {
+                        customerUid: $(this).attr('data-uid')
+                    }, _data => {
+                        if (!hasResponseError(_data)) {
+                            window.location.href = '/ic/pay/' + $(this).attr('data-invoice-uid') + '/' +
+                                _data.data;
+                            return false;
+                        }
+                    });
+                    return false;
+                });
+
+            parentSegment.find('.generate-and-copy-ic-pay-url')
+                .off('click.generate-and-copy-ic-pay-url')
+                .on('click.generate-and-copy-ic-pay-url', function() {
+                    $.post('/api/session/proLogInAsCustomer', {
+                        customerUid: $(this).attr('data-uid')
+                    }, _data => {
+                        if (!hasResponseError(_data)) {
+                            copyTextToClipboard('{{ config('app.url') }}/ic/pay/' + $(this).attr(
+                                'data-invoice-uid') + '/' + _data.data);
+                            return false;
+                        }
+                    });
+                    return false;
+                });
+        }
+        addMCInitializer('generic-customer-invoices', init, '#generic-customer-invoices')
+    }).call(window);
+</script>

+ 74 - 0
resources/views/app/patient/company-client/partials/customer-payment-methods.blade.php

@@ -0,0 +1,74 @@
+<div id="generic-customer-payment-methods" class="">
+    <div class="d-flex align-items-end pb-3">
+        <h4 class="font-weight-bold m-0">
+            Payment Methods
+        </h4>
+        <span class="mx-2 text-secondary">|</span>
+        @include('app.patient.company-client.partials.customer-add-payment-method-form')
+        <span class="mx-2 text-secondary">|</span>
+        <a href="#" data-uid="{{ $customer->uid }}"
+            class="generate-and-copy-ic-payment-method-url" native target="_blank">Copy Customer Link</a>
+    </div>
+    @if (count($customer->paymentMethods))
+        @php
+            $index = 1;
+        @endphp
+        @foreach ($customer->paymentMethods as $method)
+            <div class="mb-2 px-3 py-2 bg-light border">
+                <div class="d-flex align-items-center flex-nowrap">
+                    <span>{!! $method->displayName() !!}</span>
+                    <div moe class="ml-3">
+                        <a start show href="#" class="text-nowrap text-sm">Remove</a>
+                        <form url="/api/paymentMethod/deactivate">
+                            <input type="hidden" name="uid" value="{{ $method->uid }}">
+                            <p class="text-secondary font-weight-bold mb-2 text-nowrap">Remove this Payment Method?</p>
+                            <div class="d-flex align-items-center">
+                                <button submit class="btn btn-sm btn-primary me-2">Submit</button>
+                                <button cancel class="btn btn-sm btn-default">Cancel</button>
+                            </div>
+                        </form>
+                    </div>
+                </div>
+            </div>
+        @endforeach
+    @else
+        <div class="my-3">You have not set up any payment methods!</div>
+    @endif
+</div>
+
+<script>
+    (function() {
+        function init() {
+            initStagSuggest();
+            let parentSegment = $('body');
+            parentSegment.find('input[stag-suggest][target-key][target-field]')
+                .off('stag-suggest-selected')
+                .on('stag-suggest-selected', (_e, _input, _data) => {
+                    _input = $(_input);
+                    _input.closest('form').find('input[name="' + _input.attr('target-field') + '"]').val(_data[
+                        _input.attr('target-key')]);
+                });
+            parentSegment.find('.copy-target')
+                .off('click.copy-target')
+                .on('click.copy-target', function() {
+                    copyTextToClipboard($(this).attr('data-target'));
+                    return false;
+                });
+
+            parentSegment.find('.generate-and-copy-ic-payment-method-url')
+                .off('click.generate-and-copy-ic-payment-method-url')
+                .on('click.generate-and-copy-ic-payment-method-url', function() {
+                    $.post('/api/session/proLogInAsCustomer', {
+                        customerUid: $(this).attr('data-uid')
+                    }, _data => {
+                        if (!hasResponseError(_data)) {
+                            copyTextToClipboard('{{ config('app.url') }}/ic/payment-methods/' + _data.data);
+                            return false;
+                        }
+                    });
+                    return false;
+                });
+        }
+        addMCInitializer('generic-customer-payment-methods', init, '#generic-customer-payment-methods')
+    }).call(window);
+</script>

+ 6 - 3
resources/views/app/patient/company-client/show-set-company-client.blade.php

@@ -1,16 +1,19 @@
 @extends ('layouts.patient')
 @section('inner-content')
+     @if(count($patient->companyClients))
     <div>
         <div class="d-flex align-items-end pb-3">
             <h4 class="font-weight-bold m-0">
                 <i class="fa fa-link"></i>
-                Linked Companies
+                Linked Companies ({{ count($patient->companyClients) }})
             </h4>
             <span class="mx-2 text-secondary">|</span>
             @include('app.patient.company-client.partials.create-company-client-form')
         </div>
     </div>
-    @if(!count($patient->companyClients))
-        <div class="alert alert-danger p-2 rounded-0">No linked companies set for this patient!</div>
+    @else
+        <div class="alert alert-danger p-2 rounded-0">No linked companies set for this patient! 
+        @include('app.patient.company-client.partials.create-company-client-form')
+        </div>
     @endif
 @endsection

+ 3 - 19
resources/views/layouts/company-client-layout.blade.php

@@ -1,22 +1,6 @@
 @extends ('layouts.patient')
 @section('inner-content')
-    <div class="mb-3 bg-light">
-       <div class="row">
-        <div class="col-md-2">
-            <div class="d-flex align-items-center">
-                <div>
-                    @include('app.patient.company-client.partials.set-default-company-client-form')
-                </div>
-                <span class="mx-2 text-secondary">|</span>
-                <div>
-                    @include('app.patient.company-client.partials.create-company-client-form')
-                </div>
-           
-            </div>
-            
-        </div>
-       </div>
-    </div>
-    @yield('company-client-content')
 
-@endsection
+@yield('company-client-content')
+
+@endsection

+ 22 - 0
resources/views/layouts/default-company-client-layout.blade.php

@@ -0,0 +1,22 @@
+@extends ('layouts.patient')
+@section('inner-content')
+    <div class="mb-3 bg-light">
+       <div class="row">
+        <div class="col-md-2">
+            <div class="d-flex align-items-center">
+                <div>
+                    @include('app.patient.company-client.partials.set-default-company-client-form')
+                </div>
+                <span class="mx-2 text-secondary">|</span>
+                <div>
+                    @include('app.patient.company-client.partials.create-company-client-form')
+                </div>
+           
+            </div>
+            
+        </div>
+       </div>
+    </div>
+    @yield('company-client-content')
+
+@endsection

+ 3 - 0
resources/views/layouts/patient.blade.php

@@ -194,6 +194,9 @@ $isOldClient = (date_diff(date_create(config('app.point_impl_date')), date_creat
 						<li class="nav-item">
 							<h6 class="nav-link font-weight-bold m-0">Admin Access</h6>
 							<ul class="m-0 p-0 nav-child-list">
+								<li class="nav-item">
+									<a class="nav-link {{ strpos($routeName, 'patients.view.customers') === 0 ? 'active' : '' }}" href="{{ route('patients.view.customers', ['patient' => $patient]) }}">Customers</a>
+								</li>
 								@if($isOldClient)
 								<li class="nav-item">
 									<a class="nav-link {{ strpos($routeName, 'patients.view.migrate-canvas') === 0 ? 'active' : '' }}" href="{{ route('patients.view.migrate-canvas', ['patient' => $patient]) }}">Canvas Migrate</a>

+ 8 - 2
routes/web.php

@@ -7,6 +7,7 @@ use App\Http\Controllers\VideoTestController;
 use App\Http\Controllers\SystemFileController;
 use App\Http\Controllers\MessageController;
 use App\Http\Controllers\CompanyClientController;
+use App\Http\Controllers\CustomerController;
 
 /*
 |--------------------------------------------------------------------------
@@ -547,8 +548,12 @@ Route::middleware('pro.auth')->group(function () {
             Route::get('show-set-default-company-client', [CompanyClientController::class, 'showSetDefaultCompanyClient'])->name('show-set-default-company-client');
             Route::post('set-default-company-client', [CompanyClientController::class, 'setDefaultCompanyClient'])->name('set-default-company-client');
             Route::middleware(['client.has-company-client'])->group(function () {
-                Route::get('messages', [MessageController::class, 'messages'])->name('messages');
-                Route::get('messages/{message}/attachments', [MessageController::class, 'clientMessagesAttachments'])->name('messages-attachments');
+                Route::get('customers', [CustomerController::class, 'customers'])->name('customers');
+                Route::get('customers/view/{slug}', [CustomerController::class, 'customer'])->name('customer');
+                Route::middleware(['client.has-default-company-client'])->group(function () {
+                    Route::get('messages', [MessageController::class, 'messages'])->name('messages');
+                    Route::get('messages/{message}/attachments', [MessageController::class, 'clientMessagesAttachments'])->name('messages-attachments');
+                });
             });
 
             Route::get('sms-numbers', 'PatientController@smsNumbers')->name('sms-numbers');
@@ -812,6 +817,7 @@ Route::get('/document-pdf/{uid}', 'DocumentsController@generateDocumentPDF')->na
 Route::get('/ic/home/{sessionKey?}', 'InvoiceController@icCustomerPortal')->name('icCustomerPortal');
 Route::get('/ic/pay/{invoiceUid}/{sessionKey?}', 'InvoiceController@icPayInvoice')->name('icPayInvoice');
 Route::get('/ic/manageAccount/{sessionKey?}', 'InvoiceController@icManageAccount')->name('icManageAccount');
+Route::get('/ic/payment-methods/{sessionKey?}', 'InvoiceController@icPaymentMethods')->name('icPaymentMethods');
 
 Route::get('/serve-system-file/{uid}', [SystemFileController::class, 'serve'])->name('serve-system-file');
 Route::get("/video-test", [VideoTestController::class, 'index'])->name('video-test');