16 Commits

Author SHA1 Message Date
dhanabalan
cb8740d048 added code and plant in production order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Laravel Larastan / larastan (pull_request) Failing after 7m20s
Laravel Pint / pint (pull_request) Successful in 7m54s
2026-08-28 16:08:28 +05:30
dhanabalan
5c826e8c3d Updated discharge label on PumpTestingResultExporter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Laravel Larastan / larastan (pull_request) Failing after 7m13s
Laravel Pint / pint (pull_request) Successful in 8m21s
2026-08-28 14:30:50 +05:30
dhanabalan
02a435e93d Updated pump testing result post api function success and failure response description
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Laravel Pint / pint (pull_request) Successful in 5m36s
Laravel Larastan / larastan (pull_request) Failing after 9m10s
2026-08-28 14:18:54 +05:30
dhanabalan
ce0bfa72ca Updated unique query table name and exportAction label
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
2026-08-28 14:15:07 +05:30
dhanabalan
bc60690872 Added pump testing entry / result post api function with validations and Updated pump testing master / entry / result get api function validations,
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
2026-08-28 13:01:24 +05:30
dhanabalan
f4d416bea2 Added pump testing result resource and exporter files and Updated pump testing entry report filter functionality
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
2026-08-28 12:54:53 +05:30
dhanabalan
5279b016d1 Added pump testing result model files for hasMany relations
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
2026-08-28 12:48:51 +05:30
dhanabalan
2fb143c1f2 Added pump testing result policies and model file
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
2026-08-28 12:42:59 +05:30
dhanabalan
eac712aaac Added pump testing result migration file
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
2026-08-28 12:39:19 +05:30
dhanabalan
44b2a19270 Added remove stopped related fields on get api getClassChar function for manual laser
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Laravel Pint / pint (pull_request) Successful in 5m49s
Laravel Larastan / larastan (pull_request) Failing after 9m1s
2026-08-28 11:17:17 +05:30
dhanabalan
bb5e088b02 removed panel box checklst rework logic
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Laravel Pint / pint (pull_request) Successful in 7m40s
Laravel Larastan / larastan (pull_request) Failing after 9m39s
2026-08-28 10:39:19 +05:30
dhanabalan
393ea6a4bd removed rework logic in panel box
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-08-28 10:38:33 +05:30
dhanabalan
0c189f695c Added rework logic in panel box check list
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Larastan / larastan (pull_request) Failing after 8m50s
Laravel Pint / pint (pull_request) Successful in 9m19s
2026-08-28 10:33:40 +05:30
dhanabalan
95d70fbdca Added rework logic in panel box validation
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
2026-08-28 10:32:49 +05:30
dhanabalan
88e6b83487 removed rework logic in panel check list
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Larastan / larastan (pull_request) Failing after 9m22s
Laravel Pint / pint (pull_request) Successful in 9m32s
2026-08-27 16:34:09 +05:30
dhanabalan
8061953062 removed rework logic in panel box validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-08-27 16:33:39 +05:30
18 changed files with 2237 additions and 258 deletions

View File

@@ -22,9 +22,9 @@ class ProductionOrderExporter extends Exporter
// Increment and return the row number // Increment and return the row number
return ++$rowNumber; return ++$rowNumber;
}), }),
ExportColumn::make('plant_id') ExportColumn::make('plant.code')
->label('PLANT CODE'), ->label('PLANT CODE'),
ExportColumn::make('item_id') ExportColumn::make('item.code')
->label('ITEM CODE'), ->label('ITEM CODE'),
ExportColumn::make('quantity') ExportColumn::make('quantity')
->label('QUANTITY'), ->label('QUANTITY'),

View File

@@ -0,0 +1,93 @@
<?php
namespace App\Filament\Exports;
use App\Models\PumpTestingResult;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class PumpTestingResultExporter extends Exporter
{
protected static ?string $model = PumpTestingResult::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('tested_date')
->label('TESTED DATE'),
ExportColumn::make('tested_type')
->label('TESTED TYPE'),
ExportColumn::make('pumpTestingMaster.item.code')
->label('PUMP CODE'),
ExportColumn::make('pumpTestingMaster.item.category')
->label('PUMP CATEGORY')
->enabledByDefault(false),
ExportColumn::make('pumpTestingMaster.item.description')
->label('PUMP TYPE'),
ExportColumn::make('pumpTestingMaster.item.uom')
->label('UNIT OF MEASURE')
->enabledByDefault(false),
ExportColumn::make('pump_serial_number')
->label('PUMP SERIAL NUMBER'),
ExportColumn::make('correction_head')
->label('CORRECTION HEAD'),
ExportColumn::make('sl_no')
->label('SL. NO.'),
ExportColumn::make('voltage')
->label('VOLTAGE'),
ExportColumn::make('current')
->label('CURRENT'),
ExportColumn::make('watt')
->label('WATT'),
ExportColumn::make('frequency')
->label('FREQUENCY'),
ExportColumn::make('speed')
->label('SPEED'),
ExportColumn::make('discharge')
->label('DISCHARGE'),
ExportColumn::make('head')
->label('HEAD'),
ExportColumn::make('pump_output')
->label('PUMP OUTPUT'),
ExportColumn::make('power_p2')
->label('PUMP P2'),
ExportColumn::make('overall_efficiency')
->label('OVERALL EFFICIENCY'),
ExportColumn::make('pump_efficiency')
->label('PUMP EFFICIENCY'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your pump testing result export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
}
return $body;
}
}

View File

@@ -810,21 +810,21 @@ class PanelBoxValidationResource extends Resource
$serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first(); $serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
if ($serialExists) { // if ($serialExists) {
$set('serial_exists', true); // $set('serial_exists', true);
} else { // } else {
$set('serial_exists', false); // $set('serial_exists', false);
}
// if ($serialExists && ! $get('id')) {
// $set('validationError', 'Serial number already exists in panel box validation.');
// $set('sticker_master_id', null);
// $set('uom', null);
// $set('serial_number', null);
// return;
// } // }
if ($serialExists && ! $get('id')) {
$set('validationError', 'Serial number already exists in panel box validation.');
$set('sticker_master_id', null);
$set('uom', null);
$set('serial_number', null);
return;
}
$set('validationError', null); $set('validationError', null);
foreach ($serialFields as $column) { foreach ($serialFields as $column) {

View File

@@ -464,7 +464,7 @@ class PumpTestingEntryResource extends Resource
}) })
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Item', null); $set('Item', null);
$set('isi_type', null); $set('tested_type', null);
$set('created_by', null); $set('created_by', null);
$set('updated_by', null); $set('updated_by', null);
}), }),
@@ -479,7 +479,7 @@ class PumpTestingEntryResource extends Resource
->reactive() ->reactive()
->native(false), ->native(false),
Select::make('tested_type') Select::make('tested_type')
->label('Tested Type') ->label('Search by Tested Type')
->nullable() ->nullable()
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
@@ -592,13 +592,13 @@ class PumpTestingEntryResource extends Resource
} }
if (! empty($data['Item']) && ! empty($data['Plant'])) { if (! empty($data['Item']) && ! empty($data['Plant'])) {
$itemIds = Item::where('id', $data['Item']) $pumpMasterIds = PumpTestingMaster::where('item_id', $data['Item'])
->where('plant_id', $data['Plant']) ->where('plant_id', $data['Plant'])
->pluck('id') ->pluck('id')
->toArray(); ->toArray();
if (! empty($itemIds)) { if (! empty($pumpMasterIds)) {
$query->whereIn('item_id', $itemIds); $query->whereIn('pump_testing_master_id', $pumpMasterIds);
} }
} }
@@ -611,7 +611,14 @@ class PumpTestingEntryResource extends Resource
})->pluck('id')->toArray(); })->pluck('id')->toArray();
if (! empty($descIds)) { if (! empty($descIds)) {
$query->whereIn('item_id', $descIds); $pumpMasterIds = PumpTestingMaster::whereIn('item_id', $descIds)
->where('plant_id', $data['Plant'])
->pluck('id')
->toArray();
if (! empty($pumpMasterIds)) {
$query->whereIn('pump_testing_master_id', $pumpMasterIds);
}
} }
} }

View File

@@ -0,0 +1,808 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\PumpTestingResultExporter;
use App\Filament\Resources\PumpTestingResultResource\Pages;
use App\Models\Configuration;
use App\Models\Item;
use App\Models\Plant;
use App\Models\PumpTestingMaster;
use App\Models\PumpTestingResult;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Forms\Set;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Validation\Rule;
class PumpTestingResultResource extends Resource
{
protected static ?string $model = PumpTestingResult::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Pump Testing Panel';
protected static ?int $navigationSort = 3;
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant Name')
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->columnSpan(1) // (['default' => 1, 'sm' => 2])
->required()
->searchable()
->reactive()
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(PumpTestingResult::latest()->first())->plant_id ?? null;
})
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
$set('pump_testing_master_id', null);
$set('pump_master_id', null);
// $set('pump_type', null);
if (! $plantId) {
$set('pTeError', 'Please select a plant first.');
return;
} else {
$set('pTeError', null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->extraAttributes(fn ($get) => [
'class' => $get('pTeError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('pTeError') ? $get('pTeError') : null)
->hintColor('danger'),
Forms\Components\Select::make('tested_type')
->label('Tested Type')
->selectablePlaceholder(false)
->options(function (callable $get) {
$plantId = $get('plant_id');
if ($plantId) {
return Configuration::where('plant_id', $plantId)
->where('c_name', 'PUMP_DISPLAY_TEST_TYPE')
->whereNot('c_value', 'Routine Test')
->orderBy('created_at')
->pluck('c_value', 'c_value')
->toArray();
} else {
return Configuration::where('c_name', 'PUMP_DISPLAY_TEST_TYPE')
->whereNot('c_value', 'Routine Test')
->orderBy('created_at')
->pluck('c_value', 'c_value')
->toArray();
}
})
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->default('Pump Performance Test')
->reactive(),
Forms\Components\DatePicker::make('tested_date')
->label('Tested Date')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->default(now())
->required()
->reactive(),
Forms\Components\TextInput::make('correction_head')
->label('Correction Head')
->placeholder('Scan the correction head')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\Hidden::make('pump_testing_master_id')
// ->relationship('pumpTestingMasters', 'id')
->required(),
Forms\Components\Select::make('pump_master_id')
->label('Pump Code')
// ->relationship('pumpTestingMasters', 'id')
->options(function (callable $get) {
$plantId = $get('plant_id');
if (! $plantId) {
return [];
}
return Item::where('plant_id', $plantId)->whereHas('pumpTestingMasters')->orderBy('code')->pluck('code', 'code');
})
->columnSpan(1)
->required()
->searchable()
->reactive()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$plantId = $get('plant_id'); // Get selected plant
$set('pump_testing_master_id', null);
// $set('pump_type', null);
if (! $plantId) {
$set('pump_master_id', null);
} elseif ($state) {
// $pumpMaster = PumpTestingMaster::where('plant_id', $plantId)->where('item_id', $state)->first();
$pumpMaster = PumpTestingMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($state) {
$query->where('code', $state);
})->first();
if (! $pumpMaster) {
$set('pump_master_id', null);
} else {
$set('pump_testing_master_id', $pumpMaster->id);
// $set('pump_type', $pumpMaster->item->description ?? null);
}
}
$set('updated_by', Filament::auth()->user()?->name);
})
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
if ($get('id')) {
$itemId = PumpTestingMaster::where('id', $get('pump_testing_master_id'))->first()?->item_id;
if ($itemId) {
$item = Item::where('id', $itemId)->first()?->code;
if ($item) {
$set('pump_master_id', $item);
} else {
$set('pump_master_id', null);
}
} else {
$set('pump_master_id', null);
}
}
}),
// Forms\Components\TextInput::make('pump_type')
// ->label('Pump Type]')
// ->placeholder('Choose the pump code first')
// ->readOnly()
// ->afterStateUpdated(function ($state, callable $set) {
// $set('updated_by', Filament::auth()->user()?->name);
// })
// ->columnSpan(1)
// ->required()
// ->reactive(),
Forms\Components\TextInput::make('pump_serial_number')
->label('Pump Serial Number')
->placeholder('Scan the pump serial number')
->rule(function (callable $get) {
return Rule::unique('pump_testing_results', 'pump_serial_number')
->where('plant_id', $get('plant_id'))
->where('pump_testing_master_id', $get('pump_testing_master_id'))
->where('tested_type', $get('tested_type'))
->where('sl_no', $get('sl_no'))
->ignore($get('id'));
})
->afterStateUpdated(function ($state, callable $set) {
if (strpos($state, '|') != false) {
$parts = explode('|', $state);
$set('pump_serial_number', $parts[1]);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('sl_no')
->label('Sl. No.')
->placeholder('Scan the sl. no.')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('voltage')
->label('Voltage')
->placeholder('Scan the voltage')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('current')
->label('Current')
->placeholder('Scan the current')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('watt')
->label('Watt')
->placeholder('Scan the watt')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('frequency')
->label('Frequency')
->placeholder('Scan the frequency')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('speed')
->label('Speed')
->placeholder('Scan the speed')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('discharge')
->label('Discharge')
->placeholder('Scan the discharge')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('head')
->label('Head')
->placeholder('Scan the head')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('pump_output')
->label('Pump Output')
->placeholder('Scan the pump output')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('power_p2')
->label('Power P2')
->placeholder('Scan the power p2')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('overall_efficiency')
->label('Overall Efficiency')
->placeholder('Scan the overall efficiency')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\TextInput::make('pump_efficiency')
->label('Pump Efficiency')
->placeholder('Scan the pump efficiency')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->columnSpan(1)
->required()
->reactive(),
Forms\Components\Hidden::make('created_by')
->default(fn () => Filament::auth()->user()?->name)
->columnSpan(1)
->required(),
Forms\Components\Hidden::make('updated_by')
->default(fn () => Filament::auth()->user()?->name)
->columnSpan(1)
->required(),
Forms\Components\TextInput::make('id')
->hidden()
->columnSpan(1)
->readOnly(),
])
->columns(['default' => 1, 'sm' => 2]),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
// Tables\Columns\TextColumn::make('id')
// ->label('ID')
// ->numeric()
// ->sortable(),
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant Name')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('tested_date')
->label('Tested Date')
->date() // 'F d, Y'
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('tested_type')
->label('Tested Type')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('pumpTestingMasters.item.code')
->label('Pump Code')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('pumpTestingMasters.item.category')
->label('Pump Category')
->default('-')
->searchable()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('pumpTestingMasters.item.description')
->label('Pump Type')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('pumpTestingMasters.item.uom')
->label('Unit Of Measure')
->default('-')
->searchable()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('pump_serial_number')
->label('Pump Serial Number')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('correction_head')
->label('Correction Head')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('sl_no')
->label('Sl. No.')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('voltage')
->label('Voltage')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('current')
->label('Current')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('watt')
->label('Watt')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('frequency')
->label('Frequency')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('speed')
->label('Speed')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('discharge')
->label('Discharge')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('head')
->label('Head')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('pump_output')
->label('Pump Output')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('power_p2')
->label('Power P2')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('overall_efficiency')
->label('Overall Efficiency')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('pump_efficiency')
->label('Pump Efficiency')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->dateTime()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Search by Plant Name')
->nullable()
->searchable()
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
} else {
return Plant::whereHas('pumpTestingResults', function ($query) {
$query->whereNotNull('id');
})->orderBy('code')->pluck('name', 'id');
}
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Item', null);
$set('tested_type', null);
$set('created_by', null);
$set('updated_by', null);
}),
DatePicker::make('tested_from')
->label('Tested From')
->placeholder('Select From Date')
->reactive()
->native(false),
DatePicker::make('tested_to')
->label('Tested To')
->placeholder('Select To Date')
->reactive()
->native(false),
Select::make('tested_type')
->label('Search by Tested Type')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
if (! $plantId) {
return PumpTestingResult::whereNotNull('tested_type')->select('tested_type')->distinct()->pluck('tested_type', 'tested_type');
} else {
return PumpTestingResult::where('plant_id', $plantId)->whereNotNull('tested_type')->select('tested_type')->distinct()->pluck('tested_type', 'tested_type');
}
})
->searchable()
->reactive(),
Select::make('Item')
->label('Search by Pump Code')
->nullable()
->options(function (callable $get) {
$pId = $get('Plant');
if (! $pId) {
return [];
} else {
return Item::whereHas('pumpTestingMasters', function ($query) use ($pId) {
if ($pId) {
$query->where('plant_id', $pId);
}
$query->whereHas('pumpTestingResults');
})->pluck('code', 'id');
}
})
->searchable()
->reactive(),
TextInput::make('description')
->label('Pump Type')
->placeholder('Enter the Pump Type'),
TextInput::make('pump_serial_number')
->label('Pump Serial Number')
->placeholder('Enter the Pump Serial Number'),
Select::make('created_by')
->label('Search by Created By')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
if (! $plantId) {
return PumpTestingResult::whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
} else {
return PumpTestingResult::where('plant_id', $plantId)->whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
}
})
->searchable()
->reactive(),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder(placeholder: 'Select To DateTime')
->reactive()
->native(false),
Select::make('updated_by')
->label('Search by Updated By')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
if (! $plantId) {
return PumpTestingResult::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
} else {
return PumpTestingResult::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
}
})
->searchable()
->reactive(),
DateTimePicker::make(name: 'updated_from')
->label('Updated From')
->placeholder(placeholder: 'Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('updated_to')
->label('Updated To')
->placeholder(placeholder: 'Select To DateTime')
->reactive()
->native(false),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['tested_from']) && empty($data['tested_to']) && empty($data['tested_type']) && empty($data['Item']) && empty($data['description']) && empty($data['pump_serial_number']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to'])) {
return $query->whereRaw('1 = 0');
}
if (! empty($data['Plant'])) {
$query->where('plant_id', $data['Plant']);
} else {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return $query->whereRaw('1 = 0');
}
}
if (! empty($data['tested_from'])) {
$query->where('tested_date', '>=', $data['tested_from']);
}
if (! empty($data['tested_to'])) {
$query->where('tested_date', '<=', $data['tested_to']);
}
if (! empty($data['tested_type'])) {
$query->where('tested_type', $data['tested_type']);
}
if (! empty($data['Item']) && ! empty($data['Plant'])) {
$pumpMasterIds = PumpTestingMaster::where('item_id', $data['Item'])
->where('plant_id', $data['Plant'])
->pluck('id')
->toArray();
if (! empty($pumpMasterIds)) {
$query->whereIn('pump_testing_master_id', $pumpMasterIds);
}
}
if (! empty($data['description'])) {
$pId = $data['Plant'] ?? null;
$descIds = Item::where('description', 'like', '%'.$data['description'].'%')->whereHas('pumpTestingMasters', function ($query) use ($pId) {
if ($pId) {
$query->where('plant_id', $pId);
}
})->pluck('id')->toArray();
if (! empty($descIds)) {
$pumpMasterIds = PumpTestingMaster::whereIn('item_id', $descIds)
->where('plant_id', $data['Plant'])
->pluck('id')
->toArray();
if (! empty($pumpMasterIds)) {
$query->whereIn('pump_testing_master_id', $pumpMasterIds);
}
}
}
if (! empty($data['pump_serial_number'])) {
$query->where('pump_serial_number', 'like', '%'.$data['pump_serial_number'].'%');
}
if (! empty($data['created_by'])) {
$query->where('created_by', $data['created_by']);
}
if (! empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
if (! empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']);
}
if (! empty($data['updated_by'])) {
$query->where('updated_by', $data['updated_by']);
}
if (! empty($data['updated_from'])) {
$query->where('updated_at', '>=', $data['updated_from']);
}
if (! empty($data['updated_to'])) {
$query->where('updated_at', '<=', $data['updated_to']);
}
})
->indicateUsing(function (array $data) {
$indicators = [];
if (! empty($data['Plant'])) {
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
} else {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return 'Plant: Choose plant to filter records.';
}
}
if (! empty($data['tested_from'])) {
$indicators[] = 'Tested From: '.$data['tested_from'];
}
if (! empty($data['tested_to'])) {
$indicators[] = 'Tested To: '.$data['tested_to'];
}
if (! empty($data['tested_type'])) {
$indicators[] = 'Tested Type: '.$data['tested_type'];
}
if (! empty($data['Item']) && ! empty($data['Plant'])) {
$itemCode = Item::find($data['Item'])->code ?? 'Unknown';
$indicators[] = 'Pump Code: '.$itemCode;
}
if (! empty($data['description'])) {
$indicators[] = 'Pump Type: '.$data['description'];
}
if (! empty($data['pump_serial_number'])) {
$indicators[] = 'Pump Serial Number: '.$data['pump_serial_number'];
}
if (! empty($data['created_by'])) {
$indicators[] = 'Created By: '.$data['created_by'];
}
if (! empty($data['created_from'])) {
$indicators[] = 'Created From: '.$data['created_from'];
}
if (! empty($data['created_to'])) {
$indicators[] = 'Created To: '.$data['created_to'];
}
if (! empty($data['updated_by'])) {
$indicators[] = 'Updated By: '.$data['updated_by'];
}
if (! empty($data['updated_from'])) {
$indicators[] = 'Updated From: '.$data['updated_from'];
}
if (! empty($data['updated_to'])) {
$indicators[] = 'Updated To: '.$data['updated_to'];
}
return $indicators;
}),
])
->filtersFormMaxHeight('280px')
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->headerActions([
ExportAction::make()
->label('Export Pump Testing Results')
->color('warning')
->exporter(PumpTestingResultExporter::class)
->visible(function () {
return Filament::auth()->user()->can('view export pump testing results');
}),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListPumpTestingResults::route('/'),
'create' => Pages\CreatePumpTestingResult::route('/create'),
'view' => Pages\ViewPumpTestingResult::route('/{record}'),
'edit' => Pages\EditPumpTestingResult::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Filament\Resources\PumpTestingResultResource\Pages;
use App\Filament\Resources\PumpTestingResultResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreatePumpTestingResult extends CreateRecord
{
protected static string $resource = PumpTestingResultResource::class;
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\PumpTestingResultResource\Pages;
use App\Filament\Resources\PumpTestingResultResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditPumpTestingResult extends EditRecord
{
protected static string $resource = PumpTestingResultResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\PumpTestingResultResource\Pages;
use App\Filament\Resources\PumpTestingResultResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListPumpTestingResults extends ListRecords
{
protected static string $resource = PumpTestingResultResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\PumpTestingResultResource\Pages;
use App\Filament\Resources\PumpTestingResultResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewPumpTestingResult extends ViewRecord
{
protected static string $resource = PumpTestingResultResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

View File

@@ -3241,7 +3241,7 @@ class CharacteristicsController extends Controller
$characteristicsData = ClassCharacteristic::where('gernr', $serialNumber)->where('item_id', $itemId)->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); $characteristicsData = ClassCharacteristic::where('gernr', $serialNumber)->where('item_id', $itemId)->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
$remFields = ['id', 'plant_id', 'machine_id', 'item_id', 'gernr', 'zmm_codeclass', 'zmm_colour', 'zmm_grade', 'zmm_grwt_cable', 'zmm_grwt_pf', 'zmm_isivalve', 'zmm_isi_wc', 'zmm_length', 'zmm_license_cml_no', 'zmm_mfgmonyr', 'zmm_motoridentification', 'zmm_newt_cable', 'zmm_newt_pf', 'zmm_packtype', 'zmm_panel', 'zmm_pumpidentification', 'zmm_psettype', 'zmm_size', 'zmm_type', 'zmm_usp', 'created_at', 'updated_at', 'created_by', 'updated_by', 'deleted_at']; $remFields = ['id', 'plant_id', 'machine_id', 'item_id', 'gernr', 'zmm_codeclass', 'zmm_colour', 'zmm_grade', 'zmm_grwt_cable', 'zmm_grwt_pf', 'zmm_isivalve', 'zmm_isi_wc', 'zmm_length', 'zmm_license_cml_no', 'zmm_mfgmonyr', 'zmm_motoridentification', 'zmm_newt_cable', 'zmm_newt_pf', 'zmm_packtype', 'zmm_panel', 'zmm_pumpidentification', 'zmm_psettype', 'zmm_size', 'zmm_type', 'zmm_usp', 'created_at', 'updated_at', 'created_by', 'updated_by', 'deleted_at', 'is_stopped', 'stopped_datetime', 'stopped_by'];
$filteredData = $characteristicsData->map(function ($char) use ($remFields) { $filteredData = $characteristicsData->map(function ($char) use ($remFields) {
$charArray = $char->toArray(); $charArray = $char->toArray();

File diff suppressed because it is too large Load Diff

View File

@@ -177,62 +177,36 @@ public $records = [];
} }
} }
$latestReworkRecord = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)->where('serial_number', $this->data['serial_number'] ?? null)->latest()->first(); // $latestReworkRecord = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)->where('serial_number', $this->data['serial_number'] ?? null)->latest()->first();
if($latestReworkRecord){ // if($latestReworkRecord){
$qualityValidation = PanelBoxValidation::create([ // $qualityValidation = PanelBoxValidation::create([
'plant_id' => $this->data['plant_id'] ?? null, // 'plant_id' => $this->data['plant_id'] ?? null,
'line_id' => $this->data['line_id'] ?? null, // 'line_id' => $this->data['line_id'] ?? null,
'sticker_master_id' => $this->data['sticker_master_id'] ?? null, // 'sticker_master_id' => $this->data['sticker_master_id'] ?? null,
'production_order' => $this->data['production_order'] ?? null, // 'production_order' => $this->data['production_order'] ?? null,
'serial_number' => $this->data['serial_number'] ?? null, // 'serial_number' => $this->data['serial_number'] ?? null,
'serial_number_panel' => $this->data['serial_number_panel'] ?? null, // 'serial_number_panel' => $this->data['serial_number_panel'] ?? null,
'pack_slip_panel' => $this->data['pack_slip_panel'] ?? null, // 'pack_slip_panel' => $this->data['pack_slip_panel'] ?? null,
'name_plate_panel' => $this->data['name_plate_panel'] ?? null, // 'name_plate_panel' => $this->data['name_plate_panel'] ?? null,
'tube_sticker_panel' => $this->data['tube_sticker_panel'] ?? null, // 'tube_sticker_panel' => $this->data['tube_sticker_panel'] ?? null,
'warranty_card_panel' => $this->data['warranty_card_panel'] ?? null, // 'warranty_card_panel' => $this->data['warranty_card_panel'] ?? null,
'part_validation1' => $this->data['part_validation1'] ?? null, // 'part_validation1' => $this->data['part_validation1'] ?? null,
'part_validation2' => $this->data['part_validation2'] ?? null, // 'part_validation2' => $this->data['part_validation2'] ?? null,
'part_validation3' => $this->data['part_validation3'] ?? null, // 'part_validation3' => $this->data['part_validation3'] ?? null,
'part_validation4' => $this->data['part_validation4'] ?? null, // 'part_validation4' => $this->data['part_validation4'] ?? null,
'part_validation5' => $this->data['part_validation5'] ?? null, // 'part_validation5' => $this->data['part_validation5'] ?? null,
'panel_box_supplier' => $this->data['panel_box_supplier'] ?? null, // 'panel_box_supplier' => $this->data['panel_box_supplier'] ?? null,
'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null, // 'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null,
'panel_box_code' => $this->data['panel_box_code'] ?? null, // 'panel_box_code' => $this->data['panel_box_code'] ?? null,
'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null, // 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
'rework_count' => $latestReworkRecord ? ((int) $latestReworkRecord->rework_count + 1) : 0, // 'rework_count' => $latestReworkRecord ? ((int) $latestReworkRecord->rework_count + 1) : 0,
'created_by' => $this->data['created_by'] ?? null, // 'created_by' => $this->data['created_by'] ?? null,
'updated_by' => $this->data['updated_by'] ?? null, // 'updated_by' => $this->data['updated_by'] ?? null,
]); // ]);
} // }
else{ // else{
$qualityValidation = PanelBoxValidation::create([ // $qualityValidation = PanelBoxValidation::create([
'plant_id' => $this->data['plant_id'] ?? null,
'line_id' => $this->data['line_id'] ?? null,
'sticker_master_id' => $this->data['sticker_master_id'] ?? null,
'production_order' => $this->data['production_order'] ?? null,
'serial_number' => $this->data['serial_number'] ?? null,
'serial_number_panel' => $this->data['serial_number_panel'] ?? null,
'pack_slip_panel' => $this->data['pack_slip_panel'] ?? null,
'name_plate_panel' => $this->data['name_plate_panel'] ?? null,
'tube_sticker_panel' => $this->data['tube_sticker_panel'] ?? null,
'warranty_card_panel' => $this->data['warranty_card_panel'] ?? null,
'part_validation1' => $this->data['part_validation1'] ?? null,
'part_validation2' => $this->data['part_validation2'] ?? null,
'part_validation3' => $this->data['part_validation3'] ?? null,
'part_validation4' => $this->data['part_validation4'] ?? null,
'part_validation5' => $this->data['part_validation5'] ?? null,
'panel_box_supplier' => $this->data['panel_box_supplier'] ?? null,
'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null,
'panel_box_code' => $this->data['panel_box_code'] ?? null,
'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
'created_by' => $this->data['created_by'] ?? null,
'updated_by' => $this->data['updated_by'] ?? null,
]);
}
// $qualityValidation = PanelBoxValidation::create([
// 'plant_id' => $this->data['plant_id'] ?? null, // 'plant_id' => $this->data['plant_id'] ?? null,
// 'line_id' => $this->data['line_id'] ?? null, // 'line_id' => $this->data['line_id'] ?? null,
// 'sticker_master_id' => $this->data['sticker_master_id'] ?? null, // 'sticker_master_id' => $this->data['sticker_master_id'] ?? null,
@@ -254,9 +228,32 @@ public $records = [];
// 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null, // 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
// 'created_by' => $this->data['created_by'] ?? null, // 'created_by' => $this->data['created_by'] ?? null,
// 'updated_by' => $this->data['updated_by'] ?? null, // 'updated_by' => $this->data['updated_by'] ?? null,
// ]); // ]);
// }
$qualityValidation = PanelBoxValidation::create([
'plant_id' => $this->data['plant_id'] ?? null,
'line_id' => $this->data['line_id'] ?? null,
'sticker_master_id' => $this->data['sticker_master_id'] ?? null,
'production_order' => $this->data['production_order'] ?? null,
'serial_number' => $this->data['serial_number'] ?? null,
'serial_number_panel' => $this->data['serial_number_panel'] ?? null,
'pack_slip_panel' => $this->data['pack_slip_panel'] ?? null,
'name_plate_panel' => $this->data['name_plate_panel'] ?? null,
'tube_sticker_panel' => $this->data['tube_sticker_panel'] ?? null,
'warranty_card_panel' => $this->data['warranty_card_panel'] ?? null,
'part_validation1' => $this->data['part_validation1'] ?? null,
'part_validation2' => $this->data['part_validation2'] ?? null,
'part_validation3' => $this->data['part_validation3'] ?? null,
'part_validation4' => $this->data['part_validation4'] ?? null,
'part_validation5' => $this->data['part_validation5'] ?? null,
'panel_box_supplier' => $this->data['panel_box_supplier'] ?? null,
'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null,
'panel_box_code' => $this->data['panel_box_code'] ?? null,
'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
'created_by' => $this->data['created_by'] ?? null,
'updated_by' => $this->data['updated_by'] ?? null,
]);
if (! $qualityValidation || ! $qualityValidation->exists) { if (! $qualityValidation || ! $qualityValidation->exists) {
Notification::make() Notification::make()

View File

@@ -94,6 +94,11 @@ class Plant extends Model
return $this->hasMany(PumpTestingEntry::class, 'plant_id', 'id'); return $this->hasMany(PumpTestingEntry::class, 'plant_id', 'id');
} }
public function pumpTestingResults()
{
return $this->hasMany(PumpTestingResult::class, 'plant_id', 'id');
}
public function guardNames() public function guardNames()
{ {
return $this->hasMany(GuardName::class, 'plant_id', 'id'); return $this->hasMany(GuardName::class, 'plant_id', 'id');

View File

@@ -59,4 +59,9 @@ class PumpTestingMaster extends Model
{ {
return $this->hasMany(PumpTestingEntry::class, 'pump_testing_master_id', 'id'); return $this->hasMany(PumpTestingEntry::class, 'pump_testing_master_id', 'id');
} }
public function pumpTestingResults()
{
return $this->hasMany(PumpTestingResult::class, 'pump_testing_master_id', 'id');
}
} }

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class PumpTestingResult extends Model
{
use SoftDeletes;
protected $fillable = [
'plant_id',
'pump_testing_master_id',
'tested_date',
'tested_type',
'pump_serial_number',
'correction_head',
'sl_no',
'voltage',
'current',
'watt',
'frequency',
'speed',
'discharge',
'head',
'pump_output',
'power_p2',
'overall_efficiency',
'pump_efficiency',
'created_at',
'created_by',
'updated_at',
'updated_by',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function pumpTestingMasters(): BelongsTo
{
return $this->belongsTo(PumpTestingMaster::class, 'pump_testing_master_id', 'id');
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace App\Policies;
use App\Models\PumpTestingResult;
use App\Models\User;
class PumpTestingResultPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any PumpTestingResult');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, PumpTestingResult $pumptestingresult): bool
{
return $user->checkPermissionTo('view PumpTestingResult');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create PumpTestingResult');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, PumpTestingResult $pumptestingresult): bool
{
return $user->checkPermissionTo('update PumpTestingResult');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, PumpTestingResult $pumptestingresult): bool
{
return $user->checkPermissionTo('delete PumpTestingResult');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any PumpTestingResult');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, PumpTestingResult $pumptestingresult): bool
{
return $user->checkPermissionTo('restore PumpTestingResult');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any PumpTestingResult');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, PumpTestingResult $pumptestingresult): bool
{
return $user->checkPermissionTo('replicate PumpTestingResult');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder PumpTestingResult');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, PumpTestingResult $pumptestingresult): bool
{
return $user->checkPermissionTo('force-delete PumpTestingResult');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any PumpTestingResult');
}
}

View File

@@ -0,0 +1,61 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql = <<<'SQL'
CREATE TABLE pump_testing_results (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
plant_id BIGINT NOT NULL,
pump_testing_master_id BIGINT NOT NULL,
tested_date DATE NOT NULL DEFAULT CURRENT_DATE,
tested_type TEXT DEFAULT NULL,
pump_serial_number TEXT DEFAULT NULL,
correction_head TEXT DEFAULT NULL,
sl_no TEXT DEFAULT NULL,
voltage TEXT DEFAULT NULL,
current TEXT DEFAULT NULL,
watt TEXT DEFAULT NULL,
frequency TEXT DEFAULT NULL,
speed TEXT DEFAULT NULL,
discharge TEXT DEFAULT NULL,
head TEXT DEFAULT NULL,
pump_output TEXT DEFAULT NULL,
power_p2 TEXT DEFAULT NULL,
overall_efficiency TEXT DEFAULT NULL,
pump_efficiency TEXT DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMP,
created_by TEXT NOT NULL,
updated_by TEXT NOT NULL,
UNIQUE (plant_id, pump_testing_master_id, tested_type, pump_serial_number, sl_no),
FOREIGN KEY (pump_testing_master_id) REFERENCES pump_testing_masters (id),
FOREIGN KEY (plant_id) REFERENCES plants (id)
);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pump_testing_results');
}
};

View File

@@ -158,8 +158,12 @@ Route::get('testing/pump-master/get', [TestingPanelController::class, 'get_pump_
Route::get('testing/pump-entry/get', [TestingPanelController::class, 'get_pump_entry']); Route::get('testing/pump-entry/get', [TestingPanelController::class, 'get_pump_entry']);
Route::post('testing/pump-entry/store-data', [TestingPanelController::class, 'storePumpEntry']);
Route::get('testing/pump-result/get', [TestingPanelController::class, 'get_pump_result']); Route::get('testing/pump-result/get', [TestingPanelController::class, 'get_pump_result']);
Route::post('testing/pump-result/store-data', [TestingPanelController::class, 'storePumpResult']);
// Testing panel Controller // Testing panel Controller
Route::get('testing/user/get-data', [UserController::class, 'get_user_data']); Route::get('testing/user/get-data', [UserController::class, 'get_user_data']);