Sfoglia il codice sorgente

Updated generate invoice pay link

Samson Mutunga 3 settimane fa
parent
commit
1bf85e06b0

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

@@ -72,6 +72,9 @@ $invoices = $customer->invoices;
                             {{-- <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-store-ic-pay-url" native target="_blank">Request Pay</a>
+                            <small class="text-muted px-1">|</small>
                             <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 Url</a>

+ 23 - 0
resources/views/app/patient/invoicing/layout.blade.php

@@ -76,6 +76,29 @@
                     });
                     return false;
                 });
+
+            //Save pay url to invoice detailJson
+            parentSegment.find('.generate-and-store-ic-pay-url')
+            .off('click.generate-and-store-ic-pay-url')
+            .on('click.generate-and-store-ic-pay-url', function() {
+                $.post('/api/session/proLogInAsCustomer', {
+                    customerUid: $(this).attr('data-uid')
+                }, _data => {
+                    if (!hasResponseError(_data)) {
+                        const invoiceUid = $(this).attr('data-invoice-uid');
+                        const payUrl = '{{ config('app.url') }}/ic/pay/' + invoiceUid + '/' + _data.data
+                        console.log({payUrl});
+                        $.post('/customer/invoice/save-pay-url', {invoiceUid: invoiceUid, payUrl: payUrl }, function(response){
+                            if(response.success){
+                                toastr.success('Inoice payment url generated!');
+                            }else{
+                                toastr.error(response.message);
+                            }
+                        }, 'json');
+                    }
+                });
+                return false;
+            });
         }
         addMCInitializer('invoicing-{{$patient->uid}}', init, '#invoicing-{{$patient->uid}}')
     }).call(window);

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

@@ -91,6 +91,29 @@
                     });
                     return false;
                 });
+
+        //Save pay url to invoice detailJson
+            parentSegment.find('.generate-and-store-ic-pay-url')
+            .off('click.generate-and-store-ic-pay-url')
+            .on('click.generate-and-store-ic-pay-url', function() {
+                $.post('/api/session/proLogInAsCustomer', {
+                    customerUid: $(this).attr('data-uid')
+                }, _data => {
+                    if (!hasResponseError(_data)) {
+                        const invoiceUid = $(this).attr('data-invoice-uid');
+                        const payUrl = '{{ config('app.url') }}/ic/pay/' + invoiceUid + '/' + _data.data
+                        console.log({payUrl});
+                        $.post('/customer/invoice/save-pay-url', {invoiceUid: invoiceUid, payUrl: payUrl }, function(response){
+                            if(response.success){
+                                toastr.success('Inoice payment url generated!');
+                            }else{
+                                toastr.error(response.message);
+                            }
+                        }, 'json');
+                    }
+                });
+                return false;
+            });
         }
         addMCInitializer('company-client-{{$patient->uid}}', init, '#company-client-{{$patient->uid}}')
     }).call(window);

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

@@ -110,6 +110,29 @@ $routeName = request()->route()->getName();
 						});
 						return false;
 					});
+
+		//Save pay url to invoice detailJson
+            parentSegment.find('.generate-and-store-ic-pay-url')
+            .off('click.generate-and-store-ic-pay-url')
+            .on('click.generate-and-store-ic-pay-url', function() {
+                $.post('/api/session/proLogInAsCustomer', {
+                    customerUid: $(this).attr('data-uid')
+                }, _data => {
+                    if (!hasResponseError(_data)) {
+                        const invoiceUid = $(this).attr('data-invoice-uid');
+                        const payUrl = '{{ config('app.url') }}/ic/pay/' + invoiceUid + '/' + _data.data
+                        console.log({payUrl});
+                        $.post('/customer/invoice/save-pay-url', {invoiceUid: invoiceUid, payUrl: payUrl }, function(response){
+                            if(response.success){
+                                toastr.success('Inoice payment url generated!');
+                            }else{
+                                toastr.error(response.message);
+                            }
+                        }, 'json');
+                    }
+                });
+                return false;
+            });
 		}
 		addMCInitializer('invoice-center', init, '#invoice-center')
 	}).call(window);