|
@@ -0,0 +1,142 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+namespace App\Http\Controllers;
|
|
|
|
+
|
|
|
|
+use App\Models\AppSession;
|
|
|
|
+use App\Models\BillingReport;
|
|
|
|
+use App\Models\CareMonth;
|
|
|
|
+use App\Models\ClaimEDI;
|
|
|
|
+use App\Models\ClientProChange;
|
|
|
|
+use App\Models\Company;
|
|
|
|
+use App\Models\Customer;
|
|
|
|
+use App\Models\CustomerTransaction;
|
|
|
|
+use App\Models\GiftCard;
|
|
|
|
+use App\Models\Handout;
|
|
|
|
+use App\Models\Invoice;
|
|
|
|
+use App\Models\InvoiceTransaction;
|
|
|
|
+use App\Models\MBClaim;
|
|
|
|
+use App\Models\Measurement;
|
|
|
|
+use App\Models\Bill;
|
|
|
|
+use App\Models\Claim;
|
|
|
|
+use App\Models\Client;
|
|
|
|
+use App\Models\McpRequest;
|
|
|
|
+use App\Models\McCodeCheck;
|
|
|
|
+use App\Models\Note;
|
|
|
|
+use App\Models\Pack;
|
|
|
|
+use App\Models\Pro;
|
|
|
|
+use App\Models\Product;
|
|
|
|
+use App\Models\ProFavorite;
|
|
|
|
+use App\Models\ProGeneralAvailability;
|
|
|
|
+use App\Models\ProProAccess;
|
|
|
|
+use App\Models\ProRate;
|
|
|
|
+use App\Models\ProSpecificAvailability;
|
|
|
|
+use App\Models\ProSpecificUnavailability;
|
|
|
|
+use App\Models\ProTeam;
|
|
|
|
+use App\Models\ProTextShortcut;
|
|
|
|
+use App\Models\ProTransaction;
|
|
|
|
+use App\Models\Shipment;
|
|
|
|
+use App\Models\SupplyOrder;
|
|
|
|
+use App\Models\Team;
|
|
|
|
+use App\Models\Ticket;
|
|
|
|
+use App\Models\AccountInvite;
|
|
|
|
+use App\Models\ClientMeasurementDaysPerMonth;
|
|
|
|
+use App\Models\ClientBDTDevice;
|
|
|
|
+use App\Models\ClientMemo;
|
|
|
|
+use Carbon\Carbon;
|
|
|
|
+use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
+use Illuminate\Support\Facades\Http;
|
|
|
|
+use PDF;
|
|
|
|
+use DateTime;
|
|
|
|
+use DateTimeZone;
|
|
|
|
+use Illuminate\Http\Request;
|
|
|
|
+use App\Models\SegmentTemplate;
|
|
|
|
+use App\Models\VisitTemplate;
|
|
|
|
+use App\Models\VisitTemplateSegmentTemplate;
|
|
|
|
+use App\Models\VisitTemplateAccess;
|
|
|
|
+
|
|
|
|
+class InvoiceController extends Controller
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ public function customers(Request $request) {
|
|
|
|
+ $records = Customer::orderBy('created_at', 'DESC')->paginate();
|
|
|
|
+ return view ('app.invoice-center.customers', compact('records'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function giftCards(Request $request) {
|
|
|
|
+ $records = GiftCard::orderBy('created_at', 'DESC')->paginate();
|
|
|
|
+ return view ('app.invoice-center.gift-cards', compact('records'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function invoices(Request $request) {
|
|
|
|
+ $records = Invoice::orderBy('created_at', 'DESC')->paginate();
|
|
|
|
+ return view ('app.invoice-center.invoices', compact('records'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function customerTransactions(Request $request) {
|
|
|
|
+ $records = CustomerTransaction::orderBy('created_at', 'DESC')->paginate();
|
|
|
|
+ return view ('app.invoice-center.customer-transactions', compact('records'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function invoiceTransactions(Request $request) {
|
|
|
|
+ $records = InvoiceTransaction::orderBy('created_at', 'DESC')->paginate();
|
|
|
|
+ return view ('app.invoice-center.invoice-transactions', compact('records'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function companySuggestJSON(Request $request) {
|
|
|
|
+ $term = $request->input('term') ? trim($request->input('term')) : '';
|
|
|
|
+ if (empty($term)) return '';
|
|
|
|
+ $matches = DB::select("
|
|
|
|
+SELECT company.uid,
|
|
|
|
+ company.name as text
|
|
|
|
+FROM company
|
|
|
|
+WHERE company.name ILIKE :term
|
|
|
|
+ORDER BY company.name",
|
|
|
|
+ ['term' => $term . '%']
|
|
|
|
+ );
|
|
|
|
+ return json_encode([
|
|
|
|
+ "success" => true,
|
|
|
|
+ "data" => $matches
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function clientSuggestJSON(Request $request) {
|
|
|
|
+ $term = $request->input('term') ? trim($request->input('term')) : '';
|
|
|
|
+ if (empty($term)) return '';
|
|
|
|
+
|
|
|
|
+ // if multiple words in query, check for all (max 2)
|
|
|
|
+ $term2 = '';
|
|
|
|
+ if(strpos($term, ' ') !== FALSE) {
|
|
|
|
+ $terms = explode(' ', $term);
|
|
|
|
+ $term = trim($terms[0]);
|
|
|
|
+ $term2 = trim($terms[1]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!empty($term2)) {
|
|
|
|
+ $matches = DB::select("
|
|
|
|
+SELECT client.uid,
|
|
|
|
+ (client.name_first || ' ' || client.name_last) as text
|
|
|
|
+FROM client
|
|
|
|
+WHERE (client.name_first ILIKE :term OR client.name_last ILIKE :term OR client.name_first ILIKE :term2 OR client.name_last ILIKE :term2)
|
|
|
|
+ORDER BY client.name_first, client.name_last",
|
|
|
|
+ ['term' => $term . '%', 'term2' => $term2 . '%']
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $matches = DB::select("
|
|
|
|
+SELECT client.uid,
|
|
|
|
+ (client.name_first || ' ' || client.name_last) as text
|
|
|
|
+FROM client
|
|
|
|
+WHERE (client.name_first ILIKE :term OR client.name_last ILIKE :term)
|
|
|
|
+ORDER BY client.name_first, client.name_last",
|
|
|
|
+ ['term' => $term . '%']
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return json_encode([
|
|
|
|
+ "success" => true,
|
|
|
|
+ "data" => $matches
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|