all charts updated
This commit is contained in:
@@ -15,7 +15,6 @@ class InvoiceChart extends ChartWidget
|
||||
|
||||
protected $listeners = ['invoiceChart'];
|
||||
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$selectedPlant =session('selec_plant');
|
||||
@@ -33,13 +32,17 @@ class InvoiceChart extends ChartWidget
|
||||
}
|
||||
|
||||
if ($activeFilter === 'yesterday') {
|
||||
$startDate = now()->subDay()->startOfDay();
|
||||
$endDate = now()->subDay()->endOfDay();
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0); // yesterday 8:00 AM
|
||||
$endDate = now()->setTime(8, 0, 0); // today 8:00 AM
|
||||
$groupBy = 'EXTRACT(HOUR FROM invoice_validations.created_at)';
|
||||
}
|
||||
else if ($activeFilter === 'this_week') {
|
||||
$startDate = now()->startOfWeek(); // Monday 12:00 AM
|
||||
$endDate = now()->endOfWeek(); // Sunday 11:59 PM
|
||||
// Monday 8:00 AM of the current week
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
|
||||
// Next Monday 8:00 AM (end of Sunday + 8 hrs)
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
$groupBy = 'EXTRACT(DOW FROM invoice_validations.created_at)'; // Group by day of week
|
||||
}
|
||||
else if ($activeFilter === 'this_month') {
|
||||
@@ -49,17 +52,48 @@ class InvoiceChart extends ChartWidget
|
||||
}
|
||||
else
|
||||
{
|
||||
$startDate = now()->startOfDay();
|
||||
$endDate = now()->endOfDay();
|
||||
$startDate = now()->setTime(8, 0, 0); // today at 8:00 AM
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0); // tomorrow at 8:00 AM
|
||||
$groupBy = 'EXTRACT(HOUR FROM invoice_validations.created_at)';
|
||||
}
|
||||
|
||||
$fullyScannedInvoiceNumbers = \DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END) = COUNT(*)")
|
||||
->pluck('invoice_number');
|
||||
// $fullyScannedInvoiceNumbers = \DB::table('invoice_validations')
|
||||
// ->select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END) = COUNT(*)")
|
||||
// ->pluck('invoice_number');
|
||||
|
||||
if ($selectedInvoice === 'individual_material')
|
||||
{
|
||||
$fullyScannedInvoiceNumbers = \DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->havingRaw('MIN(quantity) = 1 AND MAX(quantity) = 1') // All rows must have quantity = 1
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END) = COUNT(*)")
|
||||
->pluck('invoice_number');
|
||||
}
|
||||
else if ($selectedInvoice === 'bundle_material')
|
||||
{
|
||||
$fullyScannedInvoiceNumbers = \DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->havingRaw('MIN(quantity) > 1')
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END) = COUNT(*)")
|
||||
->pluck('invoice_number');
|
||||
}
|
||||
else
|
||||
{
|
||||
$fullyScannedInvoiceNumbers = \DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END) = COUNT(*)")
|
||||
->pluck('invoice_number');
|
||||
}
|
||||
|
||||
|
||||
//query data
|
||||
$query = \DB::table('invoice_validations')
|
||||
@@ -173,7 +207,6 @@ class InvoiceChart extends ChartWidget
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user