Compare commits
4 Commits
b4116c7492
...
af793faf0d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af793faf0d | ||
|
|
ff75934526 | ||
|
|
338449f3f8 | ||
|
|
1af5a7d0b6 |
@@ -204,68 +204,76 @@ class InvoiceValidationResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoice_number')
|
||||
->label('Invoice Number')
|
||||
->alignCenter()
|
||||
->sortable(), //->searchable()
|
||||
Tables\Columns\TextColumn::make('stickerMaster.item.code')
|
||||
->label('Material Code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->sortable(), //->searchable()
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->sortable(), //->searchable()
|
||||
Tables\Columns\TextColumn::make('motor_scanned_status')
|
||||
->label('Motor Scanned Status')
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('pump_scanned_status')
|
||||
->label('Pump Scanned Status')
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('scanned_status_set')
|
||||
->label('Pump Set Scanned Status')
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('capacitor_scanned_status')
|
||||
->label('Capacitor Scanned Status')
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('scanned_status')
|
||||
->label('Scanned Status')
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('panel_box_supplier')
|
||||
->label('Panel Box Supplier')
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('panel_box_serial_number')
|
||||
->label('Panel Box Serial Number')
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('load_rate')
|
||||
->label('Load Rate')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('upload_status')
|
||||
->label('Upload Status')
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('batch_number')
|
||||
->label('Batch Number')
|
||||
->sortable(),
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('quantity')
|
||||
->label('Quantity')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('operator_id')
|
||||
->label('Operator ID')
|
||||
->sortable(),
|
||||
->label('Quantity')
|
||||
->alignCenter()
|
||||
->numeric(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('operator_id')
|
||||
->label('Operator ID')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
])
|
||||
|
||||
->headerActions([
|
||||
@@ -316,6 +324,8 @@ class InvoiceValidationResource extends Resource
|
||||
// Get original filename
|
||||
$originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx
|
||||
|
||||
$originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME);
|
||||
|
||||
// Store manually using storeAs to keep original name
|
||||
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local'); // returns relative path
|
||||
// uploads/temp/3RA0018735.xlsx
|
||||
@@ -323,8 +333,8 @@ class InvoiceValidationResource extends Resource
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalName)->where('plant_id', $plantId)->count();
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $originalName)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
|
||||
if($totQuan == $scanSQuan && $totQuan > 0)
|
||||
{
|
||||
@@ -594,12 +604,14 @@ class InvoiceValidationResource extends Resource
|
||||
// Get original filename
|
||||
$originalName = $uploadedFile->getClientOriginalName();
|
||||
|
||||
$originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME);
|
||||
|
||||
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local');
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalName)->where('plant_id', $plantId)->count();
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $originalName)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
if($totQuan == $scanMQuan && $totQuan > 0)
|
||||
{
|
||||
|
||||
@@ -2748,12 +2748,12 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$record->save();
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Success: Material QR')
|
||||
->body("'Material QR' scanned status updated, Scan next QR.")
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
// Notification::make()
|
||||
// ->title('Success: Material QR')
|
||||
// ->body("'Material QR' scanned status updated, Scan next QR.")
|
||||
// ->success() // commented
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
|
||||
@@ -3050,12 +3050,12 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$record->operator_id = $operatorName;
|
||||
$record->save();
|
||||
|
||||
Notification::make()
|
||||
->title('Success: Motor QR')
|
||||
->body("'Motor' QR scanned status updated, Scan next QR.")
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
// Notification::make()
|
||||
// ->title('Success: Motor QR')
|
||||
// ->body("'Motor' QR scanned status updated, Scan next QR.")
|
||||
// ->success() // commented
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
$this->form->fill([
|
||||
@@ -3160,12 +3160,12 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$record->operator_id = $operatorName;
|
||||
$record->save();
|
||||
|
||||
Notification::make()
|
||||
->title('Success: Pump QR')
|
||||
->body("'Pump' QR scanned status updated, Scan next QR.")
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
// Notification::make()
|
||||
// ->title('Success: Pump QR')
|
||||
// ->body("'Pump' QR scanned status updated, Scan next QR.")
|
||||
// ->success() // commented
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
$this->form->fill([
|
||||
@@ -3246,6 +3246,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
//hereToUpdate
|
||||
//$this->dispatch('openCapacitorModal');
|
||||
$this->dispatch('openCapacitorModal', itemCode: $itemCode, serialNumber: $serialNumber, plantId: $plantId);
|
||||
|
||||
@@ -3330,12 +3331,12 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$record->operator_id = $operatorName;
|
||||
$record->save();
|
||||
|
||||
Notification::make()
|
||||
->title('Success: Pump Set QR')
|
||||
->body("'Pump Set' QR scanned status updated, Scan next QR.")
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
// Notification::make()
|
||||
// ->title('Success: Pump Set QR')
|
||||
// ->body("'Pump Set' QR scanned status updated, Scan next QR.")
|
||||
// ->success() // commented
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
$this->form->fill([
|
||||
|
||||
@@ -17,287 +17,6 @@ class InvoiceChart extends ChartWidget
|
||||
protected $listeners = ['invoiceChart'];
|
||||
|
||||
|
||||
// protected function getData(): array
|
||||
// {
|
||||
// $selectedPlant = session('selec_plant');
|
||||
// $selectedInvoice = session('select_invoice');
|
||||
// $activeFilter = $this->filter;
|
||||
|
||||
// if (!$selectedPlant || !$selectedInvoice) {
|
||||
// return [
|
||||
// 'datasets' => [],
|
||||
// 'labels' => [],
|
||||
// ];
|
||||
// }
|
||||
|
||||
// if ($activeFilter == 'yesterday') {
|
||||
// $startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
// $endDate = now()->setTime(8, 0, 0);
|
||||
// $groupBy = 'none'; // No grouping by hour
|
||||
// } elseif ($activeFilter == 'this_week') {
|
||||
// $startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
// $endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
// $groupBy = 'day_of_week';
|
||||
// } elseif ($activeFilter == 'this_month') {
|
||||
// $startDate = now()->startOfMonth();
|
||||
// $endDate = now()->endOfMonth();
|
||||
// $groupBy = 'week_of_month';
|
||||
// } else {
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
// $groupBy = 'none'; // No grouping by hour
|
||||
// }
|
||||
|
||||
// // Get fully scanned invoices
|
||||
// if ($selectedInvoice == 'individual_material') {
|
||||
|
||||
// $allInvoiceNumbers = DB::table('invoice_validations')
|
||||
// ->select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->where('quantity', 1)
|
||||
// ->groupBy('invoice_number')
|
||||
// ->pluck('invoice_number');
|
||||
|
||||
// $fullyScannedInvoiceNumbers = DB::table('invoice_validations')
|
||||
// ->select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->where('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 == 'serial_invoice') {
|
||||
// $allInvoiceNumbers = DB::table('invoice_validations')
|
||||
// ->select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->whereNull('quantity')
|
||||
// ->pluck('invoice_number');
|
||||
|
||||
// $fullyScannedInvoiceNumbers = DB::table('invoice_validations')
|
||||
// ->select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->whereNull('quantity')
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END) = COUNT(*)")
|
||||
// ->pluck('invoice_number');
|
||||
// }
|
||||
// if ($selectedInvoice == 'bundle_material') {
|
||||
|
||||
// //Get all invoice numbers that contain bundle materials
|
||||
// $allInvoiceNumbers = DB::table('invoice_validations')
|
||||
// ->select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->whereIn('invoice_number', function ($query) use ($selectedPlant) {
|
||||
// $query->select('invoice_number')
|
||||
// ->from('invoice_validations')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->where('quantity', '>', 1);
|
||||
// })
|
||||
// ->groupBy('invoice_number')
|
||||
// ->pluck('invoice_number');
|
||||
|
||||
// //Get fully scanned bundle invoices
|
||||
// $fullyScannedBundle = DB::table('invoice_validations')
|
||||
// ->select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->where('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');
|
||||
|
||||
// //Get individual invoice numbers
|
||||
// $individualInvoices = DB::table('invoice_validations')
|
||||
// ->select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->where('quantity', 1)
|
||||
// ->groupBy('invoice_number')
|
||||
// ->pluck('invoice_number');
|
||||
|
||||
// //Get fully scanned individual invoices
|
||||
// $fullyScannedIndividual = DB::table('invoice_validations')
|
||||
// ->select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->where('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');
|
||||
|
||||
// //Find common invoices between bundle and individual
|
||||
// $commonInvoices = $allInvoiceNumbers->intersect($individualInvoices);
|
||||
|
||||
// //Identify incomplete common invoices
|
||||
// $notScannedInvoicesForBundle = $commonInvoices->filter(function ($invoice) use ($fullyScannedIndividual, $fullyScannedBundle) {
|
||||
// return !($fullyScannedIndividual->contains($invoice) && $fullyScannedBundle->contains($invoice));
|
||||
// });
|
||||
|
||||
// //Final fully scanned = only those that are scanned in both individual & bundle
|
||||
// $fullyScannedInvoiceNumbers = $fullyScannedBundle->filter(function ($invoice) use ($fullyScannedIndividual) {
|
||||
// return $fullyScannedIndividual->contains($invoice);
|
||||
// });
|
||||
|
||||
// //Exclude invoices that should be marked as "not scanned"
|
||||
// $fullyScannedInvoiceNumbers = $fullyScannedInvoiceNumbers->diff($notScannedInvoicesForBundle);
|
||||
|
||||
// //Calculate not scanned invoices = all - fully scanned
|
||||
// $notScannedInvoiceNumbers = $allInvoiceNumbers->diff($fullyScannedInvoiceNumbers);
|
||||
// }
|
||||
|
||||
// // Not scanned = all - scanned
|
||||
// $notScannedInvoiceNumbers = $allInvoiceNumbers->diff($fullyScannedInvoiceNumbers);
|
||||
|
||||
// //Get timestamps
|
||||
// $scannedTimestamps = DB::table('invoice_validations')
|
||||
// ->selectRaw("MAX(updated_at) AS final_time, invoice_number")
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->whereIn('invoice_number', $fullyScannedInvoiceNumbers)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->pluck('final_time', 'invoice_number');
|
||||
|
||||
// $notScannedTimestamps = DB::table('invoice_validations')
|
||||
// ->selectRaw("MIN(created_at) AS first_time, invoice_number")
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->whereIn('invoice_number', $notScannedInvoiceNumbers)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->pluck('first_time', 'invoice_number');
|
||||
|
||||
// // // Group timestamps
|
||||
// // $scannedGrouped = [];
|
||||
// // $notScannedGrouped = [];
|
||||
|
||||
// // foreach ($scannedTimestamps as $timestamp) {
|
||||
// // $time = \Carbon\Carbon::parse($timestamp);
|
||||
// // if ($time->lt($startDate) || $time->gt($endDate)) continue;
|
||||
|
||||
// // $key = match ($groupBy) {
|
||||
// // 'hour' => (int) $time->format('G'),
|
||||
// // 'day_of_week' => (int) $time->dayOfWeek,
|
||||
// // 'week_of_month' => (int) ceil($time->day / 7),
|
||||
// // };
|
||||
|
||||
// // $scannedGrouped[$key] = ($scannedGrouped[$key] ?? 0) + 1;
|
||||
// // }
|
||||
|
||||
// // foreach ($notScannedTimestamps as $timestamp) {
|
||||
// // $time = \Carbon\Carbon::parse($timestamp);
|
||||
// // if ($time->lt($startDate) || $time->gt($endDate)) continue;
|
||||
|
||||
// // $key = match ($groupBy) {
|
||||
// // 'hour' => (int) $time->format('G'),
|
||||
// // 'day_of_week' => (int) $time->dayOfWeek,
|
||||
// // 'week_of_month' => (int) ceil($time->day / 7),
|
||||
// // };
|
||||
|
||||
// // $notScannedGrouped[$key] = ($notScannedGrouped[$key] ?? 0) + 1;
|
||||
// // }
|
||||
|
||||
// // // Build x-axis labels and data arrays
|
||||
// // if ($groupBy == 'hour') {
|
||||
// // $shiftedKeys = array_merge(range(8, 23), range(0, 7));
|
||||
// // $labels = array_map(fn($h) => date("g A", strtotime("$h:00")), $shiftedKeys);
|
||||
// // $scannedData = array_map(fn($h) => $scannedGrouped[$h] ?? 0, $shiftedKeys);
|
||||
// // $notScannedData = array_map(fn($h) => $notScannedGrouped[$h] ?? 0, $shiftedKeys);
|
||||
// // } elseif ($groupBy == 'day_of_week') {
|
||||
// // $labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
// // $scannedData = array_fill(0, 7, 0);
|
||||
// // $notScannedData = array_fill(0, 7, 0);
|
||||
// // foreach ($scannedGrouped as $k => $v) $scannedData[$k] = $v;
|
||||
// // foreach ($notScannedGrouped as $k => $v) $notScannedData[$k] = $v;
|
||||
// // // Shift so Monday starts first
|
||||
// // $scannedData = [$scannedData[1], $scannedData[2], $scannedData[3], $scannedData[4], $scannedData[5], $scannedData[6], $scannedData[0]];
|
||||
// // $notScannedData = [$notScannedData[1], $notScannedData[2], $notScannedData[3], $notScannedData[4], $notScannedData[5], $notScannedData[6], $notScannedData[0]];
|
||||
// // } else {
|
||||
// // $weeksCount = ceil($endDate->day / 7);
|
||||
// // $labels = [];
|
||||
// // for ($i = 1; $i <= $weeksCount; $i++) {
|
||||
// // $weekStart = $startDate->copy()->addDays(($i - 1) * 7)->format('d M');
|
||||
// // $weekEnd = $startDate->copy()->addDays($i * 7 - 1)->min($endDate)->format('d M');
|
||||
// // $labels[] = "Week $i ($weekStart - $weekEnd)";
|
||||
// // }
|
||||
|
||||
// // $scannedData = array_fill(1, $weeksCount, 0);
|
||||
// // $notScannedData = array_fill(1, $weeksCount, 0);
|
||||
// // foreach ($scannedGrouped as $k => $v) $scannedData[$k] = $v;
|
||||
// // foreach ($notScannedGrouped as $k => $v) $notScannedData[$k] = $v;
|
||||
// // $scannedData = array_values($scannedData);
|
||||
// // $notScannedData = array_values($notScannedData);
|
||||
// // }
|
||||
|
||||
// // return [
|
||||
// // 'datasets' => [
|
||||
// // [
|
||||
// // 'label' => 'Scanned Invoices',
|
||||
// // 'data' => $scannedData,
|
||||
// // 'borderColor' => 'rgba(75, 192, 192, 1)',
|
||||
// // 'backgroundColor' => 'rgba(23, 211, 80, 0.7)',
|
||||
// // 'fill' => false,
|
||||
// // 'tension' => 0.3,
|
||||
// // ],
|
||||
// // [
|
||||
// // 'label' => 'Not Scanned Invoices',
|
||||
// // 'data' => $notScannedData,
|
||||
// // 'borderColor' => 'rgba(255, 99, 132, 1)',
|
||||
// // 'backgroundColor' => 'rgba(214, 105, 32, 0.9)',
|
||||
// // 'fill' => false,
|
||||
// // 'tension' => 0.3,
|
||||
// // ],
|
||||
// // ],
|
||||
// // 'labels' => $labels,
|
||||
// // ];
|
||||
|
||||
// // Group timestamps
|
||||
// // Build x-axis labels and data arrays
|
||||
// $scannedGrouped = [];
|
||||
// $notScannedGrouped = [];
|
||||
|
||||
// foreach ($scannedTimestamps as $timestamp) {
|
||||
// $time = \Carbon\Carbon::parse($timestamp);
|
||||
// if ($time->lt($startDate) || $time->gt($endDate)) continue;
|
||||
|
||||
// $key = match ($groupBy) {
|
||||
// 'hour' => (int) $time->format('G'),
|
||||
// 'day_of_week' => (int) $time->dayOfWeek,
|
||||
// 'week_of_month' => (int) ceil($time->day / 7),
|
||||
// };
|
||||
|
||||
// $scannedGrouped[$key] = ($scannedGrouped[$key] ?? 0) + 1;
|
||||
// }
|
||||
|
||||
// foreach ($notScannedTimestamps as $timestamp) {
|
||||
// $time = \Carbon\Carbon::parse($timestamp);
|
||||
// if ($time->lt($startDate) || $time->gt($endDate)) continue;
|
||||
|
||||
// $key = match ($groupBy) {
|
||||
// 'hour' => (int) $time->format('G'),
|
||||
// 'day_of_week' => (int) $time->dayOfWeek,
|
||||
// 'week_of_month' => (int) ceil($time->day / 7),
|
||||
// };
|
||||
|
||||
// $notScannedGrouped[$key] = ($notScannedGrouped[$key] ?? 0) + 1;
|
||||
// }
|
||||
|
||||
// $labels = ['Imported Invoice', 'Completed Invoice']; // Custom labels
|
||||
|
||||
// return [
|
||||
// 'datasets' => [
|
||||
// [
|
||||
// 'label' => 'Imported Invoices',
|
||||
// 'data' => [count($allInvoiceNumbers), count($fullyScannedInvoiceNumbers)],
|
||||
// 'backgroundColor' => 'rgba(75, 192, 192, 1)',
|
||||
// 'fill' => false,
|
||||
// ],
|
||||
// [
|
||||
// 'label' => 'Completed Invoices',
|
||||
// 'data' => [0, count($fullyScannedInvoiceNumbers)],
|
||||
// 'backgroundColor' => 'rgba(23, 211, 80, 1)',
|
||||
// 'fill' => false,
|
||||
// ],
|
||||
// ],
|
||||
// 'labels' => $labels,
|
||||
// ];
|
||||
// }
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$selectedPlant = session('selec_plant');
|
||||
@@ -331,16 +50,15 @@ class InvoiceChart extends ChartWidget
|
||||
}
|
||||
|
||||
// Get the counts for Imported Invoices (unique invoice numbers) and Completed Invoices
|
||||
if ($selectedInvoice == 'individual_material') {
|
||||
$importedInvoicesCount = DB::table('invoice_validations')
|
||||
->where('plant_id', $selectedPlant)
|
||||
if ($selectedInvoice == 'individual_material')
|
||||
{
|
||||
$importedInvoicesCount = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate]) // Filter by date range
|
||||
->distinct('invoice_number') // Only distinct invoice numbers
|
||||
->count('invoice_number');
|
||||
|
||||
$completedInvoicesCount = DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
@@ -349,24 +67,16 @@ class InvoiceChart extends ChartWidget
|
||||
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
)
|
||||
->count();
|
||||
|
||||
} elseif ($selectedInvoice == 'serial_invoice') {
|
||||
$importedInvoicesCount = DB::table('invoice_validations')
|
||||
->where('plant_id', $selectedPlant)
|
||||
}
|
||||
elseif ($selectedInvoice == 'serial_invoice')
|
||||
{
|
||||
$importedInvoicesCount = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->distinct('invoice_number')
|
||||
->count('invoice_number');
|
||||
|
||||
// $completedInvoicesCount = DB::table('invoice_validations')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->whereNull('quantity')
|
||||
// ->where('scanned_status', 'Scanned') // assuming scanned_status means completed
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate]) // Filter by date range
|
||||
// ->distinct('invoice_number') // Only distinct invoice numbers
|
||||
// ->count('invoice_number');
|
||||
$completedInvoicesCount = DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
@@ -376,23 +86,16 @@ class InvoiceChart extends ChartWidget
|
||||
)
|
||||
->count();
|
||||
|
||||
} elseif ($selectedInvoice == 'bundle_material') {
|
||||
$importedInvoicesCount = DB::table('invoice_validations')
|
||||
->where('plant_id', $selectedPlant)
|
||||
}
|
||||
elseif ($selectedInvoice == 'bundle_material')
|
||||
{
|
||||
$importedInvoicesCount = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate]) // Filter by date range
|
||||
->distinct('invoice_number') // Only distinct invoice numbers
|
||||
->count('invoice_number');
|
||||
|
||||
// $completedInvoicesCount = DB::table('invoice_validations')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->where('quantity', '>', 1)
|
||||
// ->whereNotNull('serial_number') // assuming serial_number presence means completed
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate]) // Filter by date range
|
||||
// ->distinct('invoice_number') // Only distinct invoice numbers
|
||||
// ->count('invoice_number');
|
||||
$completedInvoicesCount = DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
@@ -401,7 +104,6 @@ class InvoiceChart extends ChartWidget
|
||||
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
)
|
||||
->count();
|
||||
|
||||
}
|
||||
|
||||
// Prepare the chart data
|
||||
@@ -428,11 +130,10 @@ class InvoiceChart extends ChartWidget
|
||||
$dayStart = now()->startOfWeek()->addDays($index)->setTime(8, 0, 0);
|
||||
$dayEnd = $dayStart->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
$query = DB::table('invoice_validations')->where('plant_id', $selectedPlant);
|
||||
$query = InvoiceValidation::where('plant_id', $selectedPlant);
|
||||
|
||||
// Build completedQuery with only 'invoice_number' in select
|
||||
$completedQuery = DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
$completedQuery = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant);
|
||||
|
||||
if ($selectedInvoice == 'individual_material')
|
||||
@@ -513,19 +214,23 @@ class InvoiceChart extends ChartWidget
|
||||
$queryImported = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
->whereBetween('created_at', [$weekStart, $weekEnd]);
|
||||
|
||||
if ($selectedInvoice == 'individual_material') {
|
||||
if ($selectedInvoice == 'individual_material')
|
||||
{
|
||||
$queryImported->where('quantity', 1);
|
||||
} elseif ($selectedInvoice == 'serial_invoice') {
|
||||
}
|
||||
elseif ($selectedInvoice == 'serial_invoice')
|
||||
{
|
||||
$queryImported->whereNull('quantity');
|
||||
} elseif ($selectedInvoice == 'bundle_material') {
|
||||
}
|
||||
elseif ($selectedInvoice == 'bundle_material')
|
||||
{
|
||||
$queryImported->where('quantity', '>', 1);
|
||||
}
|
||||
|
||||
$importedInvoicesPerWeek[$weekIndex] = $queryImported->distinct('invoice_number')->count('invoice_number');
|
||||
|
||||
// --- Completed ---
|
||||
$queryCompleted = DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
$queryCompleted = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->whereBetween('updated_at', [$weekStart, $weekEnd]);
|
||||
|
||||
|
||||
@@ -301,13 +301,13 @@ class InvoiceDataTable extends Component
|
||||
]);
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Success: Capacitor QR')
|
||||
// ->title("Panel box code scanned: $itemCode")
|
||||
->body("'Capacitor' QR scanned status updated, Scan next QR.")
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
// Notification::make()
|
||||
// ->title('Success: Capacitor QR')
|
||||
// // ->title("Panel box code scanned: $itemCode")
|
||||
// ->body("'Capacitor' QR scanned status updated, Scan next QR.")
|
||||
// ->success() // commented
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->where('scanned_status', 'Scanned')->count();
|
||||
|
||||
Reference in New Issue
Block a user