diff --git a/routes/web.php b/routes/web.php index d532cae9..5fc91252 100644 --- a/routes/web.php +++ b/routes/web.php @@ -495,18 +495,21 @@ Route::get('/customer/summary/{year}/monthly', function ($year) { }); -Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}/{with_cbm?}', function ($active_start, $active_end, $inactive_start=null, $inactive_end=null, $with_cbm = false) { - $activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) { - return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) { - return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay()); - }); - })->pluck('id'); +Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}/{with_cbm?}', function ($active_start, $active_end, $inactive_start = null, $inactive_end = null, $with_cbm = false) { + /* $activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) { + return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) { + return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay()); + }); + })->pluck('id'); + + $companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) { + return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) { + return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay()); + }); + })->whereNotIn('id', $activeCompanies)->get();*/ + + $companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end); - $companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) { - return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) { - return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay()); - }); - })->whereNotIn('id', $activeCompanies)->get(); echo '
| Invoices | '; -foreach ($duplicatedTransactions as $transaction) { - $transactionIds = explode(',', $transaction->transaction_ids); + foreach ($duplicatedTransactions as $transaction) { + $transactionIds = explode(',', $transaction->transaction_ids); - $duplicatedInvoice = Transaction::whereIn('id', $transactionIds)->get(); - - $order_reference = $duplicatedInvoice->first()->owner->owner->reference ?? null; + $duplicatedInvoice = Transaction::whereIn('id', $transactionIds)->get(); + + $order_reference = $duplicatedInvoice->first()->owner->owner->reference ?? null; - if ($transaction->type == TransactionType::PAYMENT) { - $order_reference = $duplicatedInvoice->first()->owner->owner->owner->reference ?? null; - } - - echo '||||||
|---|---|---|---|---|---|---|
| ' . $transaction->owner_type . ' | '; - // echo '' . $transaction->owner_id . ' | '; - echo '' . $transaction->receiver . ' | '; - echo '' . ''. $order_reference .'' . ' | '; - echo '' . $transactionType[$transaction->type] . ' | '; - echo '' . count($transactionIds) . ' | '; - echo '';
- foreach ($duplicatedInvoice as $invoice) {
- echo ' ID: ' . $invoice->id . '. Status: ' . $approvalStatusArray[$invoice->status] . '. Amount: ' . $invoice->amount . ' '; + if ($transaction->type == TransactionType::PAYMENT) { + $order_reference = $duplicatedInvoice->first()->owner->owner->owner->reference ?? null; } - echo' | ';
- echo '
ID: ' . $invoice->id . '. Status: ' . $approvalStatusArray[$invoice->status] . '. Amount: ' . $invoice->amount . '
'; + } + echo'