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 ]); } public function customerSuggestJSON(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 customer.uid, (client.name_first || ' ' || client.name_last) as text FROM client join customer on client.id = customer.client_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) ORDER BY client.name_first, client.name_last", ['term' => $term . '%', 'term2' => $term2 . '%'] ); } else { $matches = DB::select(" SELECT customer.uid, (client.name_first || ' ' || client.name_last) as text FROM client join customer on client.id = customer.client_id 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 ]); } }