ranjith-dev #898

Merged
jothi merged 4 commits from ranjith-dev into master 2026-08-18 07:16:47 +00:00
4 changed files with 75 additions and 8 deletions

View File

@@ -41,6 +41,8 @@ class AlertMailRuleExporter extends Exporter
$plant = Plant::find($state);
return $plant ? $plant->code : 'Unknown';
}),
ExportColumn::make('machine.work_center')
->label('WORK CENTER'),
ExportColumn::make('cc_emails')
->label('CC EMAILS'),
ExportColumn::make('invoiceMaster.receiving_plant_name')

View File

@@ -8,6 +8,7 @@ use App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Models\AlertMailRule;
use App\Models\InvoiceMaster;
use App\Models\Plant;
use App\Models\Machine;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action;
@@ -49,6 +50,25 @@ class AlertMailRuleResource extends Resource
->required(fn ($get) => ! $get('is_active'))
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
// ->options(fn () => Plant::pluck('id', 'name')->toArray()),
Forms\Components\Select::make('machine_id')
->label('Work Center')
->options(function (callable $get) {
$plantId = $get('plant');
if (!$plantId) {
return [];
}
return Machine::where('plant_id', $plantId)
->whereNotNull('work_center')
->pluck('work_center', 'id')
->toArray();
})
->searchable()
->reactive()
->afterStateUpdated(function (callable $set) {
$set('module', null);
}),
Forms\Components\Select::make('module')
->label('Module')
->required()
@@ -187,6 +207,11 @@ class AlertMailRuleResource extends Resource
return $plants[$state] ?? 'All Plants';
}),
Tables\Columns\TextColumn::make('machine.work_center')
->label('Work Center')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('module')
->label('Module Name')
->alignCenter()
@@ -197,14 +222,14 @@ class AlertMailRuleResource extends Resource
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('invoiceMaster.receiving_plant_name')
->label('Receiving Plant')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('invoiceMaster.transport_name')
->label('Transporter')
->alignCenter()
->sortable(),
// Tables\Columns\TextColumn::make('invoiceMaster.receiving_plant_name')
// ->label('Receiving Plant')
// ->alignCenter()
// ->sortable(),
// Tables\Columns\TextColumn::make('invoiceMaster.transport_name')
// ->label('Transporter')
// ->alignCenter()
// ->sortable(),
Tables\Columns\TextColumn::make('email')
->label('TO Emails')
->searchable()

View File

@@ -18,6 +18,7 @@ class AlertMailRule extends Model
'email',
'cc_emails',
'schedule_type',
'machine_id',
'created_at',
'updated_at',
'created_by',
@@ -29,4 +30,10 @@ class AlertMailRule extends Model
return $this->belongsTo(InvoiceMaster::class);
//return $this->belongsTo(InvoiceMaster::class, 'invoice_master_id');
}
public function machine(): BelongsTo
{
return $this->belongsTo(Machine::class);
//return $this->belongsTo(InvoiceMaster::class, 'invoice_master_id');
}
}

View File

@@ -0,0 +1,33 @@
<?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 alert_mail_rules
ADD COLUMN machine_id BIGINT DEFAULT NULL,
ADD CONSTRAINT alert_mail_rules_machine_id_fkey
FOREIGN KEY (machine_id) REFERENCES machines(id);
SQL;
DB::statement($sql1);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('alert_mail_rules', function (Blueprint $table) {
// //
// });
}
};