|
@@ -59,9 +59,24 @@ use App\Models\VisitTemplateAccess;
|
|
class InvoiceController extends Controller
|
|
class InvoiceController extends Controller
|
|
{
|
|
{
|
|
|
|
|
|
|
|
+ private static $PAGE_SIZE = 25;
|
|
|
|
+
|
|
|
|
+ public function companies(Request $request) {
|
|
|
|
+ $records = Company::orderBy('name', 'ASC')->where('is_active', true)->paginate(InvoiceController::$PAGE_SIZE);
|
|
|
|
+ return view ('app.invoice-center.companies', compact('records'));
|
|
|
|
+ }
|
|
|
|
+
|
|
public function customers(Request $request) {
|
|
public function customers(Request $request) {
|
|
- $records = Customer::orderBy('created_at', 'DESC')->paginate();
|
|
|
|
- return view ('app.invoice-center.customers', compact('records'));
|
|
|
|
|
|
+ $records = Customer::orderBy('created_at', 'DESC');
|
|
|
|
+ $company = null;
|
|
|
|
+ if($request->input('companyUid')) {
|
|
|
|
+ $company = Company::where('uid', $request->input('companyUid'))->first();
|
|
|
|
+ if($company) {
|
|
|
|
+ $records = $records->where('company_id', $company->id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $records = $records->paginate(InvoiceController::$PAGE_SIZE);
|
|
|
|
+ return view ('app.invoice-center.customers', compact('records', 'company'));
|
|
}
|
|
}
|
|
|
|
|
|
public function giftCards(Request $request) {
|
|
public function giftCards(Request $request) {
|
|
@@ -73,7 +88,7 @@ class InvoiceController extends Controller
|
|
$records = $records->where('company_id', $company->id);
|
|
$records = $records->where('company_id', $company->id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $records = $records->paginate();
|
|
|
|
|
|
+ $records = $records->paginate(InvoiceController::$PAGE_SIZE);
|
|
return view ('app.invoice-center.gift-cards', compact('records', 'company'));
|
|
return view ('app.invoice-center.gift-cards', compact('records', 'company'));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -86,7 +101,7 @@ class InvoiceController extends Controller
|
|
$records = $records->where('customer_id', $customer->id);
|
|
$records = $records->where('customer_id', $customer->id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $records = $records->paginate();
|
|
|
|
|
|
+ $records = $records->paginate(InvoiceController::$PAGE_SIZE);
|
|
return view ('app.invoice-center.invoices', compact('records', 'customer'));
|
|
return view ('app.invoice-center.invoices', compact('records', 'customer'));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -99,7 +114,7 @@ class InvoiceController extends Controller
|
|
$records = $records->where('customer_id', $customer->id);
|
|
$records = $records->where('customer_id', $customer->id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $records = $records->paginate();
|
|
|
|
|
|
+ $records = $records->paginate(InvoiceController::$PAGE_SIZE);
|
|
return view ('app.invoice-center.customer-transactions', compact('records', 'customer'));
|
|
return view ('app.invoice-center.customer-transactions', compact('records', 'customer'));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -112,7 +127,7 @@ class InvoiceController extends Controller
|
|
$records = $records->where('invoice_id', $invoice->id);
|
|
$records = $records->where('invoice_id', $invoice->id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $records = $records->paginate();
|
|
|
|
|
|
+ $records = $records->paginate(InvoiceController::$PAGE_SIZE);
|
|
return view ('app.invoice-center.invoice-transactions', compact('records', 'invoice'));
|
|
return view ('app.invoice-center.invoice-transactions', compact('records', 'invoice'));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -187,8 +202,8 @@ ORDER BY client.name_first, client.name_last",
|
|
if(!empty($term2)) {
|
|
if(!empty($term2)) {
|
|
$matches = DB::select("
|
|
$matches = DB::select("
|
|
SELECT customer.uid,
|
|
SELECT customer.uid,
|
|
- (client.name_first || ' ' || client.name_last) as text
|
|
|
|
-FROM client join customer on client.id = customer.client_id
|
|
|
|
|
|
+ (client.name_first || ' ' || client.name_last || ' (' || company.name || ')') as text
|
|
|
|
+FROM client join customer on client.id = customer.client_id join company on customer.company_id = company.id
|
|
WHERE (client.name_first ILIKE :term OR client.name_last ILIKE :term OR client.name_first ILIKE :term2 OR client.name_last ILIKE :term2)
|
|
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",
|
|
ORDER BY client.name_first, client.name_last",
|
|
['term' => $term . '%', 'term2' => $term2 . '%']
|
|
['term' => $term . '%', 'term2' => $term2 . '%']
|
|
@@ -197,8 +212,8 @@ ORDER BY client.name_first, client.name_last",
|
|
else {
|
|
else {
|
|
$matches = DB::select("
|
|
$matches = DB::select("
|
|
SELECT customer.uid,
|
|
SELECT customer.uid,
|
|
- (client.name_first || ' ' || client.name_last) as text
|
|
|
|
-FROM client join customer on client.id = customer.client_id
|
|
|
|
|
|
+ (client.name_first || ' ' || client.name_last || ' (' || company.name || ')') as text
|
|
|
|
+FROM client join customer on client.id = customer.client_id join company on customer.company_id = company.id
|
|
WHERE (client.name_first ILIKE :term OR client.name_last ILIKE :term)
|
|
WHERE (client.name_first ILIKE :term OR client.name_last ILIKE :term)
|
|
ORDER BY client.name_first, client.name_last",
|
|
ORDER BY client.name_first, client.name_last",
|
|
['term' => $term . '%']
|
|
['term' => $term . '%']
|