|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
+use App\Lib\Backend;
|
|
|
use App\Models\AppSession;
|
|
|
use App\Models\BillingReport;
|
|
|
use App\Models\CareMonth;
|
|
@@ -45,8 +46,10 @@ use App\Models\ClientMemo;
|
|
|
use Carbon\Carbon;
|
|
|
use Cassandra\Custom;
|
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
+use Illuminate\Support\Facades\Cookie;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
+use MongoDB\Driver\Session;
|
|
|
use PDF;
|
|
|
use DateTime;
|
|
|
use DateTimeZone;
|
|
@@ -131,25 +134,52 @@ 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();
|
|
|
+ private function getICCustomer($sessionKey) {
|
|
|
+ $customer = false;
|
|
|
+ if($sessionKey) {
|
|
|
+ Cookie::queue('sessionKey', $sessionKey);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $session = get_current_session();
|
|
|
+ if(!$session) {
|
|
|
+ abort(403);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $customer = Customer::where('id', $session->customer_id)->first();
|
|
|
+ if(!$customer) {
|
|
|
+ abort(403);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $customer;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function icPayInvoice(Request $request, $invoiceUid, $sessionKey = '') {
|
|
|
+ $customer = $this->getICCustomer($sessionKey);
|
|
|
+ if(!$customer) {
|
|
|
+ return redirect(route('icPayInvoice', ['invoiceUid' => $invoiceUid]));
|
|
|
+ }
|
|
|
+ $invoice = Invoice::where('uid', $invoiceUid)->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 icCustomerPortal(Request $request, $customerSlug) {
|
|
|
- $customer = Customer::where('slug', $customerSlug)->where('is_active', true)->first();
|
|
|
- if (!$customer) abort(404);
|
|
|
+ public function icCustomerPortal(Request $request, $sessionKey = '') {
|
|
|
+ $customer = $this->getICCustomer($sessionKey);
|
|
|
+ if(!$customer) {
|
|
|
+ return redirect(route('icCustomerPortal'));
|
|
|
+ }
|
|
|
$client = $customer->client;
|
|
|
$company = $customer->company;
|
|
|
return view('app.invoice-center.ic-customer-portal', compact('customer', 'company'));
|
|
|
}
|
|
|
|
|
|
- public function icManageAccount(Request $request, $customerSlug) {
|
|
|
- $customer = Customer::where('slug', $customerSlug)->where('is_active', true)->first();
|
|
|
- if (!$customer) abort(404);
|
|
|
+ public function icManageAccount(Request $request, $sessionKey = '') {
|
|
|
+ $customer = $this->getICCustomer($sessionKey);
|
|
|
+ if(!$customer) {
|
|
|
+ return redirect(route('icManageAccount'));
|
|
|
+ }
|
|
|
$client = $customer->client;
|
|
|
$company = $customer->company;
|
|
|
return view('app.invoice-center.ic-manage-account', compact('customer', 'company', 'client'));
|