فهرست منبع

Invoice-center - pay invoice UI and related

Vijayakrishnan 3 سال پیش
والد
کامیت
31c8a23b85

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

@@ -131,6 +131,14 @@ class InvoiceController extends Controller
         return view ('app.invoice-center.invoice-transactions', compact('records', 'invoice'));
     }
 
+    public function icPayInvoice(Request $request, $invoiceSlug) {
+        $invoice = Invoice::where('payment_link_slug', $invoiceSlug)->where('is_active', true)->first();
+        if (!$invoice) abort(404);
+        $customer = $invoice->customer;
+        $company = $customer->company;
+        return view('app.invoice-center.ic-pay-invoice', compact('invoice', 'customer', 'company'));
+    }
+
     public function companySuggestJSON(Request $request) {
         $term = $request->input('term') ? trim($request->input('term')) : '';
         if (empty($term)) return '';

+ 96 - 0
resources/views/app/invoice-center/ic-pay-invoice.blade.php

@@ -0,0 +1,96 @@
+@extends ('layouts.guest_template')
+@section('content')
+<div class="container mcp-theme-1">
+    <h3 class="font-size-16 font-weight-bold my-3 text-dark">Invoice</h3>
+    <hr>
+    <div class="row">
+        <div class="col-md-8">
+            <div class="mb-3">Hi <b class="text-dark">{{$customer->client->displayName()}}</b>, please find your invoice below:</div>
+            <table class="table table-sm table-bordered">
+                <thead>
+                <tr>
+                    <th class="border-bottom-0 text-secondary bg-light">Date</th>
+                    <th class="border-bottom-0 text-secondary bg-light">Company</th>
+                    <th class="border-bottom-0 text-secondary bg-light">Particulars</th>
+                    <th class="border-bottom-0 text-secondary bg-light">Total</th>
+                    <th class="border-bottom-0 text-secondary bg-light">Paid</th>
+                    <th class="border-bottom-0 text-secondary bg-light">Due</th>
+                </tr>
+                </thead>
+                <tbody class="font-weight-normal">
+                <tr>
+                    <td>{{friendly_date($invoice->created_at)}}</td>
+                    <td>{{$company->name}}</td>
+                    <td>{{$invoice->description}}</td>
+                    <td class="font-weight-bold text-dark">${{!is_null($invoice->amount) ? $invoice->amount : 0}}</td>
+                    <td class="font-weight-bold text-success">${{!is_null($invoice->paid) ? $invoice->paid : 0}}</td>
+                    <td class="font-weight-bold text-warning-dark">${{!is_null($invoice->balance) ? $invoice->balance : 0}}</td>
+                </tr>
+                <tr>
+                    <td class="p-3 text-right" colspan="6">
+                        <div class="d-flex justify-content-end align-items-baseline mb-2">
+                            <span class="text-secondary">Total Amount: </span>
+                            <span class="width-50px text-left text-secondary font-weight-bold pl-2">${{!is_null($invoice->amount) ? $invoice->amount : 0}}</span>
+                        </div>
+                        <div class="d-flex justify-content-end align-items-baseline mb-2">
+                            <span class="text-secondary">Total Paid: </span>
+                            <span class="width-50px text-left text-secondary font-weight-bold pl-2">${{!is_null($invoice->paid) ? $invoice->paid : 0}}</span>
+                        </div>
+                        <div class="d-flex justify-content-end align-items-baseline">
+                            <span class="font-weight-bold text-secondary">Total Due: </span>
+                            <span class="width-50px text-left font-weight-bold pl-2 font-size-14">${{!is_null($invoice->balance) ? $invoice->balance : 0}}</span>
+                        </div>
+                        @if($invoice->balance <= 0)
+                            <div class="mt-3 border rounded border-success p-2 text-center">
+                                <i class="fa fa-check text-success"></i>
+                                <span class="text-success">PAID</span>
+                            </div>
+                        @else
+                            @if($customer->customer_balance >= $invoice->balance)
+                                <div moe relative class="mt-3">
+                                    <a href="#" start show class="btn btn-sm btn-primary text-white font-weight-bold py-2">Pay <b>${{$invoice->balance}}</b> from your current balance (${{$customer->customer_balance}})</a>
+                                    <form url="/api/invoiceTransaction/createPlusForCustomerTransaction">
+                                        <p class="mb-2 text-left">Confirm Payment?</p>
+                                        <input type="hidden" name="invoiceUid" value="{{$invoice->uid}}">
+                                        <input type="hidden" name="amount" value="{{$invoice->balance}}">
+                                        <input type="hidden" name="customMemo" value="Payment by customer via balance">
+                                        <div class="text-left">
+                                            <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 class="mt-3 border rounded border-secondary p-2 text-center text-warning-dark">
+                                    Your current balance (${{$customer->customer_balance}}) is less than the due amount (${{$invoice->balance}}). If you have a gift card, use its code on the right hand side to add funds to your balance.
+                                </div>
+                            @endif
+                        @endif
+                    </td>
+                </tr>
+                </tbody>
+            </table>
+        </div>
+        <div class="col-md-4 border-left">
+            <div class="mb-3">
+                <span class="font-weight-bold text-secondary">Current Balance: </span>
+                <span class="font-weight-bold text-dark">${{!is_null($customer->customer_balance) ? $customer->customer_balance : 0}}</span>
+            </div>
+            <h3 class="font-weight-bold mb-2 text-secondary">Redeem Gift Card</h3>
+            <div moe>
+                <form url="/api/giftCard/redeem" show>
+                    <input type="hidden" name="customerUid" value="{{$customer->uid}}">
+                    <p class="mb-2">If you have a gift card from {{$company->name}}, please enter its code below:</p>
+                    <div class="mb-2">
+                        <input type="text" name="code" placeholder="Code" class="form-control form-control-sm">
+                    </div>
+                    <div class="text-left">
+                        <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>
+        </div>
+    </div>
+</div>
+@endsection

+ 6 - 3
resources/views/app/invoice-center/invoices.blade.php

@@ -36,7 +36,7 @@
                     <textarea rows="2"
                               name="description"
                               autocomplete="off"
-                              class="form-control form-control-sm"></textarea>
+                              class="form-control form-control-sm" required></textarea>
                 </div>
                 <div>
                     <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
@@ -109,7 +109,7 @@
                                     <textarea rows="2"
                                               name="description"
                                               autocomplete="off"
-                                              class="form-control form-control-sm">{{$record->description}}</textarea>
+                                              class="form-control form-control-sm" required>{{$record->description}}</textarea>
                                 </div>
                                 <div>
                                     <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
@@ -118,7 +118,10 @@
                             </form>
                         </div>
                     </td>
-                    <td>{{substr($record->payment_link_slug, 0, 12) . '...'}}</td>
+                    <td>
+                        <a href="{{route('icPayInvoice', ['invoiceSlug' => $record->payment_link_slug])}}" native target="_blank">Visit</a>
+                        <a href="#" data-target="{{route('icPayInvoice', ['invoiceSlug' => $record->payment_link_slug])}}" native target="_blank" class="copy-target">Copy</a>
+                    </td>
                     <td>${{ is_null($record->paid) ? 0 : $record->paid }}</td>
                     <td>${{ is_null($record->balance) ? 0 : $record->balance }}</td>
                     <td>{{ friendly_date($record->created_at) }}</td>

+ 6 - 0
resources/views/layouts/invoice-center.blade.php

@@ -48,6 +48,12 @@ $routeName = request()->route()->getName();
 						_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;
+					});
 		}
 		addMCInitializer('invoice-center', init)
 	}).call(window);

+ 3 - 0
routes/web.php

@@ -235,6 +235,9 @@ Route::middleware('pro.auth')->group(function () {
         });
     });
 
+    // ic pages - client facing
+    Route::get('/ic/pay/{invoiceSlug}', 'InvoiceController@icPayInvoice')->name('icPayInvoice');
+
     Route::name('practice-management.')->prefix('practice-management')->group(function () {