|
@@ -43,6 +43,7 @@ use App\Models\ClientMeasurementDaysPerMonth;
|
|
|
use App\Models\ClientBDTDevice;
|
|
|
use App\Models\ClientMemo;
|
|
|
use Carbon\Carbon;
|
|
|
+use Cassandra\Custom;
|
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Http;
|
|
@@ -64,23 +65,55 @@ class InvoiceController extends Controller
|
|
|
}
|
|
|
|
|
|
public function giftCards(Request $request) {
|
|
|
- $records = GiftCard::orderBy('created_at', 'DESC')->paginate();
|
|
|
- return view ('app.invoice-center.gift-cards', compact('records'));
|
|
|
+ $records = GiftCard::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();
|
|
|
+ return view ('app.invoice-center.gift-cards', compact('records', 'company'));
|
|
|
}
|
|
|
|
|
|
public function invoices(Request $request) {
|
|
|
- $records = Invoice::orderBy('created_at', 'DESC')->paginate();
|
|
|
- return view ('app.invoice-center.invoices', compact('records'));
|
|
|
+ $records = Invoice::orderBy('created_at', 'DESC');
|
|
|
+ $customer = null;
|
|
|
+ if($request->input('customerUid')) {
|
|
|
+ $customer = Customer::where('uid', $request->input('customerUid'))->first();
|
|
|
+ if($customer) {
|
|
|
+ $records = $records->where('customer_id', $customer->id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $records = $records->paginate();
|
|
|
+ return view ('app.invoice-center.invoices', compact('records', 'customer'));
|
|
|
}
|
|
|
|
|
|
public function customerTransactions(Request $request) {
|
|
|
- $records = CustomerTransaction::orderBy('created_at', 'DESC')->paginate();
|
|
|
- return view ('app.invoice-center.customer-transactions', compact('records'));
|
|
|
+ $records = CustomerTransaction::orderBy('created_at', 'DESC');
|
|
|
+ $customer = null;
|
|
|
+ if($request->input('customerUid')) {
|
|
|
+ $customer = Customer::where('uid', $request->input('customerUid'))->first();
|
|
|
+ if($customer) {
|
|
|
+ $records = $records->where('customer_id', $customer->id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $records = $records->paginate();
|
|
|
+ return view ('app.invoice-center.customer-transactions', compact('records', 'customer'));
|
|
|
}
|
|
|
|
|
|
public function invoiceTransactions(Request $request) {
|
|
|
- $records = InvoiceTransaction::orderBy('created_at', 'DESC')->paginate();
|
|
|
- return view ('app.invoice-center.invoice-transactions', compact('records'));
|
|
|
+ $records = InvoiceTransaction::orderBy('created_at', 'DESC');
|
|
|
+ $invoice = null;
|
|
|
+ if($request->input('invoiceUid')) {
|
|
|
+ $invoice = Invoice::where('uid', $request->input('invoiceUid'))->first();
|
|
|
+ if($invoice) {
|
|
|
+ $records = $records->where('invoice_id', $invoice->id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $records = $records->paginate();
|
|
|
+ return view ('app.invoice-center.invoice-transactions', compact('records', 'invoice'));
|
|
|
}
|
|
|
|
|
|
public function companySuggestJSON(Request $request) {
|
|
@@ -183,9 +216,7 @@ ORDER BY client.name_first, client.name_last",
|
|
|
foreach ($customer->invoices as $invoice) {
|
|
|
$invoices[] = [
|
|
|
"uid" => $invoice->uid,
|
|
|
- "text" => '$' . $invoice->amount .
|
|
|
- ($invoice->description ? ' | ' . substr($invoice->description, 0, 15) : '') .
|
|
|
- ' | ' . friendly_date_time($invoice->created_at)
|
|
|
+ "text" => $invoice->displayName()
|
|
|
];
|
|
|
}
|
|
|
return json_encode([
|