Added migration (sale_order and job_order), and Updated model, policy, resource, importer, exporter, controller (Get API) with functionality for Testing Line Visualization #1382
@@ -30,6 +30,10 @@ class TestingLineVisualizationExporter extends Exporter
|
|||||||
->label('TEST BED GROUP'),
|
->label('TEST BED GROUP'),
|
||||||
ExportColumn::make('line_no')
|
ExportColumn::make('line_no')
|
||||||
->label('LINE NO'),
|
->label('LINE NO'),
|
||||||
|
ExportColumn::make('sale_order')
|
||||||
|
->label('SALE ORDER'),
|
||||||
|
ExportColumn::make('job_order')
|
||||||
|
->label('JOB ORDER'),
|
||||||
ExportColumn::make('pump_model')
|
ExportColumn::make('pump_model')
|
||||||
->label('PUMP MODEL'),
|
->label('PUMP MODEL'),
|
||||||
ExportColumn::make('pump_type')
|
ExportColumn::make('pump_type')
|
||||||
|
|||||||
@@ -37,6 +37,18 @@ class TestingLineVisualizationImporter extends Importer
|
|||||||
->exampleHeader('LINE NO')
|
->exampleHeader('LINE NO')
|
||||||
->example(['1'])
|
->example(['1'])
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
|
ImportColumn::make('sale_order')
|
||||||
|
->requiredMapping()
|
||||||
|
->label('SALE ORDER')
|
||||||
|
->exampleHeader('SALE ORDER')
|
||||||
|
->example(['1RA0009024'])
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('job_order')
|
||||||
|
->requiredMapping()
|
||||||
|
->label('JOB ORDER')
|
||||||
|
->exampleHeader('JOB ORDER')
|
||||||
|
->example(['7000001'])
|
||||||
|
->rules(['required']),
|
||||||
ImportColumn::make('pump_model')
|
ImportColumn::make('pump_model')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->label('PUMP MODEL')
|
->label('PUMP MODEL')
|
||||||
@@ -111,6 +123,8 @@ class TestingLineVisualizationImporter extends Importer
|
|||||||
$plantId = null;
|
$plantId = null;
|
||||||
$testBedGroup = trim($this->data['test_bed_group']);
|
$testBedGroup = trim($this->data['test_bed_group']);
|
||||||
$lineNo = trim($this->data['line_no']);
|
$lineNo = trim($this->data['line_no']);
|
||||||
|
$saleOrder = trim($this->data['sale_order']);
|
||||||
|
$jobOrder = trim($this->data['job_order']);
|
||||||
$pumpModel = trim($this->data['pump_model']);
|
$pumpModel = trim($this->data['pump_model']);
|
||||||
$pumpType = trim($this->data['pump_type']);
|
$pumpType = trim($this->data['pump_type']);
|
||||||
$motorDetails = trim($this->data['motor_details']);
|
$motorDetails = trim($this->data['motor_details']);
|
||||||
@@ -147,6 +161,14 @@ class TestingLineVisualizationImporter extends Importer
|
|||||||
$warnMsg[] = "Line no can't be empty!";
|
$warnMsg[] = "Line no can't be empty!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($saleOrder == null || $saleOrder == '') {
|
||||||
|
$warnMsg[] = "Sale order can't be empty!";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($jobOrder == null || $jobOrder == '') {
|
||||||
|
$warnMsg[] = "Job order can't be empty!";
|
||||||
|
}
|
||||||
|
|
||||||
if ($pumpModel == null || $pumpModel == '') {
|
if ($pumpModel == null || $pumpModel == '') {
|
||||||
$warnMsg[] = "Pump model can't be empty!";
|
$warnMsg[] = "Pump model can't be empty!";
|
||||||
}
|
}
|
||||||
@@ -186,7 +208,6 @@ class TestingLineVisualizationImporter extends Importer
|
|||||||
} elseif ($status != 'Running' && $status != 'OFF' && $status != 'Aligning' && $status != 'MTN') {
|
} elseif ($status != 'Running' && $status != 'OFF' && $status != 'Aligning' && $status != 'MTN') {
|
||||||
$warnMsg[] = 'Invalid status value!';
|
$warnMsg[] = 'Invalid status value!';
|
||||||
}
|
}
|
||||||
// Check for duplicate record based on plant_id, test_bed_group, and line_no
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($warnMsg)) {
|
if (! empty($warnMsg)) {
|
||||||
@@ -197,6 +218,8 @@ class TestingLineVisualizationImporter extends Importer
|
|||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'test_bed_group' => $testBedGroup,
|
'test_bed_group' => $testBedGroup,
|
||||||
'line_no' => $lineNo,
|
'line_no' => $lineNo,
|
||||||
|
'sale_order' => $saleOrder,
|
||||||
|
'job_order' => $jobOrder,
|
||||||
'pump_model' => $pumpModel,
|
'pump_model' => $pumpModel,
|
||||||
'pump_type' => $pumpType,
|
'pump_type' => $pumpType,
|
||||||
'motor_details' => $motorDetails,
|
'motor_details' => $motorDetails,
|
||||||
|
|||||||
@@ -88,6 +88,30 @@ class TestingLineVisualizationResource extends Resource
|
|||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('sale_order')
|
||||||
|
->label('Sale Order')
|
||||||
|
->placeholder('Enter Sale Order')
|
||||||
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? null : optional(TestingLineVisualization::latest()->first())->sale_order ?? null;
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}), // ->required(),
|
||||||
|
Forms\Components\TextInput::make('job_order')
|
||||||
|
->label('Job Order')
|
||||||
|
->placeholder('Enter Job Order')
|
||||||
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? null : optional(TestingLineVisualization::latest()->first())->job_order ?? null;
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}), // ->required(),
|
||||||
Forms\Components\TextInput::make('pump_model')
|
Forms\Components\TextInput::make('pump_model')
|
||||||
->label('Pump Model')
|
->label('Pump Model')
|
||||||
->placeholder('Enter Pump Model')
|
->placeholder('Enter Pump Model')
|
||||||
@@ -281,6 +305,16 @@ class TestingLineVisualizationResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('sale_order')
|
||||||
|
->label('Sale Order')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('job_order')
|
||||||
|
->label('Job Order')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('pump_model')
|
Tables\Columns\TextColumn::make('pump_model')
|
||||||
->label('Pump Model')
|
->label('Pump Model')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -405,6 +439,14 @@ class TestingLineVisualizationResource extends Resource
|
|||||||
->label('Line No')
|
->label('Line No')
|
||||||
->placeholder('Enter Line No')
|
->placeholder('Enter Line No')
|
||||||
->live(500),
|
->live(500),
|
||||||
|
TextInput::make('sale_order')
|
||||||
|
->label('Sale Order')
|
||||||
|
->placeholder('Enter Sale Order')
|
||||||
|
->live(500),
|
||||||
|
TextInput::make('job_order')
|
||||||
|
->label('Job Order')
|
||||||
|
->placeholder('Enter Job Order')
|
||||||
|
->live(500),
|
||||||
TextInput::make('pump_model')
|
TextInput::make('pump_model')
|
||||||
->label('Pump Model')
|
->label('Pump Model')
|
||||||
->placeholder('Enter Pump Model')
|
->placeholder('Enter Pump Model')
|
||||||
@@ -511,7 +553,7 @@ class TestingLineVisualizationResource extends Resource
|
|||||||
])
|
])
|
||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (empty($data['Plant']) && empty($data['test_bed_group']) && empty($data['line_no']) && empty($data['pump_model']) && empty($data['pump_type']) && empty($data['motor_details']) && empty($data['test_type']) && Str::length($data['flow']) <= 0 && Str::length($data['head']) <= 0 && Str::length($data['run_time']) <= 0 && empty($data['live_status']) && empty($data['observation_remarks']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to'])) {
|
if (empty($data['Plant']) && empty($data['test_bed_group']) && empty($data['line_no']) && empty($data['sale_order']) && empty($data['job_order']) && empty($data['pump_model']) && empty($data['pump_type']) && empty($data['motor_details']) && empty($data['test_type']) && Str::length($data['flow']) <= 0 && Str::length($data['head']) <= 0 && Str::length($data['run_time']) <= 0 && empty($data['live_status']) && empty($data['observation_remarks']) && 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');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,6 +575,14 @@ class TestingLineVisualizationResource extends Resource
|
|||||||
$query->where('line_no', $data['line_no']);
|
$query->where('line_no', $data['line_no']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['sale_order'])) {
|
||||||
|
$query->where('sale_order', 'like', '%'.$data['sale_order'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['job_order'])) {
|
||||||
|
$query->where('job_order', 'like', '%'.$data['job_order'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['pump_model'])) {
|
if (! empty($data['pump_model'])) {
|
||||||
$query->where('pump_model', 'like', '%'.$data['pump_model'].'%');
|
$query->where('pump_model', 'like', '%'.$data['pump_model'].'%');
|
||||||
}
|
}
|
||||||
@@ -614,6 +664,14 @@ class TestingLineVisualizationResource extends Resource
|
|||||||
$indicators[] = 'Line No: '.$data['line_no'];
|
$indicators[] = 'Line No: '.$data['line_no'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['sale_order'])) {
|
||||||
|
$indicators[] = 'Sale Order: '.$data['sale_order'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['job_order'])) {
|
||||||
|
$indicators[] = 'Job Order: '.$data['job_order'];
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['pump_model'])) {
|
if (! empty($data['pump_model'])) {
|
||||||
$indicators[] = 'Pump Model: '.$data['pump_model'];
|
$indicators[] = 'Pump Model: '.$data['pump_model'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ class TestingLineVisualizationController extends Controller
|
|||||||
$response[] = [
|
$response[] = [
|
||||||
'test_bed_group' => $row->test_bed_group ?? '',
|
'test_bed_group' => $row->test_bed_group ?? '',
|
||||||
'line_no' => $row->line_no ?? '',
|
'line_no' => $row->line_no ?? '',
|
||||||
|
'sale_order' => $row->sale_order ?? '',
|
||||||
|
'job_order' => $row->job_order ?? '',
|
||||||
'pump_model' => $row->pump_model ?? '',
|
'pump_model' => $row->pump_model ?? '',
|
||||||
'pump_type' => $row->pump_type ?? '',
|
'pump_type' => $row->pump_type ?? '',
|
||||||
'motor_details' => $row->motor_details ?? '',
|
'motor_details' => $row->motor_details ?? '',
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ class TestingLineVisualization extends Model
|
|||||||
'plant_id',
|
'plant_id',
|
||||||
'test_bed_group',
|
'test_bed_group',
|
||||||
'line_no',
|
'line_no',
|
||||||
|
'sale_order',
|
||||||
|
'job_order',
|
||||||
'pump_model',
|
'pump_model',
|
||||||
'pump_type',
|
'pump_type',
|
||||||
'motor_details',
|
'motor_details',
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$sql1 = <<<'SQL'
|
||||||
|
ALTER TABLE testing_line_visualizations
|
||||||
|
ADD COLUMN sale_order TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql1);
|
||||||
|
|
||||||
|
$sql2 = <<<'SQL'
|
||||||
|
ALTER TABLE testing_line_visualizations
|
||||||
|
ADD COLUMN job_order TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Schema::table('testing_line_visualizations', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user